For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Get params trought superClass
-
Developing several strategies i have to combine them. So I wrote superclasses, i.e:
class BaseStrategy(bt.Strategy): params = ( ('loShBo', 2), ('isBacktesting', False), ("sizerType", None), # Must be specified otherwise will be rised an Exception ("sizerDictParameters", {"amount": '', "retint": ""}), # Must be specified otherwise will be rised an Exception )
class OverBaseStrategy(BaseStrategy): params = ( ('sma',26), ('roc',50), ('smaRoc',50), ('ema',26), )
class MyStrategy_01(OverBaseStrategy): params = dict( stop_loss=0.05, trail=0.07, )
When I call:
cerebro = bt.Cerebro() params = { 'trail': 0.02, 'smaRoc': 20, 'isBacktesting': True} cerebro.addstrategy(strategy=MyStrategy_01, **params) pprint(cerebro.strats[0][0][0].params.__dict__)
The output is:
mappingproxy({'__doc__': None, '__module__': 'backtrader.metabase', '_getpairs': <classmethod object at 0x0000024E510751F0>, '_getpairsbase': <classmethod object at 0x0000024E51075190>, '_getrecurse': <classmethod object at 0x0000024E51075250>, 'stop_loss': 0.05, 'trail': 0.07})
What can I do to retrive all params with superclasses included?
i.e. :mappingproxy({ '__doc__': None, '__module__': 'backtrader.metabase', '_getpairs': <classmethod object at 0x0000024E510751F0>, '_getpairsbase': <classmethod object at 0x0000024E51075190>, '_getrecurse': <classmethod object at 0x0000024E51075250>, 'loShBo': 2, 'isBacktesting': True, # <== NOT False as default 'sizerType': None, 'sizerDictParameters': {"amount": '', "retint": ""}, 'sma': 26, 'roc': 20, 'smaRoc': 20, # <== NOT 50 as default 'ema': 26, 'stop_loss': 0.05, 'trail': 0.02, # <== NOT 0.07 as default })