Accessing All Historical Price Data

Posted By: JohnJits

Accessing All Historical Price Data - 10/22/19 01:00

Hello,

Is there a way to access all the historical data for an asset prior to the run function? For example, I would like to be able to scale the price data for the entire data set at once then iterate over them in the run function. It appears that if you do the following:

Code
vars Prices = series(price(0));


The Prices series is limited by the LookBack in length.

Borrowing from the code located at Better Strategies 5: A Short-Term Machine Learning System:

Code
var change(int n)
{
	return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}


The above scales the data but is limited to n bars. In ML, you would typically want to scale the data using the entire range of data.

In other words, how do you reference the historical data set after you set your StartDate and EndDate and outside of the run function?

TIA!
Posted By: jcl

Re: Accessing All Historical Price Data - 10/22/19 10:37

I would not do that, since it can produce peeking bias in the backtest. But if you still want it, you can access the complete historical data from the AssetC etc. arrays.

https://manual.zorro-project.com/algovar.htm
Posted By: JohnJits

Re: Accessing All Historical Price Data - 10/22/19 22:37

Yes thank you for pointing the bias out and agree.

I was thinking of applying fractional differentiation (based on the research of Dr Marcos Lopez de Prado in his book Advances in Financial Machine Learning) to provide a stationary series and keep memory for the features and target. I could then scale the features in Zorro (only in training cycles) for AI. Does this sound ok?
© 2024 lite-C Forums