Pipeline¶
The main orchestrator. Runs the full sequence: load → build trades →
classify → depth. Use Pipeline(format=...) for LOBSTER or other registered
formats, or pass individual components (loader=, trade_source=) to override
specific stages. Flow-toxicity metrics are computed after the run by calling
compute_vpin / compute_kyle_lambda / order_flow_imbalance on
result.trades.
Pipeline ¶
Pipeline(
config: PipelineConfig | None = None,
*,
format: Format | None = None,
loader: EventLoader | None = None,
trade_source: TradeSource | None = None,
ctx: RunContext | None = None,
)
Configurable, composable order book analytics pipeline.
Each processing stage is handled by a pluggable component that satisfies the corresponding protocol. Pass your own implementations to override any stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PipelineConfig
|
Central configuration. Passed to default components when they are not explicitly provided. |
None
|
format
|
Format
|
A format descriptor that provides default loader, trade source, writer, and config overrides. Explicit component arguments take precedence over format defaults. |
None
|
loader
|
EventLoader
|
Loads raw events from a data source. Defaults to
:class: |
None
|
trade_source
|
TradeSource
|
Builds the trades DataFrame. Defaults to
:class: |
None
|
from_format
classmethod
¶
Create a pipeline from a registered format name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Registered format name (case-insensitive), e.g. |
required |
ctx
|
RunContext
|
Per-run parameters (e.g. |
None
|
**kwargs
|
Any
|
Passed to the :class: |
{}
|
run ¶
Execute the full pipeline on source and return results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
Data source for the loader (typically a file path). |
required |
ctx
|
RunContext
|
Override the pipeline's default :class: |
None
|
Returns:
| Type | Description |
|---|---|
PipelineResult
|
Frozen dataclass with |
Steps
- Load events (
EventLoader.load) - Build trades (
TradeSource.load) - Classify order types
- Compute price-level depth
- Compute depth metrics
- Compute order aggressiveness
PipelineResult
dataclass
¶
PipelineResult(
events: DataFrame,
trades: DataFrame,
depth: DataFrame,
depth_summary: DataFrame,
config: PipelineConfig,
)
Immutable container for the core outputs of a pipeline run.
Analytic outputs (VPIN, OFI, Kyle's λ) are intentionally not stored
here — compute them post-pipeline from trades and append them to the
gallery model's analytics (build panels with the *_panel helpers).
Attributes:
| Name | Type | Description |
|---|---|---|
events, trades, depth, depth_summary |
DataFrame
|
Core pipeline tables. |
config |
PipelineConfig
|
The configuration used for the run. |
plot ¶
plot(
concept: str,
level: Any = None,
*,
backend: str = "matplotlib",
volume_scale: float | None = None,
**overrides: Any,
) -> Any
Render one plot concept from this result in a single call.
Thin convenience wrapper over
:func:ob_analytics.visualization.plot_result, e.g.
result.plot("depth_heatmap", col_bias=0.1). See
:func:~ob_analytics.visualization.available_concepts for what a given
result can plot (it varies by format).
Format registry¶
register_format ¶
Register a :class:Format implementation under name for lookup via
:meth:Pipeline.from_format.