From f9cb4148328f288491ce33949326eb7d2abdd4d8 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 15 May 2021 09:29:44 +0800 Subject: [PATCH] twap: add update-interval option --- pkg/bbgo/twap_order_executor.go | 1 + pkg/cmd/orders.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/pkg/bbgo/twap_order_executor.go b/pkg/bbgo/twap_order_executor.go index 1ad682861..db4199cd5 100644 --- a/pkg/bbgo/twap_order_executor.go +++ b/pkg/bbgo/twap_order_executor.go @@ -327,6 +327,7 @@ func (e *TwapExecution) orderUpdater(ctx context.Context) { return } + log.Infof("%s order book changed, checking order...", e.Symbol) if err := e.updateOrder(ctx); err != nil { log.WithError(err).Errorf("order update failed") } diff --git a/pkg/cmd/orders.go b/pkg/cmd/orders.go index 6c3ccbac1..4a1420114 100644 --- a/pkg/cmd/orders.go +++ b/pkg/cmd/orders.go @@ -182,6 +182,11 @@ var executeOrderCmd = &cobra.Command{ return err } + updateInterval, err := cmd.Flags().GetDuration("update-interval") + if err != nil { + return err + } + environ := bbgo.NewEnvironment() if err := environ.ConfigureExchangeSessions(userConfig); err != nil { return err @@ -207,6 +212,7 @@ var executeOrderCmd = &cobra.Command{ SliceQuantity: sliceQuantity, StopPrice: stopPrice, NumOfTicks: numOfPriceTicks, + UpdateInterval: updateInterval, } if err := execution.Run(executionCtx); err != nil { @@ -327,6 +333,7 @@ func init() { executeOrderCmd.Flags().String("target-quantity", "", "target quantity") executeOrderCmd.Flags().String("slice-quantity", "", "slice quantity") executeOrderCmd.Flags().String("stop-price", "0", "stop price") + executeOrderCmd.Flags().Duration("update-interval", time.Second*10, "order update time") executeOrderCmd.Flags().Int("price-ticks", 0, "the number of price tick for the jump spread, default to 0") RootCmd.AddCommand(listOrdersCmd)