mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-22 15:10:13 +00:00
Periodic available pairs update for manual exchanges
This commit is contained in:
@@ -251,7 +251,8 @@ func (e *Base) SetAssetTypes() error {
|
||||
exch.AssetTypes = common.JoinStrings(e.AssetTypes, ",")
|
||||
update = true
|
||||
} else {
|
||||
e.AssetTypes = common.SplitStrings(exch.AssetTypes, ",")
|
||||
exch.AssetTypes = common.JoinStrings(e.AssetTypes, ",")
|
||||
update = true
|
||||
}
|
||||
|
||||
if update {
|
||||
|
||||
@@ -101,18 +101,19 @@ func (o *OKCoin) SetDefaults() {
|
||||
o.Verbose = false
|
||||
o.Websocket = false
|
||||
o.RESTPollingDelay = 10
|
||||
o.FuturesValues = []string{"this_week", "next_week", "quarter"}
|
||||
o.AssetTypes = []string{ticker.Spot}
|
||||
o.SupportsAutoPairUpdating = false
|
||||
o.SupportsRESTTickerBatching = false
|
||||
|
||||
if okcoinDefaultsSet {
|
||||
o.AssetTypes = append(o.AssetTypes, o.FuturesValues...)
|
||||
o.APIUrlDefault = okcoinAPIURL
|
||||
o.APIUrl = o.APIUrlDefault
|
||||
o.Name = "OKCOIN International"
|
||||
o.WebsocketURL = okcoinWebsocketURL
|
||||
o.setCurrencyPairFormats()
|
||||
o.RequestCurrencyPairFormat.Delimiter = "_"
|
||||
o.RequestCurrencyPairFormat.Uppercase = false
|
||||
o.ConfigCurrencyPairFormat.Delimiter = "_"
|
||||
o.ConfigCurrencyPairFormat.Uppercase = true
|
||||
o.Requester = request.New(o.Name,
|
||||
request.NewRateLimit(time.Second, okcoinAuthRate),
|
||||
request.NewRateLimit(time.Second, okcoinUnauthRate),
|
||||
|
||||
@@ -29,6 +29,34 @@ func (o *OKCoin) Run() {
|
||||
log.Printf("%s %d currencies enabled: %s.\n", o.GetName(), len(o.EnabledPairs), o.EnabledPairs)
|
||||
}
|
||||
|
||||
if o.APIUrl == okcoinAPIURL {
|
||||
// OKCoin International
|
||||
forceUpgrade := false
|
||||
if !common.StringDataContains(o.EnabledPairs, "_") || !common.StringDataContains(o.AvailablePairs, "_") {
|
||||
forceUpgrade = true
|
||||
}
|
||||
|
||||
var currencies []string
|
||||
for x := range o.AvailablePairs {
|
||||
currencies = append(currencies, o.AvailablePairs[x][0:3]+"_"+o.AvailablePairs[x][3:])
|
||||
}
|
||||
|
||||
if forceUpgrade {
|
||||
enabledPairs := []string{"btc_usd"}
|
||||
log.Println("WARNING: Available pairs for OKCoin International reset due to config upgrade, please enable the pairs you would like again.")
|
||||
|
||||
err := o.UpdateCurrencies(enabledPairs, true, true)
|
||||
if err != nil {
|
||||
log.Printf("%s failed to update currencies. Err: %s", o.Name, err)
|
||||
}
|
||||
|
||||
err = o.UpdateCurrencies(currencies, false, true)
|
||||
if err != nil {
|
||||
log.Printf("%s failed to update currencies. Err: %s", o.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o.Websocket {
|
||||
go o.WebsocketClient()
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/request"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -114,6 +115,7 @@ func (o *OKEX) SetDefaults() {
|
||||
common.NewHTTPClientWithTimeout(exchange.DefaultHTTPTimeout))
|
||||
o.APIUrlDefault = apiURL
|
||||
o.APIUrl = o.APIUrlDefault
|
||||
o.AssetTypes = []string{ticker.Spot}
|
||||
}
|
||||
|
||||
// Setup method sets current configuration details if enabled
|
||||
|
||||
@@ -40,10 +40,6 @@ func (o *OKEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price
|
||||
var tickerPrice ticker.Price
|
||||
|
||||
if assetType != ticker.Spot {
|
||||
if p.SecondCurrency.String() == common.StringToLower("USDT") {
|
||||
p.SecondCurrency = "usd"
|
||||
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
|
||||
}
|
||||
tick, err := o.GetContractPrice(currency, assetType)
|
||||
if err != nil {
|
||||
return tickerPrice, err
|
||||
@@ -58,11 +54,6 @@ func (o *OKEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price
|
||||
tickerPrice.High = tick.Ticker.High
|
||||
ticker.ProcessTicker(o.GetName(), p, tickerPrice, assetType)
|
||||
} else {
|
||||
if p.SecondCurrency.String() == common.StringToLower("USD") {
|
||||
p.SecondCurrency = "usdt"
|
||||
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
|
||||
}
|
||||
|
||||
tick, err := o.GetSpotTicker(currency)
|
||||
if err != nil {
|
||||
return tickerPrice, err
|
||||
@@ -104,10 +95,6 @@ func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook
|
||||
currency := exchange.FormatExchangeCurrency(o.Name, p).String()
|
||||
|
||||
if assetType != ticker.Spot {
|
||||
if p.SecondCurrency.String() == common.StringToLower("USDT") {
|
||||
p.SecondCurrency = "usd"
|
||||
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
|
||||
}
|
||||
orderbookNew, err := o.GetContractMarketDepth(currency, assetType)
|
||||
if err != nil {
|
||||
return orderBook, err
|
||||
@@ -124,11 +111,6 @@ func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook
|
||||
}
|
||||
|
||||
} else {
|
||||
if p.SecondCurrency.String() == common.StringToLower("USD") {
|
||||
p.SecondCurrency = "usdt"
|
||||
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
|
||||
}
|
||||
|
||||
orderbookNew, err := o.GetSpotMarketDepth(ActualSpotDepthRequestParams{
|
||||
Symbol: currency,
|
||||
Size: 200,
|
||||
|
||||
Reference in New Issue
Block a user