Forums  > Trading  > Market making models  
     
Page 1 of 2Goto to page: [1], 2 Next
Display using:  

ahgt_123


Total Posts: 11
Joined: May 2020
 
Posted: 2020-08-31 19:12
I was looking at some papers on market making strategies on equities and was surprised by "advanced mathematics" used in them.Every paper started with formulation of problem as hamilton jacobi bellman equations with assumptions and proceeded to derive optimal quotes from there.

My intuition was that market making would deal with more order book phenomenon and adjusting bid ask prices accordingly.

It would take much time to have a reasonable understanding of equations so i was wondering if it is worth going down this rabbithole.

prikolno


Total Posts: 67
Joined: Jul 2018
 
Posted: 2020-08-31 21:32
Variational PDEs are in use at mid-freq shops with theoretical physics lineage and for optimal execution. Never seen it in the wild for market making at the >2% ADV frequency.

Haven't yet found a favorite for optimal control but Lanczos, Gelfand and Evans are some of the best written texts of all time though.

nikol


Total Posts: 1176
Joined: Jun 2005
 
Posted: 2020-08-31 21:43
Dont be scared of HJB . It's worth to crack its meaning.
Dynamic programming and control theory by Bellman and Kalaba helped me to get the idea.

Here is previous discussion on MMs.
https://www.nuclearphynance.com/Show%20Post.aspx?PostIDKey=193335

EspressoLover


Total Posts: 446
Joined: Jan 2015
 
Posted: 2020-09-01 03:08
I could be wrong, I often am. But I'd say that HJB and the like have essentially no use for practitioners of HFT-style market making. I'd freely admit that I'm taking a provincial view here, if not for the the fact that the original A&S paper was titled High-frequency trading in a limit order book. (With most subsequent papers using similar terminology.)

As far as I can tell, A&S don't seem to have talked to any actual high-frequency traders. Or for that matter anybody who even regularly uses a limit order book. The word "data" only appears once (in case you're wondering it's available, but the authors definitely won't be using it). Anytime I see these type of quant finance papers- you know the kind with pages of differential equations but zero actual datasets- my eyes glaze over.

It makes me feel like I'm reading an anthropology paper on "Childrearing Habits in Papua New Guinea". Except the author's never left Cleveland, is only vaguely familiar with New Guinea, and barely spends any time even with his own kids. The armchair anthropologist reaches speculative conclusions by long chains of logic derived from arbitrary first principles. Maybe he does winds up getting things right. And if so it'd be super-impressive. Still, if I was trying to crack the emerging Papuan toy market, I wouldn't take his advice without booking a flight to Port Moresby.

Complex PDE models like HJB usually wind up baking in a whole bunch of unvalidated assumptions. Which basically forces the data to fit the pre-determined model. In practice, it's almost always better to let the empirical evidence drive the model rather than vice versa. The upshot tends to be "flat" models with more degrees of freedom, that allow for parameterizing over a less constrained universe of behavior. Among the ways that HJB misses the mark here for real practitioners (IMO):

Over-focus on volatility and risk: The vast majority of major market makers, don't care about optimizing for portfolio volatility. Virtu had one losing day in like a decade of trading. If your Sharpe ratio's 30, you don't care about boosting it to 40.

Ignoring adverse selection: Unlike risk, this *is* the binding constraint that limits market maker sizing. Market makers don't stop quoting larger because they're afraid of portfolio risk, they do so because the expected PnL on the marginal liquidity becomes negative. It's the first, not the second, moment. Isn't this just effectively the same way that HJB penalizes inventory? No. Inventory that you've been sitting on has way less toxicity than a quote that just got lifted. Liquidity sourced from retail brokerages has less adversity than lit exchange flow. Order flow at market open is more toxic than flow at the close. From a vol perspective, inventory-reducing trades are always good. From an adversity perspective, they can still be very toxic.

Ignoring queue position: HJB assumes that there's no competition. If I had no competition, my biggest concern would be what color to paint the helipad on my yacht. In practice market making is viciously competitive. Both in terms of price and queue position. The former can fit into the HJB worldview. The latter most definitely does not. Every market maker in the world would tell you the necessity of quoting at a position that is instantaneously unprofitable to build queue position. If you listen to HJB, no one would ever try to seize first queue position on new level formation. Yet that's consistently the most profitable trade in the market making universe.

Impractical in low-latency environments: HJB requires numerically solving a complex PDE. I left this point last, because I suppose you could approximate or pre-compute in a way to get response time under 10 microseconds. I wouldn't want to be the guy responsible for it though.

Papers like Avellaneda and Stoikov certainly are impressive intellectual achievements. I certainly always feel smart when I finally work my way through the pages of stochastic calculus. And then after that feeling wears off, I realize there's nothing useful here. @prikolno is smarter and definitely better informed than me. So, I'd trust him when he says it has practical applications for some players. But I don't see it for anyone in my corner of the world.

