It would help (us) a lot if you showed us what the program is asking you for and how you manage that it requests you to do so. In general and having had a look at several samples and a quick look at the docs: cancel(order)
You keep a reference to the order(s) which have been created and use that to cancel.
Here is the approach - compare length of the daily data feed on each next() call. This will help to avoid excessive next() calls due to resampling. You might be able to come up with the only next() call at the end of the week.
There might be a case when you can stay on the same time frame, but this need to be tested.
In order to perform conservative backtest, stop orders should be processed before take orders. bt normally processes orders as first come - first go, so every time you issue buy entry order, stop order should be issued before take order. Using this and quicknotify to cancel remaining order can work.
No need to use leverage, define margin based on the price, fixed commission and mult. Usually mult is not defined as 1 / margin, but by future contract spec. Since I don't know what are you going to trade, then this need to be clarified.
As of leverage - this is bts implementation of the broker loan if you want to buy stocks more than your funds allow you. More or less in details is described here Blog - BTFD (Buy The F... Dip)
It seems like you misread that documentation. It says that it gives you the chance to make calculations for all-in strategies and not that the platform will do it for you. You shouldn't be expecting the platform to cheat simply because you want to cheat.
Summary: you have to make your own calculations and/or write a cheating sizer that uses the opening price. Of course that sizer will only be valid for such a scenario.
Thanks. So size should be positive for buy and negative for sell (not short)?
From my understanding if you buy, then internally size is positive for trade and commission calcs; if you sell, then size is negative. short is equal to sell if you have nothing to sell, so I assume negative size also, but you know your trading conditions better. anyway, code it and let us know your results.
As for the 1c, I suspect it has to do with the time the position is held. I assume it increases with time (never had long lived positions in real life, to verify this).
I don't think so. My understanding that exchange fee is included into brokerage fee and doesn't apply separately. But I can be wrong.
Disabled Categories are greyed out
This topic will be moved to the category
Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.