Exporting data to CSV
Author: fastrade
Creation Date: 8/21/2009 11:58 PM
profile picture

fastrade

#1
I like to export economic data out of WL to a csv file so I can use it in excel. Is there way of doing this? TIA
profile picture

Cone

#2
.NET would be pretty deficient if there weren't a way to save data to a file! ;)

Check out the WL5Wiki Knowledge Base, search the page for ASCII.
profile picture

fastrade

#3
thanks Robert. I played around with a it. I was able to export data from datasets. However, There is no dataset for economic indicators. It seems that they are all in a symbol called "NonSymbol.wlf". I am not sure how to export data from this file. I am using the following code to export data. Also it only outputs seven data points. I thought this line of code "for(int bar = 0; bar < Bars.Count; bar++)" checks for the number of bars in each ticker and then export the results to a csv file.

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

Cone

#4
See the example for FundamentalDataItems to get an idea how to export fundamental data.
profile picture

fastrade

#5
I can not find the example you are referring to. Would you please provide the link.
profile picture

Cone

#6
QuickRef - F11
profile picture

fastrade

#7
I have not been able to figure out how to export economic data to csv files. If it is not too much trouble, would you please provide me with the code?
profile picture

Cone

#8
Why are you doing this? How will the data be consumed?

I don't want to work on a solution that will have to be reworked because I didn't do it right the first time.
profile picture

fastrade

#9
I want to do some analysis in excel. With new programs I verfiy my in excel. Your help would be much appreciated.
profile picture

Cone

#10
Don't forget to create the VB reference identified in the comments -
CODE:
Please log in to see this code.
profile picture

Eugene

#11
2 fastrade:

btw, InputBox is already repackaged as Input (to match WL4's name) in Community.Components. Considering this extension has lots of fun stuff, you might want to consider an alternative to adding Microsoft.VisualBasic to your references:

1. Add -
CODE:
Please log in to see this code.


2. Change -
CODE:
Please log in to see this code.

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

fastrade

#12
thanks a million guys.
profile picture

fastrade

#13
all data points were exported correctly except for "intial jobless claims" which I get the follwing error message:

Error exporting intial jobless claims
System.NullReferenceException: Object reference not set to an instance of an object.
at WealthLab.Strategies.ExportEconomicIndicators.Execute()
profile picture

Cone

#14
That's because it was spelled wrong in the string array. intial -> initial

Corrected above.
profile picture

kettle

#15
I used the example script in WL5Wiki Knowledge Base for exporting 1 minute data to csv, but I was able to export only part of the data. For ZION, there were 485708 bars in the data, but only 2727 bars were exported. Checked the number using the following, which also gave a number 2727. Any ideas?

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

Eugene

#16
Data export depends on the loaded data range. Have you chosen "All data" to export all available data?
profile picture

kettle

#17
Still learning the script language, not sure where to find reference of the defined objects in WL. I used the following from wiki. Any places I could specific the data range?
profile picture

Eugene

#18
Here I mean Wealth-Lab's own data loading control. Please refer to the Wealth-Lab User Guide, Reference > Data Panel > Data Range Control.

P.S. When posting code, please paste it in between a pair of CODE tags (next to IMG, QUOTE etc.)
profile picture

kettle

#19
Thanks, it works!
profile picture

kettle

#20
Is it possible to do the data exporting in a ticker-by-ticker fasion? For 1 minute data, data sizes are large, WL always tries to bring the data of all tickers of a data set into memory. Is it possible to read data of one ticker, export the data of this ticker, clear the data in memory, then proceed to the next?
profile picture

Eugene

#21
The Wiki code for Exporting to ASCII comma-separated files (CSV) was just designed to be run in single symbol mode, thereby processing data in a ticker by ticker fashion. If you were trying to run it in Portfolio Simulation mode, then WL's behavior was just like you said. In other words, you need to click a symbol in the Data Tree for that strategy to work w/o loading all data to memory.
profile picture

fastrade

#22
kettle, would mind posting the code that you are using to export tick data? TIA
profile picture

Eugene

#23
Which data vendor are you using to get tick data? Probably it's not in ASCII, or you wouldn't want to export it to ASCII ;) Fidelity doesn't have it. Otherwise, the Wiki code should do fine for that purpose.
profile picture

fastrade

#24
I am using Fidelity. I thought fideliy provided tick data regardsless of the timeframe one chooses. My data is stored in 1 minute bars.
profile picture

Eugene

#25
1-minute bars is the minimum time scale Fidelity data can be exported.
profile picture

Cone

#26
Clarifying: Fidelity Streaming builds new bars using ticks, but these data are stored in the chart's scale, which is then what you're able to export.
profile picture

fastrade

#27
I get a 'System.OutOfMemoryException' when I run the following code. Do you why?

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

Eugene

#28
QUOTE:
I get a 'System.OutOfMemoryException' when I run the following code. Do you why?

No, because we don't have anything from this checklist >> How to report a Problem? . Although guess-work can be fun, we could help you better knowing the number of symbols, bars loaded and how do you run it (multi-symbol backtest mode vs. single symbol). Currently, my educated guess is that you're trying to execute this code -- designed to be run in single symbol mode (see the User Guide for difference) -- as a portfolio backtest.

Additionally, see the Wealth-Lab 5 Wiki FAQ:
Out of memory problems.

P.S. When posting code, please hit the CODE button and paste code in between.

Bold Italic Underline LINK QUOTE CODE IMG

Click "Edit" near the end of your message, select the code, click "CODE" and apply changes by clicking the green "Edit" button. Thank you.
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).