Visualizer / PerformanceEngine
Author: ewessely
Creation Date: 9/4/2011 9:13 AM
profile picture

ewessely

#1
I'm building up my own visializer taking some values from PerformanceEngine. What I'm missing there are some values generated by the built in performance (eg winning trades and losing trades statistics). Most of the values are calculated by the PerformanceEngine but are not provided as public. They are used as local variables inside the function.
What is the suggested way? Would WL change the PerformanceEngine or should I create my own / change the existing PerformanceEngine.
profile picture

Eugene

#2
The visibility scope of exposed performance metrics entirely depends on needs of MS123.ScoreCard and Performance+ classes. (They are consuming the PerformanceEngine class for application in Optimizer and visualization, respectively.) So what had to be exposed has been exposed, other performance metrics are internal simply because in this context, they are just building blocks.

If you could wait then I'm OK with exposing some existing performance metrics in a future release - just give me a list of what you need. If in need of an immediate solution, changing the code on your own wins.
profile picture

ewessely

#3
Hi Eugene,
would really be nice to have also all of the standard performance counter available via PerformanceEngine in the future. I just made a "difference-list" containing values in performance, but not provided by PerformanceEngine yet. Some values also would be availabe from other objects (eg SystemPerformance) but I think it would be much more comfortable to have one interface for all statistical data.

The list:

Starting and Ending capital
Net Profit%
Total Commission (absolut, % is allready implemented)
Return on cash
Margin interest paid
Dividends Received

Average Profit (absolut, % is allready implemented)

For Winning Trades:
Count of Winning Trades
Gross Profit
Average Profit
Average Profit %
Average Bars Held
Max Consecutive Winners

For Losing Trades
Count of Losing Trades
Gross Loss
Average Loss
Average Loss %
Average Bars Held
Max Consecutive Losses


Max Drawdon Date
Max Drawdon % Date

Profit Factor
Recovery Factor
Payoff Ration
profile picture

Eugene

#4
QUOTE:
Some values also would be availabe from other objects (eg SystemPerformance)

If something is already available in SystemPerformance, then please use the existing facilities. Sorry but duplicating these metrics in PerformanceEngine is not on my plans:

Starting and Ending capital, Total Commission, Margin interest paid, Dividends Received, Net Profit%, Return on cash

We look to extend SystemPerformance and the Performance tab, not to replace or wrap around it. Per your request, I'm going expose only the following performance metrics because they've already been implemented:

Average Profit/Loss abs/%
Count of Winning/Losing Trades
Gross Profit/Loss
Payoff (absolute numbers) - already exposed

Edited. See my reply below.
profile picture

ewessely

#5
Sounds pretty good! For the other things it no problem for me to extend by inheritance.
It's really nice to read from you also on weekends!
profile picture

Eugene

#6
On second thought, I've cut down the list of performance metrics to be exposed and left these items overboard:

Max Drawdown abs/% Date
Max Consecutive Winners/Losers
Average Bars Held, Winners/Losers
Profit Factor, Recovery Factor
Payoff Ratio (%, as in "Performance")
Max Drawdown Abs/% Date

Let's stress my point: we're not re-implementing anything that already exists in other classes/visualizers (i.e. Performance), in the PerformanceEngine class, sorry.
profile picture

ewessely

#7
No good news...
The idea behind having all the values in PerformanceEngine: I want to use my own optimizer, use the PerformanceEngine to calculate the values after each step and save them to a SQL-DB. This would solve 2 problems: First I have saved the data to build statistics for compairing (and when I find a new methode for statistical analysis in one month I still have the values) And second - it's important to me for documentation.
I understand that you do not want to re-implement already existing things, but I did not find any method to get the values out of the standard performance visualizer. And if there would be a methode to get the values from standard performance visualizer then it would slow down the caculation, because the trades have to be looped 2 times - one in the standard performances visualizer and one time in PerformanceEngine. So the idea behind doing everything in the performance engine is that there only one loop through all trades have to be done - so why not to use the loop and calculate the "missing" values with nearly no extra costs in performance.

So, maybe you have a hint for me to get the values from standard performance or I have to implement my own PerformanceEngine.
profile picture

Eugene

#8
I completely understand your reasons but here's my, and hopefully solid, argument. As a person who haven't taken a vacation in 5 years I will undoubtedly prefer your CPU looping as many times as required over myself re-implementing the existing stuff (only theoretically)! :)

Good news to sweeten the pill:

1. System.ExecutionEngineException preventing you and other developers from debugging has been fixed in all previously released extensions.
2. Those 4(6) metrics that I mentioned, are implemented and already available.

QUOTE:
So, maybe you have a hint for me to get the values from standard performance or I have to implement my own PerformanceEngine.

Given that Wealth-Lab's standard performance report is obfuscated, it would be pretty hard to get the values from it. The variables are private so their names were obfuscated too, making the usage of Reflection more complex.

