Algorithmic Trading in Python

Algorithmic Trading in Python
Photo by Maxim Hopman / Unsplash

One of Charlie Munger´s,  vice chairman of Berkshire Hathaway,  best-known quotes is: “The big money is not in the buying or selling, but in the waiting”, but is this actually the case?

It's a story as old as time, the average hedge fund can't consistently beat the broad index funds like the S&P500 or the NASDAQ100, but I think the keyword is "average", Renaissance Technologies´ Medallion Fund for example did it.
For more than 20 years:

Source: https://www.cash.ch/sites/default/files/public/uploads/renaissance.jpg


So how are they doing it? - Well, I wouldn't be here if I knew...
What this shows is that it is in fact possible to outperfom the market.


So what's the strategy? -  Leveraging the optionsflow.

The Proof of Concept:

Financial-wise, the biggest innovation of 2020 and 2021 in my view is the website Unusalwhales.com, as it provides the pure and unfiltered optionsflow,
it makes spotting insider trades by Nancy Pelosi, for example, Speaker of the United States House of Representatives, easy: https://unusualwhales.com/i_am_the_senate/pelosi

But how can we use this data?

Well, we can spot unusual options by volume, strike and expiry, aside from a few other factors.:

This call option, for example, has all the characteristics of an unusual option:
- It's on the Ask Side, meaning the buyer wanted to get the option as fast as possible
- It's  5.63% out of the money(strike is @$215 and the stockprice@ $203.54)
  this is not unusual by itself, but it expires in just seven days, meaning there's a   certain urgency.


A little oversimplified Crash-Course for options:
If a call option is below its strike at expiry, here $215 on the 08/27/2021,
it expires worthless.


Conclusion of the Alert:

Someone is willing to bet $652,138.00 that Nvidias´ stock rises by atleast 5.63%
in just 7 days. Was the "speculator" right?

See for yourself:

Malicious gossip has it that the "speculator" might have known of the DoE
Aurora supercomputer deal with Nvidia:
https://www.tomshardware.com/news/nvidia-amd-polaris-supercomputer-department-of-energy



The morality of insider trading and making 1200% profit in a week is not the question at hand, it being how we can spot and follow these high conviction bets?

There are a few Problems to overcome: the biggest one being the so called "Memestocks", for those, $AMC and $GME especially, a lot of small fishes buys so many high-risk options that they might look like a whale. So it's crucial to filter those stocks out.

Apart from that it's pretty straight forward, we search for high conviction, short term bets with favorably vast amounts of money behind it.

The Test Environment

Since I am living in Germany, we can only follow call options since we can't short a stock, likewise we can only buy stocks, since in Europe the derivatives market is not as well regulated as in the US, therefore we can only lookup the isin of an option manually as of now.

We can stream the options data, but only the live one, not the historic data, making back testing almost impossible.

To paper trade the stocks, we will be using lemon.markets, a German API focused up-and-coming fintech startup. It even allows us to try different strategies with its "spaces" system, dividing the main account into many smaller ones:

Each Space has its own API key, as well as a portfolio, order and transaction overview. The API structure is also quite straight forward:

https://docs.lemon.markets/img/API_Structure.png

The Results as of 09/29/2021:

You win some you lose some, but overall, we made about 14%  in 3 weeks with ~40 trades, but this being such a small timeframe we will have to see how it goes from here. Since the charting function on lemon.markets is broken right now, showing only the last day, I can't provide a chart right now, but once it is fixed, I will update this post.


BTW: The $NVDA call I analyzed above, returned 11% as of today.