Writing Fundamental Data to text files
Author: reds
Creation Date: 1/2/2010 10:08 PM
profile picture

reds

#1
I use the following CS to write some fundamental series to individual test files.

How can I change it so it will only write the value that is reported for the First Friday of the Month and only 12 values for each series will be written per year. This way all values willl be synced to the non-farm payroll report?

Thanks,

Mike

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

Eugene

#2
I can't help you with this Fidelity-specific WLP4 code (WLD3/4 didn't have these fundamental series anyway). By the way, Fidelity doesn't offer WLP4 for download any longer.

In WLP5, however, this is a piece of cake:
CODE:
Please log in to see this code.
profile picture

Eugene

#3
P.S. This is meant to run in single-symbol mode, but will export the defined fundamental DataSeries of a whole DataSet.
profile picture

reds

#4
Hi Eugene,

Is this code conditioned for the first Friday of the month? If so I made a slight error in my request. I am looking for the forst Friday that is a trading day in case the first Friday was a holiday.

Also, for legacy holders of WLD 4.0, can that still be downloaded somewhere if needed for a new install?

Thanks,

Mike
profile picture

Eugene

#5
QUOTE:
Is this code conditioned for the first Friday of the month?

Yes.
QUOTE:
I am looking for the forst Friday that is a trading day in case the first Friday was a holiday.

Dealing with actual holiday dates could take considerably more effort, but is also possible. For backtesting, you'd need a list of past holiday/halt dates for comparison. In WLP5, we have a short local history of US holidays going back to 2004. If that's enough, the Strategy could probably be tweaked to parse the list of holidays similar to what Shortened Sessions does (using the same XML data file).

For older dates, you need to search for it and obtain somewhere (e.g. here). After exporting the list to CSV/XML, a Strategy like the one above could do the check and take another Friday. As an alternative, there should be a math formula to determine if a holiday falls on Friday, but I'm not familiar with this stuff. In the past, fundtimer created an Include library for WL4 called something like Holiday Study - you might want to take a look.

QUOTE:
Also, for legacy holders of WLD 4.0, can that still be downloaded somewhere if needed for a new install?

WLD4 can still be downloaded from our site (Products). At least for some time to come.
profile picture

Wall

#6
QUOTE:
How can I change it so it will only write the value that is reported for the First Friday of the Month and only 12 values for each series will be written per year. This way all values willl be synced to the non-farm payroll report?

Each of those economic data IS reported monthly, just not on the first Friday (other than for the non-farm payroll report), so you will only have 12 data points for each.

Its probably a better idea to "extract" the value of any particular series as of a particular bar (e.g. the first Friday of the month) inside a bar loop.
profile picture

Eugene

#7
QUOTE:
Its probably a better idea to "extract" the value of any particular series as of a particular bar (e.g. the first Friday of the month) inside a bar loop.

Essentially, this is what the code above is doing. You're right, I've taken a look at the economical indicator series which contain only one value per month, and they're not reported on the first Friday, but on different dates.
profile picture

reds

#8
If you plot the Economic series on a Daily cahrt you will see the particular day a series is updated. I want to them all synced to the Non-Farm payroll, regardless if they reported earlier. So, as Eugene's code does, I am only concerend with the value of each series on the First Friday of the month. I may need to do some additional coding to insure that it is the first Friday is the first trading day of the month.

Instead of looking at holidays, could you check an external series for volume, ie the SPY, ad if that series did not hav any change in pricing, no volume, or in fact no data for that date, assume (be careful :-) ) that the first Friday was a holiday?

Thanks,

Mike
profile picture

Eugene

#9
Mike,

Your idea re: check an external series gave me some food for thought, and actually, it can be much more simple than looking at calendar.

If the first Friday is a holiday, then this bar does not exist on chart. So, we only need to determine if the bar is valid (otherwise Wealth-Lab returns -1). If it's not, we'll take the data for any bar that you consider valid for your system.

Since you didn't specify a data point (or have I overlooked it?) to consider instead of the 1st Friday, code below will illustrate how to use .NET to add 7 days to get the second Friday of the month (and take this bar's data instead):
CODE:
Please log in to see this code.

Sure, the 2nd Friday can be replaced with the next trading day or something else.
profile picture

reds

#10
Hi Eugene,

The last code you posted does a great job in identifying the first Friday of the month and if not available it moves to the next Friday.

In the original WL4 code I posted, I could open any WatchList, run the script regardless of symbols in the WL, and only the requested economic or Fundamental data was written, i.e. Retail Sales.. In the latest WL5 code you posted, it seems to write data for the symbols in the WatchList. For example, if I run it on the Dow30, all 30 Dow symbols are written as .csv files with each containing the data for Retail Sales. How do I code it to write the Economic data only, RS.txt as in the original code ?

Thanks,

Mike
profile picture

Eugene

#11
QUOTE:
In the latest WL5 code you posted, it seems to write data for the symbols in the WatchList not the Economic data.

It only seems so.
CODE:
Please log in to see this code.
profile picture

reds

#12
Sorry, you were too quick and posted before I had a chance to edit the question. Please see below.

In the latest WL5 code you posted, it seems to write data for the symbols in the WatchList. For example, if I run it on the Dow30, all 30 Dow symbols are written as .csv files with each containing the data for Retail Sales. How do I code it to write the Economic data only, RS.txt as in the original code ?
profile picture

Eugene

#13
By replacing the Execute procedure with the following code:
CODE:
Please log in to see this code.
profile picture

reds

#14
Eugene..It still does not produce a file RS.csv but files for every symbol in the WatchList, AA.csv, WMT.csv...all containing the retail sales data. What I would like it to do is produce only a file called RS.csv and have the ability to add other economic fields as well regardless of the WatchList...Mike
profile picture

Eugene

#15
It does produce a single .csv file but named after clicked symbol. Modify "string file..." to your taste. Run in single symbol mode.
profile picture

reds

#16
Ok..Now I want to add a few other economic series, for example Non-Farm Payroll. How can the script write a two files, RS.csv and NFP.csv without manually editing the string file after clicking on a symbol?

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

Eugene

#17
QUOTE:
manually editing the string file after clicking on a symbol

There's difference between modifying "string file..." and manually editing the file. :) I was trying to make you see the unique line of code that defines how the created file is named. Is this clear?
QUOTE:
How can the script write a two files, RS.csv and NFP.csv

By defining two StreamWriter directives (instead of just one), one for the RS file, and another for the NFP file. Notice the WriteLine call? Currently it serves just for the RS file, so you'll have to duplicate it for the NFP file. Do the same for closing the file (as you can see at the end of the strategy code).
profile picture

Eugene

#18
Hope this helps: C# Using StreamWriter
profile picture

reds

#19
Hi Eugene,

I realize this is a step backwards but I'll ask it nonetheless.

Using WL4.0, how can I condition the below code not only to check to see if it is Friday but only to write the first Friday of the month and then skip to the next month so only one value is written per month, typically the first if it is available.

CODE:
Please log in to see this code.


Thanks,

Mike
profile picture

Eugene

#20
Here's the ultra-simple modification I was trying to gently push you to:
CODE:
Please log in to see this code.
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).