Tuesday, May 5, 2026

Amibroker API Integration

Step 0: Amibroker 

Install Amibroker. No need to create a database.

Step 1: RAM Disk 

Download  1 Install RAM Disk.bat batch file and double click to execute. After installation complete , it open Ram Configuration . 



Change these two items. File System to FAT32 and Untick Create Temp Folder. Keep Drive letter as R. Size 64MB. Leave others default as in image. Then click ok.

Alternatively (Without Batch Script) download RAM Disk from here and Install. Watch this video for installation instructions. Open ram configuration , from start menu and set above settings. 

Step 2: Python

Download 2 Install Python.bat batch file and double click to execute. It will Install 3.13.7.

Alternatively (Without Batch Script) download official Python 3.13.7 or latest version from here . Watch this video for installation instructions and using IDLE. Jupyter notebook not required. 

Step 3: Python Libraries

Download 3 Install Py Libraries.bat this batch file and double click to execute. It update PIP and install required libraries.

Alternatively you can install required libraries manually. Open Command Prompt and enter following commands.

PIP Update

python.exe -m pip install --upgrade pip

Install Libraries 

python.exe -m pip install requests==2.32.5 pyotp==2.9.0 websocket-client==1.9.0 aiohttp==3.12.15 pandas==2.3.2 pywin32==311 nest-asyncio==1.6.0 PyJWT==2.10.1 selenium==4.38.0 webdriver-manager==4.0.2 seleniumbase==4.44.17

 

Step 4: Folders

Create a Folder in C Drive as 'API' Then in folder 'API', Create three folders. 1.Scripts 2. Files 3. HistoricalData



1. Scripts: Put all python scripts (*.py) in this folder.

2.Files: This folder is for create token master files. Put all csv files. *List.csv and IndexMaster.csv. *List.csv files are list of symbols to get tokens. 

3.HistoricalData: Historical data downloads are saved in this folder.

4. Ram Drive R: Ram disk is for saving response files, live CSV and backfill data.

5.Amibroker Formats folder: Put all format files in this folder. OneMinutFeed.format, TickDataFeed.format, EOD.format, MasterInfo.format etc.

In the Formats folder, open the file import.types in notepad, Then add following lines in the top.

OneMinuteFeed (*.*)|*.*|OneMinuteFeed.format
TickDataFeed (*.*)|*.*|TickDataFeed.format
EOD (*.*)|*.*|EOD.format
MasterInfo (*.*)|*.*|MasterInfo.format



and save it. it is for manual importing data files using Amibroker Import ASCII. Importing through script, it is not required to modify import.types file.

6. Amibroker Custom Folder: Put all AFLs in Amibroker Formulas/Custom folder.

If you pin these folders in Quick Access as above, it will be easy to access these folders.

Folder names , Files Names and Paths should be same as said here. Otherwise it not read, write or execute.

Step 5: Database

Create new database with base time interval 1 minute. Keep it default database. Download Dummysymbol.csv and import using OneMinuteFeed.format . 

Scrip Master



To get live and historical data, we need to send exchange token of the symbol. For some brokers we need to send token to place order also. This exchange token is same for almost all brokers. Zerodha have different tokens and Fyers have different format. So we create ScripMaster.csv, which have a symbol list with exchange, symbol, token. 


For stocks equity/futures, we need to create NSEEquityList.csv /NSEEquityFuturesList.csv which have symbol name. Sample is given in GitHub
 
For Index and MCX, input can give in parameter of scrip master afl.  Also you can make for any FnO symbol. For multiple symbols, do one by one.
Then click respective button. It create a csv file ***Master.csv. Then do this for all required symbols. 


Then click "Join Files" button. Now all ***Master.csv are combined and new file created as ScripMaster.csv .
 
This is the token list we use for historical data and live data. Individual master files create with additional columns for expiry date, lot size, option chain strike difference , exchange and segment. In parameter there is option to import yes/no. If you enable, these data import to Symbol Information. Then you can use this data for order placing, ATM calculation. Broker which need to send token number for order place, must import this. 


To use Stock options, you need to add points between strike price in "Point Value" . Scrip Master will import this to Futures symbol. Then create a watchlist which symbols you want to add options symbols. Then apply ExportStrike afl. Apply on analysis. Select the watchlist. Set number of strikes in parameter.  0 give only atm. First click explore. Check all columns ok. Then click scan. It create Options list.csv in API folder. Now from ScripMaster afl, click Stock options. Then click Join Files.


Dashboard


Buttons

Login Button: To execute login script and if login success execute limits script and Show the User ID and Cash Balance. 

Limit Button: To get Limits after login successful.

StartFeed: To start live feed. to stop feed just close the CMD window. 

Backfill: To backfill recent days. Files are download to RAM disk , so use this for few days data only. For longer period use Historical Data. After import it automatically delete the downloaded file.

Historical Data It download data in Historical Folder. 

EOD Data: To download data in daily timeframe. 


Parameter

Number of Days to Backfill: 0 is for current day. 1 is for yesterday and today. If yesterday is holiday, it download today only.

Number of Parallel Backfill: Number of scrips download parallel. If number of days is less, keep number of parrallel downloads large. If number of days is large, then reduce parallel backfill.