I'd suggest you take the open source code of PerformanceEngine.cs and re-implement the "missing" metrics yourself in your own class.
profile picture

ewessely

#9
Don't be so wasteful with others CPU time (also only theoretically) - time is money ;-)

QUOTE:
1. System.ExecutionEngineException preventing you and other developers from debugging has been fixed in all previously released extensions.

that are really good news :-)
QUOTE:
2. Those 4(6) metrics that I mentioned, are implemented and already available.


You are really doing a prompt work! Hope you will update also the source in WIKI (if not allready done) so that I can extend the PerformanceEngine.cs from the last valid version.
profile picture

Eugene

#10
QUOTE:
Hope you will update also the source in WIKI

Sure, in a couple of days. Have to clean the code first.
profile picture

ewessely

#11
Perfect, many thx!
profile picture

Eugene

#12
Done. The updated source code can be downloaded.
profile picture

Eugene

#13
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

aykuts

#14
Hi Eugene,

I somehow decided to include my own personalized custom performance metric in both the Performance+ tab as well as on the MS123 scorecard.

1. I clicked this link and downloaded the attachment on the top-right corner of the page
http://www2.wealth-lab.com/WL5WIKI/CommunityVisualizersMain.ashx
(Q1: Is this the right place to start for developing custom metrics, anyway?)

2. Then, I downloaded the zip file, extracted it to an arbitrary folder, did my best to understand the architecture of the code, and somehow, managed to embed my performance metric into the "PerformanceEngine" object defined in "PerformanceEngine.cs" file.
(Q2: Am I on the right direction?)

3. Compiled the solution.

4. Relaunched the wealthlab.

5. Wealthlab offered me to update my Visualizer (which I skipped)

6. Ran an arbitrary strategy.

7. Clicked and confirmed that my custom metric is there, and the resulting value is correct. Good.

8. Then, I wanted more, and wanted this metric to be presented on the MS123 scorecard as well.

9. This time, I made (really simplistic) modifications on "MS123ScoreCard.cs" now,

10. Compiled with no errors.

11. Relaunched WL

12. Wealthlab offered me to update my Visualizer (which I skipped)

13. Clicked an arbitrary strategy.

14. Clicked and confirmed that the Performance+ tab shows correctly my custom metric.

15. And then, I launched the optimization tab.

16. Clicked "begin" button (with the output option being the MS123 scorecard.)

17. and... oh no... WL crashed.

Q3: first of all, is it possible to download as open source the latest version of WLVisualizers instead of the earlier version? Currently, 2012.05 version is offered on the wiki page I mentioned above at step 1)

Q4: If your answer to Q3 is yes, then, will I get the same warning again (i.e. "update your visualizer") every time I relaunch WL (after I customize the codes myself?)

18. Anyway, I relaunched WL.

19. This time, I accepted the offer of WL and updated my Visualizer123 version (up to 2014.09)

20. Yes, the optimization worked as expected and did not crash (good),

21. but whatever I customized within the Visualizer has gone (as expected as I updated and overwritten the old version with the new version)

**

Q5: So, i think, If I start the modification NOT from the 2012.05 version (as offered from that link) but from the latest 2014.09 version of the Visualizer, I believe my (really simplistic) modifications to the MS123 ScoreCard.cs will not result in any crashes. So, is it possible to guide me to the place (on the forum, or on the web, or on the wiki) that I can download the latest version of the Visualiser code?

Thanks.




profile picture

Eugene

#15
Hi Aykut,

On how to develop performance visualizers, see related PDF on this page:

Wealth-Lab Version 6 (.NET) Development Guide
Performance Visualizers (PDF)

Updating the demo extension overwrites your compiled binaries. To prevent it, remove the ExtensionInfo attribute from the assembly. It should be in the EM.cs file. This should break the link between the Extension Manager and your assembly. To avoid conflict between the duplicate class names, you should either rename the namespace or rename the classes in the demo solution. Also, return a different name in "public string TabText". Since the demo solution is a crippled but functional prototype of what once was what you know as MS123 Visualizers, the idea is to make it different to Wealth-Lab.

On the contrary, I do not believe that your simplistic modifications to the MS123 ScoreCard.cs will not result in any crashes. The latest code is closed source and won't help with that anyhow because the demo solution is also fully functional. For example, it's possible that you didn't adjust the RP/Port.Sim. types (see private string[]... in the Scorecard code), or have duplicate classes because the Scorecard's class/namespace weren't renamed.
profile picture

aykuts

#16
Your suggestions helped a lot, once again.

Very appreciated.

Thanks.

Aykut
profile picture

Eugene

#17
Glad to have helped.

Since your questions did not have anything to do with this subject - namely the specific PerformanceEngine.cs class - please ask further non-specific/general development questions in more suitable threads.
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).