exchangeratehost

package
v0.0.0-...-83dca6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2022 License: MIT Imports: 9 Imported by: 0

README

GoCryptoTrader package Exchangerate.Host

Build Status Software License GoDoc Coverage Status Go Report Card

This exchangerate.host package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for exchangerate.host

  • Fetches up to date curency data from ExchangeRate.host API
How to enable
import (
	"github.com/thrasher-corp/gocryptotrader/currency/forexprovider/base"
	"github.com/thrasher-corp/gocryptotrader/currency/forexprovider/exchangerate.host"
)

var c exchangeratehost.ExchangeRateHost

// Define configuration
newSettings := base.Settings{
	Name:             "ExchangeRateHost",
	// ...
}

c.Setup(newSettings)

rates, err := c.GetRates("USD", "EUR,AUD")
// Handle error
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultSource uses the ecb for forex rates
	DefaultSource = "ecb"
)

Functions

This section is empty.

Types

type ConvertCurrency

type ConvertCurrency struct {
	MessageOfTheDay MessageOfTheDay `json:"motd"`
	Query           struct {
		From   string  `json:"from"`
		To     string  `json:"to"`
		Amount float64 `json:"amount"`
	} `json:"query"`
	Info struct {
		Rate float64 `json:"rate"`
	} `json:"info"`
	Historical bool    `json:"historical"`
	Date       string  `json:"date"`
	Result     float64 `json:"result"`
}

ConvertCurrency stores currency conversion data

type ExchangeRateHost

type ExchangeRateHost struct {
	base.Base
	Requester *request.Requester
}

ExchangeRateHost stores the struct for the exchangerate.host API

func (*ExchangeRateHost) ConvertCurrency

func (e *ExchangeRateHost) ConvertCurrency(from, to, baseCurrency, symbols, source string, date time.Time, amount float64, places int64) (*ConvertCurrency, error)

ConvertCurrency converts a currency based on the supplied params

func (*ExchangeRateHost) GetFluctuations

func (e *ExchangeRateHost) GetFluctuations(startDate, endDate time.Time, baseCurrency, symbols string, amount float64, places int64, source string) (*Fluctuations, error)

GetFluctuations returns a list of forex price fluctuations based on the supplied params

func (*ExchangeRateHost) GetHistoricalRates

func (e *ExchangeRateHost) GetHistoricalRates(date time.Time, baseCurrency, symbols string, amount float64, places int64, source string) (*HistoricRates, error)

GetHistoricalRates returns a list of historical rates based on the supplied params

func (*ExchangeRateHost) GetLatestRates

func (e *ExchangeRateHost) GetLatestRates(baseCurrency, symbols string, amount float64, places int64, source string) (*LatestRates, error)

GetLatestRates returns a list of forex rates based on the supplied params

func (*ExchangeRateHost) GetRates

func (e *ExchangeRateHost) GetRates(baseCurrency, symbols string) (map[string]float64, error)

GetRates returns the forex rates based on the supplied base currency and symbols

func (*ExchangeRateHost) GetSupportedCurrencies

func (e *ExchangeRateHost) GetSupportedCurrencies() ([]string, error)

GetSupportedCurrencies returns a list of supported currencies

func (*ExchangeRateHost) GetSupportedSymbols

func (e *ExchangeRateHost) GetSupportedSymbols() (*SupportedSymbols, error)

GetSupportedSymbols returns a list of supported symbols

func (*ExchangeRateHost) GetTimeSeries

func (e *ExchangeRateHost) GetTimeSeries(startDate, endDate time.Time, baseCurrency, symbols string, amount float64, places int64, source string) (*TimeSeries, error)

GetTimeSeries returns time series forex data based on the supplied params

func (*ExchangeRateHost) SendHTTPRequest

func (e *ExchangeRateHost) SendHTTPRequest(endpoint string, v url.Values, result interface{}) error

SendHTTPRequest sends a typical get request

func (*ExchangeRateHost) Setup

func (e *ExchangeRateHost) Setup(config base.Settings) error

Setup sets up the ExchangeRateHost config

type Fluctuation

type Fluctuation struct {
	StartRate        float64 `json:"start_rate"`
	EndRate          float64 `json:"end_rate"`
	Change           float64 `json:"change"`
	ChangePercentage float64 `json:"change_pct"`
}

Fluctuation stores an individual rate flucutation

type Fluctuations

type Fluctuations struct {
	MessageOfTheDay MessageOfTheDay        `json:"motd"`
	Success         bool                   `json:"success"`
	Flucutation     bool                   `json:"fluctuation"`
	StartDate       string                 `json:"start_date"`
	EndDate         string                 `json:"end_date"`
	Rates           map[string]Fluctuation `json:"rate"`
}

Fluctuations stores a collection of rate fluctuations

type HistoricRates

type HistoricRates struct {
	LatestRates
	Historical bool `json:"historical"`
}

HistoricRates stores the hostoric rates

type LatestRates

type LatestRates struct {
	MessageOfTheDay MessageOfTheDay    `json:"motd"`
	Success         bool               `json:"success"`
	Base            string             `json:"base"`
	Date            string             `json:"date"`
	Rates           map[string]float64 `json:"rates"`
}

LatestRates stores the latest forex rates

type MessageOfTheDay

type MessageOfTheDay struct {
	Message     string `json:"msg"`
	DonationURL string `json:"url"`
}

MessageOfTheDay stores the message of the day

type SupportedSymbols

type SupportedSymbols struct {
	MessageOfTheDay MessageOfTheDay   `json:"motd"`
	Success         bool              `json:"success"`
	Symbols         map[string]Symbol `json:"symbols"`
}

SupportedSymbols store a collection of supported symbols

type Symbol

type Symbol struct {
	Description string `json:"description"`
	Code        string `json:"code"`
}

Symbol stores an individual symbol

type TimeSeries

type TimeSeries struct {
	MessageOfTheDay MessageOfTheDay               `json:"motd"`
	Success         bool                          `json:"success"`
	TimeSeries      bool                          `json:"timeseries"`
	Base            string                        `json:"base"`
	StartDate       string                        `json:"start_date"`
	EndDate         string                        `json:"end_date"`
	Rates           map[string]map[string]float64 `json:"rates"`
}

TimeSeries stores time series data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL