Skip to main content

Module paper_exchange

Module paper_exchange 

Source
Expand description

Paper Exchange: Simulates order execution using real quotes.

Wraps a real exchange for quote data but simulates fills locally. Orders fill when the quote price crosses the order price. Uses FillSimulator for shared fill matching logic. Uses MarginLedger for accurate perp margin accounting.

Structs§

ArcExchange
Newtype wrapper around Arc<dyn Exchange> to implement Exchange trait. This allows PaperExchange to wrap any Arc<dyn Exchange> while satisfying orphan rules.
NoOpExchange
Minimal exchange that does nothing - used internally by PaperExchange::new_standalone() All quotes come from queue_quotes/inject_quote, not from this exchange.
PaperExchange
Paper Exchange - wraps a real exchange for quotes, simulates fills locally.

Functions§

create_standalone_paper_exchange
Create a standalone paper exchange for backtesting without any inner exchange. Uses queue_quotes() or inject_quote() for price data.
create_standalone_paper_exchange_with_id
Create a standalone paper exchange with a custom exchange ID and environment. Use exchange_id = “hyperliquid” and environment = Mainnet for backtest mode compatibility.

Type Aliases§

StandalonePaperExchange
Type alias for standalone PaperExchange (no inner exchange dependency)