How can I inherit params from a parent class and append on the child class?
-
How can I inherit params from a parent class and append on the child class?
I have tried the code below, but received an error.class Parent(bt.Strategy):
params = {
'p1': '',
'p2': '',
}class Child(Parent):
params = Parent.params
params.update({
'p3': '',
'p4': '',
}) -
would be nice to have the error posted also.
-
C:\Users\SERVER_OPT1\anaconda3\envs\Denali\python.exe D:/onedrive/AndreTavares/Fundo/Denali/strats/momentumfactor.py --symbols PETR4 BBAS3 ABEV3 "--strat={'symbols_idx': 'ibrx100'}" --start_date=2019-03-01
Traceback (most recent call last):
File "D:/onedrive/AndreTavares/Fundo/Denali/strats/momentumfactor.py", line 40, in <module>
class MomentumFactor(strategy.Strategy):
File "D:/onedrive/AndreTavares/Fundo/Denali/strats/momentumfactor.py", line 44, in MomentumFactor
params.update({
AttributeError: type object 'AutoInfoClass_LineRoot_LineMultiple_LineSeries_Lin' has no attribute 'update'Process finished with exit code 1
-
@André-Tavares said in How can I inherit params from a parent class and append on the child class?:
params.update({
No need to update the
params
dict. The parameters from the base classes are fusedautomagically
by metaclass during the instantiation. You may take a look at the following post as well: https://community.backtrader.com/topic/2379/difference-between-params-and-p/2