Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
f0cii committed Oct 3, 2020
1 parent 4e47278 commit 666e9a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
23 changes: 15 additions & 8 deletions serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 加载策略并执行
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions testdata/serve-config-sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "deribit"
debug_mode = false
access_key = ""
secret_key = ""
passphrase = "" # 可选,OKEX需要配置此参数
testnet = true
websocket = false

Expand Down

0 comments on commit 666e9a5

Please sign in to comment.