Building an Algorithmic Trading Strategy with Enigma Catalyst
By: Jonas Bostoen
Tags: Python, Blockchain, Trading, Algorithmic Trading, Bitcoin

Building an Algorithmic Trading Strategy with Enigma Catalyst

Walking you through the Enigma project and using Catalyst to build an automated trading strategy.

Introduction to Enigma

Blockchains, in their current form, don’t handle privacy well. The data that is stored on a blockchain is available for everyone to inspect — a side-effect of radical transparency. Although this is still better than the current data model (whose problems I summed up below), some data is just not suitable to put on display.

Problems with the current model:

No Privacy ~ theft (hacks), selling to other parties etc.

~ theft (hacks), selling to other parties etc. Lost Natural Income ~ your data is a natural resource

~ your data is a natural resource Sensitive Product Problem ~ some data is extremely personal

~ some data is extremely personal Aggregated Power ~ large companies own basically all of our data

Machine Learning, and especially Deep Learning, has given us insights on our data that are invaluable. With our rapid increase in computational power, together with the enormous growth of data, there is no better time to train these models. Deep Learning is on its way to reshape almost every industry out there:

Industries disrupted by Deep Learning [Source: Insight AI whitepaper]

The need for a new way of storing our personal data, that addresses the 4 main problems I mentioned above, on which Machine Learning models can still be trained, is huge. This is where Enigma comes in.

Enigma is a decentralized computation platform with guaranteed privacy. Data can be stored both on the public blockchain (non-sensitive data like ENG token transactions) or on the private Enigma network (sensitive data like medical logs). The private Enigma network architecture, which is not a blockchain, is that of a Distributed Hash Table, which is also a huge part of the InterPlanetary File System (IPFS). Read about that here. You own your data, so in essence, if a large company wants to train a model (like a targeted advertising model), you would sell your data to that company in order for them to use it. Computation on sensitive data is still possible, due Enigma’s secure multi-party computation. If you want to know more about Enigma, read their whitepaper.

Catalyst

Inspired by the rapid growth and proliferation of crypto-assets, we propose Catalyst — the first investment platform that enables developers to build, test, and execute micro crypto-funds.

This extract is from the Catalyst whitepaper, and it pretty much sums up what they aim to do. Catalyst is the first Application on the Enigma protocol, since the crypto-data that powers the platform comes from the Enigma decentralized data marketplace.

It aims to be the one-stop shop for quantitative traders to test their strategies in the crypto-asset domain. It also aims to be a platform on which people can buy strategies from Catalyst developers. The Python Software Development Kit is a Zipline based engine in which strategies can be back-tested or live-traded.

Building the Strategy

The first step will be to install Catalyst on your system. Follow the guidelines their documentation provides here.

What we’ll build is a simple strategy that utilizes the RSI or Relative Strength Index. This is a momentum indicator that signals the strength of price movements. This will be the logic:

If we are not in a position and the RSI is oversold (≤ 30), go long

If we are in a long position and the RSI reaches 60, close long

If we are not in a position and the RSI is overbought (≥ 70), go short

If we are in a short position and the RSI reaches 40, close short

These random exit-position numbers (40 for short, 60 for long) are chosen arbitrarily. It’s to make sure that the strategy can actually exit a position once the RSI has pulled back. One thing you may try is to optimize these values for maximal profit. Not like that will be a whole lot.

This is what the complete strategy looks like in Python, and we’ll break it down part by part:

I suggest just copying lines 1 through 12. This will basically be any strategy’s skeleton (along with initialize, handle_data and analyze) and I won’t go deeper into these.

If I run this algorithm with the catalyst.run_algorithm function (providing the right parameters), this is the output. First graph being our portfolio value, second graph price, with the buys and sells displayed as arrows. The third graph plots the RSI, and the last graph shows our percentage gain (Blue) compared to just holding the asset (Orange). Courtesy of our analyze function.