User Tools

Site Tools


haolin_ren:projectfinal

Analyse the performance of the trading bot ADM8


README:

Tulip file of this project, Tulip file of the project . You can download directly.

All the related codes, pictures about this project are in this site: related codes

If the following pictures can't display normally, please refresh the page.


1. Introduction

Algorithmic trading involves entering trading orders through electronic trading platforms using an algorithm which helps in taking into account order’s characteristic like timing, price, and the volume of the order. On august 31st, 2011, RYBN has launched the Trading Bot ADM8 on the financial markets.The motivation of this project is using data visualization to study the performance of this robot.By analysing the performance of this bot, to see wether this algorithmic trading Bot was profitable, and to find wether there exist some problems of Bot that could be improved. We would provide some evidence to support the prediction on the Bot(we call this trading bot as Bot in the following part) going bankrupt. The data visualisation results were generated by tulip software.

Prepare Data

  • Step1. Acquired the data from its monitoring page http://rybn.dyndns.org/ANTI/ADM8/ , from the site we got its historical operating records, the records shows when the Bot bought or sold the stock, and the price, the quantity, the currency of that stock. We organised the data into a CSV file as the following format, we used the data from 08/31/2011 to 11/07/2014.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_figure1dataformat.jpg

  • Step2. Because of Bot have using different currency to buy stocks from different Exchange, we exchanged euro and HKD into US dollars, in order to improve accuracy, we wrote a script for searching the exchange rate historical data, and translate the search result into a python dictionary variable.related code.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_qq20150121-1_2x.jpg

  • Step3. Unordered List Item In order to find out which markets did Bot buy and sell stocks, we also wrote a script for searching some properties of each stock, the results were also translated into a python file in order to analyse the data. After doing that, we got each stock’s trading locations and the industry which it belongs to.related code.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_qq20150121-2_2x.jpg

3. Data Visualisation

  1. Section 3.1 gives some graph to show that this Bot is a high frequency trading robot
  2. Section 3.2 gives an analysis of Bot’s performance based on markets
  3. Section 3.3 shows the Bot fixed settings of trading hours
  4. Section 3.4 shows the Bot’s ability of making money
  5. Section 3.5 give the answer of the prediction on the Bot going bankrupt
  6. Section 3.6 shows the property of stocks which Bot bought.

3.1 Trading frequency analysis

3.1.1 Stock holding time

After importing the data into tulip, we got the result like figure4 shows, each nodes in the right windows represents one transaction. The 1563 nodes stands for 1563 times historical transactions by the Bot, each node includes the information of one stock, such as the name of stock and when it was bought or sold and the value of cost or earn, etc. We sorted the nodes according to the time, in order to distinguish different types of transactions, buying stocks were arranged in the left side, selling stocks were arranged in the right side. As figure 5 shows, The height of the nodes based on the date of his operation, The arrows indicate the direction of time growth. If the buying node is the same stock as the selling node, we added an edge between two nodes.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-1_2x.jpg

From figure5, we can make two conclusion, first conclusion is that each time Bot bought about five different stocks. Secondly, every time Bot oversold all the shares he own before it bought shares, that means this Bot didn’t do long-term holdings.

The figure6 represents the interval of one complete transaction(after the Bot selling the stock it had bought, we define this as one complete transaction), in the graph each small circle stands for one complete transaction, the label on it is the days interval between buying and selling of a same stock. From Bot operating records, 93.3% transactions were finished within two days, it should be added that, if the stock had been bought on Friday then been sold next Monday, we counted this 1 day, we didn’t count the other holidays, so the ratio of 1 day transaction was more than 93.3%.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-2_2x.jpg

In addition, we noticed that, there were two stocks which had been bought and sold in the same day, as figure7 shows. We verified these two transactions, we found that those special cases were caused by the sharp dropping of the stock’s value.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-3_2x.jpgraw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-4_2x.jpg

