Coding strategy on day-to-day basis allocation instead of Combination strategies
Author: algotradingwl
Creation Date: 5/3/2017 3:17 PM
profile picture

algotradingwl

#1
Hello!
As child strategy in combination strategies uses the initial size, then it became necessary to code this strategy, that readjusted on a day-to-day basis :
There are 8 industries. In the industry can be bought only one symbol. So, when the condition is triggered, it is checked whether there is a position for other symbol of the industry.
Below I give a variant for 2 industries, but when I test on the DataSet it takes a long time, about 10 min on the “Number of Bars” = 150 in “Data Range” .
What am I doing wrong? Help me please.
DataSet:
Amgn
Axp
Gild
Ma
Pfe
Pypl
V
CODE:
Please log in to see this code.
profile picture

Eugene

#2
Hi,

Speed-wise, SetContext() wrapped in nested loops is guaranteed to make any code very inefficient.

Next, evaluation of a condition like "there's a Position in a symbol in an industry group" takes place once a bar. For this reason it won't stop the child systems from sending concurrent same-bar alerts for symbols from the same industry group.

You might want to rewrite using a different design pattern:

WealthScript Techniques | Portfolio-wide conditions

Another (and more natural) solution would be to design a custom PosSizer that filters Alerts with regard to the industry.
profile picture

algotradingwl

#3
Eugene thanks for your tips, I will study them.
profile picture

KGo

#4
QUOTE:
As child strategy in combination strategies uses the initial size, then it became necessary to code this strategy, that readjusted on a day-to-day basis

You may find success with Historical Trades combinations which size trades based on day-to-day equity. See combination method at https://www.wealth-lab.com/Forum/Posts/New-style-of-Combination-Strategy-uses-Historical-Trades-40092/
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).