On a tangent, one piece that I would recommend for background reading that does a pretty good job of tying together academic theory with real-world is
this presentation. The author uses a fair bit of stochastic calculus, but he always keeps it grounded in the empirical data before straying too far into the clouds. I won't endorse every statement in there, but I think if more academics in quant finance would do well to follow his example.

Good questions outrank easy answers. -Paul Samuelson

Strange


Total Posts: 1661
Joined: Jun 2004
 
Posted: 2020-09-01 04:02
@EspressoLover is there any good introductory reading about modern market making?

'Progress just means bad things happen faster.’

gaj


Total Posts: 113
Joined: Apr 2018
 
Posted: 2020-09-01 04:53
HJB is quite easy to understand if you discretize the problem (and you’ll have to discretize the PDE to solve it anyway). Before reading the papers, I came up with the same equations by playing with a discrete model, and a bright high schooler should be able to understand my derivation. The math for the continuous version looks intimidating, but it’s really unnecessary for practical trading purposes.

Like EL said, I never ended up using it in production. The purpose of a market making model is to tell you where to place your orders: how wide is your spread, do you skew up/down, and what size. HJB gives you these, but you have to provide the input parameters, which are unintuitive and the model’s assumptions are not necessarily realistic. I find it much more straightforward to just set the market making parameters to be some intuitive functions of inventory, volatility, time of day, etc.

prikolno


Total Posts: 67
Joined: Jul 2018
 
Posted: 2020-09-01 12:35
>Impractical in low-latency environments

If you have enough alpha on the entries, you can actually bifurcate it from everything else so this doesn't pose a limitation. Then your entry model and its execution is invariant to inventory, past a certain (e.g. time) threshold the positions go into a bin that the model is not responsible for. This reduces the remainder into a classical portfolio liquidation problem. There's various informal terms to refer to this, including "exhaust", "take-make" (it's more viable if you strictly aggress to increase inventory) or a colorful French term with the initials v and c.

There's a certain appeal to this, including that "everything else" isn't as latency-sensitive and is heavily studied, and you can now quantify whether to roll your own or outsource it, including to HJB-based solutions like OptimIS and its relatives. It's also more plausible in a pro rata market where broker execution often has size advantage for the "make" leg. This would still be a "HFT" MM strategy in loose sense of the term.

But I started this post with a big "if" and was explicit when I mentioned the 2% mark. I don't know anyone that does it this way these days because there's not a lot of alpha to go around. YMMV.

It's befitting that your analogy about academic models ends with a reminder of said firm's S-1 original filing. I remember when the news broke about the 1 losing day, several academics and journalists put together some convoluted models and armchair theories to estimate the SR because it seemed almost unimaginable to them at the time. What is whimsical is that they were still underestimating the SR in those models because they didn't realize what's obvious to a practitioner, which is that they would've had zero losing days if there wasn't such a thing as a partial trading day.

EspressoLover


Total Posts: 446
Joined: Jan 2015
 
Posted: 2020-09-01 13:53
@prikolno

Thanks for the elucidation! I always learn something from your posts. I've never heard of the "exhaust" paradigm before, but can definitely see how it'd add value for certain categories of strategies.

@strange

At nearly 20 years old, it's starting to get a little long in the tooth. But I'd still recommend Larry Harris' Trading and Exchanges. To drop the link again, this presentation covers things from basics to fairly advanced concepts pretty well. Most of the papers by Kirilenko or Brogaard are pretty good, especially because they have access to de-anonymized datasets. Hasbrouk's a good author too.

Good questions outrank easy answers. -Paul Samuelson

doomanx


Total Posts: 89
Joined: Jul 2018
 
Posted: 2020-09-01 15:02
Using PDE solvers in HFT is something done in the options space quite often. The idea is you have some other threads populating the cache with solutions in a grid around the current parameters. Matt Hurd talks about this a bit in his legendary post I recommend everyone read https://meanderful.blogspot.com/2018/01/the-accidental-hft-firm.html

Here's a good tutorial from a practitioner (KCG) https://ieor.columbia.edu/files/seasdepts/industrial-engineering-operations-research/pdf-files/Borden_D_FESeminar_Sp10.pdf. I think the HJB approach is better suited for building a simulation environment for backtesting. Under your model it tells you the 'optimal' execution fraction to target, which you can compare to your realised results. Can also use it to generate reward/cost signals for a reinforcement learning system.

did you use VWAP or triple-reinforced GAN execution?

ahgt_123


Total Posts: 11
Joined: May 2020
 
Posted: 2020-09-01 18:27
@doomanx I have read about reinforcement learning for market making, sounded interesting and relatively easy.Can you suggest few good papers on the topic.

Maggette


Total Posts: 1251
Joined: Jun 2007
 
Posted: 2020-09-02 07:51
At first you should read doomanx signature:)

