mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 01:01:56 +00:00
disable bbgo.sync in common strategy
This commit is contained in:
parent
1d35be8d2a
commit
095ca85669
|
@ -87,6 +87,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
s.cancelOrders(ctx)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
s.cron = cron.New()
|
||||
|
|
|
@ -69,9 +69,6 @@ func (s *Strategy) Initialize(ctx context.Context, environ *bbgo.Environment, se
|
|||
s.OrderExecutor.BindEnvironment(environ)
|
||||
s.OrderExecutor.BindProfitStats(s.ProfitStats)
|
||||
s.OrderExecutor.Bind()
|
||||
s.OrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) {
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
if !s.PositionHardLimit.IsZero() && !s.MaxPositionQuantity.IsZero() {
|
||||
log.Infof("positionHardLimit and maxPositionQuantity are configured, setting up PositionRiskControl...")
|
||||
|
|
|
@ -95,6 +95,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
|
||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -123,6 +123,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
_ = s.OrderExecutor.GracefulCancel(ctx)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -152,6 +152,8 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
if err := tradingutil.UniversalCancelAllOrders(ctx, s.Session.Exchange, nil); err != nil {
|
||||
util.LogErr(err, "unable to cancel all orders")
|
||||
}
|
||||
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -80,6 +80,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
_ = s.OrderExecutor.GracefulCancel(ctx)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
s.cron = cron.New()
|
||||
|
|
|
@ -137,6 +137,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
_ = s.OrderExecutorMap.GracefulCancel(ctx)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
s.cron = cron.New()
|
||||
|
|
|
@ -95,6 +95,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
|
|||
|
||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -148,6 +148,8 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
|
||||
err = s.adjustmentOrderBook.GracefulCancel(ctx, s.Session.Exchange)
|
||||
util.LogErr(err, "unable to cancel adjustment orders")
|
||||
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -333,6 +333,8 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
|||
|
||||
// check if there is a canceled order had partially filled.
|
||||
s.OrderExecutor.TradeCollector().Process()
|
||||
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
return nil
|
||||
|
|
|
@ -156,6 +156,7 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
_ = s.OrderExecutor.GracefulCancel(ctx)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
|||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
close(s.stopC)
|
||||
bbgo.Sync(context.Background(), s)
|
||||
bbgo.Sync(ctx, s)
|
||||
})
|
||||
|
||||
// from here, set data binding
|
||||
|
|
Loading…
Reference in New Issue
Block a user