Rendering Data
Rendering Data with CSharp
Using Processing Framework
During this part of the contribution process, you need to edit the Lean.DataSource.<vendorNameDatasetName> / DataProcessing / Program.cs file so it transforms and moves your raw data into the format and location the GetSource methods expect. The program should save all the data history to the output directory in your machine's root directory (for example, C: / output) and it should save a sample of the data history to the Lean.DataSource.<vendorNameDatasetName> / output directory.
Follow these steps to set up the downloading and processing script for your dataset:
- Change the structure of the Lean.DataSource.<vendorNameDatasetName> / output directory to match the path structure you defined in the
GetSource
get_source
methods (for example, output / alternative / xyzairline / ticketsales). - In the Lean.DataSource.<vendorNameDatasetName> / DataProcessing / Program.cs file, add some code to time how long it takes to process the entire dataset and how long it takes to update the dataset with one day's worth of data.
- In the processing file, load the raw data from your source.
- If your dataset is for universe selection data and it's at a higher frequency than hour resolution, resample your data to hourly or daily resolution.
- If any of the following statements are true, skip the rest of the steps in this tutorial:
- Your dataset is not related to Equities.
- Your dataset is related to Equities and already includes the point-in-time tickers.
- If you don't have the US Equity Security Master dataset, contact us.
- In the Lean.DataSource.<vendorNameDatasetName> / DataProcessing / Program.cs file, create and initialize a map file provider.
- Create a security identifier.
- In a terminal, compile the data processing project to generate the process.exe executable file.
$ dotnet build .\DataProcessing\DataProcessing.csproj
You can fetch data from any of the following sources:
Source | Considerations |
---|---|
Local Files | It can help to first copy the data into location. |
Remote API | Stay within the rate limits. You can use the rate gate class. |
You should load and process the data period by period. Use the date range provided to the script to process the specific dates provided.
If your dataset is related to Equities and your dataset doesn't account for ticker changes, the rest of the steps help you to adjust the tickers over the historical data so they are point-in-time.
var mapFileProvider = new LocalZipMapFileProvider(); var mapFileProvider.Initialize(new DefaultDataProvider());
var sid = SecurityIdentifier.GenerateEquity(pointInIimeTicker, Market.USA, true, mapFileProvider, csvDate)
After you finish compiling the Program.cs file, run the process.exe file to populate the Lean.DataSource.<vendorNameDatasetName> / output directory and the output directory in your machine's root directory.