Skip to content

Commit

Permalink
twap: handle delayInterval after canceling order
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Aug 20, 2024
1 parent 9a2b792 commit a0cbf82
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/twap/v2/stream_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ type FixedQuantityExecutor struct {
executionCtx context.Context
cancelExecution context.CancelFunc

orderUpdateRateLimit *rate.Limiter

userDataStreamCtx context.Context
cancelUserDataStream context.CancelFunc

Expand All @@ -61,10 +59,11 @@ type FixedQuantityExecutor struct {

userDataStream types.Stream

activeMakerOrders *bbgo.ActiveOrderBook
orderStore *core.OrderStore
position *types.Position
tradeCollector *core.TradeCollector
orderUpdateRateLimit *rate.Limiter
activeMakerOrders *bbgo.ActiveOrderBook
orderStore *core.OrderStore
position *types.Position
tradeCollector *core.TradeCollector

logger logrus.FieldLogger

Expand Down Expand Up @@ -353,6 +352,10 @@ func (e *FixedQuantityExecutor) updateOrder(ctx context.Context) error {

e.tradeCollector.Process()

if e.delayInterval > 0 {
time.Sleep(e.delayInterval)
}

orderForm, err := e.generateOrder()
if err != nil {
return err
Expand Down

0 comments on commit a0cbf82

Please sign in to comment.