Access Wealth-Lab Score from Strategy?
Author: sifty
Creation Date: 3/28/2012 8:25 PM
profile picture

sifty

#1
Is there any way to access the "Wealth-Lab Score" presented in the Performance Visualizer from a Strategy? What I would like to do is run a strategy over a set of symbols and record the Wealth-Lab Score for each individual symbol off to a file somewhere and rank symbols by their Wealth-Lab Score. Any input as to approach appreciated...
profile picture

Eugene

#2
Have you seen Tools > Strategy Ranking?
profile picture

sifty

#3
OK, I had a look at Strategy Ranking and it looks to be great at judging a set of strategies over a fixed set of symbols. What I would like to be able to do is judge a set of symbols over a fixed strategy. E.G. For my strategy, which symbols currently show the highest Wealth-Lab score for the given data range. Do you see the difference? Thanks!
profile picture

Eugene

#4
Yes, now I see.

For simplicity sake, it's not possible to access a performance metric from a Strategy. Visualizers do their job after a Strategy has already finished processing. There are solutions but you'd have to code the Wealth-Lab Score from scratch for the concept to work anyway.

Ideally, if the By Symbol visualizer could be expanded to show the Wealth-Lab Score or other metrics, would that do the trick?
profile picture

abegy

#5
It could be interesting if you think in a future to have an extension with all performance metrics available in Wealth-Lab (Visualizer, scorescard...) that we can request value on fly in a script (Possizer, strategy...).
profile picture

Eugene

#6
It's not possible. See above.
profile picture

sedelstein

#7
The WelathLab score is available in the performance engine of either

using Community.Components;

or

using WealthLab.Visualizers.MS123; I forget which w/o outgoing back to the source code (you'll likely need both anyway

So if you are able to work with the solution Eugene pointed out, you could loop through symbols, spit the data out to a .csv file and screen from there.

It's not an automated strategy. It's a semi automated "human in the loop" solution but it works

CODE:
Please log in to see this code.


then pe.WLScore is available.

profile picture

Eugene

#8
Good point Steve. No need to code the WL Score from scratch.
profile picture

abegy

#9
One more question... Can we find in the Performance engine object all performance metrics or only a selection of them ?
profile picture

Eugene

#10
If you program all performance metrics, you'll find everything there. :)

Of course only a selection that I coded.
profile picture

sifty

#11
Thank you Eugene and sedelstein for the pointers. I have been resisting setting up Visual Studio for WL. Looks like this is my reason. I will have a look through the materials and post back my findings and any code I end up "improving". Cheers.
profile picture

sifty

#12
OK - Had some time to code this up. It would appear that Utility.runDonor() is not properly filling out all its attributes? When run over the Dow 30 it reports the correct number of trades and the correct BuyAndHold net profit, but reports zero as the value of the strategy net profit, long net profit, and short net profit. Any input welcome.

Here is the code I wrote this afternoon....

CODE:
Please log in to see this code.


Here is the debug console.

QUOTE:

AA; NumTrades=6; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-127072.8
AA = 0
AXP; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=81009.25
AXP = 0
BA; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=4012.47000000004
BA = 0
BAC; NumTrades=5; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-85937.54
BAC = 0
CAT; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-19173.96
CAT = 0
CSCO; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=72884.7
CSCO = 0
CVX; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-3627.39000000001
CVX = 0
DD; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-14131
DD = 0
DIS; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=6370.91000000003
DIS = 0
GE; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-9734.34
GE = 0
HD; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=102473.21
HD = 0
HPQ; NumTrades=5; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-123122.4
HPQ = 0
IBM; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=80763.98
IBM = 0
INTC; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=126639.9
INTC = 0
JNJ; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=32571.32
JNJ = 0
JPM; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-906.080000000004
JPM = 0
KFT; NumTrades=1; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=59787
KFT = 0
KO; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=30296.98
KO = 0
MCD; NumTrades=0; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=86005.13
MCD = 0
MMM; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-11176.87
MMM = 0
MRK; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=45899.26
MRK = 0
MSFT; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=80115.265
MSFT = 0
PFE; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=30838.4
PFE = 0
PG; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=24353.28
PG = 0
T; NumTrades=2; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=4800.53000000002
T = 0
TRV; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-3165.11999999998
TRV = 0
UTX; NumTrades=4; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-9598.68000000001
UTX = 0
VZ; NumTrades=0; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=-2339.40000000003
VZ = 0
WMT; NumTrades=1; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=51153.06
WMT = 0
XOM; NumTrades=3; NetProfit=0; NPLong=0; NPShort= 0; NPBuyHold=8748.74
XOM = 0

profile picture

Eugene

#13
The code works OK. RawTrades is the number of all theoretical trades. If you'd use sp.Results.Positions.Count instead, it would show that the system hasn't taken any trades. Probably because your position size was too large e.g. 100%.
profile picture

sifty

#14
Pilot Error! Whoops. I'm somewhat famous for that ;0) OK - I have my filter. Thanks to all who contributed. Final code below. It will create a WLScore.csv file in "My Documents" which contains the symbol and Wealth-Lab Score.

CODE:
Please log in to see this code.


profile picture

Eugene

#15
Important note to the users of the PerformanceEngine class (internal, unsupported part of the MS123 Visualizers library):

The information regarding PerformanceEngine calling conventions provided across the forum before is actual as of the library version 2012.05.1 and earlier. In future versions, the syntax will most likely undergo a breaking change due to a complete rewrite of the PerformanceEngine class.
profile picture

richard1000

#16
System: Windows 8 x64, WL v6.4 64bit

I ran the directly above code but getting some compile errors.

1)
QUOTE:
warning CS1685@(0.0): The predefined type 'System.Treading.Tasks.Task' is defined in multiple assemblies in the global alias; using definition from 'c:\\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll'


How can I correct this warning?

2)
QUOTE:
error CS0104@(28.4): 'Utility' is an ambiguous reference between 'WealthLab.Visualizers.MS123.Utility' and 'Community.Components.Utility'


Fixed by replacing 'Utility' by 'Community.Components.Utility'. But should there be confusion about different namespaces with same class reference?

3)
QUOTE:
error CS1729@(31,27): 'WealthLab.Visualizers.MS123.Utility' does not contain a constructor that takes 2 arguments


MS123 Visualizers wiki states a breaking change to PerformanceEngine class. So, in the above code, what changes need to be made to implement this new calling convention to PerformanceEngine? I looked at the PerformanceEngine demo code and it does take 2 arguments.
profile picture

Eugene

#17
QUOTE:
How can I correct this warning?

Disregard it.
QUOTE:
Fixed by replacing 'Utility' by 'Community.Components.Utility'. But should there be confusion about different namespaces with same class reference?

Yes, there should be. The new, rewritten MS123 Visualizers library itself contains a Utility class. Your task, as compiler suggests, was to fix that ambiguous reference and you've fixed it correctly, good job.
QUOTE:
MS123 Visualizers wiki states a breaking change to PerformanceEngine class. So, in the above code, what changes need to be made to implement this new calling convention to PerformanceEngine?

This should suffice:
CODE:
Please log in to see this code.

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".
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).