Skip to content

Commit

Permalink
fix backtest Initialize call
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 28, 2024
1 parent 4b70f86 commit 9efd8bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/emacross.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ backtest:
endTime: "2022-03-01"
symbols:
- BTCUSDT
sessions: [max,binance]
sessions: [binance]
# syncSecKLines: true
accounts:
binance:
Expand Down
1 change: 0 additions & 1 deletion pkg/bbgo/trader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/backtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/strategy/rsicross/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9efd8bd

Please sign in to comment.