Skip to content

Commit 666e9a5

Browse files
committed
Update
1 parent 4e47278 commit 666e9a5

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

serve/serve.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ type SLog struct {
2525
}
2626

2727
type SExchange struct {
28-
Name string `toml:"name"`
29-
DebugMode bool `toml:"debug_mode"`
30-
AccessKey string `toml:"access_key"`
31-
SecretKey string `toml:"secret_key"`
32-
Testnet bool `toml:"testnet"`
33-
WebSocket bool `toml:"websocket"`
28+
Name string `toml:"name"`
29+
DebugMode bool `toml:"debug_mode"`
30+
AccessKey string `toml:"access_key"`
31+
SecretKey string `toml:"secret_key"`
32+
Passphrase string `toml:"passphrase"`
33+
Testnet bool `toml:"testnet"`
34+
WebSocket bool `toml:"websocket"`
3435
}
3536

3637
// Serve 加载策略并执行
@@ -75,12 +76,18 @@ func SetupStrategyFromConfig(strategy Strategy) (err error) {
7576
}
7677
var exs []interface{}
7778
for _, ex := range c.Exchanges {
78-
exchange := exchanges.NewExchange(ex.Name,
79+
var opts = []ApiOption{
7980
ApiDebugModeOption(ex.DebugMode),
8081
ApiAccessKeyOption(ex.AccessKey),
8182
ApiSecretKeyOption(ex.SecretKey),
8283
ApiTestnetOption(ex.Testnet),
83-
ApiWebSocketOption(ex.WebSocket))
84+
ApiWebSocketOption(ex.WebSocket),
85+
}
86+
if ex.Passphrase != "" {
87+
opts = append(opts, ApiPassPhraseOption(ex.Passphrase))
88+
}
89+
exchange := exchanges.NewExchange(ex.Name,
90+
opts...)
8491
exs = append(exs, exchange)
8592
}
8693
if err = strategy.Setup(TradeModeLiveTrading, exs...); err != nil {

testdata/serve-config-sample.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "deribit"
33
debug_mode = false
44
access_key = ""
55
secret_key = ""
6+
passphrase = "" # 可选,OKEX需要配置此参数
67
testnet = true
78
websocket = false
89

0 commit comments

Comments
 (0)