Lead Bars Solution
Author: Panache
Creation Date: 1/27/2014 9:56 AM
profile picture

Panache

#1
Is there a way to load more data for a symbol than what is shown in the Data Range without having to load all the data for the symbol?

What I'd like to do is to load only enough extra bars to have the strategy trading from day one, without loading all the data. LoadFromFile would work, but I'm wondering if there is an extension of Bars.Symbol that would be easier.

Is there somewhere where things like Bars.Symbol.GetAllDataForSymbol are documented?
profile picture

Eugene

#2
GetAllDataForSymbol from Community Components is the lead bars solution. What it does is expose through Reflection an internal method used by Wealth-Lab itself to load the data. So should you happen to develop a better / more suitable way than the Wealth-Lab's native method, please don't forget to share the code with the community and come up with a couple paragraphs for the online manual.

QUOTE:
Is there somewhere where things like Bars.Symbol.GetAllDataForSymbol are documented?

Naturally, it's exactly where you found the GetAllDataForSymbol documentation:

Pages of the Category Community Components

See more on extension methods here: Home - Community Components
profile picture

Panache

#3
Thanks. I forgot this was a Community Component.

Not having seen the code for Bars.Symbol.GetAllDataForSymbol, would it be possible to add an optional parameter for startDate, like LoadFromFile has? I assume Bars.Symbol.GetAllDataForSymbol is basically LoadFromFile directed at the symbol being processed, so I would think it should be relatively easy to do.

If not, I can write a code snippet using LoadFromFile. The biggest problem for publication would be that there would be several more steps to the cut and paste Lead Bars Solution dealing with converting symbols to file names and directories.

With a startDate parameter, if you had a 200 day sma, you could either do a rough approximation (200 / 5 days per week = 40 weeks / 4 weeks per month = 10 months, so if your start date were one year prior to the beginning of the Date Range, you would have more than enough bars) or an exact DateTime calculation to determine the first bar of data you needed to load,

When running a strategy which searches a large DataSet for signals (or worse yet, optimizing one), with fewer bars to load for each symbol, I would expect a substantial decrease in the time required.
profile picture

Eugene

#4
QUOTE:
Not having seen the code for Bars.Symbol.GetAllDataForSymbol, would it be possible to add an optional parameter for startDate, like LoadFromFile has? I assume Bars.Symbol.GetAllDataForSymbol is basically LoadFromFile directed at the symbol being processed, so I would think it should be relatively easy to do.

No, what you're asking for is not possible with regard to GetAllDataForSymbol. As the method name implies, the whole purpose of it is to load all available data for a symbol. Consequently, an optional parameter for startDate would not make sense even if it was possible (but it is not). Additionally, the method is not based on LoadFromFile anyhow.

QUOTE:
When running a strategy which searches a large DataSet for signals (or worse yet, optimizing one), with fewer bars to load for each symbol, I would expect a substantial decrease in the time required.

Does your PC already have an SSD where the Wealth-Lab data is stored?

QUOTE:
The biggest problem for publication would be that there would be several more steps to the cut and paste Lead Bars Solution dealing with converting symbols to file names and directories.

Your guess is absolutely correct: there's too much left to go to come up with a transparent solution that would work with every bar scale of every data provider. Don't forget that not all data providers keep their data in files. Essentially, with all this you'd be doing the StaticDataProvider's job. So for your private need, LoadFromFile should do. But if you want to leverage your workaround and turn it into a universal solution, the proper way might be to:

1. Get rid of LoadFromFile to avoid having to deal with the folder structure and symbol name conversion
2. Instantiate the StaticDataProvider and call one of its methods: RequestData.

Since all this is an unsupported stuff, I'm leaving the discussion after pointing you at some loosely related examples:

Trick to request scheduled data updates more than once a day?
Is it possible to manipulate DataSet Contents and change symbols programmatically?
Adding/Removing symbols from Data Manager
profile picture

Panache

#5
Perhaps the easiest solution is if Performance could be programmed to start on the date of the first trade. I don't know how hard it would be to change Wealth-Lab to do that, but it would eliminate any need for a work-around.

If you did that, you could use Data Range to load whatever data is necessary and use the following if you want to start trading on a specific date.

CODE:
Please log in to see this code.


Even better would be to add a Wealth-Lab command, e.g. StartDate(DateTime) ,which could not only be the date for the Buy and Hold comparison begin, but also the date used to begin the calculation of Annualized Gain %, which is also distorted when you have something like a 200 day sma.

Intellectually, I think it would be very pure. Data Range would be just that, how much data you want to load. You could then have complete freedom to program what you did with that data and how performance is measured.
profile picture

Eugene

#6
I too don't have a clue as to how hard would it be to change something that is working by design. If it was considered the easiest solution back in 2006-07 when redesigning WL for .NET, we simply won't be talking here about what was purposefully dropped from the drawing board!
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).