From 666e9a5a35997ed53c6477fad24ea01472016c53 Mon Sep 17 00:00:00 2001 From: frankrap <2201441955@qq.com> Date: Sat, 3 Oct 2020 17:10:17 +0800 Subject: [PATCH] Update --- serve/serve.go | 23 +++++++++++++++-------- testdata/serve-config-sample.toml | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/serve/serve.go b/serve/serve.go index 8f0a6ed..b91b6af 100644 --- a/serve/serve.go +++ b/serve/serve.go @@ -25,12 +25,13 @@ type SLog struct { } type SExchange struct { - Name string `toml:"name"` - DebugMode bool `toml:"debug_mode"` - AccessKey string `toml:"access_key"` - SecretKey string `toml:"secret_key"` - Testnet bool `toml:"testnet"` - WebSocket bool `toml:"websocket"` + Name string `toml:"name"` + DebugMode bool `toml:"debug_mode"` + AccessKey string `toml:"access_key"` + SecretKey string `toml:"secret_key"` + Passphrase string `toml:"passphrase"` + Testnet bool `toml:"testnet"` + WebSocket bool `toml:"websocket"` } // Serve 加载策略并执行 @@ -75,12 +76,18 @@ func SetupStrategyFromConfig(strategy Strategy) (err error) { } var exs []interface{} for _, ex := range c.Exchanges { - exchange := exchanges.NewExchange(ex.Name, + var opts = []ApiOption{ ApiDebugModeOption(ex.DebugMode), ApiAccessKeyOption(ex.AccessKey), ApiSecretKeyOption(ex.SecretKey), ApiTestnetOption(ex.Testnet), - ApiWebSocketOption(ex.WebSocket)) + ApiWebSocketOption(ex.WebSocket), + } + if ex.Passphrase != "" { + opts = append(opts, ApiPassPhraseOption(ex.Passphrase)) + } + exchange := exchanges.NewExchange(ex.Name, + opts...) exs = append(exs, exchange) } if err = strategy.Setup(TradeModeLiveTrading, exs...); err != nil { diff --git a/testdata/serve-config-sample.toml b/testdata/serve-config-sample.toml index c685259..a189315 100644 --- a/testdata/serve-config-sample.toml +++ b/testdata/serve-config-sample.toml @@ -3,6 +3,7 @@ name = "deribit" debug_mode = false access_key = "" secret_key = "" +passphrase = "" # 可选,OKEX需要配置此参数 testnet = true websocket = false