Thank you for the quick reply!
@backtrader said in Backtesting with tick data and ask/bid prices:
It would seem you have an extra component besides
bid
andask
Indeed. I wanted to keep the example simple because I think if I can make this simple version work I'll be able to figure out the rest. But in fact I have a market depth with n-prices and n-volumes for multiple assets. I'm exploring triangular arbitrage in illiquid markets.
Thank you for pointing me to the Filter. As I understand it you can use it to modify the incoming data feed. What complicates it in my case is that I sometimes need to use ask and sometimes bid based on the currently opened positions and the current arbitrage opportunity which is calculated in the strategy on each incoming tick.
Concrete (simplified) example: Let's say we have two assets: A1, A2 with bid/ask prices A1.b, A1.a, A2.b, A2.a. An arbitrage opportunity between A1 and A2 appears and we need to go long on A1, short on A2. Therefore we need to use A1.a for entering the long position and A2.b for entering the short position (assuming Market orders). The difference between bid and ask is quite important in this case because with arbitrage we're going for tiny market inefficiencies.
My current understanding from what I tried with backtrader and from what you wrote is that this probably won't be possible, right? I also explored all other Python backtesting frameworks you mention in Github README and it seems that none of them will be easily applicable to my use case although I need to explore QSTrader and QTPyLib in more depth.