Polygon to Amibroker Scripts

Documentation for the Polygon download scripts and the Amibroker import process.
Published Nov 13, 2025

Download the Code

There are two scripts in this package that are involved in the Polygon to Amibroker import process.

The first is polygon_fetch.py and it downloads the flat files from Polygon's minute aggregate files.

They'll be downloaded into a directory called polygon_files.

The second script is polygon_to_ami.py and it formats the Polygon files into a format that Amibroker can import nicely.

Both of these scripts require Python to run. The polygon_fetch.py requires the Boto3 library for downloading files from S3.

You can install Boto3 by running the following command:

pip install boto3

or

python -m pip install boto3

Using the Polygon Fetch Script

When you subscribe to Polygon, you'll need to create a key for accessing the Flat Files (S3). On your Dashboard in your account, look for the Keys section. You may already have a set of keys available. You're looking for these key values:

  • Access Key ID
  • Secret Access Key

The polygon_fetch.py file looks for a file called poly_credentials.py in the same directory as the script.

Create the file if it doesn't exist and add your keys to it.

Running the Polygon Fetch Script

When you run the script, it will prompt you for a start date and an end date for files to download.

You can also specify the dates in the command line:

python polygon_fetch.py --start-date 2025-11-10 --end-date 2025-11-12

The script will go through the dates (skipping weekends) and download each day's file and place it in the polygon_files directory (which it will create if it doesn't already exist).

About the Polygon to Amibroker Conversion Script

The second script is called polygon_to_ami.py and reads the files and converts them to a format that Amibroker can import.

python polygon_to_ami.py

It will cycle through any files in the polygon_files directory and create files to be imported into Amibroker. The files will have an extension of .polyintradaycsv. This will allow Amibroker to apply the right format when importing the data. (See next step.)

Creating a Custom Amibroker Import

Add the following line to your import.types file located in C:\Program Files\Amibroker\Formats\import.types:

Polygon Intraday (*.polyintradaycsv)|*.polyintradaycsv|polygon_intraday.format

Copy the polygon_intraday.format file into the c:\Program Files\Amibroker\Formats\ directory.

Now, in Amibroker when you go to File -> Import ASCII..., you should see an entry for Polygon Intraday on the list:

Amibroker Import Item

Then in Amibroker you should be able to choose the *.polygonintradaycsv files and import them using the Polygon Intraday item in the Files of Type dropdown.