Loading lead bars for symbol
Author: thodder
Creation Date: 11/28/2012 3:27 PM
profile picture

thodder

#1
I need to load the current symbol with about 10 years of prices leading up to the start date (if available). Currently the only scripting tool I see is LoadFromFile. I use the following code...
CODE:
Please log in to see this code.

This works fine for most securities; however, index symbols are still an issue. Do you know what is typically used for encoding index symbols? Is my test for IsLetterOrDigit appropriate for all symbols?

On a wish list note, it would be nice if GetExternalSymbol allowed for start and end dates to be passed so you could load prices outside of the current test range. I've seen others request a lead bars setting in the past (bars prior to back test start date to allow indicators to be stable on bar == 0). This could be used as a work around.
profile picture

Eugene

#2
It's easier if you use:

WealthLab.DataStore.FileNameForSymbol(string, WealthLab.BarScale, int)
profile picture

thodder

#3
Sounds like a good idea... however, it is undocumented and adding that line of code doesn't compile. I'm assuming my method above could be changed to...
CODE:
Please log in to see this code.

profile picture

thodder

#4
More likely something like this as the datastore needs to be specified...
CODE:
Please log in to see this code.


This still gets a compile error as FidelityStaticProvider does not contain a definition for FileNameForSymbol.
profile picture

Eugene

#5
QUOTE:
I'm assuming my method above could be changed to...

No, because the DataStore class is not static.

Okay, this should work:
CODE:
Please log in to see this code.
profile picture

thodder

#6
Actually your first line in the code example above looks like it needs to be...
CODE:
Please log in to see this code.


The 'Data' node needs to be included as I got a file exception without it when I called LoadFromFile.

Thanks for the code! This should work great.
profile picture

Eugene

#7
You're welcome. That's right, it should be prefaced with "Data\", I'm editing my post, thanks.
profile picture

Eugene

#8
In case somebody stumbles onto this thread, a solution for Lead Bars has long been found:

FAQ | Strategies and WealthScript > How to start Buy&Hold from specific bar (not at bar #0)?
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).