Make ticks on edges count as open for next bar (instead of close of current bar)
-
Hello gentlemen,
I am back at this topic (everyhing I say is based on my current understanding, please feel to comment if I am wrong somewhere):
When resampling ticks to a higher timeframe then currently backtrader counts ticks on the edge (e.g.14:00:00
whenTick
->Hour
) as last (closing) value for the current bar. This intentionally as far as I know.
I was expeceting (since I know it from other software packages) that such ticks would count as the open value for the following bar.I had a topic about this here already (I thought it was a bug back then):
https://community.backtrader.com/topic/777/bug-building-bars-in-live-mode-regarding-last-tickSo I tried to change the backtrader code to make it behave like I am used to. I did it with this commit which touches backtrader's
Resampler
filter:
https://github.com/verybadsoldier/backtrader/commit/014344445e0fde1b217cf912619839f4cca20cc8The commit adds a parameter
tickedgestart
to theResampler
(defaults toFalse
). When setting toTrue
then the alternative behavior is activated (only when resamplingTick
). So far it does what I wanted for me.Please @backtrader would you maybe take a look at the commit and tell me if you see problems with that approach? I feel that I don't have a well enough understanding of the internals to be sure to avoid side effects. :(