We can conclude that the Bot is a high-frequency trading algorithm Bot. Its algorithm designed to buy stocks every day, and then sell the next day. But in some special situation, it strategy would be modified by the operator.

3.1.2 Bot's activities

The figure9 shows the activities of Bot, one cube stands for one day, if the color of cube is yellow, that means Bot didn’t make any transaction that day, if the cube is red or green, it means Bot had did at least one transaction that day, from the didn’t figure out how many stocks were bought or sold in a day, the aim of this figure is just to figure out which days did Bot not trade and why. The conclusion from this graph is that in 2011 and 2013 Bot was running almost every weekday, at the beginning of 2012, Bot slowed down the trading frequency, after the middle of 2014, the trading frequency decreased sharply. After introducing the different exchange markets, we would give some possible reasons for this frequency decline. raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-5_2x.jpg

3.2 Stock Exchanges

From the historical records, the Bot was trading with three currencies: USD, EUR, HKD. In past 1563 transactions, trading in euro and HKD were both 220 times, and the rest 1123 transactions were operated in USD. We also find the Stock Exchange for each stock bought, there were: NewYork(NYSE), NASDAQGS, HongKong, ENParis, Xetra and ENAmsterdam, first two are American Stock Exchange, last three are in Europe. The figure10 shows the percentage of the amount of stocks bought from different Stock Exchange over the total number of operations. From figure10, we can find that Bot preferred to trade stocks in the United States. We would discuss the reasons latter. Considering the difference between Stock Exchange, we compared the trading frequency in different locations. Figure11 shows the trading frequency difference of American markets, European markets and HongKong markets.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-6_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-7_2x.jpg

From figure11, we can conclude that if excluding the influence of the european debt crisis on European markets, the trading frequency in HongKong markets and European markets were almost the same. The Bot focused on American stocks.

3.3 Operating hour analysis

From Bot’s page, we can get information about buying or selling hour, in this section we would analyse its operating hour setting. Figure12 shows the operating time, X-axis represents the date, Y-axis represents the time of day, a circle represents a selling stock, a cube represents a buying stock, We can directly see from the picture, the operating time is a regular. In addition, all the following is (UTC/GMT +1) Central European Time Zone.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-8_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-9_2x.jpg

After adding edges between the same buying and selling stocks as Figure13 shows, the operating time strategy is very clear. Considering the time difference in different locations, we shows this graph depend different locations.

3.3.1 American Exchange

From figure14, we find that in American Stock Exchange, Bot sold the stocks in 15:00 - 16:00(New York time), bought in 10:00 - 11:00.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-10_2x.jpg

3.3.2 European Exchange

From figure15, in European Stock Exchange, Bot sold the stock in 16:00 - 17:00, and bought in 09:00 - 10:00.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-11_2x.jpg

3.3.3 HongKong Exchange

From figure15, in HongKong Stock Exchange, Bot sold the stock in 15:00 - 16:00, and bought in 10:00 - 11:00.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-12_2x.jpg

We can conclude that, Bot bought the stock at the opening of the Stock Exchange each day, then sold at the close of Exchange next day.

3.4 Profits analysis

Figure17 shows the profits of all the complete transaction, Bot made profits 390 times, lost 391 times, it lost 1849dollars. its forecast accuracy was 49.93%. In American Exchange, it make profits 292 times, lost 269 times, market’s profits was 516 dollars, forecast accuracy was 52.04%; in European Exchange, it made profits 58 times, lost 52 times, market’s profits was -295dollars, forecast accuracy was 52.72%; in HongKong Exchange, it made profits 40 times, lost 70 times, market’s profits was -2071 dollars forecast accuracy was 36.36%.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-13_2x.jpg

We can conclude that Bot’s performance is much better in American Exchange, in fact those four years it was losing money. Figure18 shows the change of amount of it’s money.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-14_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-15_2x.jpg

Figure19 shows the profits of each transactions, we can find that most of its profits is less than 40 $.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-16_2x.jpg

