Democratizing Algo Trading

John Studarus
3 min readOct 22, 2020

My first foray into algorithmic trading with Alpaca’s fintech API atop Equinix Metal infrastructure

What if you were able to convert Elon Musk’s impulsive tweets into market deals and get a jump on a move in Tesla stock? Or take Apple — one of the hottest stocks on the market — what if you could instantly gauge public reaction to a new iPhone and execute a trade to capitalize on the news?

This is the playpen of deep pocket quant funds with advanced technology, proprietary APIs, and closed ecosystems. These silk pocket traders are the chosen few, catching real time announcements from Apple and capitalizing upon the news. A press release announcing a supplier change can automatically kick off trades buying stock in that supplier while shorting the old supplier. They turn the rest of us into hagglers who spend hours pouring over announcement looking for such opportunities.

However, there is a golden ticket… access inside! What used to be closed off to most is now available to all. You can have access to open and freely available APIs and advanced computing and networking infrastructure by tapping into today’s interconnected bare metal clouds and freely available fintech APIs.

I used the Alpaca trading API and Equinix Metal to run my first trading algorithm. Here’s how to start: Spin up an Equinix Metal c3.medium.x86 (Ubuntu) and put the “long-short” algo to work. The full details of setting up the server and algo environment are available on GitHub: https://github.com/packet-labs/AlgoTradingOnEquinixMetal.

Alpaca has a few sample trading algorithms (or simply “algo” if you’re in the industry), including a “long-short” strategy. This algo tracks a bucket of stocks. It constantly buys and sells the top and bottom quartile through the day and then closes out all the positions 15 minutes before market close (so as not to hold any positions overnight). It looks back a few minutes at the stock performance when ranking the stocks to determine the top and bottom quartile. The premise of this algo is to perform like a day trader catching waves of stocks moving up and dumping those on their way down. An algo can work much faster than a day trader, who is dependent on a mouse and keyboard.

While my first steps were simplistic, taking those steps demonstrated that the software and hardware infrastructure is readily available for the masses. It doesn’t require a pricey investment in hardware infrastructure, network connectivity, or the cost of a seat on a stock exchange. Technologies such as Alpaca, with free API based trading, and Equinix Metal, with a deep pool of pay-as you-go bare metal computing resources, have leveled the playing field. The revolution of open APIs and cloud based bare metal infrastructure is the golden ticket; it makes algorithmic trading viable.

Think even bigger.

Equinix Metal provides a readily available pool of computing resources. This makes it possible to pull in external resources for data mining to determine market trends. This small, single server algorithm could easily become a cluster which can pull in Twitter feeds, SEC filings, and news reports (closed captions) to make stock and commodity trades. It is now possible to process a massive amount of market information, and create a powerful automated investment program.

The computing infrastructure is also flexible — you don’t have to use their resources at all when the market isn’t open. With a little bit of “infrastructure-as-code,” the whole cluster can be spun up before the market opens, run for the day, and then spun down when no longer needed. Scaling up and down the Equinix computing infrastructure as stock conditions warrant is as easy as a few clicks. Scaling can even be programmed directly into the algo itself!

So while my first steps were simple, and long-short isn’t going to make me a ton of money, it does show what is possible. And don’t worry, my gains and losses are purely fictitious. I experimented with the algo through the use of an Alpaca paper trading account. Keep an eye on my Github repo, though! I’m looking forward to building it out with some exciting algo I have in mind for the next Apple product launch…

--

--

John Studarus

John is the president of JHL Consulting focused on cloud, networking, and security product consulting.