xmaker: add SubscribeFeeTokenMarkets option

This commit is contained in:
c9s 2024-10-07 17:07:09 +08:00
parent 969e813c7f
commit 2599a4bcd3
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -88,6 +88,8 @@ type Strategy struct {
HedgeInterval types.Duration `json:"hedgeInterval"` HedgeInterval types.Duration `json:"hedgeInterval"`
OrderCancelWaitTime types.Duration `json:"orderCancelWaitTime"` OrderCancelWaitTime types.Duration `json:"orderCancelWaitTime"`
SubscribeFeeTokenMarkets bool `json:"subscribeFeeTokenMarkets"`
EnableSignalMargin bool `json:"enableSignalMargin"` EnableSignalMargin bool `json:"enableSignalMargin"`
SignalConfigList []SignalConfig `json:"signals"` SignalConfigList []SignalConfig `json:"signals"`
SignalMarginScale *bbgo.SlideRule `json:"signalMarginScale,omitempty"` SignalMarginScale *bbgo.SlideRule `json:"signalMarginScale,omitempty"`
@ -232,6 +234,13 @@ func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
sourceSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: sig.BollingerBandTrendSignal.Interval}) sourceSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: sig.BollingerBandTrendSignal.Interval})
} }
} }
if s.SubscribeFeeTokenMarkets {
feeTokenQuote := "USDT"
subscribeOpts := types.SubscribeOptions{Interval: "1m"}
sourceSession.Subscribe(types.KLineChannel, sourceSession.Exchange.PlatformFeeCurrency()+feeTokenQuote, subscribeOpts)
makerSession.Subscribe(types.KLineChannel, makerSession.Exchange.PlatformFeeCurrency()+feeTokenQuote, subscribeOpts)
}
} }
func aggregatePrice(pvs types.PriceVolumeSlice, requiredQuantity fixedpoint.Value) (price fixedpoint.Value) { func aggregatePrice(pvs types.PriceVolumeSlice, requiredQuantity fixedpoint.Value) (price fixedpoint.Value) {