I've had this problem as well, the only reliable solution I've found is to restart the backtrader process and manually manage any open orders. Kinda sucks to have to do this.
Posts made by nooby_mcnoob
RE: IBController + Backtrader, no bars being produced after connection has resumed
RE: Is it possible to backtest minute data with a lunch break?
You'd do something like this:
class MyStrategy(...): def next(self): now = self.data0.datetime.datetime(0) if now.time() >= datetime.time(11,31) and now.time() <= datetime.time(12,59): ... your logic here ...
RE: Trailing take profit
It does seem in times of volatility the StopTrailLimit would be very disadvantageous - are there any advantages?
It can be problematic. I've had markets go right over my limit. The only thing I do is have a OCO stop market order further than the trail in case markets go crazy and I'm not there to do something.
RE: Is there way to track open orders with IB broker?
Here is how I debug live trades:
notify_orderfunctions and print out the status as it comes in
- Don't use GTC orders unless your strategy cancels orders. I use time-limited orders
Additionally, when I place an order, I assign the current order to a member:
self._order = ...and unset it when
notify_trademarks it as closed. Then, I don't do any of the strategy logic unless
RE: Weekly resampling, set cutoff to a different weekday?
Looks like I should use a trading calendar
Weekly resampling, set cutoff to a different weekday?
See summary. Is there any way to set the specific day of the week used to mean the beginning/end of the week? Currently it appears to default to Sunday/Monday which is OK but I'd like more control.
RE: Brain limitations: position sizing for forex
@backtrader Actually, I'm unable to see how to apply this.
If we have
But the actual price is $.75, the order will go to the broker at $100... I'm very confused. Maybe the right thing to do is to manually create the bracket orders.
Brain limitations: position sizing for forex
This is tough, I think because the "size" has to be different if you want to convert 100% of the amount back to your base currency.
So say my base currency is USD and I am trading USD/GBP (I know this isn't a real pair). If I convert $100 to £75, the order could look like this:
The sizer is called once, and lets say the idea is to always trade a size of $100, so we configured
Now say the profit limit is hit, that means we will convert £100 into $133. But we only had £75 which means we will be taking some sort of a position instead of closing it out.
I'm trying to figure out how we would size this properly, but it seems to be a limitation in my brain.
RE: Optimizing Strategy with IBStore data returns pickle error
I tried to resolve this issue by walking recursively down the object tree rooted at cerebro and setting all lock types to None. Didn't work, still found a lock somewhere.