Hi!
I am looking to loop over a DataSet (similar to a rotation strategy) and store the results in a Global series before running through a standard Portfolio simulation. Here is my code start:
CODE:
Please log in to see this code.
What do I need to do further? Is this correct?
Thanks!
Vince
Size:
Color:
Size:
Color:
Hi Eugene!
That code does a portion of the job but does not store the series in Global for future access.
Here is the resultant code with that addition:
CODE:
Please log in to see this code.
Is this correct now?
Vince
Size:
Color:
Hmm, the same Description assigned to two DataSeries looks suspicious.
Size:
Color:
Good catch Eugene! Thanks!
HNY!!
Vince
Size:
Color:
Happy New Year to you too!
Size:
Color:
Hi Eugene!
There seems to be an issue with my code
CODE:
Please log in to see this code.
When I run it against 20 years of Daily bars of the Dow 30 I get the attached errors messages. Is there an issue with synchronization?
Vince
Size:
Color:
Wouldn't using the "Above SMA" IndexDefinition be more straightforward than coding it?
Size:
Color:
Yes, if that was what I planned to do. The code is just an example. I have a more complex concept in mind.
Size:
Color:
Anyway, ran your code once and it didn't throw an exception.
Size:
Color:
Found that with 20 years of data the errors do not occur consistently but with 30 years they do. AAPL, the first symbol, has complete data for the period, so the "first symbol" is not the issue.
Vince
Size:
Color:
Added some more data checking, but still generates errors when tested on 30 years of Daily data for the Dow 30
CODE:
Please log in to see this code.
Any ideas?
Vince
Size:
Color:
Here's something for you to troubleshoot. For version from post #7 the global DataSeries will be zero for the first symbol if you run a multi-symbol backtest and then click on AAPL. With the one in post #12, for all symbols.
Size:
Color:
There is something more basic at play here. If I remove the "run once" code (below) that still results in the same errors. Your suggestions are really related to that aspect.
CODE:
Please log in to see this code.
Size:
Color:
With added synchronization and some unncessary code removed, this doesn't produce errors for me when run on 20 years of Dow 30 (Yahoo! data):
CODE:
Please log in to see this code.
Size:
Color:
Thanks Eugene! The errors are gone, but a new issue has emerged. The code stops trading after about 10 years even though the conditions for trading are met (see attached).
Size:
Color:
It's your (unknown) DataSet so troubleshooting is on you!
Make sure that your position size is sufficient to purchase at least one share of the instrument (like higher-priced indices). See trades not taken due to insufficient funds, review the PosSizer settings etc.
Size:
Color:
Hi Eugene!
I checked my dataset and it appears that it does work correctly for Daily Scale on the Dow 30 but the problem seems to be when it is run on a Weekly scale. See attached. These were run with 2% of Equity and as you can see there is always plenty of available Equity for purchase.
Vince
Size:
Color:
Hi Vince,
Cannot reproduce. Check your position sizing settings and Wealth-Lab Preferences (trading related).
Size:
Color: