Multi-timeframe backtests in PyneCore got much faster
Strategies and indicators that pull data from other timeframes with request.security now backtest much faster in PyneCore. The output is the same as before, only the time it takes has changed.
Until now, every extra timeframe exchanged a message with the main chart on every single bar, so a script with a dozen contexts spent most of its time on that exchange. Now most contexts compute their whole history in one pass, including higher-timeframe requests that look at the developing bar. Contexts in branches that never run cost nothing, and contexts that don’t depend on each other start in parallel. On a 30,000-bar chart, a long higher-timeframe run finished in 30 seconds instead of 42, and needed about half the memory.
The hardest part was deciding which requests really depend on each other. On real-world scripts, a too-cautious dependency analysis had chained every request to every other one and forced them to run one after another. In one community indicator from our public test collection, removing those false links alone cut the run from over 2 minutes to 9 seconds.