Skip to content

Commit

Permalink
Merge pull request #1487 from c9s/c9s/bitget-ignore-offline-symbols
Browse files Browse the repository at this point in the history
FIX: [bitget] ignore offline symbols
  • Loading branch information
c9s authored Jan 8, 2024
2 parents 2afc72d + e358da1 commit 11309ac
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
14 changes: 8 additions & 6 deletions pkg/exchange/bitget/bitgetapi/v2/get_symbols_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 18 additions & 4 deletions pkg/exchange/bitget/bitgetapi/v2/get_symbols_request_requestgen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pkg/exchange/bitget/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions pkg/exchange/bitget/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func Test_toGlobalBalance(t *testing.T) {

func Test_toGlobalMarket(t *testing.T) {
// sample:
//{
// {
// "symbol":"BTCUSDT",
// "baseCoin":"BTC",
// "quoteCoin":"USDT",
Expand All @@ -59,7 +59,7 @@ func Test_toGlobalMarket(t *testing.T) {
// "minTradeUSDT":"5",
// "buyLimitPriceRatio":"0.05",
// "sellLimitPriceRatio":"0.05"
//}
// }
inst := v2.Symbol{
Symbol: "BTCUSDT",
BaseCoin: "BTC",
Expand All @@ -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),
}
Expand All @@ -99,7 +99,7 @@ func Test_toGlobalMarket(t *testing.T) {

func Test_toGlobalTicker(t *testing.T) {
// sample:
//{
// {
// "open":"36465.96",
// "symbol":"BTCUSDT",
// "high24h":"37040.25",
Expand All @@ -116,7 +116,7 @@ func Test_toGlobalTicker(t *testing.T) {
// "openUtc":"36465.96",
// "changeUtc24h":"0.00599",
// "change24h":"-0.00426"
//}
// }
ticker := v2.Ticker{
Symbol: "BTCUSDT",
High24H: fixedpoint.NewFromFloat(24175.65),
Expand Down Expand Up @@ -540,7 +540,7 @@ func Test_toGlobalTrade(t *testing.T) {
// "tradeScope":"taker",
// "cTime":"1699020564676",
// "uTime":"1699020564687"
//}
// }
trade := v2.Trade{
UserId: types.StrInt64(8672173294),
Symbol: "APEUSDT",
Expand Down
5 changes: 5 additions & 0 deletions pkg/exchange/bitget/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 11309ac

Please sign in to comment.