mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-23 15:25:14 +00:00
liqmaker: fix interval checking
This commit is contained in:
parent
8073f4c304
commit
55e9910441
|
@ -155,6 +155,8 @@ func (s *Strategy) updateMarketMetrics(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) liquidityWorker(ctx context.Context, interval types.Interval) {
|
func (s *Strategy) liquidityWorker(ctx context.Context, interval types.Interval) {
|
||||||
|
s.logger.Infof("starting liquidity worker with interval %v", interval)
|
||||||
|
|
||||||
metricsTicker := time.NewTicker(5 * time.Second)
|
metricsTicker := time.NewTicker(5 * time.Second)
|
||||||
defer metricsTicker.Stop()
|
defer metricsTicker.Stop()
|
||||||
|
|
||||||
|
@ -233,21 +235,19 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if intervalProvider, ok := session.Exchange.(types.CustomIntervalProvider); ok {
|
if intervalProvider, ok := session.Exchange.(types.CustomIntervalProvider); ok && intervalProvider.IsSupportedInterval(s.LiquidityUpdateInterval) {
|
||||||
if intervalProvider.IsSupportedInterval(s.LiquidityUpdateInterval) {
|
session.UserDataStream.OnAuth(func() {
|
||||||
session.UserDataStream.OnAuth(func() {
|
s.placeLiquidityOrders(ctx)
|
||||||
|
})
|
||||||
|
session.MarketDataStream.OnKLineClosed(func(k types.KLine) {
|
||||||
|
if k.Interval == s.LiquidityUpdateInterval {
|
||||||
s.placeLiquidityOrders(ctx)
|
s.placeLiquidityOrders(ctx)
|
||||||
})
|
}
|
||||||
session.MarketDataStream.OnKLineClosed(func(k types.KLine) {
|
})
|
||||||
if k.Interval == s.LiquidityUpdateInterval {
|
} else {
|
||||||
s.placeLiquidityOrders(ctx)
|
session.UserDataStream.OnStart(func() {
|
||||||
}
|
go s.liquidityWorker(ctx, s.LiquidityUpdateInterval)
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
session.UserDataStream.OnStart(func() {
|
|
||||||
go s.liquidityWorker(ctx, s.LiquidityUpdateInterval)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user