mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: fix injection
This commit is contained in:
parent
7ce7a1b11c
commit
de62d9dd67
|
@ -473,6 +473,11 @@ func (session *ExchangeSession) Positions() map[string]*types.Position {
|
|||
// MarketDataStore returns the market data store of a symbol
|
||||
func (session *ExchangeSession) MarketDataStore(symbol string) (s *MarketDataStore, ok bool) {
|
||||
s, ok = session.marketDataStores[symbol]
|
||||
if !ok {
|
||||
s = NewMarketDataStore(symbol)
|
||||
session.marketDataStores[symbol] = s
|
||||
return s, true
|
||||
}
|
||||
return s, ok
|
||||
}
|
||||
|
||||
|
|
|
@ -292,10 +292,22 @@ func (trader *Trader) injectFields() error {
|
|||
return fmt.Errorf("market of symbol %s not found", symbol)
|
||||
}
|
||||
|
||||
indicatorSet, ok := session.StandardIndicatorSet(symbol)
|
||||
if !ok {
|
||||
return fmt.Errorf("standardIndicatorSet of symbol %s not found", symbol)
|
||||
}
|
||||
|
||||
store, ok := session.MarketDataStore(symbol)
|
||||
if !ok {
|
||||
return fmt.Errorf("marketDataStore of symbol %s not found", symbol)
|
||||
}
|
||||
|
||||
if err := dynamic.ParseStructAndInject(strategy,
|
||||
market,
|
||||
session,
|
||||
session.OrderExecutor,
|
||||
indicatorSet,
|
||||
store,
|
||||
); err != nil {
|
||||
return errors.Wrapf(err, "failed to inject object into %T", strategy)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user