Inspiration
Taking part in the Optiver Challenge at HackTheBurgh has been a great opportunity! While we have had little to no experience with algortithmic trading before, we managed to expirment with many different algorithms over the time period, before settling on what we thought was a winning strategy.
What it does
The algorithm starts off by producing the half-life of the historical data produced by the previous trades. This informs us of how long the instrument will take to revert to it's mean. We then use this to calculate a rolling average and standard deviation of the negation of the basket and the two instruments. This should be close to 0, and therefore is close to a normal distribution.
We then find the Z Scores for the buy and sell prices, and compare this to the current offerings on the market. We increase the amount we want to buy and sell on each stock based on the Z score. Doing this, we make sure our position is close to 0, and hedge our bets in order to profit from any movement in the market. To further protect from holding high positions, we increase our buy/sell price dynamically based on the number of each instrument already owned. This means that we will always revolve close to 0, making our program less vulnerable to risk
Finally, our algorithm serves as a market maker for the TECH_BASKET instrument, by providing liquidity. Finding the mean and variance based on the rolling mean and variance, we then calculate a narrow bid/ask spread that we aim to constantly provide on the market.
How we built it
We made several different iterations using our cloud-9 account, making several different trading strategies. Most of them were in the form of a simple python file made up of several helper functions to assist with the process. Later, we looked at developing this further by producing several new iterations, working together to combine our ideas and make the most profitable trading bot possible!
Challenges we ran into
We initially had trouble wondering where to start. The basis of a trading algorithm is simple: buy low and sell high. Unfortunately, it wasn't as simple as that! We needed to make sure our risk was as low as possible, so we initially just tried to hedge our bets using an arbitrage on the basket and values. However, in testing we found it was not particularly profitable. We decided therefore to de-link the buying and selling of the two, which while could lead to a more vulnerable position under certain circumstances, made us able to trade more frequently and at tighter margins. Predicting the buy/sell prices for the TECH_BASKET instrument was also very difficult. Being an instrument with low liquidity, we wanted to make a predictor completely based on previous trades, and not on the current trades available, and do this with as narrow a spread as possible. In the end, it took a lot of trial and error, but we finally made this work: about half an hour before the official trading started!
Accomplishments that we're proud of
We are really proud of the volume and velocity of transactions we are able to make around TECH_BASKET, while the profit margins are small, we are one of the most frequent traders for this instrument, providing liquidity in the market.
What we learned
We learned several crucial ideas about pairs trading and market making, and in the end, we are very proud of our final result! As well as the basics of how to make money from cointegrated instruments, and a illiquid market, we also learned how to effectively manage our time in a group of three, alowing us plenty of time to experiment, while still leaving time to polish and submit a finished project!
The code is available on our Cloud-9 account, provided to us by Optiver.
Built With
- cloud-9
- optibook
- python

Log in or sign up for Devpost to join the conversation.