mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
add more injection checks
This commit is contained in:
parent
822a010932
commit
5ec0566888
|
@ -211,7 +211,7 @@ func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy Si
|
|||
}
|
||||
|
||||
if symbol, ok := isSymbolBasedStrategy(rs); ok {
|
||||
log.Debugf("found symbol based strategy from %s", rs.Type())
|
||||
log.Infof("found symbol based strategy from %s", rs.Type())
|
||||
if _, ok := hasField(rs, "Market"); ok {
|
||||
if market, ok := session.Market(symbol); ok {
|
||||
// let's make the market object passed by pointer
|
||||
|
@ -223,18 +223,24 @@ func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy Si
|
|||
|
||||
// StandardIndicatorSet
|
||||
if _, ok := hasField(rs, "StandardIndicatorSet"); ok {
|
||||
if indicatorSet, ok := session.StandardIndicatorSet(symbol); ok {
|
||||
if err := injectField(rs, "StandardIndicatorSet", indicatorSet, true); err != nil {
|
||||
return errors.Wrapf(err, "failed to inject StandardIndicatorSet on %T", strategy)
|
||||
}
|
||||
indicatorSet, ok := session.StandardIndicatorSet(symbol)
|
||||
if !ok {
|
||||
return fmt.Errorf("standardIndicatorSet of symbol %s not found", symbol)
|
||||
}
|
||||
|
||||
if err := injectField(rs, "StandardIndicatorSet", indicatorSet, true); err != nil {
|
||||
return errors.Wrapf(err, "failed to inject StandardIndicatorSet on %T", strategy)
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := hasField(rs, "MarketDataStore"); ok {
|
||||
if store, ok := session.MarketDataStore(symbol); ok {
|
||||
if err := injectField(rs, "MarketDataStore", store, true); err != nil {
|
||||
return errors.Wrapf(err, "failed to inject MarketDataStore on %T", strategy)
|
||||
}
|
||||
store, ok := session.MarketDataStore(symbol)
|
||||
if !ok {
|
||||
return fmt.Errorf("marketDataStore of symbol %s not found", symbol)
|
||||
}
|
||||
|
||||
if err := injectField(rs, "MarketDataStore", store, true); err != nil {
|
||||
return errors.Wrapf(err, "failed to inject MarketDataStore on %T", strategy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user