Visualization API¶
The lumina_lob.viz package provides Matplotlib-based plotting and animation export.
lumina_lob.viz.depth_ladder
¶
Depth-ladder visualization for an order book.
Functions:¶
plot_depth_ladder(book, top_n=10)
¶
Render a horizontal depth-ladder plot for book.
Parameters¶
book:
An OrderBook instance (Python lumina_lob.core.OrderBook or the
C++ lumina_lob._core.OrderBook).
top_n:
Number of price levels to show on each side.
Returns¶
(fig, ax) from matplotlib.
Source code in lumina_lob/viz/depth_ladder.py
lumina_lob.viz.history
¶
Time-series visualisation for simulation history.
Functions:¶
plot_simulation_history(history)
¶
Plot mid price, spread, and trades from a simulation history.
Parameters¶
history:
A list of step records (as returned by Simulation.run) or a
pandas.DataFrame produced by Simulation.to_dataframe().
Returns¶
(fig, axes) from matplotlib. axes is a 3-element array with:
- mid price + trade markers
- bid-ask spread
- trade volume per step
Source code in lumina_lob/viz/history.py
lumina_lob.viz.realtime
¶
Real-time simulation visualisation using matplotlib.
Classes¶
SimulationAnimator
¶
Animate a running Simulation with depth ladder + mid-price trace.
Source code in lumina_lob/viz/realtime.py
Methods:¶
run(n_steps=100)
¶
Return a FuncAnimation that runs n_steps frames.
Source code in lumina_lob/viz/realtime.py
update(_frame=None)
¶
Advance the simulation by one step and redraw both panels.
Source code in lumina_lob/viz/realtime.py
Functions:¶
run_animation(simulation, n_steps=100, top_n=10, history_window=50, interval_ms=200)
¶
Create and return a running animation for simulation.
Parameters¶
simulation:
The Simulation to animate.
n_steps:
Number of animation frames.
top_n:
Number of price levels to show on each side of the depth ladder.
history_window:
How many recent steps to show in the mid-price trace.
interval_ms:
Delay between frames in milliseconds.
Returns¶
A matplotlib.animation.FuncAnimation instance. Call plt.show() or
save it to display/record.
Source code in lumina_lob/viz/realtime.py
save_animation(animation, path, fps=5)
¶
Save a simulation animation to path as GIF or MP4.
Parameters¶
animation:
A matplotlib.animation.FuncAnimation instance (e.g. from
run_animation).
path:
Destination file path. Supported extensions: .gif (requires
Pillow) and .mp4 (requires ffmpeg).
fps:
Frames per second for the output file.
Raises¶
ValueError If the file extension is unsupported or the required writer is not available.