cmd/order: add margin-side-effect option

This commit is contained in:
c9s 2022-09-07 02:01:38 +08:00
parent 33fdcefba3
commit 90b633158a
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -334,6 +334,11 @@ var submitOrderCmd = &cobra.Command{
return fmt.Errorf("can not get quantity: %w", err)
}
marginOrderSideEffect, err := cmd.Flags().GetString("margin-side-effect")
if err != nil {
return fmt.Errorf("can not get quantity: %w", err)
}
environ := bbgo.NewEnvironment()
if err := environ.ConfigureExchangeSessions(userConfig); err != nil {
return err
@ -361,6 +366,7 @@ var submitOrderCmd = &cobra.Command{
Price: fixedpoint.MustNewFromString(price),
Market: market,
TimeInForce: "GTC",
MarginSideEffect: types.MarginOrderSideEffectType(marginOrderSideEffect),
}
co, err := session.Exchange.SubmitOrders(ctx, so)
@ -386,6 +392,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().String("margin-side-effect", "", "margin order side effect")
executeOrderCmd.Flags().String("session", "", "the exchange session name for sync")
executeOrderCmd.Flags().String("symbol", "", "the trading pair, like btcusdt")