For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

TypeError: __init__() got an unexpected keyword argument 'size'



  • Hi, normally i can solve these sorts of problems for myself but this time i just can't work it out, hopefuly someone here can help. i get this error when trying to run a simple backtest, no optimisation or anything
    '''
    Traceback (most recent call last):
    File "C:/Users/ross_/PycharmProjects/MA-Cross/backtest-1m.py", line 60, in <module>
    strat_list = cerebro.run()
    File "C:\Users\ross_\AppData\Local\Programs\Python\Python38\lib\site-packages\backtrader\cerebro.py", line 1127, in run
    runstrat = self.runstrategies(iterstrat)
    File "C:\Users\ross_\AppData\Local\Programs\Python\Python38\lib\site-packages\backtrader\cerebro.py", line 1217, in runstrategies
    strat = stratcls(*sargs, **skwargs)
    File "C:\Users\ross_\AppData\Local\Programs\Python\Python38\lib\site-packages\backtrader\metabase.py", line 88, in call
    _obj, args, kwargs = cls.doinit(obj, *args, **kwargs)
    File "C:\Users\ross
    \AppData\Local\Programs\Python\Python38\lib\site-packages\backtrader\metabase.py", line 78, in doinit
    _obj.init(*args, **kwargs)
    TypeError: init() got an unexpected keyword argument 'size'
    '''

    Thanks



  • Based on the info shown - it is definitely the bug in your code somewhere. So, we have two options. We can wait for the mind reader, and he can read your code from your mind and find the bug. Or you can post your code and then regular members can try to find the bug. You choose.



  • I guess you are trying to instantiate your strategy with an argument size which is unknown to your strategy?
    But still, debugging code is alot easier when you actually can see the code in question :)


  • administrators

    @Ross-Coates said in TypeError: __init__() got an unexpected keyword argument 'size':

    Hi, normally i can solve these sorts of problems for myself but this time i just can't work it out, hopefuly someone here can help. i get this error when trying to run a simple backtest, no optimisation or anything

    @vbs and @ab_trader have already given the right tips. You probably haven't defined a parameter named size but you pass it in any case.

    It is actually impossible to know, since you only provide an error trace and not actual sample code.


  • administrators

    @Ross-Coates said in TypeError: __init__() got an unexpected keyword argument 'size':

    '''

    In any case let me point out that those three ticks (i.e ' vertical) are not backticks as in `

    You may want to directly copy the ticks from the announcement at the top of the forum

    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    

Log in to reply
 

});