feat(FutureExchange): iterate the orders from the end makes the simulation run faster #430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've notice that there are some strategies that works very fast and some very slow while they use the same indicators.
The difference was if i change the orders every candle.
The base code iterate over all of the orders from the beginning to the end while personally i dont know why its needed, beacuse most of the orders is always at the end. On my strategy it makes this loop iterate O(n**2) on the number of candles!
Simulation of 6 months, timeframe "5m"
Simply search from the end make a major difference for such strategies.
Base code:
173s
where on_order_cancel is 45s and getitem (again probably because of this loop) another 38s
With this change:
60s