diff --git a/pkg/cmd/orders.go b/pkg/cmd/orders.go index 04f891698..f5dbf496c 100644 --- a/pkg/cmd/orders.go +++ b/pkg/cmd/orders.go @@ -300,7 +300,6 @@ var submitOrderCmd = &cobra.Command{ "session", "symbol", "side", - "price", "quantity", }), RunE: func(cmd *cobra.Command, args []string) error { @@ -329,6 +328,11 @@ var submitOrderCmd = &cobra.Command{ return fmt.Errorf("can not get price: %w", err) } + asMarketOrder, err := cmd.Flags().GetBool("market") + if err != nil { + return err + } + quantity, err := cmd.Flags().GetString("quantity") if err != nil { return fmt.Errorf("can not get quantity: %w", err) @@ -363,12 +367,23 @@ var submitOrderCmd = &cobra.Command{ Side: types.SideType(strings.ToUpper(side)), Type: types.OrderTypeLimit, Quantity: fixedpoint.MustNewFromString(quantity), - Price: fixedpoint.MustNewFromString(price), Market: market, - TimeInForce: "GTC", MarginSideEffect: types.MarginOrderSideEffectType(marginOrderSideEffect), } + if asMarketOrder { + so.Type = types.OrderTypeMarket + so.Price = fixedpoint.Zero + } else { + if len(price) == 0 { + return fmt.Errorf("price is required for limit order submission") + } + + so.Type = types.OrderTypeLimit + so.Price = fixedpoint.MustNewFromString(price) + so.TimeInForce = types.TimeInForceGTC + } + co, err := session.Exchange.SubmitOrders(ctx, so) if err != nil { return err @@ -392,6 +407,7 @@ func init() { submitOrderCmd.Flags().String("side", "", "the trading side: buy or sell") submitOrderCmd.Flags().String("price", "", "the trading price") submitOrderCmd.Flags().String("quantity", "", "the trading quantity") + submitOrderCmd.Flags().Bool("market", false, "submit order as a market order") submitOrderCmd.Flags().String("margin-side-effect", "", "margin order side effect") executeOrderCmd.Flags().String("session", "", "the exchange session name for sync")