Expand description
Embeddable pre-trade risk engine for trading systems.
openpit focuses on the moment before an order leaves the application.
The crate provides:
Engineto coordinate pre-trade checks and post-trade feedback;paramfor typed financial values such asparam::Priceandparam::Pnl;pretradefor policy traits, rejects, deferred requests, and reservations.
The pipeline is intentionally explicit:
Engine::start_pre_traderuns start-stage policies and returns apretrade::Request.pretrade::Request::executeruns main-stage policies and returns apretrade::Reservation.pretrade::Reservation::commitorpretrade::Reservation::rollbackfinalizes reserved state.Engine::apply_execution_reportfeeds realized outcomes back into policies.
The current crate scope is deliberately narrow: in-memory admission control, exact decimal value types, and a small set of built-in start-stage policies. Persistence, market connectivity, and thread synchronization stay with the caller.
Re-exports§
pub use pretrade::PostTradeResult;
Modules§
- param
- Parameter value types for trading operations.
- pretrade
- Pre-trade pipeline types and extension points.
Macros§
- has_
request_ field_ trait - A macro to generate the trait that requests a specific field from the request.
- impl_
request_ has_ field
Structs§
- Engine
- Risk engine orchestrating start-stage and main-stage pre-trade checks.
- Engine
Builder - Fluent builder for
Engine. - Execution
Report Fill Details - Data: trade reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Execution
Report Operation - Data: main operation parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Execution
Report Position Impact - Data: position impact parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Financial
Impact - Data: financial impact parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Instrument
- Trading instrument definition.
- Order
Margin - Data: margin configuration parameters.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Order
Operation - Data: main operation parameters that describe side, instrument, price, and amount.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - Order
Position - Data: position management parameters.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Execution Report Fill Details - Adds financial impact parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Execution Report Operation - Adds main operation parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Execution Report Position Impact - Adds position impact parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Financial Impact - Adds financial impact parameters reported by the execution.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Order Margin - Adds margin configuration parameters.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Order Operation - Adds main operation parameters that describe side, instrument, price, and amount.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates. - With
Order Position - Adds position management parameters.
No
#[non_exhaustive]: these are client-facing convenience structs meant to be constructed via struct literals from external crates.
Enums§
- Engine
Build Error - Errors returned by
EngineBuilder::build.
Traits§
- HasAuto
Borrow - HasClose
Position - HasExecution
Report IsTerminal - HasExecution
Report Last Trade - HasExecution
Report Position Effect - HasExecution
Report Position Side - HasFee
- HasInstrument
- HasLeaves
Quantity - Remaining order quantity after the fill.
- HasLock
- Reservation lock context captured during pre-trade.
- HasOrder
Collateral Asset - HasOrder
Leverage - HasOrder
Position Side - HasOrder
Price - Requested worst execution price used for size translation and price-sensitive checks.
- HasPnl
- HasReduce
Only - HasSide
- HasTrade
Amount