The usual approach is to take the midprice which is just the average between the best bid and ask. This is decent for most applications, but can definitely be improved. Decent won't cut it in HFT! ...
2/n
Let's outline a few approaches:
OB Liquidity Based:
Weighted Midprice
Exponentially Weighted Midprice
TA (MA) based variants
Starting with the most basic, OB liquidity based, this is effectively taking into account the liquidity that exists in the book when generating fair value. This still relies on an efficient market assumption when pricing fair value and only incorporates information...
4/n
from our current timestamp. Simply weighting the midprice by the liquidity on each side of the order book is the idea. The question is how many levels. This is where you can decide. Large parts of the orderbook remain dormant and are only there to catch flash crash...
5/n
type scenarios. Look at many assets and you will so +80% LOs, these really shouldn't be incorporated so use volume to size this part when naively weighting them. The next approach plays on this and uses exponential weighting so that these dormant levels of the OB...
6/n
are discounted to something effectively gone. From there those familiar with using moving averages as indicators may notice that this is similar to the WMA and EWMA. There are plenty of MAs TRIMA, KAMA, MAMA, KMA, etc and evene Kalman variants can be used to weight the...
7/n
levels of the order book. There is no literature on this as far as I am aware, but I can verify that it works from personal toying around.
Now let's move on to the use of microprice approaches. This removes the efficient market assumption and says that potentially...
8/n
the price we see is not accurate, the idea that previous price information should be incorporated into fair value. Towards the end of my explanation of weighted approaches, I mentioned Kalman. When we incorporate past values we can generalize that the liquidity should...
9/n
play far less of a role in our prediction if we have past prices since we assume that liquidity will in turn drive changes in the order book and should appear in the price patterns. Thus we can use prediction-based models such as HMM uses hidden states like Kalman, but...
10/n
is more suited to the problem. We now must specify the number of ticks ahead. Usually, this is one or two, but we can draw from the approaches of exponential weighting to discount future tick predictions. Sasha Stoikov has a GitHub with code for those who would...
11/n
like to play around with this a bit more, and there are papers out there. Moving forward we may want a little less complex model since we are trying to regularize so ARIMA will bring trends into the OB. Finally, supervised autoencoding with MLP or LSTM models to...
12/n
supervise the AE are a practical choice for those with large data quantities. These are all important for market makers who need to make sure they receive a fair price for their liquidity. Thus I will show an approach that is better for those like...
13/n
Hummingbot who genuinely want to provide liquidity, but obviously don't want adverse fills. This would involve a centralized approach but instead of predicting each OB level or using complex RL models to not just prevent adverse fills, but attempt to create positive...
14/n
expectancy in their inventory. With this we use a volatility dependent offset from the fair value estimation. We prevent adverse fills simply by having our fair value accurately reflect a prediction of future price. This method is MUCH faster to compute than...
15/n
each level and will enable much lower latency, plus an easier project as a whole.
Disclosure:
I have tested this and it works pretty well, but don't use it since I am a taker just trying to get cheap fills with LOs not a maker.
16/16
But I do use the fair value approaches for training models, just not the centralized fair value prediction + offset approach.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
This is when you are on the other side of the OB with an aggressive (usually) LO acting as a maker, but the price moves and now you are on the opposite side of the OB, and get matched with an order as such. You pay taker fees when this...
happens which for a lot of HFT strats means certain death. No kidding. Rebate of 1bps vs 4bps fees. Not a fun time when your alpha is likely only a few bps and your BAS is a bp maybe. This example is crypto futures. The risk of getting flipped is why you have to be...
fast as a MM, not just to prevent leaving stale quotes on the OB, but also to prevent getting flipped. The risk increases as you become more aggressive, which is why a lot of stat arb strategies (like I use) that don't even need that fast execution, have to use it because...
Whilst I am not a big fan of using linear regressions I do use regressions in the models I develop. Polynomial logistic regressions are effectively a smoothed decision tree surface for example. Regularization that limits depth of an NN or tree is great, but introducing...
1/n
the bias that jagged jumps in the decision surface are a bad idea through the use of regression-based models massively denoises your data. (not strictly regressions, for ex: regression NNs and regression decision trees are awesome). As I have mentioned before...
2/n
a decision tree cannot replicate a linear regression with regularization. It's like if you tried to fit a sin wave with a Taylor series, you can get close, but the level of complexity would be infinity for a perfect replication. (for taylor series this would be polynomial...
3/n
I previously mentioned the use of CDS pricing literature for alternative copula distributions, and for bringing assumptions to the higher dimensions without using vines.
Continuing, this topic I'll go through some other methods/tricks:
For optimizing copulas the easiest method is to use a heuristic method and then brute force the lower dimensions. This is usually bivariate only, but with smaller asset universes trivariate is possible. From there you just test all permutations that include...
2/n
your established pair or triplet. To solve for the weights you can do this with standard methods. Another note is that since copulas are effectively conditional probabilities and vine copulas form chains, the Baum Welch algorithm can be adapted with use of non-gaussian...
3/n
I’ve totally made up this word but there’s not word for the concept it captures and I’ve been using it for over a year regardless.
If you use bollinger bands to trade mean reverting portfolios your lag error is the loss of alpha from the deterministic component.
This comes in 3 forms:
Jump risk:
Large jumps in the mean will take time for your mean to move to and cause errors because moving averages are lagged. This is a regime shifting ish problem and is aided by unsupervised learning models with conservatism controls.
…
The next is mismatched period:
If there is a sin wave with white noise we may attempt to use an MA to trade the noise part. This will give us lag error as we will not be accounting for the broader sim function and get lag error, hurting our PnL. Mismatched timeframe
For anyone making an HFT strat, you need a simulator to see when you get filled. You can use Kalman queues, multi-queues, sim matching engines and they are all cool but usually don't properly capture effects like adversity. Then there are stochastic approaches...
1/n
This would be like simulating the poisson process. This sucks even worse as it utterly and entirely ignores adversity. At least sim matchers give a try, although not a great one and an easy NN will trounce it. Plus stochastic approaches don't use historical data...
2/n
Other methods involve procedural OB sims which basically just take the data and add a bit of stochastic overlay to the historical OB, this assumes (most of the time) that you get filled when midprice crosses your bid/ask which is just wrong because it neglects...
3/n
Async I/O
Multi-threaded CPU tasks
Hyper-threaded CPU tasks
Async I/O will only benefit speed-wise from the writing data component of the work and can slow you down if that is not significant. There is only one NAC remember, but there is not infinite cache and management is expensive.
1/3
Multi-threading is great, but not for file handling, that won't be faster and will split your cache once again so for ultra low latency applications you usually just have one super fast core enabled so you can maximise cache.
2/3