Defining additional symbol data needed for a strategy
(system method) Overview:backtesting_extra_symbols() is used to define the additional symbol data needed for testing that might not have been selected in in_symbol_universe(). Method can be used to dynamically create the desired symbols (e.g. md.stat.avol > 1000000).
Interface:@classmethod
def backtesting_extra_symbols(cls,
symbol,
md,
service,
account):
pass
Name | Type | Default | Information |
---|---|---|---|
symbol | string | required | The instance of Strategy (used by the system). |
md | object | required | market data object |
service | object | required | service object |
account | object | required | account object |
- This method is not called, if extra symbols is passed in with the submission.
- return True if the symbol should in included in extra symbols.
- backtesting_extra_symbols() is called for each symbol in the current trading days known symbols.
- Method is called by the simulation engine (once) after is_symbol_qualified() and before instances is created.
- backtesting_extra_symbols() is a @staticmethod. It is not called in the context of script (e.g. there is no self).
- md - allows access to information in md.bar.daily(), and md.stat. Other md will have different behavior in backtesting vs forward testing.
- service - allows acces to md.symbol_list. Other md will have different behavior in backtesting vs forward testing.
- symbol is note self.symbol
Load market data for all symbols that start with the letter "A".
from cloudquant.interfaces import Strategy
class MyStrategy(Strategy):
@classmethod
def backtesting_extra_symbols(cls, symbol, md, service, account):
if symbol.startswith('A'):
return True
return False
Console
None