From 310943d0105402e7a63ad77cfe2a42d8e4efc735 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 9 Jan 2021 11:12:48 +0800 Subject: [PATCH] add isolated margin symbol option --- pkg/bbgo/config.go | 10 ++++++---- pkg/bbgo/environment.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/bbgo/config.go b/pkg/bbgo/config.go index 89cb61815..88441fd9f 100644 --- a/pkg/bbgo/config.go +++ b/pkg/bbgo/config.go @@ -52,10 +52,12 @@ type NotificationConfig struct { } type Session struct { - ExchangeName string `json:"exchange" yaml:"exchange"` - EnvVarPrefix string `json:"envVarPrefix" yaml:"envVarPrefix"` - PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` - Margin bool `json:"margin,omitempty" yaml:"margin"` + ExchangeName string `json:"exchange" yaml:"exchange"` + EnvVarPrefix string `json:"envVarPrefix" yaml:"envVarPrefix"` + PublicOnly bool `json:"publicOnly,omitempty" yaml:"publicOnly"` + Margin bool `json:"margin,omitempty" yaml:"margin"` + IsolatedMargin bool `json:"isolatedMargin,omitempty" yaml:"isolatedMargin,omitempty"` + IsolatedMarginSymbol string `json:"isolatedMarginSymbol,omitempty" yaml:"isolatedMarginSymbol,omitempty"` } type Backtest struct { diff --git a/pkg/bbgo/environment.go b/pkg/bbgo/environment.go index b7814d6a4..a49aefde2 100644 --- a/pkg/bbgo/environment.go +++ b/pkg/bbgo/environment.go @@ -147,7 +147,7 @@ func (environ *Environment) AddExchangesFromSessionConfig(sessions map[string]Se return fmt.Errorf("exchange %s does not support margin", exchangeName) } - marginExchange.UseMargin(true) + marginExchange.UseIsolatedMargin(sessionConfig.Margin) } environ.AddExchange(sessionName, exchange)