Trade Options with QuantConnect

Welly Tambunan
9 min readMay 7, 2020

Hi All,

I just want to share some of my finding for a couple of weeks on Quantitative Trading. What i found, my failure and mistake also some light for the next future to come.

Background

As Head of Engineering at kata.ai my job is always focusing on innovation. When come to innovation kata.ai is an amazing place to work. That’s why i have sometimes to explore something that maybe seems unrelated to work at all.

Who knows where this goes ? Freedom is the key for innovation right ? So let’s get started.

Forex Trading

I learn to trade Forex in 2012. It’s almost 8 years ago. It has ups and down, but i also learn a lot about myself, personality, weakness and strength. The transition from programmer to trader is not easy. The market is a irrational beast.

Given that my background as distributed system programmer at the time, i like to work with realtime data. As the domain of my company is oil and gas especially in upstream or exploration.

I’m quite confident that i will find Holy Grails! Of course, as all the newbie in forex trading i’m focusing on Technical Analysis alone!

However after hundreds and thousands of backtesting in Expert Advisor in Metatrader 4 using MQL language. Throw a bunch of indicators, even create your own but all i’ve got is one failure after failure and failure. It show excellent result at backtesting but failure when live trading.

What a mess…

I finally found a great forum that give the analysis about currency market but he’s using fundamental analysis. His name is Jarrat Davis. I learn a lot form his blog and his videos. Implement it and following the news. They use realtime news feed website like newsquawk and currently they create forexsource.

I become news junkie. I made good profit from that. But i’m not enjoying looking at chart and waiting for the announcement or economic release. It’s really stressful.

I try to automate the process but it seems impossible, so many variable need to be implemented. Finally after sometimes i give up trading because i think i waste enough time for this. I made money but not enjoy it and it made me stress. What for…

Quant Trading

Back to my daily life, i try to forget about trading. Seems no way i can make money like this from trading.

Even i’ve not trading anymore i still have a great interest on this financial market. I try to browse and read lots of article and find a blog on Quantitative Trading. It’s Ernie Chan blog. Seems the approach is quite different from mine. But it focusing on stock mostly at that time.

I learn his 2 books everyday until i’ve done and finally get some ideas. The use of Technical Analysis and Indicator is very minimum in that book. I learn about new scientific concept like mean reversion, cointegration and pairs trading.

Finding the new ideas i try to backtest and apply the concept i read to Forex. But i haven’t quite get the meaningful result applying the same techniques in Forex market. I feel that all the strategy in Quantitative Trading mostly focusing on Stock !

I try to implement the same approach to Indonesian Stock Market. But the data from Yahoo Finance is very poor and the result is not significant. Also in our country there’s no ability of short selling.

Should i try US Stock ? But it way too expensive for me at that time.

So all i can do for that time is playing around with code in Quantopian in my free time over the weekend. Nothing got traded in the real account yet. Lots of material is available in the website, lectures and also youtube channel. They introduce notebook and backtesting and more strategy.

Then on that journey i stumble upon the blog that sell a books that says. Fooled by Technical Analysis.

What ? Seriously ?

I sign up instantly and use my new credit card there. The author is Michael Harris. Found the new hero i read all his blog and follow every track he made on the net. Follow his twitter and also have a couple discussion with him via twitter. Getting more confused with conversation. Perils of backtesting, overfitting, newbie quant mistake, failure of curve fitting and machine learning, data mining bias etc. The list is go on and on and on. Seems the journey in this field is so hard.

I also order the oldest book that out of print from US ! Well, my wife got angry but i don’t care. I just want to pick his brain as i know what i need and fix in my approach. I bought 2 books. I got the algorithm but failed to implement given the computing power and the combinatorial problem that need to be solved. Seems i’m losing my touch with my competitive programming skill. Getting old basically.

Getting deep into this area made me feel i’ve much to learn and it’s like never ending. I become tired with analysis paralysis without any improvement. All i get is confusion. The i read, the more i confuse. There’s a lot of noise and less signal from all the books and article that i read.

