Navigation

Agrobot-ATS


Agrobot-ATS is an Automated Trading Systems that automatically submits trades to an exchange. The current Agrobot-ATS version trades on the Folhainvest.

The Folhainvest is a web investment simulator created by an association of  the BM&FBOVESPA(Brazilian Stock Exchange) and the FOLHA(Brazilian conglomerate of publishing companies). At the end of 2009, there were more than 0.5 million participants in the Folhainvest. Despite the hypothetical financial transaction, all stock quotes and trading follow the dynamics of the BM&FBOVESPA with some minutes of delay.

The picture bellow shows the Agrobot-ATS information flow architecture. As we can see, the system interact with two others external systems. The first one(t_{a}) is the Folhainvest where the trades happen and the second one (t_{b}) is an Home Broker where the Agrobot-ATS can load "almost" real-time stock quotes.


The Agrobot-ATS buy and sell stock on the Folhainvest, and also collects book and order status and stock quotes which are delayed more than 15 minutes from the real world (lets call this delay t_{a}). Additionally, the system loads stock quotes from an Home Broker with a short delay(lets call this delay t_{b}), normally less than 1 minute. So, t_{a} \geq 15 min and t_{b} \leq 1 min \Rightarrow  \Delta t\geq 14min, which means that Agrobot-ATS can operates in Folhainvest with more than 14 minutes of advantage. Knowing 14 minutes ahead, Agrobot-ATS analysis stocks prices movements and detects which one increase and how much is this grow. Detecting such good opportunities automatically, brings to the system a competitive advantage.

To determ which stock will trade, the Agrobot-ATS must considered trade costs to find out the positive stock change threashold value. Considering brokage and custody fees, the equation that relates total profits (A_{profit}), positive stock price change (I_{profit}) and total amount used in each operation (V_{buy} = Amount \times Stock Price ) is:

A_{profit}=\left[  0,99475\times I_{profit} - 1,00525 \right]\times V_{buy} - $50,42

Lets assume A_{profit} = $10 which means that Agrobot-ATS will seek 10BRL profits in each back to back (buy and then sell) operation. The following graph shows the relationship between the positive price change and total amount used in each operation considerating the assumed fixed total profit:


For example, VALE5 (VALE R DOCE PN) share price in  t_{a} is equal $50,00 and in t_{b} is equal $50,59, which means that VALE5 has a price change equals +1,18% within 14 minutes. The Agrobot-ATS must buy (in  t_{a}) 1000 shares, so the total amount used in this operation is $50K. After buy those shares, the system must sell all shares for $50,59 per share. This buy and sell operations generates $10 profits.

During the development tests, the Agrobot-ATS was able to detect many shares with price change more than 1% within 14 minutes and in that case, it executed trades.

The following picture shows a stock quote watchlist from a Home Broker and the Agrobot Importer System (data collector) working together. Basically, the user access the Home Broker, then navigates until stock watchlist page and finally click on a specific bookmark entry (which appends a JavaScript code in the page). Henceforth, all stock quote are collected and sent to Agrobot-ATS by HTTP protocol.



The user can monitor all transaction including all stock quote and his statement by Agrobot Monitor System(following picture). It is a web based system that shows a watchlist, the book, the order status and the statement. 



The Agrobot-ATS is an open source project and all source code can be found here. Next steps of this project are: [1] design a robust architeture; [2] add event processing capabilities (Drools Fusion); [3] use Google Web Toolkit as GUI; [4] use FIX protocol; [5] use unstructured data; [4] R&D trade strategies; ...

This Automated Trading System illustrated how data latency is important in stock trading. Actually, a 1-millisecond advantage in trading applications can be worth $100 million

The Agrobot-ATS is not working full-time, that is why the Agrobot Simulator (system's participant name in the Folhainvest) is not among the firsts in the overall classification. By the way, Is fair the Agrobot-ATS compete in the Folhainvest game? Please, leave your comments ... Thanks!