exchangerates

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 11 Imported by: 0

README

GoCryptoTrader package Forexprovider

Build Status Software License GoDoc Coverage Status Go Report Card

This forexprovider 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 forexprovider

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

c := exchangerates.ExchangeRates{}

// Define configuration
newSettings := base.Settings{
  	Name: "ExchangeRates",
	Enabled: true,
	Verbose: false,
	RESTPollingDelay: time.Duration,
	APIKey: "key",
	APIKeyLvl: "keylvl",
	PrimaryProvider: true,
}

c.Setup(newSettings)

mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
// 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

This section is empty.

Functions

This section is empty.

Types

type ExchangeRates

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

ExchangeRates stores the struct for the ExchangeRatesAPI API

func (*ExchangeRates) GetHistoricalRates

func (e *ExchangeRates) GetHistoricalRates(date, baseCurrency string, symbols []string) (HistoricalRates, error)

GetHistoricalRates returns historical exchange rate data for all available or a specific set of currencies. date - YYYY-MM-DD [required] A date in the past baseCurrency - USD [optional] The base currency to use for forex rates, defaults to EUR symbols - AUD,USD [optional] The symbols to query the forex rates for, default is all supported currencies

func (*ExchangeRates) GetLatestRates

func (e *ExchangeRates) GetLatestRates(baseCurrency, symbols string) (Rates, error)

GetLatestRates returns a map of forex rates based on the supplied params baseCurrency - USD [optional] The base currency to use for forex rates, defaults to EUR symbols - AUD,USD [optional] The symbols to query the forex rates for, default is all supported currencies

func (*ExchangeRates) GetRates

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

GetRates is a wrapper function to return forex rates

func (*ExchangeRates) GetSupportedCurrencies

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

GetSupportedCurrencies returns the supported currency list

func (*ExchangeRates) GetTimeSeriesRates

func (e *ExchangeRates) GetTimeSeriesRates(startDate, endDate, baseCurrency string, symbols []string) (TimeSeriesRates, error)

GetTimeSeriesRates returns daily historical exchange rate data between two specified dates for all available or a specific set of currencies. startDate - YYYY-MM-DD [required] A date in the past endDate - YYYY-MM-DD [required] A date in the past but greater than the startDate baseCurrency - USD [optional] The base currency to use for forex rates, defaults to EUR symbols - AUD,USD [optional] The symbols to query the forex rates for, default is all supported currencies

func (*ExchangeRates) SendHTTPRequest

func (e *ExchangeRates) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error

SendHTTPRequest sends a HTTPS request to the desired endpoint and returns the result

func (*ExchangeRates) Setup

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

Setup sets appropriate values for CurrencyLayer

type HistoricalRates

type HistoricalRates Rates

HistoricalRates stores the historical rate info

type Rates

type Rates struct {
	Base  string             `json:"base"`
	Date  string             `json:"date"`
	Rates map[string]float64 `json:"rates"`
}

Rates holds the latest forex rates info

type TimeSeriesRates

type TimeSeriesRates struct {
	Base    string                 `json:"base"`
	StartAt string                 `json:"start_at"`
	EndAt   string                 `json:"end_at"`
	Rates   map[string]interface{} `json:"rates"`
}

TimeSeriesRates stores time series rate info

Jump to

Keyboard shortcuts

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