lookback setting performance issue

Posted By: 7th_zorro

lookback setting performance issue - 04/15/24 10:15

If I develop a mix of several assets and algorithms, lookback settings greatly affect the backtesting performance. Can you tell me why?
Posted By: AndrewAMD

Re: lookback setting performance issue - 04/15/24 16:59

There can be many reasons. Post code.
Posted By: 7th_zorro

Re: lookback setting performance issue - 04/16/24 03:08

When using a mix of assets and algos, the manual suggests the following.
Select asset first, then algo.

Code
// initial settings
...
LookBack = max((1440 / BarPeriod) * MANUAL_LOOKBACK_DAY_SETTING, LookBackNeeded);
...

while(asset(loop(Assets))
{
    algo("trend"); trendAlgo();
    algo("reversion"); reversionAlgo();
}


However, it is often convenient to choose algo first.
For example, if you write an algo that you want to trade selectively from multiple assets.

Code
// initial settings
...
LookBack = max((1440 / BarPeriod) * MANUAL_LOOKBACK_DAY_SETTING, LookBackNeeded);
...

for(auto it : myAlgoContainerMap)
{
    algo(it.first);  // name of algo

    while(asset(loop(Assets))
    {
        it.second->run();  // process function of algo
    }
}


In this case, the number of times the asset is switched will also increase in proportion to the increase in algo.
When the asset is switched, lookback data may also need to be moved(or copied).
I'm asking you to review whether this can be a factor in performance degradation.

© 2024 lite-C Forums