Quantify your edge II

Quantitools
4 min readJun 11, 2022

--

Continuing with our discussion about trading systems and data we will actually code a simple set of rules within the same environment we worked before, Multicharts. Our goal is to demonstrate how only granular and highly accurate data can serve to build our prediction model.

We start with our previous example of a spread trading strategy where we want to perform arbitrage between FTX futures LUNAPERP and Coinbase spot WLUNA-USDT.

Please note that aside the usual disclaimers which also apply here that this model shouldn’t be used for actual trading for many reasons (we will discuss only a few of them), these instruments are no longer trading and data to replicate the analysis may only be available through some data vendors or not available at all (message us and we will provide it for free).

One of the conclusions that we reached from our previous exploratory analysis was that graphical interpretation of data was interesting but falls short when building a model.

FTX LUNAPERP against Coinbase WLUNA-USDT | 1000 Ticks TF | Chart created with Multicharts | QT Data | 11th May zoom

This is the most granular we can get (only half a day covered) for seeing something in the spread, however as we demonstrated before we are missing a lot of opportunities and information if we don’t maximize the possibilities of our data and this means going into a tick-by-tick analysis.

We will stablish a few conditions for our trading model to execute transactions, it will be extremely simple but hopefully you’ll get an idea. In this particular case we can’t buy the spread as Coinbase does not allow shorting that specific instrument, but we can always short the spread. This will be equivalent to going short FTX LUNAPERP and long Coinbase WLUNA-USDT which we can do without issue.

Rules for the system will be:

  • Short the spread whenever it goes above 1.05
  • Cover the spread whenever it goes below 1

Position size will stay fixed at $1k per leg and we will use a conservative value for slippage (we don’t want to complicate the model with limit orders at this stage) and commissions from the exchanges at 0.25% per transaction, which is equivalent to 1% RT for the two legs. Initial portfolio size will be $2k.

These small quantities are actually a prudent choice, a lot of instruments will have severe constraints in the capital that can be deployed, specifically with high frequency trading models. Also, since the opportunities are usually vast across the crypto space and exchanges, it would be way more interesting if we could deploy models across many pairs and exchanges to diversify risks.

The code in Multicharts (Powerlanguage) looks like this:

And these are the results using respectively a 1 min, 1 sec and 1 tick timeframe, we will still work with our original date range: 1st May 2022 to 13th May 2022.

QT_SpreadDemo — Equity Curve — 1 min granularity
QT_SpreadDemo — Equity Curve — 1 sec granularity
QT_SpreadDemo — Equity Curve — 1 tick granularity

Getting deeper in the granularity of the execution of systems is where the opportunities arise as you can see. However, this is also where a myriad of complexities appear and we need to cover them all.

One important thing that we didn’t consider yet is our execution price. Why are we taking for granted our slippage at a fixed level when it is evident that edges and opportunities are clearly correlated with increased transaction costs? As the alpha is more visible it is likely that more traders will compete for this and the slippage will grow or the edge will even vanish when we try to collect it.

So, speed matters too, but how much? We need to get an analysis covered also of our latency and even more important, be able to answer other questions: is our latency stable or is it correlated with volatility or other factors? Some exchanges will have a better routing mechanism that does not affect us much, but others will definitely have some limits or they even will display messages saying their system is overloaded and we should try again later… But even if we are not throttled by the exchange routing system other traders might be ahead of us.

At this point it should be clear that this analysis is missing several details in many fronts, but the most important thing is again data. How fast is our spread moving when we try to leverage an edge? What’s the liquidity for our market orders?

We need quotes. And not a snapshot every few seconds or minutes, we need to rebuild the full state of the orderbook with a quote by quote fully granular data stream. More on this coming!

By Jesús Martín García

--

--