Save Equity Curve Data
Author: levyfred
Creation Date: 10/22/2009 6:12 AM
profile picture

levyfred

#1
Hi,


Is there any function in the code to save the results of a strategy (The ones we get using Equity Curve Data) on a file?

Thanks
profile picture

Eugene

#2
Because position sizing is applied after the strategy has finished executing, equity curve is not available during strategy execution phase.

It's still possible to obtain the equity though, using some "arcane" API calls (unsupported):

WealthScript Techniques | Interacting Dynamically with Portfolio Level Equity
profile picture

levyfred

#3
I just tried the code below and I have the error

Runtime error: Objest Reference not set to an instance of an object at WealthLab.STrategies.OnTheFly.Execute()

CODE:
Please log in to see this code.

profile picture

Eugene

#4
I'm currently somewhat busy with a library of PosSizers for 5.6 and the challenges it brings, so please bear with delays. Although this KB article is unsupported, I'll try to help you though. For this, I need enough food for thought and the checklist (see my link above) is likely to provide me with some.
profile picture

levyfred

#5
Ok, thanks.

I am using Wealth-Lab 5.5, my computer has 4GB Ram and I use Vista 32 bits.

I create a new strategy,then delete all the code and paste the one from

WealthScript Techniques | Interacting Dynamically with Portfolio Level Equity

I then have the error below

Runtime error: Objest Reference not set to an instance of an object at WealthLab.STrategies.OnTheFly.Execute()


----------------------------------------
profile picture

Eugene

#6
This is all that I already know. I need the data scale, which data provider, the data range, and the selected position sizing option.
profile picture

Eugene

#7
By chance, if you selected "Max Percent Risk", you need to choose another position sizing option or introduce a RiskStopLevel to the code. This one requires a predefined RiskStopLevel and the Wiki code doesn't have one.
profile picture

levyfred

#8
H,

sorry for my delay answer, I was away.

I did not choose Max Percent Risk. I took the Raw Profit mode with fix dollar position equal to 10,000 USD.
I took the stock AA from Dow 30.
Data scale is "Daily"
Data Range is "All Data"
profile picture

Eugene

#9
Hi,

This setup works fine for me. Have you turned off On Demand Updates in the Data Manager and updated the dataset before running the strategy?
profile picture

levyfred

#10
I confirm I have turned off On Demand Updates in the Data Manager and updated the dataset before running the strategy

Also I checked line by line and the issue may come from the line

DataSeries globalEquity = sr.EquityCurve

I also replaced "EquityCurve" by some others functions such as "CashCurve" (Which is also a DataSeries) and I have the same error message
profile picture

Eugene

#11
If "globalEquity" has an issue, then the script's most likely having some trouble retrieving performance results from WL's global memory. Like it couldn't be found, it doesn't exist. I can not reproduce the problem. Try it on a different dataset, restarting WLD5.
profile picture

levyfred

#12
I finally found what is the issue. I need to write the donor script first. below the code with no issue

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

Eugene

#13
That's incorrect. The strategy does not work now as intended i.e. it should display the equity curve in its own pane (and that's all, no trades).

Usually, the order of classes shouldn't matter. But not in this case. Your modification effectively disables the "OnTheFly" class so it's not being processed. You just see the trades made by the dummy system that you normally shouldn't see, but no equity curve.
profile picture

levyfred

#14
Yes, that s right. OntheFly is not executed anymore

I removed Wealth-lab and re-installed it. seems to work now. maybe bceause I re-started my computer too.

Will keep you in touch if any new issue. thanks
profile picture

Eugene

#15
Restarting the computer (or simply Wealth-Lab) could have done the trick.
profile picture

RuneHS

#16
If you loop through each bar or date, and then "foreach (Position p in Positions)" inside this loop sum up each position's p/l so that [ total_equity = (p.NetProfitAsOfBar(bar) * position_sizeadjust) ], where I set that adjustment parameter "position_sizeadjust" to something like "if in raw profit mode then position_sizeadjust = 1 else position_sizeadjust = p.OverrideShareSize", then the equity data is summed just fine. An equity number per date, quick and easy. Or more in detail if you like, the equity per position per date. I typically lump this into a "StringBuilder" and then dump to a file when running scripts. The data is available via the "Equity curve" and right-click, however the file dump is more "automatic".

If that code is interesting to you, let me know. I do not know it this topic is closed or not (a while since last post), so I will leave out code for now.
profile picture

Eugene

#17
As far as I can tell this is an approximation, because Strategies are executed with 1 share per trade (note: even trades skipped later due to insufficient funds!) and position sizing is applied after the fact.
profile picture

Eugene

#18
Theoretically, a PosSizer in v5.6 can export the final equity curve (not approximated) to a file if needed (but what for?)
profile picture

RuneHS

#19
I am aware of skipped trades etc, yes. The equity that come out in my dump is in any case a 100% match according to what is produced in the "Trades" table in WL (no approximations, I think). I always hand-check all calculations - man, I have to!

Reason for this dumping of mine is really that WL seems not to be able to handle multi-currency positions. So I have to extract the local currency returns and work out the rest myself.

Example: If I want to implement a breakout strategy in short interest rates with in the global macro investment universe, for instance in eurodollar futures, there are a lot of markets outside the US - EUR, GBP, AUD, JPY, CHF, etc. In effect the returns for each futures contract comes out in the local currency, and if I want to look at the whole "global macro short-maturity interest rates book" as one then I have to transform the returns into the same base currency. Pointing-and-clicking and right-click-and-copy-and-paste for each single future/symbol is not the way to go about this, I think.

As mentioned in other posts, this issue is even more tricky when it comes to a book fx positions. It is doable, though, at the cost of having to build all the performance tools myself (cannot really use the standard stuff in WL).

Are there any plans to make the standard WL "performance visualizers" work with a portfolio of multi-currency fx and futures positions, is that on the "to-do table"? There are some issues here (e.g. having to supply the system with fx rates etc.), but I think it is doable
profile picture

Cone

#20
Multi-currency support is not on the radar for the moment.
profile picture

Eugene

#21
If the equity dump is a 100% match, IMHO you're using fixed shares and no trades were skipped due to insufficient trades. If it works for you, then it's fine.
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).