Add generalised functions for handling exchange enabled and available currencies

This commit is contained in:
Adrian Gallagher
2017-08-25 15:54:45 +10:00
parent 9bdc316ae8
commit 55ea1fe434
45 changed files with 1032 additions and 208 deletions

View File

@@ -31,6 +31,10 @@ func (i *ItBit) SetDefaults() {
i.Verbose = false
i.Websocket = false
i.RESTPollingDelay = 10
i.RequestCurrencyPairFormat.Delimiter = ""
i.RequestCurrencyPairFormat.Uppercase = true
i.ConfigCurrencyPairFormat.Delimiter = ""
i.ConfigCurrencyPairFormat.Uppercase = true
}
func (i *ItBit) Setup(exch config.ExchangeConfig) {
@@ -46,6 +50,10 @@ func (i *ItBit) Setup(exch config.ExchangeConfig) {
i.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
i.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
i.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
err := i.SetCurrencyPairFormat()
if err != nil {
log.Fatal(err)
}
}
}

View File

@@ -22,8 +22,9 @@ func (i *ItBit) Run() {
}
for i.Enabled {
for _, x := range i.EnabledPairs {
currency := pair.NewCurrencyPair(x[0:3], x[3:])
pairs := i.GetEnabledCurrencies()
for x := range pairs {
currency := pairs[x]
go func() {
ticker, err := i.GetTickerPrice(currency)
if err != nil {