MultiSymbol backtest

Questions about MultiCharts .NET and user contributed studies.
gofortips
Posts: 7
Joined: 30 Nov 2017
Has thanked: 4 times

MultiSymbol backtest

Postby gofortips » 05 Feb 2018

Hello,
I want to backtest my strategy on a list of symbols but, those symbols are not part of a portfolio. I mean, I will create a loop and inside it I read a symbol from the list; load the symbols data with the loader; and perform the backtest procedure for this given symbol. Then return to the begining of the loop.
At the end of the process described above, I will analize the reports from each one of the symbols backtest.
Then, my question is, how can I do it. I understand how to backtest a portfolio but I'm not sure how to automate backtest for a list of independent symbols.
Thank you in advance for your help.

User avatar
fbertram
Posts: 164
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 37 times
Been thanked: 70 times
Contact:

Re: MultiSymbol backtest

Postby fbertram » 05 Feb 2018

I suggest you still use Portfolio Trader to do this. There is no way to simply code a loop and run backtest for a basket of instruments. But you can run them in parallel with Portfolio Trader, and then look at the individual reports by symbol.

Cheers, Felix
These users thanked the author fbertram for the post:
gofortips

gofortips
Posts: 7
Joined: 30 Nov 2017
Has thanked: 4 times

Re: MultiSymbol backtest

Postby gofortips » 08 Feb 2018

Thank you fbertram.
I think I will follow your suggestion.
Now, because I have a long list of symbols to backtest, is there any way to introduce symbols into my portfolio from my code? I didn't find a set of commands to do it.
Best wishes, Carlos

User avatar
fbertram
Posts: 164
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 37 times
Been thanked: 70 times
Contact:

Re: MultiSymbol backtest

Postby fbertram » 08 Feb 2018

Hi Carlos,

while you can load any symbol using the Data Loader, there are many reasons why you shouldn't try to use that to run multiple strategies 'manually'. Use the Portfolio Trader instead. You can load a list of symbols into it...

Cheers, Felix
These users thanked the author fbertram for the post:
gofortips

gofortips
Posts: 7
Joined: 30 Nov 2017
Has thanked: 4 times

Re: MultiSymbol backtest

Postby gofortips » 09 Feb 2018

Hi,
I agree with you with respect to use the Portfolio Trader by previously loading the list of symbols I want to backtest.
My question is, specifically, about how to load that symbol list automatically, and not manually.
Briefly, I plan to write a code to:
1 - get a raw symbol list from the Quote Manager.
2 - filter the retrieved list, by using the Data Loader, applying some rules on that data (price range, volume, etc.)
3 - and finally, loading the filtered symbol list into the Portfolio Trader (and this is my question: How can I do it?)
I hope I'm not bothering you asking always the same question. I would invite you to a cup of coffee if we were living in the same country LOL.
Thank you for your patience and your help.
Carlos.

User avatar
fbertram
Posts: 164
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 37 times
Been thanked: 70 times
Contact:

Re: MultiSymbol backtest

Postby fbertram » 09 Feb 2018

Hi Carlos,

no, you are not bothering me... I am happy to help.

MultiCharts does not have a feature to programmatically load a symbol list into Quote Manager. I see 2 options how to achieve what you are trying to do:

1) The MultiCharts way: Your Portfolio Trader contains the whole stock universe. You write a routine to filter down the universe, which is triggered from the first CalcBar. Here you either set a flag in PortfolioData, or you use AllowEntries/ AllowExits to prevent the strategy from trading. Setting a flag might be the better way, as it allows you to skip processing of bars for those strategies being disabled, largely reducing your strategy run time.

2) The hack: While a lot of MultiCharts cannot be automated in a clean way, you can automate it with standard UI automation tools, e.g. AutoIt. I am using AutoIt to automate my whole trading server, from launching TWS to starting auto-trading, and shutting things down at the end of the session. It's a little clunky, but it can be done.

My personal advise would be to go with the clean 'MultiCharts way' of doing things. Unless your universe is too large and you are running into memory or cpu constraints, which is when you should consider option 2. I am personally developing algorithms that constantly evaluate a universe of about 200 stocks, and pick about 10 to actually trade, and I have the complete universe in the Portfolio Trader workspace.

As a final option, you could of course switch tools. Quantopian has a so-called pipeline, pretty much exactly doing what you are describing. NT allows you to dynamically load symbols using AddDataSeries in State.Configure. I have reservations against both tools (which is why I feel at home in this forum), but your mileage may vary.


Hope this helps,
Cheers,

Felix
These users thanked the author fbertram for the post:
gofortips

gofortips
Posts: 7
Joined: 30 Nov 2017
Has thanked: 4 times

Re: MultiSymbol backtest

Postby gofortips » 09 Feb 2018

Hi Felix,
I'm really happy with your detailed answer.
Many ideas are flying in my head now, after having read your post.
I'm going to evaluate each one of the points you talked about and
construct a solution for me.
Thanks, again, for your patience and support.
Carlos


Return to “MultiCharts .NET”