A Technical Deep Dive Into the Jane Street ETC
Coauthored with Caroline Okun

This past weekend, our team participated in Jane Street’s Electronic Trading Competition, a day-long programming contest where teams compete against each other in a simulated market. Contestants wrote algorithms to trade various financial instruments such as bonds, stocks, ETFs, and ADRs, with the intention of maximizing profit. The competition was structured into five minute rounds, each simulating one day in the market. During the first competition, teams traded and built up their portfolio for ten hours. In the last hour, portfolios were reset, allowing teams to compete in a second competition with the best version of their bots. In this latter competition, we developed algorithms that placed us 2nd out of 44 teams.
At the start of the day, our first order of business was getting our development and competition environment set up on our machines. The competition was hosted using the Amazon EC2 Cloud, where the automated exchange would run. None of us had experience coding in an Ubuntu Linux virtual box, so before we had the opportunity to dive into the algorithms, one of our challenges was getting ourselves connected to the server and ready to trade. We ultimately established a TCP connection using JSON protocol by passing in the IP address of the exchange to a socket function inside our bot. We then wrote code locally on our personal computers, pushed to Github, and pulled those changes into the virtual box, where we were able to run our files. We chose this flow because we were most comfortable developing locally, and we set up aliases for the most common git commands to avoid wasting time — efficiency was crucial.
The one critical decision we had to make pre-competition was what programming language to use. We decided on Python because of its simple syntax: we didn’t have to worry about the verbosity of declaring variables, and our code was more succinct than it would have been in a non-scripting language. Because of its inherent readability, it was suitable for use in a group with team members from varying technical backgrounds. Also, its extensive libraries simplified implementation and allowed us to focus on the logic of our algorithms. Nevertheless, we encountered two problematic setbacks in the form of complex server errors.
The first error resulted in a loss of connection to the marketplace and an error message of “broken pipe”. We commented out various chunks of code, realizing that it had to do with the frequency with which we were placing orders. Since we were reading the state of the book one line at a time (as per the JSON TCP client protocol) and placing orders at a constant rate directly after, the number of messages being sent to us increased at an exponential rate, ultimately bogging down the server to the point where it crashed. We reconciled this by placing orders at randomized frequency, instead of every time we read from the market. The second error logged “connection refused by peer”. It occurred to us while reviewing the writeup Jane Street provided, that we were making requests too frequently to the server. This was fixed by sleeping our program for 0.01 seconds every time we placed a trade.
Once we were connected to the server, we wrote our first algorithm to trade bonds with a simple penny-pinching strategy. Because not many people were trading yet, this strategy did relatively well for the first two hours of the competition, keeping us at 7th place.
After we had solidified our bond algorithm, we needed a more profitable strategy, so we moved on to analyzing American Depository Receipts (ADRs). Our first approach was to average the book’s buy and sell price for the liquid stock and trade the illiquid ADR at a margin of ±15 USD. We added a global counter to avoid placing any trades before analyzing at least 200 buy and sell prices. However, we later realized our counter was being incremented in our infinite while loop,which resulted in us placing trades too soon at values well outside the fair market. Additionally, we should have been analyzing the price of the trades executed and not all the buy and sell offers placed on the book.We seemed to be making no progress with this strategy, so in an attempt to debug our logic, we added more structure to our code to track and output the status of our assets, which showed us we were making no trades. Although now more informed, we were slowly slipping down the leaderboard as more teams joined the competition with better strategies than our bond trading.
Around five hours in, we hit rock bottom. We found ourselves ranked at 23rd and steadily slipping without a source of income. At this point, our team stepped back to rehash our strategy. We decided to do a serious overhaul of this algorithm and start over with a new way to analyze the ADRs. This time, we targeted the price of the illiquid ADR using the most recent trade price of the liquid ADR. Trade prices are a much more reliable measure of a stock’s true market value than the book’s offers, and because the liquid stock is less volatile in price, its value is a good estimate of the illiquid ADR’s value. If we had more time, we would have averaged the past five trade prices, but we wanted to get our new algorithm running. Also, we knew the liquid stock’s value was only fluctuating within a few dollars, and our margin was larger than that. We placed trades on the book for the liquid ADR with a smarter margin of ±10 USD, knowing no trades went through while using the wider margin. Additionally, we incorporated hedging to keep our assets more stable, so every time we made a trade we then converted back to the illiquid ADR. Once this was all implemented, we ran our algorithm in the test server. Seeing one successful round, we let it fly in the production market. With this new strategy, our Profit and Loss (PnL) was 1,000 USD per round, a promising turn of events following our previous downslide. Because of the conversion fee, we quickly refactored our algorithm to only convert back and forth when we had either bought or sold 10 units of the liquid ADR. At this point we had a steady PnL of around 2,000 USD, so we decided to move on to a more advanced third algorithm and tackle the ETFs.
The ETF held bonds and three different stocks all at different quantities and all liquid than the ETF itself. Our strategy started off fairly similar to our previous one with the ADRs, except now we were valuing the ETF using a bundle of stocks as opposed to just one. As before, we valued the three stocks using their most recent trade price, which we updated each time one of these was traded. Once we had valued all the stocks, we estimated the price of the ETF and placed trades with a margin of ±30 USD. We used a wider margin here because of the greater volatility we observed with the ETF. We deployed this strategy to production after seeing success in the test market, which resulted in a steady PnL of roughly 7,000 USD, our best result yet. With this last algorithm, we quickly climbed up the ranks to seventh place before the end of the first competition. If we had more time, we would have liked to try out trading with a smaller margin and converting back to the liquid stocks and bonds. For the second competition, Jane Street cleared the leaderboard, and we started off strong as 1st of 44 teams. We were making a sizable and steady profit, but towards the end, the team behind us gained ground due to their penny-pinching strategy. During the last five-minute round, they surpassed us. As a last-gasp effort to keep our place, we changed our margin but ended the game with a lower PnL and second place in the competition. Nevertheless, given that a few hours earlier we were scrapping our code, second place was a thrill and a great end to a long day.
The competition was a great introduction into algorithmic trading and an opportunity to learn a new real-world technical application for computer science. We had the chance to familiarize ourselves with new technologies like virtual boxes, debug puzzling scenarios, and explore the logic behind an untried discipline. Definitely worth investing our time!
