Friday, May 23, 2025

Amibroker Datafeed - Flattrade


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

Amibroker API Integration read this post and follow the instructions.

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.


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.

Flattrade Dashaboard


Apply Flattrade Dasboard.afl on chart. You can apply on background sheet also like Sheet 2, Sheet 8 etc.

Usernum given as in parameter. it is for multiple users. for single user , use the default. Also the same number used in variables and scripts.

Check Parameter C:\API\ Driver letter and Folder Name are same as yours. 

Login Button, It 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 is to start feed. to stop feed just close the CMD window. 
Backfill to backfill as per given number of days. 0 is for current day. 1 is for yesterday and today. If yesterday is holiday, it download today only. Files are download to RAM disk , so use this for few days data only. For longer period use Historical Data button.   
Historical Data download data by given From to date. It have option to Import and Delete. It download data in Historical Folder. If Import is Yes. Then it Import. If Delete is Yes, then it delete after import.
EOD Data is download data in daily timeframe. Use this data in separate database.
Login not work in morning between 5 to 7. Today login/token work upto tomorrow 5AM. If login in one pc, you can use the login response file in any PC and use, but don't use websocket in multiple PCs.

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


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