mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
xdepthmaker: remove disable hedge option
This commit is contained in:
parent
10a71d83f1
commit
18968c67a1
|
@ -134,8 +134,8 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
||||||
s.orderStore = core.NewOrderStore(s.Position.Symbol)
|
s.orderStore = core.NewOrderStore(s.Position.Symbol)
|
||||||
s.orderStore.BindStream(hedgeSession.UserDataStream)
|
s.orderStore.BindStream(hedgeSession.UserDataStream)
|
||||||
s.orderStore.BindStream(makerSession.UserDataStream)
|
s.orderStore.BindStream(makerSession.UserDataStream)
|
||||||
s.tradeCollector = core.NewTradeCollector(symbol, s.Position, s.orderStore)
|
|
||||||
|
|
||||||
|
s.tradeCollector = core.NewTradeCollector(symbol, s.Position, s.orderStore)
|
||||||
s.tradeCollector.OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
|
s.tradeCollector.OnTrade(func(trade types.Trade, profit, netProfit fixedpoint.Value) {
|
||||||
c := trade.PositionChange()
|
c := trade.PositionChange()
|
||||||
if trade.Exchange == s.hedgeSession.ExchangeName {
|
if trade.Exchange == s.hedgeSession.ExchangeName {
|
||||||
|
@ -156,6 +156,8 @@ func (s *CrossExchangeMarketMakingStrategy) Initialize(
|
||||||
s.Environ.RecordPosition(s.Position, trade, &p)
|
s.Environ.RecordPosition(s.Position, trade, &p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
s.tradeCollector.BindStream(s.hedgeSession.UserDataStream)
|
||||||
|
s.tradeCollector.BindStream(s.makerSession.UserDataStream)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -195,8 +197,6 @@ type Strategy struct {
|
||||||
// MaxExposurePosition defines the unhedged quantity of stop
|
// MaxExposurePosition defines the unhedged quantity of stop
|
||||||
MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"`
|
MaxExposurePosition fixedpoint.Value `json:"maxExposurePosition"`
|
||||||
|
|
||||||
DisableHedge bool `json:"disableHedge"`
|
|
||||||
|
|
||||||
NotifyTrade bool `json:"notifyTrade"`
|
NotifyTrade bool `json:"notifyTrade"`
|
||||||
|
|
||||||
// RecoverTrade tries to find the missing trades via the REStful API
|
// RecoverTrade tries to find the missing trades via the REStful API
|
||||||
|
@ -240,7 +240,11 @@ func (s *Strategy) CrossSubscribe(sessions map[string]*bbgo.ExchangeSession) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hedgeSession.Subscribe(types.BookChannel, s.Symbol, types.SubscribeOptions{})
|
hedgeSession.Subscribe(types.BookChannel, s.Symbol, types.SubscribeOptions{
|
||||||
|
Depth: types.DepthLevelMedium,
|
||||||
|
Speed: types.SpeedHigh,
|
||||||
|
})
|
||||||
|
|
||||||
hedgeSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
hedgeSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
||||||
makerSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
makerSession.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"})
|
||||||
}
|
}
|
||||||
|
@ -324,8 +328,6 @@ func (s *Strategy) CrossRun(
|
||||||
s.tradeCollector.OnRecover(func(trade types.Trade) {
|
s.tradeCollector.OnRecover(func(trade types.Trade) {
|
||||||
bbgo.Notify("Recovered trade", trade)
|
bbgo.Notify("Recovered trade", trade)
|
||||||
})
|
})
|
||||||
s.tradeCollector.BindStream(s.hedgeSession.UserDataStream)
|
|
||||||
s.tradeCollector.BindStream(s.makerSession.UserDataStream)
|
|
||||||
|
|
||||||
s.stopC = make(chan struct{})
|
s.stopC = make(chan struct{})
|
||||||
|
|
||||||
|
@ -337,12 +339,6 @@ func (s *Strategy) CrossRun(
|
||||||
posTicker := time.NewTicker(util.MillisecondsJitter(s.HedgeInterval.Duration(), 200))
|
posTicker := time.NewTicker(util.MillisecondsJitter(s.HedgeInterval.Duration(), 200))
|
||||||
defer posTicker.Stop()
|
defer posTicker.Stop()
|
||||||
|
|
||||||
quoteTicker := time.NewTicker(util.MillisecondsJitter(s.UpdateInterval.Duration(), 200))
|
|
||||||
defer quoteTicker.Stop()
|
|
||||||
|
|
||||||
reportTicker := time.NewTicker(time.Hour)
|
|
||||||
defer reportTicker.Stop()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
||||||
|
@ -354,12 +350,6 @@ func (s *Strategy) CrossRun(
|
||||||
log.Warnf("%s maker goroutine stopped, due to the cancelled context", s.Symbol)
|
log.Warnf("%s maker goroutine stopped, due to the cancelled context", s.Symbol)
|
||||||
return
|
return
|
||||||
|
|
||||||
case <-quoteTicker.C:
|
|
||||||
s.updateQuote(ctx, orderExecutionRouter)
|
|
||||||
|
|
||||||
case <-reportTicker.C:
|
|
||||||
bbgo.Notify(s.ProfitStats)
|
|
||||||
|
|
||||||
case <-posTicker.C:
|
case <-posTicker.C:
|
||||||
// For positive position and positive covered position:
|
// For positive position and positive covered position:
|
||||||
// uncover position = +5 - +3 (covered position) = 2
|
// uncover position = +5 - +3 (covered position) = 2
|
||||||
|
@ -377,7 +367,7 @@ func (s *Strategy) CrossRun(
|
||||||
|
|
||||||
uncoverPosition := position.Sub(s.CoveredPosition)
|
uncoverPosition := position.Sub(s.CoveredPosition)
|
||||||
absPos := uncoverPosition.Abs()
|
absPos := uncoverPosition.Abs()
|
||||||
if !s.DisableHedge && absPos.Compare(s.hedgeMarket.MinQuantity) > 0 {
|
if absPos.Compare(s.hedgeMarket.MinQuantity) > 0 {
|
||||||
log.Infof("%s base position %v coveredPosition: %v uncoverPosition: %v",
|
log.Infof("%s base position %v coveredPosition: %v uncoverPosition: %v",
|
||||||
s.Symbol,
|
s.Symbol,
|
||||||
position,
|
position,
|
||||||
|
@ -795,7 +785,7 @@ func (s *Strategy) updateQuote(ctx context.Context, orderExecutionRouter bbgo.Or
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(submitOrders) == 0 {
|
if len(submitOrders) == 0 {
|
||||||
log.Warnf("no orders generated")
|
log.Warnf("no orders are generated")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user