fixer

package
v0.0.0-...-eb07c7e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 9 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 progresss 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 Fixer.io
How to enable
import (
"github.com/thrasher-/gocryptotrader/currency/forexprovider/base"
"github.com/thrasher-/gocryptotrader/currency/forexprovider/fixer.io"
)

c := fixer.Fixer{}

// Define configuration
newSettings := base.Settings{
  Name: "Fixer",
	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:

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conversion

type Conversion struct {
	Success bool      `json:"success"`
	Error   RespError `json:"error"`
	Query   struct {
		From   string  `json:"from"`
		To     string  `json:"to"`
		Amount float64 `json:"amount"`
	} `json:"query"`
	Info struct {
		Timestamp int64   `json:"timestamp"`
		Rate      float64 `json:"rate"`
	} `json:"info"`
	Historical bool    `json:"historical"`
	Date       string  `json:"date"`
	Result     float64 `json:"result"`
}

Conversion contains data for currency conversion

type Fixer

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

Fixer is a foreign exchange rate provider at https://fixer.io/ NOTE DEFAULT BASE CURRENCY IS EUR upgrade to basic to change

func (*Fixer) ConvertCurrency

func (f *Fixer) ConvertCurrency(from, to, date string, amount float64) (float64, error)

ConvertCurrency allows for conversion of any amount from one currency to another. from - The three-letter currency code of the currency you would like to convert from. to - The three-letter currency code of the currency you would like to convert to. amount - The amount to be converted. date - [optional] Specify a date (format YYYY-MM-DD) to use historical rates for this conversion.

func (*Fixer) GetFluctuationData

func (f *Fixer) GetFluctuationData(startDate, endDate, baseCurrency string, symbols []string) (map[string]Flux, error)

GetFluctuationData returns fluctuation data between two specified dates for all available or a specific set of currencies.

func (*Fixer) GetHistoricalRates

func (f *Fixer) GetHistoricalRates(date, baseCurrency string, symbols []string) (map[string]float64, 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 base - USD [optional] symbols - the desired symbols

func (*Fixer) GetLatestRates

func (f *Fixer) GetLatestRates(baseCurrency, symbols string) (map[string]float64, error)

GetLatestRates returns real-time exchange rate data for all available or a specific set of currencies. NOTE DEFAULT BASE CURRENCY IS EUR

func (*Fixer) GetRates

func (f *Fixer) GetRates(baseCurrency, symbols string) (map[string]float64, error)

GetRates is a wrapper function to return rates

func (*Fixer) GetSupportedCurrencies

func (f *Fixer) GetSupportedCurrencies() ([]string, error)

GetSupportedCurrencies returns supported currencies

func (*Fixer) GetTimeSeriesData

func (f *Fixer) GetTimeSeriesData(startDate, endDate, baseCurrency string, symbols []string) (map[string]interface{}, error)

GetTimeSeriesData returns daily historical exchange rate data between two specified dates for all available or a specific set of currencies.

func (*Fixer) SendOpenHTTPRequest

func (f *Fixer) SendOpenHTTPRequest(endpoint string, v url.Values, result interface{}) error

SendOpenHTTPRequest sends a typical get request

func (*Fixer) Setup

func (f *Fixer) Setup(config base.Settings) error

Setup sets appropriate values for fixer object

type Fluctuation

type Fluctuation struct {
	Success     bool            `json:"success"`
	Error       RespError       `json:"error"`
	Fluctuation bool            `json:"fluctuation"`
	StartDate   string          `json:"start_date"`
	EndDate     string          `json:"end_date"`
	Base        string          `json:"base"`
	Rates       map[string]Flux `json:"rates"`
}

Fluctuation holds fluctuation data

type Flux

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

Flux is a sub type holding fluctation data

type Rates

type Rates struct {
	Success    bool               `json:"success"`
	Error      RespError          `json:"error"`
	Historical bool               `json:"historical"`
	Timestamp  int64              `json:"timestamp"`
	Base       string             `json:"base"`
	Date       string             `json:"date"`
	Rates      map[string]float64 `json:"rates"`
}

Rates contains the data fields for the currencies you have requested.

type RespError

type RespError struct {
	Code int    `json:"code"`
	Type string `json:"type"`
	Info string `json:"info"`
}

RespError defines a general resp error sub type

type Symbols

type Symbols struct {
	Success bool              `json:"success"`
	Error   RespError         `json:"error"`
	Map     map[string]string `json:"symbols"`
}

Symbols defines a symbols list

type TimeSeries

type TimeSeries struct {
	Success    bool                   `json:"success"`
	Error      RespError              `json:"error"`
	Timeseries bool                   `json:"timeseries"`
	StartDate  string                 `json:"start_date"`
	EndDate    string                 `json:"end_date"`
	Base       string                 `json:"base"`
	Rates      map[string]interface{} `json:"rates"`
}

TimeSeries holds timeseries data

Jump to

Keyboard shortcuts

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