Possible to extend assetHistory with own source?

Posted By: Dalla

Possible to extend assetHistory with own source? - 09/24/18 09:01

Hi

I was wondering if there is any source code available for the mode functions used by assetHistory, like FROM_AV, FROM_STOOQ etc?

I have an external source from where I would like to download D1 data and it would be great if I could somehow tie that to the existing assetHistory call.

Regards,
Daniel
Posted By: jcl

Re: Possible to extend assetHistory with own source? - 09/24/18 09:30

This is possible by downloading it with a script. Example for Google:

Code:
void main()
{
	string MyAsset = "SPY";
	string URL = strf("https://www.google.com/finance/historical?q=%s&startdate=01-Jan-2000&output=csv",MyAsset);
	string Content = http_transfer(URL,0);
	if(!Content) return;
	file_write("History\\history.csv",Content,0);
	dataNew(1,0,7);
	if(!dataParse(1,"%d-%b-%y,f3,f1,f2,f4,f6","History\\history.csv"))
			return;
	dataSave(1,strf("History\\%s.t6",MyAsset));
}

Posted By: Dalla

Re: Possible to extend assetHistory with own source? - 09/24/18 11:45

I was hoping to be able to use UpdateDays=-1 after the initial download to avoid downloading the entire history every time, which would take time if I have a universe of ~ 200 stocks.

I guess I could use dataLoad and dataVar to get the latest date and adjust the startdate accordingly, or is there an easier way?
Posted By: jcl

Re: Possible to extend assetHistory with own source? - 09/24/18 14:32

For UpdateDays, you can use the file_date function and compare the file date with the current date. That's what the assetHistory function internally does. This, and the code above, are almost the complete assetHistory function.
© 2024 lite-C Forums