@RandomTrader88 Exactly this happened with me. I tried to run a strategy with no buy/sell signal and got this error.
Best posts made by zuj
-
RE: cerebro.plot() error
Latest posts made by zuj
-
Resampling data issue
Suppose you have a weekly strategy that executes on Wednesday and you're using indicators on a resampled weekly timeframe data.
I think when we resample the data, it only changes the daily data from Monday to Sunday to a Week, but if you have a strategy that runs on Wednesday, shouldn't it have a weekly resample from Wednesday to Tuesday to include Monday and Tuesday of this week in the resampled data just before Wednesday? -
Implemented stop loss having no effect on results
I implemented stopLoss using the following code where stopLoss price is
d.close[0] - p * standardDeviation(d,10)
. I vary the parameter p from [0.5,1,2 to 10], but it had just a bare minimum effect on the returns even for a large amount of data from 2005 to 2020. All the results including the one without stoploss differ within 0.1%. I mean even adding or deleting a month from this whole data would have had more impact on returns than stopLoss did. Am I doing something wrong?o = self.buy(d,size=size) s = self.sell(d,price=stopLoss, size=size,exectype=bt.Order.Stop, parent=o) self.stops[d] = s
-
RE: How to rebalance bracket orders?
@ab_trader Basically creating a bracket order and then when rebalancing the order, you change the past values of stops and targets according to the new values when rebalancing.
-
RE: StopTrail giving weird Results ....Probably
I figured it out. StopTrail doesn't work correctly with target orders.
-
Significantly different results by resampling data
I have a strategy executing for a resampled weekly timeframe data which executed every week on Wednesday. I just wanted another perspective so I decided to add daily data too. I did exactly the same thing, executing trades on Wednesday using indicators on weekly data but executing the trades using self.buy(self.dataDaily) instead of self.buy(self.dataWeekly) and it lead to a massive difference in the results.
Here is the code which is used to add datadata0 = bt.feeds.PandasData(dataname=sym,plot=False) cerebro.resampledata(data0,name=sym) cerebro.resampledata(data0,name=sym+"weeks",timeframe=bt.TimeFrame.Weeks)
and for the weekly data only, I used
data0 = bt.feeds.PandasData(dataname=sym,plot=False) cerebro.resampledata(data0,name=sym+"weeks",timeframe=bt.TimeFrame.Weeks)
Anybody else has faced this issue????
-
RE: StopTrail giving weird Results ....Probably
@zuj Now I noticed that even setting trailpercent=0 gives similar but different results?????????
-
StopTrail giving weird Results ....Probably
I am using
self.order_target_percent(d, target=self.perctarget, exectype=bt.Order.StopTrail, trailpercent=1)
for the stoptrail implementation. I checked the source code and I expected it to give me the same result that I get when I only use
self.order_target_percent(d, target=self.perctarget)
But I am getting very different results
without stoptrail trailpercent=1 143631.53 with stoptrail trailpercent=1 75766.57
I also got the same value without stoptrail, when I used stoptrail with trailpercent=0, but then I checked the source code and I saw that it is initialized with 0, so they are the same thing.
I still think that if I have a trailing stop with 100% distance then it should be pretty similar(IF NOT SAME) to the case without stopTrail. Am I missing something here?
-
RE: How to stop ZeroDivisionError on a single optimization process?
@vladisld I changed my code to adapt to the error so I can't post the exact trace now but I remember it happening in the multiprocessing module: float Division by zero error. But I figured out that trailpercent wasn't the issue. ADX was probably causing some error unexpectedly, it doesn't have any safediv param either. I don't know why it happened on a subset of the data but never on the whole data.
Besides, the StopTrail is causing problems too, I thought that if I set the trailpercent=1, then it would just be the normal execution without any stoptrail getting executed because it lags by 100% of the price so why is it making my returns so negative as compared to my returns without using stoptrails? Shouldn't they be the same?
-
StopTrail with order_target_percent?
Does it work? What if I want to rebalance the stock again using order_target_percent but I don't want to use the StopTrail? What will happen to the old stocks and the rebalanced stocks?