fix backtest Initialize call

This commit is contained in:
c9s 2024-01-28 14:29:54 +08:00
parent 4b70f864ff
commit 9efd8bd604
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 9 additions and 3 deletions

View File

@ -26,7 +26,7 @@ backtest:
endTime: "2022-03-01"
symbols:
- BTCUSDT
sessions: [max,binance]
sessions: [binance]
# syncSecKLines: true
accounts:
binance:

View File

@ -357,7 +357,6 @@ func (trader *Trader) Run(ctx context.Context) error {
}
func (trader *Trader) Initialize(ctx context.Context) error {
log.Infof("initializing strategies...")
return trader.IterateStrategies(func(strategy StrategyID) error {
if initializer, ok := strategy.(StrategyInitializer); ok {
return initializer.Initialize()

View File

@ -303,6 +303,10 @@ var BacktestCmd = &cobra.Command{
return err
}
if err := trader.Initialize(ctx); err != nil {
return err
}
if err := trader.Run(ctx); err != nil {
return err
}

View File

@ -37,7 +37,10 @@ type Strategy struct {
}
func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}
if s.Strategy == nil {
s.Strategy = &common.Strategy{}
}
return nil
}