Wanting to Backtest 1000's of Symbols

I want to backtest thousands of symbols because I want to get a large sample size for testing, but the way Amibroker is working for me, it only backtests at most 70 - 80 symbols - even with a database of over 7000 symbols.

I have a database of over 7000 symbols that I have loaded into the system via AmiQuote.

Is there a way to have Amibroker test thousands of symbols? Here is the code I am using.

It is telliing Amibroker to have 50000000 open positions with 1 share - still Amibroker only tests 70 - 80 symbols.

Thanks in advance

maxpos = 50000000; // maximum number of open positions
SetOption("InitialEquity", 200000000000 ); // set initial equity 
SetOption( "MaxOpenPositions", maxpos );
SetPositionSize( 1, spsShares ); // 1 share by default

I know EXACTLY WHAT IT IS...

The moon is in retrograde to Venus and the aperture of Saturn is influencing Sol's kingdom. :rofl:

Sorry, I couldn't (well, I didn't) resist.

Your code shows your settings, but it does not show your logic in selecting. Perhaps the error is there.

What do your backtest reports show? Perhaps they could reveal an issue.

We can't help without reasonable information.

THANKS for using Code Blocks when posting your code.

1 Like

You are not telling which version of AmiBroker you are using, but generally feeding it with absurd values is not good idea. MaxOpenPositions = 50000000 ???
50 MILLION simultaneous positions. Really?

You need to realize that your computer is not made out of some elastic matter that can stretch infinitely.

To perform portfolio backtest you potentially need to store N * M signals where N is number of simultaneously open positions and M is number of bars. So say 10 years of EOD data (2700 bars) times 50 million = 135 BILLIONs of signals. The memory for signals need to be pre-allocated as reallocations are extremely costly performance-wise. Signal is an object and requires something like 64 bytes (approx) which means you would need to have 8640 GB of RAM to try to backtest 50 million simultaneous positions over 10 years.

So if you want to backtest 7000 symbols, you should use not more than 7000 max open positions.

Generally AmiBroker has many protections from being abused. In version 5.85 I have added protection NOT to allow to set "MaxOpenPositions" beyond number of symbols in the database.

Anyway, enough of rant ... please follow debugging ADVICE here and run DETAILED LOG - it will tell you exactly why it does not open more positions (there are other restrictions/constraints in the Settings than just max open pos that are checked during backtest and will limit your number of open positions).

4 Likes