Creating a DataSet programmatically
Author: Partha
Creation Date: 9/4/2019 1:02 AM
profile picture

Partha

#1
I have a screener that classifies stocks based on certain parameters. Is there a way to automatically create a data set using the C# code after the screener is run. The idea is to create a data set with the subset of symbols after the screener.

For example lets say I run the screener on the S&P 500 symbols and the screener picks up 25 symbols that meet the criteria. Now I would like to create a new data set with these 25 symbols. I can do it manually by dumping the symbols in a text file and copying them in a new data set but it would be great if this can be achieved using code
profile picture

superticker

#2
If you only have 50 or less stocks to import from the Fidelity website screener into Wealth-Lab, then the process is easy. Simply place those stocks into a website watch list. Afterwards, you can use the WL Data Manager (via the [Create a new DataSet] button) to import that watch list into WL as a new WL dataset. You're done.

If you have more than 50 stocks to import from the Fidelity screener and want to avoid duplicates already in your existing WL datasets, then the solution gets somewhat more complicated. I've written a command line utility that does that, but there are many more moving parts involved and command line options. You can review that approach in the thread below. That's another topic ... https://www.wealth-lab.com/Forum/Posts/Supplementing-existing-DataSets-with-new-stocks-from-Fidelity-screener-38596

---
If the stocks you're screening against already exist in a WL dataset (like the S&P500), then you can simply use WL itself as your screener. See the WealthScript Programming Guide > Techniques > "Creating a Screener" section.
profile picture

Eugene

#3
First off, programmatic creation of a DataSet with a WealthScript Strategy requires a WLP restart. Unlike a WL addin (like the Data Tool), WLP will not pick up your change until you restart it.

An easy way to create a DataSet file that does not involve undocumented calls from code is string manipulation. It's based on Cone's idea from How to create Dataset dynamically?, post #2

* Run your screener to determine the list of symbols.
* Keep a DataSet XML template in a string. Take a Fidelity DataSet from "c:\Users\your Windows username\AppData\Roaming\Fidelity Investments\WealthLabPro\1.0.0.0\Data\DataSets\" and keep its contents
* replace the Name tag with your new DataSet's name. If the DataSet is always the same this step can be skipped.
* Replace whatever XML tag that identifies the symbols with your own sequence (string) of 25 symbols meething the criteria. I don't have a Fidelity DataSet on hand but it may be called DSString
* Save the XML file under a new name in your Strategy code (or under a fixed name if the DataSet name is always the same)
* Restart WLP

You can find some sample code to generate a DataSet this way here: How to create/convert GICS database for symbols
profile picture

Partha

#4
Thanks Mark Mehl (superticker) and Eugene...I followed the idea by Eugene and implemented it...works perfectly

profile picture

Eugene

#5
Always a pleasure to help!
profile picture

fred9999

#6
QUOTE:
* Run your screener to determine the list of symbols.
* Keep a DataSet XML template in a string. Take a Fidelity DataSet from "c:\Users\your Windows username\AppData\Roaming\Fidelity Investments\WealthLabPro\1.0.0.0\Data\DataSets\" and keep its contents
* replace the Name tag with your new DataSet's name. If the DataSet is always the same this step can be skipped.
* Replace whatever XML tag that identifies the symbols with your own sequence (string) of 25 symbols meething the criteria. I don't have a Fidelity DataSet on hand but it may be called DSString
* Save the XML file under a new name in your Strategy code (or under a fixed name if the DataSet name is always the same)
* Restart WLP


Please tell me if it is possible to do the same with WLD + Norgate provider?
profile picture

Eugene

#7
QUOTE:
Please tell me if it is possible to do the same with WLD + Norgate provider?

I may be wrong due to lack of experience with Norgate data. If their DataSets are like those created by most other data providers then I see no reason why it shouldn't apply to Norgate. You just have to examine the structure of a Norgate DataSet's XML file to find out how symbol names are stored there for this step to work:

* Replace whatever XML tag that identifies the symbols with your own sequence (string) of 25 symbols meething the criteria. I don't have a Fidelity DataSet on hand but it may be called DSString

Problem may arise if it codifies symbol names. (For example, this is how Finam and MFD data providers function: an "Acme Corp" stock is assigned an id e.g. 12345. Programmatic creation of DataSets as per post #3 would be virtually impossible with them - or at least highly unpractical). If you zip and attach an XML file of your Norgate DataSet I can tell in more detail.
profile picture

fred9999

#8
QUOTE:
If you attach an XML file of your Norgate DataSet I can tell in more detail.


For example, file "NASDAQ 100.xml"

<?xml version="1.0"?>
<DataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>NASDAQ 100</Name>
<Scale>Daily</Scale>
<BarInterval>0</BarInterval>
<DSString>NASDAQ 100</DSString>
<ProviderName>NorgateDataProvider</ProviderName>
</DataSet>
profile picture

Eugene

#9
Apparently Norgate DataSets are attached to NorgateData watchlists which is another way of codification. You create a watchlist in NDU (NorgateData Updater) and then it becomes available for use in Wealth-Lab. Which means that programmatic creation of DataSets is impossible, unfortunately.
profile picture

fred9999

#10
Thanks, i thought so.
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).