Merge pull request #582 from c9s/rename-backtest-account-to-accounts

improve: backtest: rename backtest.account to backtest.accounts
This commit is contained in:
Yo-An Lin 2022-05-03 12:41:32 +08:00 committed by GitHub
commit 159c972d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -83,7 +83,16 @@ func NewExchange(sourceName types.ExchangeName, sourceExchange types.Exchange, s
endTime = time.Now()
}
configAccount := config.Account[sourceName.String()]
configAccount, ok := config.Accounts[sourceName.String()]
if !ok {
// fallback to the legacy account syntax
configAccount, ok = config.Account[sourceName.String()]
if !ok {
return nil, errors.New("config backtest.accounts is not defined, please check your config file.")
} else {
log.Warnf("config backtest.account is deprecated, please use backtest.accounts instead.")
}
}
account := &types.Account{
MakerFeeRate: configAccount.MakerFeeRate,

View File

@ -105,7 +105,10 @@ type Backtest struct {
// RecordTrades is an option, if set to true, back-testing should record the trades into database
RecordTrades bool `json:"recordTrades,omitempty" yaml:"recordTrades,omitempty"`
// Account is deprecated, use Accounts instead
Account map[string]BacktestAccount `json:"account" yaml:"account"`
Accounts map[string]BacktestAccount `json:"accounts" yaml:"accounts"`
Symbols []string `json:"symbols" yaml:"symbols"`
Sessions []string `json:"sessions" yaml:"sessions"`
}