Meta Strategy with PortfolioEquityEx
Author: sedelstein
Creation Date: 1/9/2015 3:00 PM
profile picture

sedelstein

#1
In an effort to give back to the community here I wanted to make all aware of something I've been using that might be helpful to the sharper C# (pun intended) programmers out there. I still struggle with C# a bit at times. I imagine a better programmer will think it’s really handy (though UNSUPPORTED as I’ve been told many times).

Here goes...

Take a strategy you like, call it Strat-XYZ. I often find that it generates many alerts/trades, sometimes too many to trade due to capital restrictions and given that, too time consuming to see which one I would choose out of the many.

I create a strategy, call it MetaStrategy.

MetaStrategy calls the (once again) unsupported Community Component, run.Donor to run Strat-XYZ

You can then get access to the SystemPerformance and PerformanceEngine objects as well as all the alerts and position lists.

Given the current alerts, I take each one sequentially and use run.Donor once again to see how Strat-XYZ has performed on this particular symbol. Taken together with current values of any indicators I like, I can write these results to a csv file to screen in Excel to see which trades I want to take. This saves me tons of time by not running all the alerts individually. (If these parameters are fixed for you, you could also just generate the alert for the trades out of the many generated that you might want to take.) So for example, for some symbols the strategy might have a higher win% or Sharpe than for other symbols. (of course, that may or may not be a predictor of future performance and does ignore the correlations in a portfolio sense with other symbols)

In addition to this, I sometimes send performance data and other indicators using RDotNet which is an extremely powerful (and free) statistics package for further analysis (all within the strategy).

You could also look at the positions one by one historically and see the performance up to but not including the one you are examining to see, for example, if the Sharpe Ratio to that point is a predictor of future performance. I wrote a SharpeRatio_as_of_bar() function

I hope some of you find it interesting and would be willing to explore possible avenues for finding a good system. Let's discuss.
profile picture

Eugene

#2
Steve,

Thanks for sharing your experience with the community.
profile picture

sedelstein

#3
Eugene

Your thoughts on the concept??? Could support for this utility be considered some day?

profile picture

Eugene

#4
RunDonor method is member of the PortfolioEquityEx class which well exemplified and documented:

Interacting Dynamically with Portfolio Level Equity

It is feature complete and thus does not require any support beyond that you can find in the form of the many existing forum threads. This is what I meant when saying "unsupported" here before. Since it's open source, asking for support seemed equivalent to asking for some single user solution in my opinion. As the "equity interaction" solution contains all intended functionality, I do not have plans to make any modifications.
profile picture

sedelstein

#5
Okay, I thought by unsupported meant that questions about it or help here on the forums would not be entertained.
Like I said above, I hope someone appreciates the possibilities in the method described and can perhaps add to the conversation.
Have a good weekend.
profile picture

sedelstein

#6
Hello Eugene

I just upgraded all my extensions and tried to load my strategy

My previous code

CODE:
Please log in to see this code.


now generates the CS1729 error Wealthlab Visualizers MS123 PerformanceEngine does not contain a constructor that takes 3 arguments.

Perhaps you can throw me a bone, and tell me if this is easy to fix and offer a suggestion. I'm not sure what's changed and my C# isn't as good as it could be

The code still works on my other computer that for some reason fails to load the updated extensions

Thanks
profile picture

Eugene

#7
profile picture

sedelstein

#8
Thanks Eugene

I think I've done what was suggested above
CODE:
Please log in to see this code.


but still generate the error

I've tried
CODE:
Please log in to see this code.

and
CODE:
Please log in to see this code.


Not sure how you qualify it
profile picture

Eugene

#9
PerformanceEngine is part of MS123 Visualizers: an unsupported and undocumented internal class of the performance visualizer library. Usage of an internal API implies that the developer is prepared to do some D.I.Y. work on his own. As suggested by the last sentence in post #17,

Hint: You can solve such issues on your own by opening up Visual Studio, adding a library, and exploring the classes it contains with "Object Browser".

Since internal and undocumented classes are expected to have breaking changes any time, the developer which uses them should be prepared and familiar with the object browser tool.
profile picture

Eugene

#10
P.S. I'll be kind and save you a minute or so by not having to start the IDE and just leave the signature here:

CODE:
Please log in to see this code.


But please don't ask me what this means. It's your own development against an undocumented API.
profile picture

sedelstein

#11
I'll take it from here

Though I can generally code, I'm more of a market guy than a coder. These tips help. I do most development within WL

Thanks for the help. A little goes a long way.
profile picture

Eugene

#12
P.P.S. As you can see, there are 4 parameters now instead of 3. I suggest passing a "false" as both of these boolean arguments.
profile picture

sedelstein

#13
Roger, Thanks again

It compiles. I've downloaded visual studio express on the pc with the updated extensions. Will explore further

On a separate note (and if you like) a separate thread. Is there an API for Fidelity Active Trader Pro that can be used within WL?
profile picture

Eugene

#14
QUOTE:
Is there an API for Fidelity Active Trader Pro that can be used within WL?

ATP is an unmanaged application with no API exposed.
profile picture

sedelstein

#15
Too bad. ATP lets you place orders tagged as MOO or MOC. With that feature, though you arent guaranteed execution, you can often get the Open price that a lot of my strategies are using
WL doesnt let you set TIF (Time in force)
I don't know of any work around other than to generate the trades for the next day in WL and port them over to ATP

I realize this discussion is getting far afield of the topic. Where would you like me to post this?