- ago
Is it possible to export backtest bar by bar equity curve data as a CSV (or similar) file?
Thx
0
530
Solved
12 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.31% )
- ago
#1
Yes right click on it and copy equity curve data to clipboard, paste into spreadsheet.
0
- ago
#2
Or use the new finantic.Export extension.
It will create a complete file directly.
And supports more file formats.
0
Best Answer
- ago
#3
Many thanks both
0
eike8
- ago
#4
I want to export data for all symbols in dataset to csv-files. I don't see any button to do so (finantic.Export installed), there are no hints.
I would like even more to convert qx files with an external program. How are these files encoded?
0
- ago
#5
Re: no hints - how about these screenshots?
https://www.wealth-lab.com/extension/detail/finantic.Export#screenshots
0
Glitch8
 ( 8.31% )
- ago
#6
We don't disclose the QX format, it's our internal proprietary format. If we need to change anything we don't want to have to worry about users relying on the format for external programs.

What exactly do you want to export? What symbol data? The historical price data? When I need to do this I write a C# Strategy that writes the data to a file, and then run it on the DataSet.
0
eike8
- ago
#7
Thanks for the quick reply. Yes, I would like to export the historical data.
@Eugene
Under “Backtest Results” I find “Export” but no entry for “BarHistory (date, open, high, low, close, volume)”. This must be done individually for each symbol?
@Glitch
What I actually want: Start WealthLab automatically (when absent) and save (possibly send) the result of a backtest.
Nevertheless, I would like to know how to read the BarHistory and write it to a file. (I have written routines for my server and don't want to download the stock data twice).
0
- ago
#8
@eike: If you are using C# strategies then you can use the following. Call the method from the BacktesetComplete method of your strategy. See the method's comments.

You could add this your library if you have one.

CODE:
/// <summary> /// For the given bar histories, output the bar data to a CSV file, one file per symbol. /// The output folder is the current user's Downloads folder. For each file's name /// see the code. /// Call this method from method BacktestComplete like this: /// OutputBarHistory(Backtester.Symbols, ",", true); /// </summary> /// <param name="histories">The bar histories for which the file output should be generated</param> /// <param name="separator"> /// In the output file(s), each component (i.e. date, open, etc.) is separated by this string. Defaults to a single /// comma. /// </param> /// <param name="includeHeader"> /// Set to true to include a heading line indicating each bar history component's name (i.e. /// Open, Close, etc.). Defaults to true. /// </param> public static void OutputBarHistory(List<BarHistory> histories, string separator = ",", bool includeHeader = true) { // output is to the current user's Downloads folder var outputFolder = $@"C:\Users\{Environment.UserName}\Downloads\"; // go through each bar history and output it to a file foreach (var barHistory in histories) { var startDate = barHistory.DateTimes[0]; var endDate = barHistory.DateTimes[barHistory.Count - 1]; // note: file is always named with csv extension, regardless of separator var fileName = $"{outputFolder}{barHistory.Symbol}_{barHistory.Scale.ToString().Replace(" ", "_")}_{startDate:yyyyMMddhhmm}_{endDate:yyyyMMddhhmm}.csv"; var outputFile = File.CreateText(fileName); if (includeHeader) { outputFile.WriteLine( $"Date/Time{separator}Open{separator}High{separator}Low{separator}Close{separator}Volume"); } // speed things up a tad var dates = barHistory.DateTimes; var opens = barHistory.Open; var highs = barHistory.High; var lows = barHistory.Low; var closes = barHistory.Close; var volumes = barHistory.Volume; // for each bar... for (var i = 0; i < barHistory.Count; i++) { // sortable date output for all dates, scales var outputDate = dates[i].ToString("s"); var open = opens[i]; var high = highs[i]; var low = lows[i]; var close = closes[i]; var volume = volumes[i]; var line = $"{outputDate}{separator}{open}{separator}{high}{separator}{low}{separator}{close}{separator}{volume}"; outputFile.WriteLine(line); } outputFile.Close(); } }
1
- ago
#9
QUOTE:
I want to export data for all symbols in dataset to csv-files.

Here is the answer for non-coders:

With finantic.Export extension installed, go to Help->Extensions->Export.
The help page "Export" says:

Export of BarHistories
A bar history is a TimeSeries with columns Date, Open, High, Low, Close and Volume. Bar histories are exported by a special strategy named ExportBarHistory in the Export folder. Open this strategy and adapt the base Directory. If the strategy is run in Single Symbol mode just data of the selected symbol is exported. If run as a Portfolio backtest a set of export files is created one for each symbol in the portfolio.
Please take notice of your Data Provider's license agreement.
1
- ago
#10
QUOTE:
What I actually want: Start WealthLab automatically (when absent) and save (possibly send) the result of a backtest.


This should be possible with a clever use of WL's workspaces and comandline options.
0
- ago
#11
@eugene: The second part of this thread (exporting BarHistories) is somewhat off-topic (does not match thread's header) and should probably be moved to a new discussion thread.
0
- ago
#12
Re: Post #11. Given how the offtopic has progressed, it would be tricky to split the thread. Let's rename the topic then.
1

Reply

Bookmark

Sort