Open WhileE opened 8 months ago
It looks like if I swap the order add_price_event() and add_bar_event(), things work better.
Digging into the code a bit, it initially looks like the final_prices are getting squashed here:
(BacktestController.py, line 418)
if len(relevant_data) > 0:
final_prices[symbol] = pd.concat(relevant_data)
My initial testing shows that the following code preserves all prices @ all resolutions:
if len(relevant_data) > 0:
if symbol not in final_prices:
final_prices[symbol] = pd.concat(relevant_data)
else:
new_data = pd.concat(relevant_data)
final_prices[symbol] = pd.concat([final_prices[symbol], new_data])
I'm not super familiar with enough of the code to understand what impact this could cause, but if there are tests I can run against it just let me know. Going to keep testing to see if it breaks anything else that I can see.
Description
If you add both a bar_event and price_event, the bar_event's resolution impacts the price_event's price. For example, if I have a bar_event that is triggered at a resolution of 15m, and a price_event with a resolution of 1m, then the price_event will be triggered every 1m, but the price will only change at 15m thresholds.
Output:
If I comment the add_bar_event() out, or simply change the resolution to 1m (matches price_event) then it works fine:
So is this an issue, or is my implementation/assumption incorrect?