Trading automation

May 30, 2021 - 2 minutes

I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it - Bill Gates

For the past few months I’ve been fine-tuning a fully automated trading system that I have designed and built. The reson behind it was simple - I am a lazy person by nature so in order for me to do things I want while doing very little - I automate as much as possible - let the compute (yes, I said compute not the computer) do the boring repeatitive things while I can do something interesting…

I have been trading stocks for a while - sometimes with good results and sometimes not - but this post is not about trading. I was just getting bored of doing the same thing every other day whenever my system would tell me about the trading signals. Also I do travel quite often and you don’t want to miss that trading opportunity when you’re in transit.

And since I’ve been working alot with AWS - I thought to myself - why not let automation do the work? So I devised a plan and start building the system. Obviously I wanted to make it serverless and use Lambdas. Why Lambdas? Because I wanted to use AWS Step Functions to handle the application logic for me. Why built resilient code when you can build resilience into the framework? And since Lambda has a runtime limit of just 15 minutes I couldn’t build all the logic I wanted into one function. So instead I started creating small Lambda and tie them together with Step Functions.

In short: AWS Step functions are awesome. All I do now is - check the emails with submitted trading orders and do some occasional bug improvement/fixing (why can’t different vendors have the same format for tickers). The only process that can run long enough is IBKR’s TWS Gateway with no access from the outside and bunch of Lambdas to handle everything else.

The monthly cost running on AWS - less than $2 (yes, two) dollars a month.

The actual trading system:

Serverless framework