Add method to fetch available currencies from Poloniex, fix available currency bug in poloniex and update config_example.json

This commit is contained in:
Adrian Gallagher
2018-01-09 16:31:15 +11:00
parent 0b00ea8bf1
commit 16629c6c6e
3 changed files with 67 additions and 12 deletions

View File

@@ -221,6 +221,22 @@ func (p *Poloniex) GetCurrencies() (map[string]PoloniexCurrencies, error) {
return resp.Data, common.SendHTTPGetRequest(path, true, p.Verbose, &resp.Data)
}
// GetExchangeCurrencies returns a list of currencies using the GetTicker API
// as the GetExchangeCurrencies information doesn't return currency pair information
func (p *Poloniex) GetExchangeCurrencies() ([]string, error) {
response, err := p.GetTicker()
if err != nil {
return nil, err
}
var currencies []string
for x := range response {
currencies = append(currencies, x)
}
return currencies, nil
}
// GetLoanOrders returns the list of loan offers and demands for a given
// currency, specified by the "currency" GET parameter.
func (p *Poloniex) GetLoanOrders(currency string) (PoloniexLoanOrders, error) {

View File

@@ -26,6 +26,22 @@ func (p *Poloniex) Run() {
if p.Websocket {
go p.WebsocketClient()
}
exchangeCurrencies, err := p.GetExchangeCurrencies()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", p.GetName())
} else {
forceUpdate := false
if common.DataContains(p.AvailablePairs, "BTC_USDT") {
log.Printf("%s contains invalid pair, forcing upgrade of available currencies.\n",
p.GetName())
forceUpdate = true
}
err = p.UpdateAvailableCurrencies(exchangeCurrencies, forceUpdate)
if err != nil {
log.Printf("%s Failed to update available currencies %s.\n", p.GetName(), err)
}
}
}
// UpdateTicker updates and returns the ticker for a currency pair