package obook

All checked builds pass
  1. Overview
  2. Docs
Zero-allocation L3 limit order book and streaming HFT math in pure OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v1.0.0.tar.gz
sha256=059c1cd865ee1364e685dd57b1be0f8dd8b6feaa129c62e25f4673cbb8b2ab15
sha512=830508c1acfb828b30367715cd3e531e08a2404b7163f8da9b4347dc35a326321c1cc3bb05ee5c5e7f723064c68b00257b2dc551d1014d15e3ff03ed5a3a8e5c

doc/obook/Obook/Book/index.html

Module Obook.BookSource

Zero-allocation L3 Limit Order Book & Matching Engine. Supports GTC, IOC, FOK (with read-only pre-scan), Post-Only, Iceberg orders, Self-Trade Prevention (STP), O(1) cancel/amend, and integrated streaming quant stats.

Sourcetype side = Arena.side =
  1. | Bid
  2. | Ask
Sourcetype tif =
  1. | GTC
  2. | IOC
  3. | FOK
  4. | Post_only
Sourcetype stp_mode =
  1. | Stp_none
  2. | Cancel_newest
  3. | Cancel_oldest
  4. | Decrement_and_cancel
Sourcetype status =
  1. | Resting
  2. | Partial_and_resting
  3. | Filled
  4. | Cancelled_ioc
  5. | Cancelled_stp
  6. | Rejected_fok
  7. | Rejected_post_only
  8. | Rejected_duplicate_id
  9. | Rejected_arena_full
  10. | Rejected_invalid_qty
Sourcetype fill = {
  1. maker_id : int;
  2. taker_id : int;
  3. px : Fixed.t;
  4. qty : Fixed.t;
  5. maker_side : side;
  6. ts : int64;
}
Sourcetype exec_report = {
  1. order_id : int;
  2. status : status;
  3. req_qty : Fixed.t;
  4. filled_qty : Fixed.t;
  5. resting_qty : Fixed.t;
  6. cancelled_qty : Fixed.t;
  7. fills : fill list;
}
Sourcetype level_snap = {
  1. px : Fixed.t;
  2. disp_qty : Fixed.t;
  3. hid_qty : Fixed.t;
  4. orders : int;
}
Sourcetype order_snap = {
  1. id : int;
  2. trader : int;
  3. side : side;
  4. px : Fixed.t;
  5. disp_qty : Fixed.t;
  6. hid_qty : Fixed.t;
  7. ts : int64;
}
Sourcetype t
Sourceval create : ?capacity:int -> ?stp:stp_mode -> ?vpin_bucket_vol:Fixed.t -> ?vpin_buckets:int -> symbol:string -> unit -> t
Sourceval clear : t -> unit
Sourceval symbol : t -> string
Sourceval order_count : t -> int
Sourceval trade_count : t -> int
Sourceval volume_traded : t -> Fixed.t
Sourceval add_limit : t -> id:int -> ?trader:int -> side:side -> px:Fixed.t -> qty:Fixed.t -> ?tif:tif -> ?iceberg_peak:Fixed.t -> ?ts:int64 -> unit -> exec_report
Sourceval add_market : t -> id:int -> ?trader:int -> side:side -> qty:Fixed.t -> ?ts:int64 -> unit -> exec_report
Sourceval cancel : t -> id:int -> (Fixed.t, [> `Not_found ]) result
Sourceval amend : t -> id:int -> new_px:Fixed.t -> new_qty:Fixed.t -> ?ts:int64 -> unit -> (exec_report, [> `Not_found ]) result
Sourceval best_bid : t -> (Fixed.t * Fixed.t) option
Sourceval best_ask : t -> (Fixed.t * Fixed.t) option
Sourceval bbo : t -> (Fixed.t * Fixed.t) option * (Fixed.t * Fixed.t) option
Sourceval mid : t -> Fixed.t option
Sourceval spread : t -> Fixed.t option
Sourceval micro_px : t -> Fixed.t option
Sourceval imbalance : t -> float option
Sourceval depth : t -> ?levels:int -> unit -> level_snap list * level_snap list
Sourceval l3_orders : t -> side:side -> px:Fixed.t -> order_snap list
Sourceval find_order : t -> id:int -> order_snap option
Sourceval mid_stats : t -> Stats.Welford.t
Sourceval mid_ewma : t -> Stats.Ewma.t
Sourceval ofi : t -> Stats.Ofi.t
Sourceval vpin : t -> Stats.Vpin.t
Sourceval roll : t -> Stats.Roll.t
Sourceval verify_report_conservation : exec_report -> bool
Sourceval audit : t -> (unit, string) result