A more constructive remark: what would your agent "play against"?

IMHO you would need a kind of realistic simulation of an LOB market and all its effects. This is a hard thing to do (impossible if you ask me). And if you had it, you could probably monte carlo tree search the problem.

You could go down the rabbit hole and try training a GAN to replicate the LOB, and than run RF against that Big Smile

Disclaimer: I don't know much about market making.

Ich kam hierher und sah dich und deine Leute lächeln, und sagte mir: Maggette, scheiss auf den small talk, lass lieber deine Fäuste sprechen...

prikolno


Total Posts: 67
Joined: Jul 2018
 
Posted: 2020-09-02 14:24
If you're looking for something easy, I think reverse K-S is better than RL and optimal control for MM. :)

@Maggette No, you typically wouldn't bootstrap with simulated data from a multi-agent setting. You'd just use production data.

The difficult part about RL for MM is that there's a lot of plumbing that I don't think any academic paper will discuss, without which you're likely better off reformulating this into a setup which you can attack with classical literature on optimal control like I described. Label resolution is one of many that's easier to explain: Let's say your label resolves on uptick/downtick, then on each uptick/downtick you have a cascade of model updates. Not easy to make it run in amortized constant time with typical patterns like speculative LUT (described in Matt's post) because there's an extra dimension in the number of feature vector observations since last uptick/downtick.

I don't have MS lawyers preventing me from explaining all the plumbing, but I think a more fundamental issue is that you should condition on the problem not condition on the tool. Otherwise you'll just find simple lookup table will beat whatever sophisticated tricks you use, which is quite typical of problems that you might throw RL and approximate DP at. There's many parts to MM that you might address with RL, not just the prediction alpha. In some cases, you'd solve it in a way that the prediction alpha comes for "free", in some cases the optimal policy comes for "free".

@EL: No problem. Likewise, your comments are always appreciated.

gaj


Total Posts: 113
Joined: Apr 2018
 
Posted: 2020-09-02 14:48
> You'd just use production data.

You mean you let the RL learner modify the trading parameters and influence your actual trades? Sounds a bit dangerous, and doesn't seem like you would get enough data.

prikolno


Total Posts: 67
Joined: Jul 2018
 
Posted: 2020-09-02 15:37
>Sounds a bit dangerous

Why would it be dangerous? When you A/B test a parameter by hand you'd generally let it push 10s to 100s of bps ADV to see how it works right? In many cases that's the only way to know. A lot more dangerous to me than letting a learner do it in a principled way.

You would absolutely have enough data, you just need to reduce the state representations to control the rate of convergence. In typical ML applications you would learn the reduced state representations with a NN, but for MM there's very effective heuristics.

gaj


Total Posts: 113
Joined: Apr 2018
 
Posted: 2020-09-03 03:08
Interesting. Didn’t know that people actually train RL in production. Like Maggette, I thought you’d normally train it on a simulator.

> In some cases, you'd solve it in a way that the prediction alpha comes for "free", in some cases the optimal policy comes for "free".

Do you mind elaborating on this part? This sounds extremely interesting, but I don’t quite get how you get either the alpha or the optimal policy for free.

doomanx


Total Posts: 89
Joined: Jul 2018
 
Posted: 2020-09-03 18:46
In all seriousness, I don't think market making with RL is a good idea. As Maggette alluded to, building the interaction with the 'environment' is like perfectly simulating the market reaction to any order, which is difficult to do. As prikolno said, what you can do is use your current parameter settings as a initialisation point and use a RL type method to update your current policy with production data.

I have had success applying it in optimal execution situations. There is a lot of literature on the cost of execution of different types of orders. You might be interested in https://arxiv.org/pdf/1403.2229.pdf for some ideas. There is also earlier work by Kearns where they introduce this idea as well as RL for optimal routing between different venues.


did you use VWAP or triple-reinforced GAN execution?

bullero


Total Posts: 71
Joined: Feb 2018
 
Posted: 2020-09-09 12:26
Most of the models do not deal with the queue position of your limit order. They suggest a quoting strategy which is not realistic.

A filled limit order may be regarded as an option to make the spread and the option value depends on the current and anticipated queue configuration(s). Essentially, it is better to be filled when there is more stuff sitting behind you.

