mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 15:25:14 +00:00
xmaker: add option for separate stream
This commit is contained in:
parent
2af2b4e7ad
commit
190f5bbfda
|
@ -148,6 +148,8 @@ type Strategy struct {
|
||||||
BollBandMargin fixedpoint.Value `json:"bollBandMargin"`
|
BollBandMargin fixedpoint.Value `json:"bollBandMargin"`
|
||||||
BollBandMarginFactor fixedpoint.Value `json:"bollBandMarginFactor"`
|
BollBandMarginFactor fixedpoint.Value `json:"bollBandMarginFactor"`
|
||||||
|
|
||||||
|
SeparateMarketDataStream bool `json:"separateMarketDataStream"`
|
||||||
|
|
||||||
// MinMarginLevel is the minimum margin level to trigger the hedge
|
// MinMarginLevel is the minimum margin level to trigger the hedge
|
||||||
MinMarginLevel fixedpoint.Value `json:"minMarginLevel"`
|
MinMarginLevel fixedpoint.Value `json:"minMarginLevel"`
|
||||||
|
|
||||||
|
@ -233,6 +235,8 @@ type Strategy struct {
|
||||||
|
|
||||||
metricsLabels prometheus.Labels
|
metricsLabels prometheus.Labels
|
||||||
|
|
||||||
|
sourceMarketDataStream, makerMarketDataStream types.Stream
|
||||||
|
|
||||||
sourceMarketDataConnectivity, sourceUserDataConnectivity *types.Connectivity
|
sourceMarketDataConnectivity, sourceUserDataConnectivity *types.Connectivity
|
||||||
connectivityGroup *types.ConnectivityGroup
|
connectivityGroup *types.ConnectivityGroup
|
||||||
|
|
||||||
|
@ -1726,11 +1730,37 @@ func (s *Strategy) CrossRun(
|
||||||
s.ProfitStats.ProfitStats = profitStats
|
s.ProfitStats.ProfitStats = profitStats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.makerMarketDataStream = s.makerSession.MarketDataStream
|
||||||
|
s.sourceMarketDataStream = s.sourceSession.MarketDataStream
|
||||||
|
|
||||||
|
// separate market data stream
|
||||||
|
if s.SeparateMarketDataStream {
|
||||||
|
s.makerMarketDataStream = s.makerSession.Exchange.NewStream()
|
||||||
|
s.makerMarketDataStream.SetPublicOnly()
|
||||||
|
for _, sub := range s.makerSession.MarketDataStream.GetSubscriptions() {
|
||||||
|
s.makerMarketDataStream.Subscribe(sub.Channel, sub.Symbol, sub.Options)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.makerMarketDataStream.Connect(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
s.sourceMarketDataStream = s.sourceSession.Exchange.NewStream()
|
||||||
|
s.sourceMarketDataStream.SetPublicOnly()
|
||||||
|
for _, sub := range s.sourceSession.MarketDataStream.GetSubscriptions() {
|
||||||
|
s.sourceMarketDataStream.Subscribe(sub.Channel, sub.Symbol, sub.Options)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := s.sourceMarketDataStream.Connect(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.makerBook = types.NewStreamBook(s.Symbol, s.makerSession.ExchangeName)
|
s.makerBook = types.NewStreamBook(s.Symbol, s.makerSession.ExchangeName)
|
||||||
s.makerBook.BindStream(s.makerSession.MarketDataStream)
|
s.makerBook.BindStream(s.makerMarketDataStream)
|
||||||
|
|
||||||
s.sourceBook = types.NewStreamBook(s.Symbol, s.sourceSession.ExchangeName)
|
s.sourceBook = types.NewStreamBook(s.Symbol, s.sourceSession.ExchangeName)
|
||||||
s.sourceBook.BindStream(s.sourceSession.MarketDataStream)
|
s.sourceBook.BindStream(s.sourceMarketDataStream)
|
||||||
|
|
||||||
if s.EnableSignalMargin {
|
if s.EnableSignalMargin {
|
||||||
s.logger.Infof("signal margin is enabled")
|
s.logger.Infof("signal margin is enabled")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user