I need to loop twice over my assets to code a particular strategy, because the decision to enter short or long depends on the ranking of signals over the assets.

So, in the first loop an ML model is called to get estimated probabilities:

char* symbol;
int i = 0;
while(asset(symbol = loop(Assets))) {
Spread = RollLong = RollShort = Commission = Slippage = 0;

var signal = adviseLong(NEURAL, target[0], features, LookBack);
signals[i++] = signal;
}

Here I found that loop(Assets) and for(listed_assets) have different behaviour (I guess this is an example of "special parameter handling by loop"?), so I stick with the "standard" choice of loop(Assets).

Then the signal rankings are determined:

sortRank(ranks_01, signals, NumAssetsListed);

And a second loop decides whether to go long or short depending on the ranking:

i = 0;
for(listed_assets) {
asset(Asset);

int rank = ranks[i++];

... enterLong() or enterShort() if the rank is high or low enough, respectively ...
}

This works perfectly when I tried it with up to 50 assets. However, when I test with my full asset list of 448 symbols, the second loop does not work anymore. It makes calls to enterShort() but no short trades are taken.

Am I doing something wrong here?


Last edited by JamesHH; 08/12/19 23:29.