Now, someone here said HJB does not incorporate the queue position. This is not an entirely accurate statement. HJB is only a tool to describe the evolution of an abstract "value function" given your state and given that you do not touch the environment. Now, is it possible to take into account the queue position in the HJB? The answer is yes, but you have to make certain technical changes to the statement of the problem. You need to transform the problem into an optimal stopping problem which relies on the queue position, queue imbalance, order flow imbalance etc.. Also, you need to transform the way you treat time in the model. In the existing academic literature you get optimal spreads around some reference price for some fixed point in time which essentially means that you do not take into account book changes. Instead, what you need to do is to define time as time until next event (marketable order arrival, limit order addition or limit order cancellation). After all these rather large modifications you get a set of HJB-QVIs that is applicable to one book configuration. There are quite a lot of combinations of these... You solve all of them numerically over a large grid of possible parameters, save them for later use and load them into memory when you do trading. The solution is a binary mapping from "market state" to decisions to cancel, insert or do nothing (conditional on your state). The math of this stuff is quite trivial, the most challenging part of this is the management of your computational resources. Why? Your HJBs will be quite jumpy between different book configurations and this will creep into your finite difference scheme. Why is this a problem? It is a problem because your optimal decisions will depend on the relative value of the value function in different states: should I cancel now or roll a dice and do nothing (in which case I might get the option to the spread + expected rebate). Now, if there is numerical instability in the HJBs you tend to get oscillation in your decisions if the oscillation in HJB-QVIs hide the option value + expected rebate that is baked in the value function. So, not only are you solving over a huge space of possible book states but you are also solving over a large inventory time grid.



edit: typos etc.


nikol


Total Posts: 1176
Joined: Jun 2005
 
Posted: 2020-09-09 13:02
@bullero

perhaps, you suggest to solve BHJ-problem with Bellman recursive equation on top of Markov discrete process, where decision policy (immediate order execution strategy) is a solution. Since HFT is discrete, it is even more precise way of solving the problem.

bullero


Total Posts: 71
Joined: Feb 2018
 
Posted: 2020-09-09 13:04
@nikol, ;)

Jurassic


Total Posts: 367
Joined: Mar 2018
 
Posted: 2020-09-09 13:39
are we talking about mming on exchanges, because i didnt think the banks had anywhere near the sophiscation of hjb

nikol


Total Posts: 1176
Joined: Jun 2005
 
Posted: 2020-09-09 14:06
@bullero

Once you know "shape" of the solution, it is more optimal to parameterise it. To save the memory and time...

@Jurassic
1. This is applicable to everything I can think of
2. Banks? Why do you ask?

bullero


Total Posts: 71
Joined: Feb 2018
 
Posted: 2020-09-09 16:32
@nikol, interesting idea indeed pm. me with an example

nikol


Total Posts: 1176
Joined: Jun 2005
 
Posted: 2020-09-10 10:06
@bullero

By "shape" I mean this:
while searching for optimum at input you have:
- current state of the market, M
- current inventory (also state), I
- dynamics of future market states, F
- inventory states (depend on strategy, s), FI(s)

You define PnL response to a strategy, S, and solve HJB/Bellman of that S by maximizing PnL.

While solving this (MC or numerically) you should record system response to PnL as measurement points over grid (likely non-regular) of input parameters, M, F, I (they are not numbers, of course, but sets and distributions).

This kind of calculations you do anyway, but as you say you do it slowly. Now, suppose function of dPnL(M+dM,F+dF,I+dI) is smooth. Then you can interpolate it with multi-dim spline and use during short period of time to speed up your decisions.

Strategy is discrete chain of actions, so, dPnL might be far from being smooth. Therefore, you might get more reliable result if you interpolate some intermediate results, like expected filling probabilities. You have to test what actually works. Maybe, factorization is possible to reduce the complexity.

Of course, it is high level view and all complexity is hidden, but you get the idea.

doomanx


Total Posts: 89
Joined: Jul 2018
 
Posted: 2020-09-10 10:37
@nikol might sound meme-ish at this point, but this is kind of how *deep* reinforcement learning works. In vanilla RL you have mapping from state-action pair to decision. If state-action (sa) pair is discrete the space of pairs grows exponentially with each possible state and action, so you instead learn a continuous function f : (s,a) -> d (which will of course be a neural network), where the parameters of f are learned by backpropagation. You can view this as an approximation of what you are suggesting.

I still don't think it would work at all for market making on it's own, but perhaps as a layer on top of a solid base system viewed as a function approximator.

did you use VWAP or triple-reinforced GAN execution?

bullero


Total Posts: 71
Joined: Feb 2018
 
Posted: 2020-09-10 11:28
@nikol and doomanx, I think we are hijacking the thread with our mathematical tangent.

But the intuition about the approximation is a correct approach when the 'curse of dimensionality' kicks in. In fact, it is also feasible in theory (and somewhat in practice). For example, if you consider the HJB what does it tell you? Well, it tells you that _the function_ (that defines your strategy) satisfies a relation that equates to zero. Zero to the power of two is also zero. So if you take a wrong function and plug it into your HJB^2 you get non-zero. At this point, you should go hmmm already.

edit: Which method is very good for overfitting relationships with only a small set of data :)?
Previous Thread :: Next Thread 
Page 1 of 2Goto to page: [1], 2 Next