An Electronic Trading Hackathon (eth0)

Last weekend, Jane Street organised ‘eth0′ – the first edition of their hackathon. Being a quantitative trading firm, Jane Street write smart computer programs that are constantly trading on the stock market, implementing novel algorithms and ideas. This means that they need efficient and robust code, as well as profitable strategies.

Thus, the aim of the hackathon was to provide a similar experience to computer science students by getting teams to write bots that would compete on a mock exchange. Not missing the opportunity to strut our stuff, the team from Queens’ comprised Jeppe, Eduard and Sid.

The brief was simple: an online service was provided, to which bots could send JSON requests and execute trades. There were a few stocks – FOO, BAR, BAZ, QUUZ – that every team could trade (along with a few bots written by Jane Street). There was also an additional product called CORGE which was a kind of ETF (Exchange Traded Fund). This meant that it was a composite of other stocks – 0.1 FOO and 0.8 BAR. At any point, you could convert from one form to the other.

Given only that much information, the teams were to compete in three rounds. The scores were weighted such that your worst performances counted more than your best ones. This was to simulate the real world where a big loss is far more negative (potentially causing the firm to close down) than a profit is positive.

The first part of the hackathon turned out to be more a technical than financial task. The team from Queens’ spent a few hours just writing code to connect to the server, receive updates on prices and trades, store/ parse this data, and finally send responses.

When it finally got to the trading bits, Queens’ managed to implement two strategies.

The first is called ‘market making’. Essentially, every stock currently trading has two sets of prices. One of these is the ‘offer’ – the price someone is willing to sell the stock at. The other is the ‘bid’ – the price someone is willing to buy at. There is normally a difference between the highest bid and the lowest offer – known as the ‘spread’. The bot worked by placing a buy request just above the bid and a sell request just below the offer. When people wanted to either buy or sell, the bot’s price would be the most attractive and the trade would get executed. Thus, the bid-offer spread (albeit small) is the profit the bot makes.

Queens’ managed to get this working before the first round and was the only team to make money.

For the next rounds, another strategy was used – ‘ETF arbitrage’. Arbitrage means the simultaneous buying and selling of a product to make a ‘riskless profit’ from price differences. For example, if you could buy an apple for $1 at store A, and then sell it to store B at $1.01, you could technically make $0.01 without spending any of your money. You could then borrow money and do this ad infinitum – as long as it was profitable. The ETF arbitrage worked similarly with CORGE, FOO and BAR. This could be thought of as buying a basket of 10 apples for $1 and then selling each for $0.11. Since CORGE could always be converted to 0.1 FOO and 0.8 BAR – it should always be priced as 0.1 the price of FOO plus 0.8 the price of BAR. If it is ever priced less than this (like the apples), you can buy the stock and convert it to FOO and BAR which are worth more. Thus, you can then sell them and pocket the difference (individual apples being sold). If the basket were to be worth more, you could do the reverse transaction. The challenge was made harder with a few extra transaction costs, but the idea was the same.

Queens’ turned out to be pretty successful in round two – coming second, and finishing third overall due to a large loss in the final round.

All in all, the excessive code, food and (of course) Red Bull, contributed to a really fun Saturday. We’re looking forward to doing more of these.

Advertisements