Introduction
AutoTrader is an automated trading software (API) connecting to many Indian stock trading platforms.
This article explains how AutoTrader works with AmiBroker. Primarily targeted for users of AutoTrader to improve their understanding & make them better prepared to debug any issues that they may face.
Demo Video
The demo is available on YouTube.
Prerequisite
You need to install AutoTrader & AmiBroker software.
Overview
There is a 2-way communication that happens.
- Your commands like (place/cancel order, square off position etc.) flow from AmiBroker to AutoTrader & they are executed on your trading platform by AutoTrader.
- You portfolio details (orders, positions, margin etc.) are read by AutoTrader from your trading platform & sent to AmiBroker.
Architechture
More details of this architecture can be read at Connecting AutoTrader with other softwares
API functions provided by AutoTrader can be found at AutoTrader Functions
How AmiBroker & AutoTrader communicate?
Code Explanation
All functions provided by AutoTrader are included in algotrader-util.afl file. In order to make these functions available to your strategy afl, you must include this afl. Write following line at the top of your afl.
#include <algotrader-util.afl>
Now you can use AutoTrader functions. Let us see an example below:
orderId = placeOrderUsingParams(“NSE”, “SBIN”, “BUY”, “MARKET”, 10, 250.20, defaultTriggerPrice(), 1);
You can see that all placeOrder* functions return an order_id once an order is successfully passed to AutoTrader.
This order_id can then be stored for later use.
atStaticVarSetText(“BUY_ORDER_ID”, orderId);
Later, we can use this id in all functions that accept an order_id. For example, we can retrieve order details or cancel the order.
buyOrderId = atStaticVarGetText(“BUY_ORDER_ID”);
buyOrderStatus = getOrderStatus(buyOrderId);
cancelOrder(buyOrderId);
How does the code work?
The placeOrder* function will simply write order details into a file (C:\autotrader\data\order\orders.csv). A new line with the order details is appended to the file. AutoTrader software keeps a watch on this file, as soon as it is changed; AutoTrader reads it & parses the line. AutoTrader understands that there is a request to place an order. AutoTrader parses order details from the line & then places an order onto the trading terminal.
All functions that require reading of portfolio data work in a reverse way. As seen from the architecture diagram, AutoTrader will write the platform details to respective files. This process is repeated every N seconds (defined by AutoTrader setting SYNC_INTERVAL). For example, getOrderStatus(orderId) function will read the platform_orders.csv file, find the row with given order id & then read its status.
You can also look at Connecting AutoTrader with other softwares to get more insights.
Conclusion
As you can see from the article, all communication takes place via simple csv files. So whenever you are debugging an issue; you can view these files to find a root cause.
nice work…Thanks
November 30, 2018 at 3:33 amThanks
November 30, 2018 at 11:07 amThis gave much needed information to us. thanks
November 30, 2018 at 10:23 amThank you
November 30, 2018 at 11:07 amif I connect to my office network,itsnot able to connect to zerodha.getting below error
December 3, 2018 at 7:01 amFailed to connect to ‘ws.zerodha.com:443’: Connection timed out: connect…is there anyway I can configure proxy
Not much we can do, as there might a firewall in your office blocking certain types of connections.
December 8, 2018 at 2:10 amI want to create my own customize strategy in AmiBroker for auto trading , is it possible ?
February 23, 2019 at 7:25 amplease contact me on my mobile n. 9825023442 or give me your contact number for more details inquiry.
https://stocksdeveloper.in/trading-strategy-development/
February 28, 2019 at 6:06 pm1. Auto trader software work for zerotha as now the day zerotha close the basket order facility.
2. Auto trader put order directly on kite without using nest?
3. Are you providing any strategy?
4. If I used my strategy, you configured my strategy in auto trade.
April 3, 2019 at 6:09 pmUNFORTUNATELY THERE IS NO CONTACT NO MENTION ON THE WEB SITE, I DON’T KNOW HOW AN INTERESTED PARTY WILL BE ABLE TO CONTACT YOU, A WEEK BEFORE I LEFT A MESSAGE THROUGH A MAIL AS WELL NO RESPONSE RECEIVED IN LAST SEVEN DAYS. I DON’T KNOW WHAT IS THE PURPOSE OF MAKING THIS WEB SITE ?
June 21, 2019 at 10:49 amAll queries are taken on help@stocksdeveloper.in mail address. We did not find your mail. Please resend it.
We support 11 systems in total & there is a lot of development work as well. Hence we do not take calls, as people consume too much of our time.
June 25, 2019 at 5:31 amIs it possible to have the feeds into amibroker today?
May 21, 2020 at 11:43 amNot sure we understand your question.
May 24, 2020 at 10:02 amgreat sir u r autotrader is awasome…i
June 17, 2020 at 11:29 amlike it..
Thank you…
June 17, 2020 at 12:06 pmVERY NICE, autotrader & autotrader web bt plz provide call support if possible in future…
June 17, 2020 at 11:32 amSupport is done by developers & providing on-call costs a lot. But we will come up with some solution to this…
June 17, 2020 at 12:07 pmhi!
June 19, 2020 at 2:59 pmIm retail trader I want your assitance regarding amibroker setup , real time data feed, ur auto trader web, and some of my stratergies coded. is it possible to heip me out .
regards kumar hosamani
Sir,
It is not possible to provide personal consultation. You are advised to go through all the help material available on our website and youtube. In case you face any issue, always write a mail to support.
June 20, 2020 at 8:16 amDose it works for iran’s stock
September 27, 2020 at 11:53 pmWhat is iran’s stock?
September 29, 2020 at 7:18 pm