Historical Data download: If yyou want to download for all symbols, select ScripMaster, otherwise select respective master file.

Historical Data From/To: Date for download historical data From and To.

Import Downloaded Hist Data: If yes, It import downloaded to amibroker, otherwise it only save files in HistoricalData folder.

Delete Downloaded Hist Data: If yes , it delete the downloaded data after import, otherwise it keep the data files. If "Import Downloaded Hist Data" is No, it igoner this parameter and keep the data.

Historical data Timeframe: It is the timmeframe to download Historical Data.

Number of Parallel Hist downloads: Same as said backfill

EOD Data: same as said in Historical Data.

Path: Check the paths are right.

User Number: it is for multiple users. for single user , use the default. Also use the same number in variables, AFLs and scripts. For multiple users add dashboard AFL multiple times and set this parameter 1,2,3..


Points to Remember

Installation charges as per freelance to install through anydesk. But if you cannot install yourself, don't use this code. Because if there are any changes in broker or python, I cannot help immediately. I instruct only which accounts I am using. For example, now I use Flattrade for data, order placement for Kotak. If there is an issue, I can tell. But for other brokers I may not give solution immediately.  Text support is free. But I can give in my free time only. Telegram call support for tamil only. 

Don't run Amibroker as administrator. It is for data feed users . If you use order placing only, then no problem.

Backfill or live feed data go to the database which is opened in amibroker. So, if other database open, if live feed script running or strat backfill script, it will get filled.

Avoid using Antivirus. Windows defender is enough. If you have separate system for trading, you can stop defender also.



If you have installed both 32 bit and 64 bit take some care. I don't know, it make any issue.

Datafeed send data to the opened amibroker, irrespective of default database . If you opened two databases (two Amibroker instances) take care.

Always keep two brokers for live feed. 

Start your datafeed as much as early as possible. We can start around 8AM also. Also if need place dummy order and check. Password expired, Expiry date changed, API issue etc. can verify.

When Backfilling or live feed there is green bar scrolling or blinking at bottom of Amibroker. For backfilling progress for importing is ok. But for live, it should like as blinking. In live , if it visible slowly, then there will be lag in data feed. In ram disk , live csv file size less than 20kb is good. If it more than 30kb it will slow. Don't use tick datafeed unnecessary.

You can run two feed parallel/simultaneously. Check both have different name for live CSV. Do this for one minute feed only . Not for tick data. Once I compared Flattrade with shoonya, Flattrade with Alice Blue all are same only. So one feed candle replace other. It won't make any issue. Initially I tried few days.

Tick database 

If you use tickdata, for backfilling we get one minute data only. After backfill it come different kind of chart with mixed candle and ticks. So after deleting tick data backfill with one minute is good. Soon I add an option to delete quote.

Curl 

From 2018, all windows/server curl is pre installed. To check curl, open cmd and types as following and enter.

curl --help

It shows the help menu. Otherwise say error. If you use windows 7/8 only you need to install curl. Check my you YouTube video to install curl.

Python 

I am using official python and IDLE only. Current code are tested in 3.13.7 . Currently batch file install tested version libraries. 

If you are already using any older python version, anaconda, VS code or any other Python, you are considering as developer. So you should solve issues by yourself (with help of AI). Particularly for VS code. VS code get python interpretor from Microsoft as add-on. But to use python outside of VScode we need to install python to execute from python. So you take care. 

Initially I started with anaconda and develop through jupyter notebook. But now I use IDLE only. Don't use notebook. To check older notebook , I installed jupyter notebook with official python.

SSL Certificate Error 

This certificate verification can be bypassed. It may be ok for data, but not for the order place. 

First try Windows Update. Also try by disabling Firewall. 

After update also not work, Download Certi Cerificate to SSL.py script and double click to execute or run in IDLE. It copy Certi certificate to SSL.  It require admin. may require disable antivirus. If this script not work, do manually as follows

Copy certificate file cacert.pem from C:\Program Files\Python313\Lib\site-packages\certifi\  and create folder SSL in C:\Program Files\Common Files\SSL And paste it then rename it to cert.pem

If Certificate path cannot find, Download SSL Certi Certificate Path.py script and run in IDLE. It show the path of both certificates.

IDLE

At present login file and Live feed only run from IDLE or double click to excute in cmd. All other files need to excute from amibroker, because we send parameters to script from amibroker.


Sys.argv[]


in some scripts like historical data, master , you can see this sys.argv[1] these are need to execute from amibroker. these variable values are need to send from amibroker. if you execute this directly it give error as index out of range. if you want run directly from IDLE or execute, disable these inputs enable manually. remove the triple quotes for above inputs and disable sys.argv inputs


Backfill


During backfill, if you get this error " 'str' object has no attribute 'get'. No retry." means broker not give data for them, usually they are far OTM and illiquid scrips. Download Historical data in 1 min timeframe. I checked 15 min, It gives wrong candle on split days. 
Live Feed


if you click Start Feed and it come like this, it is ok, tomorrow you are ready for live feed. to stop datafeed, just close the cmd window.

PreMarket Data

if you want Pre Market data, disable these two lines by put # at start of the line. it gives 9:00 and 9:07 tick for stocks. For Nifty and Sensex, 9:00 to 9:07 continuous candle