mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
Merge pull request #1487 from c9s/c9s/bitget-ignore-offline-symbols
FIX: [bitget] ignore offline symbols
This commit is contained in:
commit
11309ac8c8
|
@ -12,12 +12,14 @@ import (
|
|||
type SymbolStatus string
|
||||
|
||||
const (
|
||||
// SymbolOffline represent market is suspended, users cannot trade.
|
||||
SymbolOffline SymbolStatus = "offline"
|
||||
// SymbolGray represents market is online, but user trading is not available.
|
||||
SymbolGray SymbolStatus = "gray"
|
||||
// SymbolOnline trading begins, users can trade.
|
||||
SymbolOnline SymbolStatus = "online"
|
||||
// SymbolStatusOffline represent market is suspended, users cannot trade.
|
||||
SymbolStatusOffline SymbolStatus = "offline"
|
||||
|
||||
// SymbolStatusGray represents market is online, but user trading is not available.
|
||||
SymbolStatusGray SymbolStatus = "gray"
|
||||
|
||||
// SymbolStatusOnline trading begins, users can trade.
|
||||
SymbolStatusOnline SymbolStatus = "online"
|
||||
)
|
||||
|
||||
type Symbol struct {
|
||||
|
|
|
@ -137,15 +137,29 @@ func (g *GetSymbolsRequest) Do(ctx context.Context) ([]Symbol, error) {
|
|||
}
|
||||
|
||||
var apiResponse bitgetapi.APIResponse
|
||||
|
||||
type responseUnmarshaler interface {
|
||||
Unmarshal(data []byte) error
|
||||
}
|
||||
|
||||
if unmarshaler, ok := interface{}(&apiResponse).(responseUnmarshaler); ok {
|
||||
if err := unmarshaler.Unmarshal(response.Body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// The line below checks the content type, however, some API server might not send the correct content type header,
|
||||
// Hence, this is commented for backward compatibility
|
||||
// response.IsJSON()
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
type responseValidator interface {
|
||||
Validate() error
|
||||
}
|
||||
validator, ok := interface{}(apiResponse).(responseValidator)
|
||||
if ok {
|
||||
|
||||
if validator, ok := interface{}(&apiResponse).(responseValidator); ok {
|
||||
if err := validator.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ func toGlobalBalance(asset v2.AccountAsset) types.Balance {
|
|||
}
|
||||
|
||||
func toGlobalMarket(s v2.Symbol) types.Market {
|
||||
if s.Status != v2.SymbolOnline {
|
||||
log.Warnf("The symbol %s is not online", s.Symbol)
|
||||
if s.Status != v2.SymbolStatusOnline {
|
||||
log.Warnf("The market symbol status %s is not online: %s", s.Symbol, s.Status)
|
||||
}
|
||||
|
||||
return types.Market{
|
||||
Symbol: s.Symbol,
|
||||
LocalSymbol: s.Symbol,
|
||||
|
|
|
@ -72,7 +72,7 @@ func Test_toGlobalMarket(t *testing.T) {
|
|||
QuantityPrecision: fixedpoint.NewFromFloat(4),
|
||||
QuotePrecision: fixedpoint.NewFromFloat(6),
|
||||
MinTradeUSDT: fixedpoint.NewFromFloat(5),
|
||||
Status: v2.SymbolOnline,
|
||||
Status: v2.SymbolStatusOnline,
|
||||
BuyLimitPriceRatio: fixedpoint.NewFromFloat(0.05),
|
||||
SellLimitPriceRatio: fixedpoint.NewFromFloat(0.05),
|
||||
}
|
||||
|
|
|
@ -111,6 +111,11 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
|
|||
|
||||
markets := types.MarketMap{}
|
||||
for _, s := range symbols {
|
||||
if s.Status == v2.SymbolStatusOffline {
|
||||
// ignore offline symbols
|
||||
continue
|
||||
}
|
||||
|
||||
markets[s.Symbol] = toGlobalMarket(s)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user