mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +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 {
|
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 _, ok := hasField(rs, "Market"); ok {
|
||||||
if market, ok := session.Market(symbol); ok {
|
if market, ok := session.Market(symbol); ok {
|
||||||
// let's make the market object passed by pointer
|
// let's make the market object passed by pointer
|
||||||
|
@ -223,18 +223,24 @@ func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy Si
|
||||||
|
|
||||||
// StandardIndicatorSet
|
// StandardIndicatorSet
|
||||||
if _, ok := hasField(rs, "StandardIndicatorSet"); ok {
|
if _, ok := hasField(rs, "StandardIndicatorSet"); ok {
|
||||||
if indicatorSet, ok := session.StandardIndicatorSet(symbol); ok {
|
indicatorSet, ok := session.StandardIndicatorSet(symbol)
|
||||||
if err := injectField(rs, "StandardIndicatorSet", indicatorSet, true); err != nil {
|
if !ok {
|
||||||
return errors.Wrapf(err, "failed to inject StandardIndicatorSet on %T", strategy)
|
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 _, ok := hasField(rs, "MarketDataStore"); ok {
|
||||||
if store, ok := session.MarketDataStore(symbol); ok {
|
store, ok := session.MarketDataStore(symbol)
|
||||||
if err := injectField(rs, "MarketDataStore", store, true); err != nil {
|
if !ok {
|
||||||
return errors.Wrapf(err, "failed to inject MarketDataStore on %T", strategy)
|
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