Inspiration
As many countries decide to list their securities on multiple exchanges, whether due to voting rights, currency considerations, or accessibility and expansion to the local markets, dual-listed stocks create many arbitrage opportunities for traders to exploit. Striking the Optibook economy as an ambitious market maker, we decided to develop a trading bot that utilizes both the active arbitraging strategy and passive market-making approach to take zero-risk trades and provide liquidity to the market.
Development Journey
The trading bot essentially performs two strategies in parallel, always checking for two trading signals: zero-risk arbitrage opportunities between exchanges A and B, and market-making opportunities based on the default spread given by the Optiver algorithm and other market-makers.
For the arbitrage strategy, the trading bot checks the highest bid and lowest ask of both exchanges, and when one of the asks is lower than the other's highest bid, we make a bid and ask market order in the two exchanges, taking the zero-risk profit. However, we soon realized that the market became saturated as other players started implementing the same strategy, engendering frequent order failures and general uncertainty in making an IOC order in both exchanges.
As we looked for alternative solutions, we noticed that the order book was only filled by Optiver bids and asks, meaning they were dominating the market with an unfairly large spread! This was why we started developing the market-making strategy to provide tighter spreads and higher liquidity to the market.
We have two market-making strategies: an arbitrage one across two exchanges and an intra-exchange market-making based on valuation methods.
To make a market across exchanges, our trading bot sets a limit order bid/ask in exchange B, the less liquid exchange, based on the price and spread of exchange A, assuming that B will eventually converge to A due to A's higher liquidity. When the order in exchange B gets filled, we immediately make the counter IOC order in exchange A, taking the profit from the spread, which we keep very tight to obtain a consistent edge over other market-makers. We believe this involves very low risk because we only make the market when the illiquid market order has been filed, making it a great risk-managing strategy in a trending market.
To make a market within each exchange, we follow the real value of the underlying stock Philip, arguing that when there is a large difference between the weighted average price of the two exchanges, we should observe a convergent behavior from both exchanges (leaning towards A due to higher liquidity), making a tight market around that convergent price. We further sharpened this valuation method because it does not work well when the market is trending, so we used two moving averages to track the general trend to better pinpoint the convergent price, tweaking the weight factor to optimize the valuation accuracy.
Currently, the two configurations above can be manually switched depending on the market structure (i.e. market-making across exchanges in a trending market, and market-making within a single exchange in a mean reversive market with a random walk). However, we aim to develop indicators to analyze the market structure using the Gaussian process model or an LTSM, automatically determining the configuration to be used.
Finally, we employed multiple risk-managing mechanisms to avoid the bot trading over the limit or when encountered a significant exchange or system error. When making markets across exchanges, we consistently remove inactive limit orders outstanding in B, assuming the market moved away from that order. In the case when we find a severe exchange or system error such as a server shutting down, we utilized the hack out method to avoid any unmonitored action. Currently, we are looking to set up a stop mechanism if we encounter any unexpected loss that could drive us to bankruptcy, which would not be so pleasant.
Challenges
The main challenge was the saturation of the market. With dual-listing arbitrage, the most obvious strategy is to wait for a clear discrepancy between the two exchanges and take the zero-risk arbitrage profit. However as mentioned above, this strategy soon became saturated, so there were times when our market orders would not go through. This was why we devoted most of our time to developing market-making strategies.
Another main challenge was the lack of backtesting abilities. Although we believe the cross-exchange market-making strategy is strong for a trending market over the timespan of the hackathon, we did not have a chance to test this with historical data, meaning we cannot be fully confident with the strategies in the long run, thus unable to tweak various parameters such as the volume of each limit order, weighting factors of the spread, and the moving average time spans. With more data available, we can optimize these parameters and update them automatically based on the current maket situation.
Accomplishments
We are extremely proud of the fact that we have been one of the few market-makers that consistently provided liquidity to both exchanges, facilitating both exchanges with tighter spreads. While other groups saw occasional spikes in their pnl when the market situation faced an abrupt shift, our strategy kept us strong no matter what the market situation is, making consistent returns. We believe this was possible due to our combinations of two market-making configurations, and we kept our risks low to prioritize providing liquidity to the exchanges.
What we learned
Before participating in this challenge, we had a misconception that delta neutral strategies like market-making cannot be as effective as the conventional one sided investments. Throughout this challenge, we learned that market-making is an essential role in any market to provide liquidity and facilitate trading for any financial players. We believe our consistent returns reflect the power of market-making strategies, and we hope to look further in sharpening and optimizing our strategies.
What's next for Trading
In this project, due to the lack of backtesting facility, it is very difficult to come up with radical ideas in a safe manner, as this can easily generate huge losses. With a backtesting system which is capable of testing the long term PNL of a certain strategy and simulating other market-makers working against us, we can leverage optimisation methods or technology such as Neural Evolution of Augmenting Topologies (NEAT) to find the best bot given our architecture, by running generational trials in backtesting. This allows the best set of parameters to be found, such as the volume of the trade to place, the frequency, the rate at which the old open trades should be deleted and the threshold for switching between different model configurations.
Built With
- amazon-web-services
- jupyter-notebook
- python
- quant
- trading
Log in or sign up for Devpost to join the conversation.