pub struct PaperExchange { /* private fields */ }Expand description
A deterministic, network-free exchange that simulates fills through an internal portfolio. The fill model is documented on the methods below.
Implementations§
Source§impl PaperExchange
impl PaperExchange
Sourcepub fn new() -> PaperExchange
pub fn new() -> PaperExchange
A frictionless spot paper exchange (zero fees, zero slippage). Add costs
with with_fees / with_slippage_bps
and seed the account with with_balance.
Sourcepub fn with_market_type(self, market_type: MarketType) -> PaperExchange
pub fn with_market_type(self, market_type: MarketType) -> PaperExchange
Set the market type this paper account trades (default MarketType::Spot).
Sourcepub fn with_fees(self, maker_bps: Decimal, taker_bps: Decimal) -> PaperExchange
pub fn with_fees(self, maker_bps: Decimal, taker_bps: Decimal) -> PaperExchange
Set the maker and taker fees, in basis points.
Sourcepub fn with_slippage_bps(self, slippage_bps: Decimal) -> PaperExchange
pub fn with_slippage_bps(self, slippage_bps: Decimal) -> PaperExchange
Set the fixed slippage applied to every fill, in basis points.
Sourcepub fn with_balance(
self,
asset: impl Into<String>,
amount: Decimal,
) -> PaperExchange
pub fn with_balance( self, asset: impl Into<String>, amount: Decimal, ) -> PaperExchange
Seed (or top up) the free balance of asset.
Sourcepub fn market_type(&self) -> MarketType
pub fn market_type(&self) -> MarketType
The market type this account trades.
Sourcepub fn set_price(&mut self, symbol: &Symbol, price: Decimal)
pub fn set_price(&mut self, symbol: &Symbol, price: Decimal)
Set the current mark price for symbol, used for fills and the ticker.
Sourcepub fn cancel_all(&mut self) -> u32
pub fn cancel_all(&mut self) -> u32
Cancel every open order, releasing the funds they locked, and return the
number cancelled. This is the actuator a
DeadMansSwitch fires on disconnect.
Trait Implementations§
Source§impl Debug for PaperExchange
impl Debug for PaperExchange
Source§impl Default for PaperExchange
impl Default for PaperExchange
Source§fn default() -> PaperExchange
fn default() -> PaperExchange
Source§impl Exchange for PaperExchange
impl Exchange for PaperExchange
Source§impl Execution for PaperExchange
impl Execution for PaperExchange
Source§fn place_order(&mut self, request: &OrderRequest) -> Result<Order, Error>
fn place_order(&mut self, request: &OrderRequest) -> Result<Order, Error>
Source§fn cancel_order(
&mut self,
_symbol: &Symbol,
order_id: &str,
) -> Result<(), Error>
fn cancel_order( &mut self, _symbol: &Symbol, order_id: &str, ) -> Result<(), Error>
Source§fn query_order(
&mut self,
_symbol: &Symbol,
order_id: &str,
) -> Result<Order, Error>
fn query_order( &mut self, _symbol: &Symbol, order_id: &str, ) -> Result<Order, Error>
Source§impl MarketData for PaperExchange
impl MarketData for PaperExchange
Source§fn ticker(&mut self, symbol: &Symbol) -> Result<Ticker, Error>
fn ticker(&mut self, symbol: &Symbol) -> Result<Ticker, Error>
symbol. Read moreSource§fn klines(
&mut self,
_symbol: &Symbol,
_interval: &str,
_limit: u32,
) -> Result<Vec<Candle>, Error>
fn klines( &mut self, _symbol: &Symbol, _interval: &str, _limit: u32, ) -> Result<Vec<Candle>, Error>
limit historical candles for symbol at the given interval
(e.g. "1m", "1h"). Returns wickra_core::Candles so the result
feeds the indicator core directly. Read moreSource§fn order_book(
&mut self,
_symbol: &Symbol,
_depth: u32,
) -> Result<OrderBookSnapshot, Error>
fn order_book( &mut self, _symbol: &Symbol, _depth: u32, ) -> Result<OrderBookSnapshot, Error>
Source§fn subscribe_trades(&mut self, _symbol: &Symbol) -> Result<(), Error>
fn subscribe_trades(&mut self, _symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn subscribe_book(&mut self, _symbol: &Symbol) -> Result<(), Error>
fn subscribe_book(&mut self, _symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn subscribe_ticker(&mut self, _symbol: &Symbol) -> Result<(), Error>
fn subscribe_ticker(&mut self, _symbol: &Symbol) -> Result<(), Error>
symbol. Read moreSource§fn poll_events(&mut self) -> Vec<Event>
fn poll_events(&mut self) -> Vec<Event>
Auto Trait Implementations§
impl Freeze for PaperExchange
impl RefUnwindSafe for PaperExchange
impl Send for PaperExchange
impl Sync for PaperExchange
impl Unpin for PaperExchange
impl UnsafeUnpin for PaperExchange
impl UnwindSafe for PaperExchange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more