-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm optimizing some parameters, and some configurations result in a null price in the middle of the optimization. I'm not sure what is causing it, maybe trying to sell twice in the same period somehow
Steps to Reproduce
I use this Function:
stats, heatmap = bc.optimize(
iaf1 = [0.015],
maxaf1 = [0.16],
mgain = [0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10],
mloss = [0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10],
constraint=lambda p: p.iaf1 < p.maxaf1,
maximize='Equity Final [$]',
return_heatmap=True)WIth a parabolic SAR indicator:
def next(self):
if not self.position:
if self.boole == 1:
self.buy()
elif self.boole == -1 and not self.position:
self.sell()
else:
if self.position.pl_pct >= self.mgain or self.position.pl_pct <= -self.mloss:
self.position.close()Getting this assertion error
~\Anaconda3\lib\site-packages\backtesting\backtesting.py in sell(self, price, sl, tp)
465
466 def sell(self, price=None, sl=None, tp=None):
--> 467 assert (tp or -np.inf) <= (price or self.last_close) <= (sl or np.inf), "For short orders should be: TP ({}) < BUY PRICE ({}) < SL ({})".format(tp, price or self.last_close, sl) # noqa: E501
468 self.orders._update(price, sl, tp, is_long=False)
469
AssertionError: For short orders should be: TP (None) < BUY PRICE (nan) < SL (None)
Where the price is null, but the model works fine on other parameters.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working