FlatTrade Account
If you want to open account with Flattrade kinndly use this link https://openaccount.flattrade.in/O_FT038256
Donate
If you like my codes, consider for a donation. UPI details given in right side tab and in my telegram channel
Instructions
Points to Remember for Data Feed read this post.
Live Updates/instructions will be given in the telegram channel EasySimpleTradeUpdates
Join falttrade official telegram group @FlattradeAPISupport to get offical support
FlatTrade API
Get API from from Flattrade . Watch this video . Only for API . For Login and Orders new AFL available.
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. 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 . 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
Here PyJWT Selenium webdriver-manager seleniumbase are not required for Flattrade but required for other brokers.
Step 4: Create Folders and Download Files
Download 4 Flattrade Ami32.bat for Amibroker 32 bit and Windows 64bit or Download 4 Flattrade Ami64.bat for Amibroker 32 bit and Windows 64bit . Double click to execute .
It creates required folders, download files and put in respective folder.
Alternatively (Without Batch Script) Create a Folder in C Drive as 'API' and 'HistoricalData'. Then keep drive letter as 'R'. In codes , these are default path to be used. if you want different paths change them in codes. Put all .csv files .py scripts in API folder. Ram Disk R is for to save response file. HistoricalData folder is for long period data download. All codes download here. Download Flattrade Login 1.py and Flattrade Limits 1.py and Put these two scripts in API folder (C:\API) . Download Flattrade Dasboard.afl and put in custom folder. Download format file OneMinuteFeed.format . Put the files in Format folder in Amibroker installation folder. For 32bit it is C:\Program Files (x86)\AmiBroker\Formats. OneMinuteFeed is for live feed. Download FlatTrade OneMinuteFeed.py and FlatTrade Backfill.py and put in C:\API folder . Open import.types file in the format folder by notepad add the following line.
OneMinuteFeed (*.*)|*.*|OneMinuteFeed.format
and save it. it is for manual importing data files from Amibroker Import ASCII.
Step 5: Database
Download 5 Database.bat for Amibroker 32 bit and Windows 64bit or Download 5 Database Ami64.bat for Amibroker 32 bit and Windows 64bit.
Alternatively Create new database with base time interval 1 minute. Keep it default database. Download Dummysymbol.csv and import using OneMinuteFeed.format .
Login Script
From C:\API folder, open Flattrade Login 1.py file in IDE or in notepad.
Change your credentials with in the quotes. Change User ID, Password, TOTP Key, API Ket and API Secret . In the login_file drive letter R is the RAM disk drive letter. check this you are also using the same. It can run by from IDLE run module or double click to Execute. In Limits file no need to change anything. Limits file can run from Amibroker only.
Apply Flattrade Dasboard.afl on chart. You can apply on background sheet also like Sheet 2, Sheet 8 etc.
Check Parameter C:\API\ Driver letter and Folder Name are same as yours.
Scrip Master
For Backfill and Live we need to create ScripMaster.csv , which have a symbol list with exchange, symbol , token. For stocks equity/futures, we need to create NSEEquityList.csv which have symbol name. Sample is given in API folder. For Index and MCX, input can give in parameter of scrip master afl. Then click respective button. It create a csv file ***Master.csv. Then do this for all required symbols. Then click join files. 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. This exchange token is same for all broker. I think Fyers and zerodha have different .
The next version Scrip Master have more features. It is under development. It import expiry data, exchange, lot size, strike difference etc to Amibroker. It is useful for all options users even you not use my datafeed or order place. Currently in options order afl, manually we give them. With this new scrip master, no need for that.
To use stock options, you need to add points between strike in "Point Value" . Upcoming scrip master do this. Before that you need DM me. Then create a watchlist which symbols you want to add options symbols. Then apply ExportStrike afl. ( Batch script download this afl also, if not download from GitHub) Apply on analysis. Select the watchlist. Set number of strikes in parameter. I think 0 give only atm. First click explore. Check all columns ok. Then click scan. It create Options list.csv in API folder. Now ScripMaster afl, click stock options. Then click join files.
Now you can backfill , Historical Data and Live Feed.
Backfill or live feed data go to opened database. So, if other data feed open, if live feed script running or strat backfill script, it will get filled.
Backfill
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.
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