1
$\begingroup$

I am trying to implement my own exchange with simulated data and test some strategies on such data. What would be the best way to go about modelling the data that supports live interaction ( limit/market orders ) executed by my bot?

Simulating data on it's own seems easy, I can simulate bid and ask separetely using real world data, extrapolating prices from that and adding a probability distribution on top of it. But I am not certain how to adjust data given that I will be directly impacting the order books in somewhat realistic way.

$\endgroup$
  • $\begingroup$ What are you trying to achieve with this setup? $\endgroup$ – vonjd Aug 4 '19 at 16:56
  • $\begingroup$ Its more of a learning project. Just would like to simulate an exchange and try to implement some strategies for it. $\endgroup$ – Paul Aug 4 '19 at 17:06
  • $\begingroup$ Ok... so what exactly are you trying to learn then? $\endgroup$ – vonjd Aug 4 '19 at 17:07
  • $\begingroup$ Smart order routing, reinforcement learning and efficient implementation of order books. Also some common models to simulate market data. I have seen a few papers on those but I am not certain how to implement them and actually trade myself without breaking them $\endgroup$ – Paul Aug 4 '19 at 17:11
  • $\begingroup$ You are going to have a very hard time trying to solve this. Try to pipe in crypto exhange data, which is much easier to acquire. $\endgroup$ – jason m Aug 5 '19 at 1:44
2
$\begingroup$

As a starting point I would make the assumption that your new orders are negligibly small, in order that their market impact does not affect the trajectory of the price. This will provide a reasonable way to test strategies that do not possess any forward looking or snooping data.

When you are in the position that your actions are believed to impact the orderbook I would engineer some solution that disadvantages your position. Of course you must be careful not to adapt your algorithm to respond well to your own adversarial design (which may not really be reflective of the true market).

I have never used it but I believe Quantopian introduces this kind of concept as a trading drag in its back testing, essentially as an additional cost to transactions. Market impact is often empirically stated as $k\sqrt{V}$, i.e. some value (a constant or value dependent upon volatiliy and average volume) multiplied by the root of your volume.

Over the course of many transactions you would probably encounter the fact that any market impact arising from your transactions can be equivocated to a average increased transaction cost. You may never be able to predict which precise transactions are impacted or to what degree each transaction will be affected but by the law of large numbers / central limit theorem the total impact can be assessed with high confidence.

| improve this answer | |
$\endgroup$
  • $\begingroup$ If he recorded the exchange's message book, he could reconstruct the orderbook at any given moment in time, and (depending on the number of rows the exchange provided) market impact would then be explicitly modelled as a theoretical fills against resting depth in the book inside his exchange simulator. $\endgroup$ – wildbunny Aug 9 '19 at 10:21
  • $\begingroup$ By $k\sqrt{v}$ are you referring to sigma-root-liquidity model? Are there any papers on back testing I can look into? $\endgroup$ – Paul Aug 11 '19 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.