i am trying to write some statistics to a file and later to a database. I looked at the C# language and it show a
System.IO.File
(System.IO.StreamWriter
I tried add them to the Using System.IO. but it does not have either class available.
how can I write a simple text/number to a file.
Size:
Color:
Size:
Color:
I'd like to do something similar.
After running a strategy on a list of securities, say the S&P 100, I get perhaps 10 alerts. Currently, I copy and paste the alerts to excel I then run each symbol one by one and record stats like the number of trades, win/loss percentage, and the sharp ratio. Can items like these exported to a csv file which I can then use in excel? It would save a lot of time.
Size:
Color:
Sure, see the QuickRef for "Alert Object".
Size:
Color:
Hi Eugene
I went to the Alert object in the QuickRef. While it has a number of properties I'm interested in, it didn't have what I was looking for which was for each security that generated an alert, the number of trades, win/loss percentage, and the sharp ratio for the period that was just run. Did I miss something?
Size:
Color:
Are you writing a Performance Visualizer, or do you want to do this in the script? There's no problem calculating Alerts (Alerts collection), number of trades, and win/loss in the script (using the Positions collection), but you'd have to use extraordinary measures to calculate sharpe there since positions are not sized (generally) during the strategy execution phase.
Size:
Color:
Actually, it was the AlertDate Property QuickRef entry on my mind which exactly illustrates the relevant parts of what you were looking for: exporting the Alerts list generated on the current bar, to a CSV file. The example indicates which security has produced the Alert.
The win/loss percentage and the Sharpe ratio are somewhat far-fetched in this context because they have nothing to do with Wealth-Lab Alert generation. It takes a list of historical trades and equity series which are not available on the Alerts tab.
As the WealthScript Programming Guide (Programming Trading Strategies > Strategy Code Limitations) states, "it is not possible to create trading strategies that enter or exit trades as a function of Portfolio Equity, which includes Portfolio Cash and Drawdown." Consequently, the values/series like Sharpe ratio or portfolio equity are available only after Strategy finishes executing i.e. in Performance Visualizers.
Size:
Color:
After the strategy is run for a particular symbol, the performance tab produces the data I would like to see. I realize this is done after the execution phase (as per Cone's comment)
Using the alert object, I can output each alert generated to a file. Can another script be run where I read each of the symbols from the file, re-run the strategy (in a sub script?), and output some/all of the data normally found on the performance tab?
I might generate 20 alerts but only be interested after screening the performance tab data, that 3 are worth taking so I'd like to help reduce the workload of looking at each alert individually.
Size:
Color:
QUOTE:
Can another script be run where I read each of the symbols from the file, re-run the strategy (in a sub script?), and output some/all of the data normally found on the performance tab?
Why not? It's all up to your motivation and programming skills. At any rate, to output from the Performance tab you'll have to do it manually by copying to clipboard.
As a possible workaround, you can
try to run the Strategy in a sub script (see od Wiki Knowledge Base article on multiple systems), or even access the
SystemPerformance object in a Strategy (Wiki KB article on interacting with equity curve) to
try to build the required performance metrics right in your code.
Size:
Color:
ok, I'll give these a look. I think if there was an object with data found on the performance tab as properties it would be very helpful. Since you already have the calculation methods, it would be good not to have to recreate them.
Size:
Color:
QUOTE:
I think if there was an object with data found on the performance tab as properties it would be very helpful.
I doubt that there could be such thing as a generic object here because the decision what to put on clipboard is up to the performance visualizer developer. They can be simple or complex (i.e. with several tabs containing mixed content type like bitmap/tables e.g. Monte Carlo or Portfolio Inspector).
Size:
Color:
Thanks again
I'm reading the suggested wiki article
Is there a link that describes the SystemPerformance object so I can learn more about it.
My search was unsuccessful
Size:
Color:
I went to article suggested
http://www2.wealth-lab.com/WL5WIKI/kbInteractingWithPortfolioEquity.ashxI pasted the code into WL and ran the last 400 bars of symbol AA
The execution loop of the donor strategy starts at bar 21
At the end of code I inserted (which starts from bar 0)
CODE:
Please log in to see this code.
Why is there negative equity (and changing equity) when no trades have been executed?
0 -3595.088
1 -3309.908
2 -3626.258
3 -3365.608
4 -3356.268
5 -3046.848
6 -3000.318
Size:
Color:
QUOTE:
Is there a link that describes the SystemPerformance object so I can learn more about it.
My search was unsuccessful
Check out the Performance Visualizer API, a PDF document available
here.
QUOTE:
Why is there negative equity (and changing equity) when no trades have been executed?
As a guess, the global equity might belong to a different backtest. To debug, try clearing the global memory by adding
ClearGlobals() the first thing in the
Execute() method body.
At any rate, this unsupported technique works properly even in 6.3 but you need to realize that it has a number of limitations. First and foremost, with AtStop/AtLimit orders it had the lowest chance of duplicating the original results. It was developed during 5.x times so there's a chance that the changes re: Stop/Limit precision treatment in 6.2 (which I summarized here:
Difference in BuyAtStop in 5.6 vs 6.2) might have changed something but I haven't experimented with this yet. Finally, see Notes at the bottom of the Wiki page on "Interacting with equity curve".
Size:
Color:
Please keep from discussing the "interacting with equity" technique in this thread. Just revive any existing forum thread on this matter (there's a number of them). We've gone too far from topic starter's original intent.
Size:
Color:
Is there any way I can export the profits as a single series?
(I'd like to do this in order to analyze the series in an econometric software package)
[Post has been edited so that only questions related to "Write information to file" are showing]
Size:
Color:
Welcome to the forums!
If the profits you're talking about is the strategy's equity curve or a particular symbol's profit, then there is more than one way:
* By using a Performance Visualizer. These addins - designed to visualize a Strategy's performance in a graphical, tabular or textual view - naturally get the true portfolio-level equity curve information.
* From Strategies, using the Position.NetProfitAsOfBarPercent property. As the true net profit series are not available during the Strategy execution phase, in portfolio simulation mode, all trades are pre-executed using 1 share per Position, and then position sizing is applied after the fact. So this way, your series will always be based on 1 share while the Strategy is executing.
* By using an advanced technique like this (requires customer-only extension access):
Interacting Dynamically with Portfolio Level EquityThe idea is that regardless of the option you choose, information can be exported using any means supported by the .NET Framework and C#: file, DDE, clipboard, HTTP... you get the picture.
Note that we've already got many options to analyze the series inside Wealth-Lab, and of course more performance visualizer solutions can be created to suit custom analysis tasks:
Home - MS123 Visualizers
Size:
Color: