sell_bracket() order: sell() got an unexpected keyword argument 'size'
-
Re: TypeError: init() got an unexpected keyword argument 'size'
Hello, I was looking at this post from last year and don't know whether it was solved or not. It looks like the sell() method isn't computing the size parameter properly when calling the sell_bracket() method.
This is my python error:
sell() got an unexpected keyword argument 'size'
This is my code below:
def sell(self, pivot_point_price, asset_key, target_retracement): entry_price = pivot_point_price - .1 entry_price = round(entry_price, 2) exit_price = entry_price - target_retracement exit_price = round(exit_price, 2) stop_price = entry_price + (.5 * target_retracement) stop_price = round(stop_price, 2) size = utilities.determine_position_size(entry_price, stop_price) if type(self).__base__.__name__ == 'Strategy': # TODO: what's going on with the size param? super().sell_bracket(limitprice=exit_price, price=entry_price, stopprice=stop_price, size=1, valid=constants.VALID_ORDER_TIMEDELTA) else: api.send_entry_trigger_oco_order_short( entry_price, exit_price, stop_price, asset_key, size) self.order_list.append(asset_key)
Stepping through the sell_bracket order I verified that the size parameter is being passed properly to the
kwargs
that then gets passed toself.sell(**kargs)
Has anyone else experienced this? Let me know if you need anything else from me. Thanks.
-
This is the full error:
File "/Users/hfuess/trading/quantstream/env/lib/python3.9/site-packages/backtrader/strategy.py", line 1217, in sell_bracket o = self.sell(**kargs) TypeError: sell() got an unexpected keyword argument 'size'
-
Seems unusual to me.
May I ask why do you even call super().sell_bracket ?
Why not just self.sell_bracket ? Did you change sell_bracket somehow?