mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
fix backtest Initialize call
This commit is contained in:
parent
4b70f864ff
commit
9efd8bd604
|
@ -26,7 +26,7 @@ backtest:
|
||||||
endTime: "2022-03-01"
|
endTime: "2022-03-01"
|
||||||
symbols:
|
symbols:
|
||||||
- BTCUSDT
|
- BTCUSDT
|
||||||
sessions: [max,binance]
|
sessions: [binance]
|
||||||
# syncSecKLines: true
|
# syncSecKLines: true
|
||||||
accounts:
|
accounts:
|
||||||
binance:
|
binance:
|
||||||
|
|
|
@ -357,7 +357,6 @@ func (trader *Trader) Run(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (trader *Trader) Initialize(ctx context.Context) error {
|
func (trader *Trader) Initialize(ctx context.Context) error {
|
||||||
log.Infof("initializing strategies...")
|
|
||||||
return trader.IterateStrategies(func(strategy StrategyID) error {
|
return trader.IterateStrategies(func(strategy StrategyID) error {
|
||||||
if initializer, ok := strategy.(StrategyInitializer); ok {
|
if initializer, ok := strategy.(StrategyInitializer); ok {
|
||||||
return initializer.Initialize()
|
return initializer.Initialize()
|
||||||
|
|
|
@ -303,6 +303,10 @@ var BacktestCmd = &cobra.Command{
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := trader.Initialize(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := trader.Run(ctx); err != nil {
|
if err := trader.Run(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,10 @@ type Strategy struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Strategy) Initialize() error {
|
func (s *Strategy) Initialize() error {
|
||||||
|
if s.Strategy == nil {
|
||||||
s.Strategy = &common.Strategy{}
|
s.Strategy = &common.Strategy{}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user