GetExternalSeries
Author: ss161
Creation Date: 6/22/2009 1:18 PM
profile picture

ss161

#1
Below is a code fragment from a symbol rotation style strategy. The dataset that I run it on contains SPY, which i define as my benchmark symbol.

CODE:
Please log in to see this code.


at the start of the strategy, I load in SPY and calculate a dividend adjusted series -- with no issues. In the for loop part of the code, when the strategy gets to SPY in the dataset, instead of "reloading" SPY again, the line
CODE:
Please log in to see this code.

seems to return a reference to the already dividend adjusted Bars object

CODE:
Please log in to see this code.


as a result, when i call my dividend adjustment routine, it actually adjusts the already dividend adjusted Bars object. For now i've coded around the issue with an if statement, but I'm curious whether

1) whether this is the intentional behavior and
2) if there is a way to force the Bars object to be reloaded.

thanks.
profile picture

Cone

#2
Try the Cache.Clear Bars method.

But, it sounds to me like the problem is the use of the same Bars reference in your adjustment routine. You're changing the cached Bars data, so use a new Bars reference.
profile picture

ss161

#3
the dividend adjustment routine does change the cached Bars data. on my end, that was by design. i want all the signals generated and the trades that i execute to operate on the dividend adjusted series. by creating a new bars object inside the dividend adjustment routine, the signals would probably be right, but the trades would occur on the non-div adjusted series. i guess that's ok if the include divs in backtest option is turned on. i'll see how that works.

but also, i'm still not clear on how GetExternalSymbol works. I call it twice, with two separately defined Bars objects: Bars sym and Bars benchmark. Are you saying the GetExternalSymbol looks to see whether the symbol has been loaded, and if it is, just returns a pointer to the symbol vs re-loading it? It seems to me that if it is explicitly called again, it should re-load the data.

here's the dividend adjustment routines:

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).