How to import of Polygon EODData file into Amibroker using Amiquote?


New Amibroker/Amiquote user here. I have been going thru the forum posts and wondering how I can implement import of EOD Data file from Polygon to Amibroker using Amiquote. I have changed the delivered javascript code as below:

function pad(num, size) 
    num = num.toString();
    while (num.length < size) num = "0" + num;
    return num;

function dateToYMD( d )
	return  d.getFullYear() + "-" +
           pad( d.getMonth() + 1, 2 ) + "-" +
           pad( d.getDate(), 2 );

function dateToHMS( d )
	return	 pad( d.getHours(), 2 ) + ":" +
           pad( d.getMinutes(), 2 ) + ":" +
           pad( d.getSeconds(), 2 );

// the processing function takes text as input and produces text as ouput
function Process( input )
		all = JSON.parse( input );

		if( all.status == "ERROR" ) 
			return "Error: " + all.error;

		if( all.resultsCount == 0 )
			return "Error: no data for this symbol";

		quotes = all.results;

		output = "";
		for( i = 0; i < quotes.length; i++ )
			date = new Date( quotes[ i ].t );

			ticker = quotes[ i ].T;
            open = quotes[ i ].o;
			high = quotes[ i ].h;
			low = quotes[ i ].l;
			close = quotes[ i ].c;
			volume = quotes[ i ].v;
            output += ticker + ", ";
			output += dateToYMD( date ) + ", ";
			// output += dateToHMS( date ) + ", ";

			output += open + ", ";
			output += high + ", ";
			output += low + ", ";
			output += close + ", ";		
			output += volume + "\n";		
	catch( e )
      output = "Error: " + + ": " + e.message;

	return output;

I am using URL template as below:{from_ymd}?adjusted=true&include_otc=true&apiKey={api_key}

Using the javascript code, when I tried to fetch data using debug option on user-definable data source, data is coming out correctly however when I tried to run Amiquote, Amiquote is trying to read 1 ticker at a time. Even 1 ticker at a time wont work as the URL I am using is incorrect for getting 1 ticker data.

Please advise if this is something that is possible by making any changes or I am running in a wrong direction. Thanks

If I recall correctly, you are using a polygon function that returns EOD data for all ALL stocks in the polygon universe. So what you need to do is tell amiquote WHICH tickers you are getting. Possible solutions to your problem are:

  1. Download the polygon stock universe EOD data for the last year for all tickers into ascii/CSV files. Then import the files into an amibroker database. This then creates a ticker list of available symbols that you can then potentialy update via Amiquote / your code.
  2. I recall Polygon has a different API call where you can specify the individual ticker to download data (EOD presumptively). You might want to run that instead as it works more similarly to the way amiquote does. Code rewrite though, iterating through your tickers one at a time for that data (still pretty fast)

I actually settled on a variation where I maintain a list of tickers I am interested in and periodically download new data (in my case, minute data) from another vendor and once I have that data integrated, I just replace the database in amibroker with the new data. Works, I'm sure there is a better way to do it with amiquote but haven't implemented it.

you need to spend a little more time with the polygon API and amiquote to figure this out. Sorry I can't help you more as I don't program in java nor have I used polygon in 3++ years.

Thanks for your response. I am a free user of Polygon.

So, I cannot download using ticker by ticker as Polygon has a restriction of 5 calls per minute. Using this API can actually work with Amiquote but that can take a lot of time.

At the sametime, Amiquote cannot work with the single EOD file that can be downloaded from Amiquote.

I have tried a lot and I couldnt make Amiquote work with Polygon in the way I want.

I am using Python to download the file using a scheduled job, load the file into Amibroker manually. For now, this is working very well and planning to continuing it.

Why do you make such incorrect assumption? AmiQuote is perfectly capable of downloading single and multiple files. No problems at all. For example AmiQuote imports both multiple files from Tiingo as well as single "all symbols" EOD file.

I apologize for that assumption and not correctly explaining it. What I intend to say is, with the delivered source for in Amiquote, I was not able to achieve what I intend to do.

I have made changes to the sourse and even then I was not able to download the full file and load it into amibroker.

Having said that, Tiingo EOD source doesnt exist in c:\Program Files\AmiBroker\AmiQuote\DataSources\ to mimic what it is doing.

I couldnt get any answer here, so I gave up after trying for sometime.

Tiingo is built-in data source. It is directly selectable from "Data Source" combo and you don't need to import it or look for importable file.

1 Like