1189
How I earned $ 500K on machine learning and high-frequency trading - Part 2
From the interpreter: Continue translating articles ( part 1 ), captured my attention and strangers on habrazhitelyam soul, about a guy who, using their technological skills, was able to earn over half a million dollars a year. i>
90,178,461
Creating a full-fledged trading simulator h4>
When the command is sent to the market in the simulator I have to simulate the time lag. The fact that my system "saw" the proposal does not mean that she can buy it immediately. The system will send a command, wait for about 20 milliseconds and only if the offer is still valid, it will be regarded as the closing of the transaction. This is not entirely accurate, since the duration of the actual lag is not always the same and is not registered. When I place an offer to buy or sell shares, I need to take into account the flow of execution of transactions (which provides API) and use it to track when my order will be executed. To do this properly, I need to keep track of the position of my team in the queue (generated by the system first-in first-out). And again, I could not do it exactly, but modeled as close to reality system.
Ensuring profitable trades h4>
The prediction of the behavior of prices (which we discussed earlier) Treated price level (internal levels means a more likely price jump) The number of contracts to my order in the queue (the the smaller the better) Number of contracts after my order in the queue (the higher the better)
All variables used in this step to be optimized. It was done in the same way that I optimized variables indicators of price changes, except that in this case I optimized variables at the lower boundary of the profit and loss.
What ignored my program h4>
The price on the entry position - In the office of the trading companies often talk about the price at which someone enters into long and short transaction as if it should affect such decisions in the future. Despite the fact that such data are of some importance in the strategy to reduce the risks they bear no relation to the further development of market developments. So my program is completely ignored this information. It's like that ignore sunk costs. Conclusion long / short trade - As a rule, a trader, a person would have a special criteria to determine where to sell a long position, and where - to enter a short trade. However, from the viewpoint of my algorithm, there was no difference between these two concepts. If my algorithm expecting a fall in prices, the sale was a logical step, regardless of which character was the deal: "Long", "short" or "flat». The strategy of "doubling" - This is a common strategy according to which traders buy more shares in the event that the auction was originally not go in their favor. As a result, your average purchase price is reduced, and this means that when (if) the stock price change course, you "discourage" their costs in no time. I think it's just a horrible strategy, unless you are Warren Buffett. You deceive yourself into thinking that you are all well, because most of your transactions will burn. The problem is that if you're not lucky, the loss will be stunning. Another consequence of this approach is that it becomes extremely difficult to determine whether or not you got a market advantage, or you just got lucky. An important quality of my program was just what I was able to track and confirm the situation where my program really had such an advantage. Risk Management h4>
Using the algorithm h4>
90,178,461
Creating a full-fledged trading simulator h4>
So, I had a framework that allowed me to test and optimize indicators. But I had to do something more - I needed a framework that would allow me to test and optimize the entire Trader trading system entirely; one in which I could send commands and open positions. In that case I would be able to optimize the overall gains and losses, and - to some extent - the average gains and losses in one trading session.
To create such a framework would be difficult - in some sense even impossible to simulate exactly, but I did everything I could. And here are some questions that I had to face:
When the command is sent to the market in the simulator I have to simulate the time lag. The fact that my system "saw" the proposal does not mean that she can buy it immediately. The system will send a command, wait for about 20 milliseconds and only if the offer is still valid, it will be regarded as the closing of the transaction. This is not entirely accurate, since the duration of the actual lag is not always the same and is not registered. When I place an offer to buy or sell shares, I need to take into account the flow of execution of transactions (which provides API) and use it to track when my order will be executed. To do this properly, I need to keep track of the position of my team in the queue (generated by the system first-in first-out). And again, I could not do it exactly, but modeled as close to reality system.
Ensuring profitable trades h4>
With the simulation model placement of orders, I was able to send commands to the exchange in simulation mode and track contingent gains and losses. But as my system will understand where and when to buy and sell?
Predicting the behavior of prices was the starting point for the system, but the story is not over. Next, I developed a scoring system for each of the 5 levels of prices for buying and selling. Among such input level one level higher internal demand price (for buy orders) and one level below the inside bid price (for sell orders).
If the account at any price level is above a predetermined threshold value, it means that at this level in my system should be actively offer buy / sell. If the score is below the threshold, then any active orders should be abolished. These conditions are often would be a situation where my system would suddenly exhibited on the market offer to purchase, then immediately remove him (actually I was trying to minimize the likelihood of such events, as any living person to a similar situation on the screen would have seemed terribly annoying).
The accounts for the different price levels were calculated based on the following factors:
The prediction of the behavior of prices (which we discussed earlier) Treated price level (internal levels means a more likely price jump) The number of contracts to my order in the queue (the the smaller the better) Number of contracts after my order in the queue (the higher the better)
All variables used in this step to be optimized. It was done in the same way that I optimized variables indicators of price changes, except that in this case I optimized variables at the lower boundary of the profit and loss.
What ignored my program h4>
When trade leads people to it often significantly influence the emotions and prejudices that can lead to a sub-optimal solutions. Of course, I did not want to have these prejudices had any reflection in my code. So my system ignore some factors:
The price on the entry position - In the office of the trading companies often talk about the price at which someone enters into long and short transaction as if it should affect such decisions in the future. Despite the fact that such data are of some importance in the strategy to reduce the risks they bear no relation to the further development of market developments. So my program is completely ignored this information. It's like that ignore sunk costs. Conclusion long / short trade - As a rule, a trader, a person would have a special criteria to determine where to sell a long position, and where - to enter a short trade. However, from the viewpoint of my algorithm, there was no difference between these two concepts. If my algorithm expecting a fall in prices, the sale was a logical step, regardless of which character was the deal: "Long", "short" or "flat». The strategy of "doubling" - This is a common strategy according to which traders buy more shares in the event that the auction was originally not go in their favor. As a result, your average purchase price is reduced, and this means that when (if) the stock price change course, you "discourage" their costs in no time. I think it's just a horrible strategy, unless you are Warren Buffett. You deceive yourself into thinking that you are all well, because most of your transactions will burn. The problem is that if you're not lucky, the loss will be stunning. Another consequence of this approach is that it becomes extremely difficult to determine whether or not you got a market advantage, or you just got lucky. An important quality of my program was just what I was able to track and confirm the situation where my program really had such an advantage. Risk Management h4>
Since my algorithm made decisions equally, regardless of what stage of development of events, he made a deal and whether the position is currently long or short, it really opened temporarily disadvantageous position and concludes unsuccessful transactions for large amounts of money (although there were good deals at least large amount). However, do not believe that I did nothing to risk management.
I rigidly set the maximum size of the position at 2 contracts per unit of time as during active trading maximum gap size could occasionally increase. I also was put a limit on the maximum amount of losses for the day to guard against any unexpected changes in the market, as well as bugs in their own program. These limits have been prescribed in the code, but I additionally made secure by giving instructions to your broker. By taking these precautions, I subsequently did not experience any significant problems.
Using the algorithm h4>
Since the start of work on my program, it took six months before I brought it to the point where it has become to make a profit, and I was able to test it in the case. Although, to be honest, most of that time I was studying programming language. As I worked to improve the program, I recorded the incremental profit in each of the next four months.
Every week I would have to re-educate my program on the basis of data collected during the previous 4 weeks. However, I found that it upsets the balance between finding the latest behavioral market trends and the certainty that my algorithm receives enough information to develop meaningful patterns of behavior. When learning has become more and take more time, I broke it so that it could be implemented 8 virtual machines using a service Amazon EC2. Then the obtained results are combined on my local machine.
The highest point of my trading was October 2009 when I earned almost $ 100 000. Subsequently, I spent another 4 months, trying to improve my program despite the fact that profits each month decreased. Unfortunately, to date, I think I tried all their best ideas, because everything that I used is not particularly helped me.
Facing the frustration of failure to improve the program and the lack of sense of growth, I started thinking about a new direction. I wrote a letter of 6 different trading company specializing in high-bid, and asked whether they would not want to buy my program and hire me to work for him. No one answered. Then I began to have ideas for new start-ups, on which I would like to work, so I finally gave up this business.
Note
Top of page [ in the original post i> - approx. interpreter] is a comment in which there are such expressions as "the manipulation of statistics", and I called one of the "investor-retailers" about whom these quanta [ quanta / Quant - in Russian translation practices used both versions of the translation i> - approx. translator] say that their "need to shoot." This is a very unfortunate comment, just far from reality. Meanwhile, there are more interesting reviews to my article.
Note 2 список answers to frequently asked questions that I have received from traders, read this article.
Source: habrahabr.ru/company/itinvest/blog/211642/
As I earned $ 500K in machine learning and high-frequency trading - Part 1
Kremlin does not need Ukraine and Kazakhstan - Russia intends to conquer the Moon and Mars (not fake!)