Meet the Options

While trying to find the right strategy i found an interesting website called tastytrade. It teach about options and probability. The man behind the show, Tom Sosnoff trying to teach his daughter Chase to learn Options Trading. It’s really fun and entertaining. Seems the Options is a really great instrument.

I try to find a way to automate the trade. But seems it quite hard given that TD Ameritrade that time not giving the API to public. I found Interactive Broker but seems that we need to deposit a huge money there and the cost is expensive. Not possible for now.

I learn that there’s a lot of instrument out there in financial market. Bond, Futures, Equities, CFD, FX, Options etc. And lot of market not only in US but all over the world. I learn that to make a really good portfolio, we need to do diversification on strategy and also instrument. So the curve is smooth and the drawdown is limited.

But here we go again… Not possible for now. I have money but there is more important plan that need to be solved. Need to ditch my ego to solve the market. For now…

After a years…

Finally time goes by, after a long years of vacuum from trading world. I finally find a chance to give this a try once again. This time i’m getting more resources for research and also support from lots of party. Everything looks nice and give me some focus for this.

I look back into my previous notes and found the last state of my research and resume from there. After i look at the internet a lot of things has change. More backtesting software out there. That’s when i found QuantConnect that give the various instrument to trade including Options! It also support live trading. What’s not too like.

The community is quite small compare to Quantopian, but who cares. I can get the best from both community but use QuantConnect as a trade platform. So here’s my strategy.

Given that trading Options is cheaper than the underlying. I think it’s more cost effective to trade Options. And we are not buying options. We need to become Options Seller, as we need to act like casino or insurance company. This instrument basically give you a built-in edge. A lot of this knowledge comes from TastyTrade before.

You can use directional trading strategy from stocks strategy you’ve found in the books, internet, forum etc. But convert that to Options. That way you can maximize your probability of success while minimizing your cost basis.

Ok let’s start with the very basic of learning to trade options using QuantConnect. First you need to learn about the options itself.

Options Tutorial

If you want to found a good resource for learning options you can learn from these videos.

Introduction to Options
Options Usage
We prefer Options

I think that’s all you need for learning that the correct way. Please don’t get scary if the lesson is doesn’t make any sense and looks complicated. You can go through the video and lectures multiple times. I also doing that at first when learning. No need to hurry. Just understand one thing at a time.

Options Strategy

There are a dozen of strategies around options trading. You don’t need all of that. Keep it simple. The more complex your strategy is, the more tired and confuse you maintaining your position if something bad happen. No need to be perfect. This is the strategic games. My objective to give the minimal information that you need to be successful.

Basically you need to remember only 4 strategies.

Bullish Strategy

If you bullish on instrument, instead of buying stock you sell the OTM naked put.

If you have a small account or want to trade expensive stock you can sell the vertical put spread.

Here’s a good video that explain the rationale for the strategy

Bearish Strategy

If you bearish on instrument, instead of short stock you sell the OTM naked call

Or sell the vertical call spread for smaller buying power reduction.

You can also watch the videos below for more clear explanation.

That’s how you convert your existing strategy in buying or selling stock into option trading. Options give you leverage. It’s good if you use it wisely. I will talk more about this later for more strategic bet sizing. But you have it all now.

Options in QuantConnect

Now we will learn how to use Options API in QuantConnect. There are a couple of resource you need to follow. I will give the enough to get started and discard the noise. Too much information just made you confuse.

The above tutorial will teach you the basic concept of the API and you can clone the code at the end of the post then play with it.

Just use this sample on how to use Options Chain Provider. Look at the code sample at the bottom of the article and clone it.

That’s all you need.

What’s Next?

Start play with it and implement 4 strategy. If you have existing stock strategy you can use it as started.

Here’s my first Short Put sample

I will post more about Options Strategy on more detail. Especially about how we can decide which direction to trade, position sizing, strike prize etc. Will also give you the good books that you can use for simple trading strategy.

Until next time.

Rock On !

--

--