How can I write dataseries to file, after raw profit mode?
Author: mikesblack
Creation Date: 9/17/2010 6:03 PM
profile picture

mikesblack

#1
Hello Gentlemen,

I have a routine that basically takes certain data series values that are essentially (day prior)signals that are paired with trades generated from a multi or single symbol backtest and writes them as a text file to a folder on my c drive. I use this data to do further analysis in Excel.

What I would like to be able to do is take the trades that are filtered through some sizer method or really, just values from Portfolio Simulation Mode at a certain percent of equity, rather than all the trades generated through Raw Profit mode.

Can this be done, and if so, what can I do to accomplish this?

Thanks.

Also, have a nice weekend.

Mike



CODE:
Please log in to see this code.


CODE:
Please log in to see this code.
profile picture

Eugene

#2
PosSizers are applied 1) after a WealthScript strategy has finished executing and 2) before performance visualizers are applied.

So, exporting to Excel (btw, even directly to an XLS file) the results of a Portfolio Simulation (including PosSizers) can take place either in your PosSizer or in a Performance Visualizer. Custom PV appears to be the optimal way as the PosSizer(s) code can be left untouched.

It takes some D.I.Y. in a C# IDE (for instance, Visual Studio Express or SharpDevelop) to "inject" the file export code to an existing PV or build your own from scratch (using our open source examples and API documentation from the Wiki).
profile picture

mikesblack

#3



QUOTE:
It takes some D.I.Y. in a C# IDE (for instance, Visual Studio Express or SharpDevelop) to "inject" the file export code to an existing PV or build your own from scratch (using our open source examples and API documentation from the Wiki).


Eugene,

Is there or are there any specific example or examples that you can think of in the Wiki that may be helpful to what I'm after or that could help me become better able to accomplish similar tasks ?

Also, let me see if I understand this correctly. The Wealth Lab editor can only perform routines and methods at the raw portfolio level, and any further steps must be compiled in an IDE e.g. Sharp Develop, etc.

Sorry if this seems really obvious, but it is only just starting to become clear to me. Remember, I have no programing background, so this process of developing functional literacy takes a while.

Thanks very much.
profile picture

Eugene

#4
Mike,

The MS123 Visualizers project source code, esp. "Trades+", may be helpful to what you're after. It already contains code that exports the contents of the "Trades+" tab to a text file.

If your task can't be accomplished simply by storing the data series in e.g. Position.EntrySignal (I guess it has to be more complex than that), then it should be feasible to modify my code to suit your needs.

If exporting some data series is what you're after, then just to remind: each created Position has a parent Bars object, which contains all registered DataSeries for that symbol (if not explicitly cleared by Bars.Cache.Clear, of course). The real question is how do you get those DataSeries in a visualizer? This is where the Bars.Cache property comes to help - see the QuickRef example which will give you an idea and a code sample. In the visualizer, while looping by positions of a Portfolio Simulation backtest, you extract a DataSeries by its key from the Bars.Cache property just like the QuickRef snippet shows.

The particular point of interest in "Trades+" is void GenerateOutput -- this is where you extract your DataSeries, format the string, and append to string buffer (all the rest is done by void SaveToFile).
profile picture

mikesblack

#5
Thanks Eugene. I'll work with your suggestion. Much appreciated.
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).