The error I am getting
Runtime Error: TypeError : trade() takes 1 positional argument but 2 were given
at BearRebalance
self.trade({**self.HLD_IN in main.py: line 338 (Open Stacktrace)
Working through combining two separate algorithms and I seem to be running into an issue I believe is at the part that is checking whether the algorithm is already holding stocks:
if not self.BE_IN:
# Only trade when changing from in to out
self.trade({**dict.fromkeys(self.HLD_IN, 0), **self.HLD_OUT})
elif self.BE_IN:
# Only trade when changing from out to in
self.trade({**self.HLD_IN, **dict.fromkeys(self.HLD_OUT, 0)}
Can anyone point me in the right direction here?
Mak K
Hey Axist ,
Haven't looked at the code much yet but one issue in the code might be that there are multiple different “trade” functions, since python does not support function overloading this is probably causing the problem, especially since them of them only take 1 argument and some take 2 arguments.
I would suggest you rename your functions and see if the bug persists.
Unless you were planning on having the functions constantly overriding each other.
Thanks!
Fred Painchaud
Hi Axist,
The kinda thing you see in a second when you take a short break away from your code… 😊😊😊
Use:
Note the missing ‘)’ at the end of the line.
Fred
Axist
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!