From 74feb928c9da241e8ffd45a06ca77ac4b8076a16 Mon Sep 17 00:00:00 2001 From: edwin Date: Tue, 15 Oct 2024 15:31:19 +0800 Subject: [PATCH] pkg/exchange: use execution.fast topoc --- pkg/exchange/bybit/stream.go | 8 -------- pkg/exchange/bybit/types.go | 6 ++++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/exchange/bybit/stream.go b/pkg/exchange/bybit/stream.go index 12e594722..ad1a07894 100644 --- a/pkg/exchange/bybit/stream.go +++ b/pkg/exchange/bybit/stream.go @@ -438,14 +438,6 @@ func (s *Stream) handleKLineEvent(klineEvent KLineEvent) { } } -func pollAndGetFeeRate(ctx context.Context, symbol string, poller FeeRatePoller, marketsInfo types.MarketMap) (SymbolFeeDetail, error) { - err := poller.PollFeeRate(ctx) - if err != nil { - return SymbolFeeDetail{}, err - } - return getFeeRate(symbol, poller, marketsInfo), nil -} - func getFeeRate(symbol string, poller FeeRatePoller, marketsInfo types.MarketMap) SymbolFeeDetail { feeRate, found := poller.GetFeeRate(symbol) if !found { diff --git a/pkg/exchange/bybit/types.go b/pkg/exchange/bybit/types.go index 1b387049d..eb258e6c2 100644 --- a/pkg/exchange/bybit/types.go +++ b/pkg/exchange/bybit/types.go @@ -107,6 +107,7 @@ const ( TopicTypeWallet TopicType = "wallet" TopicTypeOrder TopicType = "order" TopicTypeKLine TopicType = "kline" + TopicTypeFastTrade TopicType = "execution.fast" TopicTypeTrade TopicType = "execution" ) @@ -385,6 +386,11 @@ func (t *TradeEvent) toGlobalTrade(symbolFee SymbolFeeDetail) (*types.Trade, err // IsMakerOrder = FALSE // -> Side = Buy -> base currency (BTC) // -> Side = Sell -> quote currency (USDT) +// +// The `execution.fast` topic doesn't support fee currency and execution fees, so we're calculating the transaction fees here. +// Although the `execution` topic is supported, it only covers the execution fee, so you'll still need to calculate the +// fee currency. +// Overall, I chose the one with lower latency (execution.fast) and calculated the fee myself. func calculateFee(t bybitapi.Trade, feeDetail SymbolFeeDetail) (string, fixedpoint.Value) { if feeDetail.MakerFeeRate.Sign() > 0 || !t.IsMaker { if t.Side == bybitapi.SideBuy {