Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

will-thompson-k/microstructure-plotter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microstructure-plotter

For those of you in the trenches, I offer ye this tool ⚔️

This is a plotting tool designed to help visualize financial market data 📈 and trading system behavior 🤖 on the smallest timescales 🔎.

As all things in life, when it comes to financial microstructure: the devil 😈 is in the details

Built using Chaco 🌮

See the illustrated example for a deep dive into what this plotting tool can uncover 🔎.

zoooooom

tts

orders

Contents

⚠️Disclaimer

There is no α here. This is just a fancy wrapper on top of an open-source plotting package.

You should B.Y.O.A (Bring Your Own Alpha).

However...for the trained eye 👁️, this simple type of visualization can be immensely helpful.

✨Features

Here are some useful features to take note of 🥁:

  1. ✨Plot multiple 🤹, asynchronous (unsampled) microstructure elements together on the sample plot: order book quotes, trades, orders, order acks, fills etc etc
  2. ✨Analyze events on seconds, milliseconds, microseconds, nanoseconds 🕳️ : zoom 🔎 in on the most granular time unit available to microstructure behavior
  3. ✨All axes are 🔗linked : 🔎 zoom in on one product, see what's happening in all others at that same timestamp

🧠Illustrated Example

To show why a tool like this might be useful, here is an example motivated from things seen in the wild.

Note: This data was painstakingly created by hand 🤌 to appear quasi-realistic. I am not an artist 🧑‍🎨 nor is this real 🌎 data.

See the legend 👇 to understand the plots further.

🧪Test It Out Right Now

After installing the package either via pip or via setup.py, run this quick line to see this in action right now:

bash examples/example_1/plot_example.sh

or

python examples/example_1/plot_example.py

Right-click 🖱️ to zoom in on different parts of the plot to see what is happening on smaller and smaller timescales 🔎. Consult the legend or illustrated example for more clarity on how to interpret the plots.

🗺️Plots Legend

Here is a complete legend of everything the plotter can visualize.

💸Free Advice

  1. Don't log in prod ✏️ (unless logging isn't occuring on the hot path).
  2. Make sure the timestamps are from ⏰ synchronized clocks ⏰ (better if geosync'd/GPS) with enough precision, otherwise these plots will be uninformative or misleading. If you don't trust others' timestamps, do your own capture.
  3. This plotter is memory intensive 🧠. Don't try to plot too much at once.

✏️Data Schema

This plotting module expects a specific data schema.

🤔What is "Market Microstructure"?

For the uninitiated, here is a ⏰ 30 second primer ⏰ on market microstructure.

🛞Installation

You can install the repo using pip directly:

pip install git+https://github.com/will-thompson-k/microstructure-plotter

Alternatively you can use the setup.py.

📜Reqs

Python 3.7+ recommended.

Here are the package requirements (found in requirements.txt)

  • chaco==5.1.0
  • enable==5.3.1
  • traits==6.4.1
  • traitsui==7.4.2
  • pandas==1.3.5
  • pyqt

𓊍To Do

  • add more order types: modifies, equity order types, etc.
  • add "decision boundary" of model: bid/ask edges, etc.
  • unit tests

Citation

@misc{microstructure-plotter,
  author = {Thompson, Will},
  url = {https://github.com/will-thompson-k/microstructure-plotter},
  year = {2023}
}

License

MIT