Figure20 shows percentage of the amount of cost for buying stock over all the cash it owned, this diagram wants to analyse each time if the Bot cost all its money for buying, the average percentage is 27%, it means Bot only spent part of it’s money to buy stocks every day.

3.5 Prediction of bankrupt

At the head of it’s page, it gives an prediction of going bankrupt, in this section we will give how it’s computed. raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-17_2x.jpg

From 08/13/2011 until now, it running for 1234 days, in those days it lost -433 euros, and there are 22013 days before it bankrupt. But as we just showed, it lost 1849 dollars. for past 4 years, -433 euros do not equal to 1849 dollars. was I wrong? In fact both of me and the Bot are right. It calculate income in euros. raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-27_2x.jpg raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-28_2x.jpg

But is this calculation method correct? My answer is no. First is that most of its transaction were operating in American Exchange using dollars; secondly, 90% of its property are not euros. Using euro for summary cause illusion.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-18_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-19_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-29_2x.jpg

8148 days is much less than 22116 days, so the prediction given by Bot is not correct. But according to its recent performance, I think Bot already changed it’s initial strategy for running, we will discuss this in next section.

3.6 Different sectors of stock

Although Bot have bought 781 times of stock, it bought 178 different stocks in past 4 years. Figure 24 gives the layout of those 178 different stocks. The Figure using my shell algorithm layout.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-20_2x.jpg

There are 15 different stocks are bought more then 10 times. 90% of those stock are in American Exchange.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-21_2x.jpg

Figure25 shows the stock ‘Bristol-Myers’ operating records. The motivation of showing this diagram is to analyse the buying strategy of Bot, but after knowing Bot’s algorithm, we found that this direction is useless. Because Bot make decision depend on continuous data, but figure25 shows record discrete distributions. Figure26 shows the strategy of Bot which was found from Internet.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-22_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-23_2x.jpg

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-24_2x.jpg

Bot operated 165 times in sector ConsumerDiscretionary, for 10.55 %. Bot operated 116 times in sector Industrials, for 7.421 %. Bot operated 174 times in sector Energy, for 11.13 %. Bot operated 84 times in sector Utilities, for 5.374 %. Bot operated 92 times in sector Communications, for 5.886 %. Bot operated 126 times in sector Materials, for 8.061 %. Bot operated 186 times in sector HealthCare, for 11.90 %. Bot operated 220 times in sector ConsumerStaples, for 14.07 %. Bot operated 136 times in sector Technology, for 8.701 %. Bot operated 264 times in sector Financials, for 16.89 %.

4. Data Analysis

After 4 years operation, Bot lost 1849 dollars, we can’t say that’s a good performance. But it’s lost did not due to continuous predictive failure. If ignore it’s worst transaction, it could realise profits. We find its profits came from small income, its lost were caused by less then 5 failure prediction. If I design Bot’s algorithm, I would add a tracking system, if the stock falls below a certain percentage, then immediately sell out, also, my vector of buying would concern the whole perform in the same sector during past short days.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-25_2x.jpg

In addition, through observation, we find that the robot's recent performance has been significantly changed since 2014. From figure30, we know that the first change is Bot increase the cost of each stocks, The average cost of year 2011 is 938. The average cost of year 2012 is 509. The average cost of year 2013 is 345. The average cost of year 2014 is 1568. second change is that it slow the transaction frequency from April 2014, Bot stopped buying stock from HongKong and Europe. The performance since April 2014 is much better than before, As figure32 shows, it earned 420 $ in 2014 until November.

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-30_2x.jpg

5. Codes

5.1 UML of project

The UML about this project as following:

raw.githubusercontent.com_haolinren_bio_visu_final_project_master_pictureresult_from_20report_qq20150122-31_2x.jpg

/net/html/perso/melancon/Visual_Analytics_Course/data/pages/haolin_ren/projectfinal.txt · Last modified: 2015/01/23 11:28 by ren