mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 02:53:50 +00:00
pkg/exchange: use execution.fast topoc
This commit is contained in:
parent
b41cd348bc
commit
74feb928c9
|
@ -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 {
|
func getFeeRate(symbol string, poller FeeRatePoller, marketsInfo types.MarketMap) SymbolFeeDetail {
|
||||||
feeRate, found := poller.GetFeeRate(symbol)
|
feeRate, found := poller.GetFeeRate(symbol)
|
||||||
if !found {
|
if !found {
|
||||||
|
|
|
@ -107,6 +107,7 @@ const (
|
||||||
TopicTypeWallet TopicType = "wallet"
|
TopicTypeWallet TopicType = "wallet"
|
||||||
TopicTypeOrder TopicType = "order"
|
TopicTypeOrder TopicType = "order"
|
||||||
TopicTypeKLine TopicType = "kline"
|
TopicTypeKLine TopicType = "kline"
|
||||||
|
TopicTypeFastTrade TopicType = "execution.fast"
|
||||||
TopicTypeTrade TopicType = "execution"
|
TopicTypeTrade TopicType = "execution"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -385,6 +386,11 @@ func (t *TradeEvent) toGlobalTrade(symbolFee SymbolFeeDetail) (*types.Trade, err
|
||||||
// IsMakerOrder = FALSE
|
// IsMakerOrder = FALSE
|
||||||
// -> Side = Buy -> base currency (BTC)
|
// -> Side = Buy -> base currency (BTC)
|
||||||
// -> Side = Sell -> quote currency (USDT)
|
// -> 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) {
|
func calculateFee(t bybitapi.Trade, feeDetail SymbolFeeDetail) (string, fixedpoint.Value) {
|
||||||
if feeDetail.MakerFeeRate.Sign() > 0 || !t.IsMaker {
|
if feeDetail.MakerFeeRate.Sign() > 0 || !t.IsMaker {
|
||||||
if t.Side == bybitapi.SideBuy {
|
if t.Side == bybitapi.SideBuy {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user