twap: add update-interval option

This commit is contained in:
c9s 2021-05-15 09:29:44 +08:00
parent ae256ce9d3
commit f9cb414832
2 changed files with 8 additions and 0 deletions

View File

@ -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")
}

View File

@ -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)