pub struct InventoryLedger { /* private fields */ }Expand description
Inventory ledger managing balances and reservations.
Implementations§
Source§impl InventoryLedger
impl InventoryLedger
Sourcepub fn set_balance(&mut self, asset: &AssetId, total: Decimal)
pub fn set_balance(&mut self, asset: &AssetId, total: Decimal)
Set the total balance for an asset (from exchange polling)
Sourcepub fn reserve(
&mut self,
order_id: &ClientOrderId,
asset: &AssetId,
amount: Decimal,
) -> bool
pub fn reserve( &mut self, order_id: &ClientOrderId, asset: &AssetId, amount: Decimal, ) -> bool
Reserve funds for an order Returns true if reservation succeeded, false if insufficient funds
Sourcepub fn release_order(&mut self, order_id: &ClientOrderId)
pub fn release_order(&mut self, order_id: &ClientOrderId)
Release all reservations for an order
Sourcepub fn apply_fill(
&mut self,
side: OrderSide,
base_asset: &AssetId,
quote_asset: &AssetId,
qty: Qty,
price: Price,
fee: &Fee,
)
pub fn apply_fill( &mut self, side: OrderSide, base_asset: &AssetId, quote_asset: &AssetId, qty: Qty, price: Price, fee: &Fee, )
Apply a fill to inventory (spot-style accounting)
Sourcepub fn partial_release(
&mut self,
order_id: &ClientOrderId,
asset: &AssetId,
filled_fraction: Decimal,
)
pub fn partial_release( &mut self, order_id: &ClientOrderId, asset: &AssetId, filled_fraction: Decimal, )
Partially release reservation proportional to a fill
Sourcepub fn set_allocation(&mut self, allocation: StrategyAllocation)
pub fn set_allocation(&mut self, allocation: StrategyAllocation)
Register a strategy allocation
Sourcepub fn check_strategy_budget(
&self,
strategy_id: &StrategyId,
asset: &AssetId,
amount: Decimal,
) -> bool
pub fn check_strategy_budget( &self, strategy_id: &StrategyId, asset: &AssetId, amount: Decimal, ) -> bool
Check if a strategy has budget for an amount
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InventoryLedger
impl RefUnwindSafe for InventoryLedger
impl Send for InventoryLedger
impl Sync for InventoryLedger
impl Unpin for InventoryLedger
impl UnsafeUnpin for InventoryLedger
impl UnwindSafe for InventoryLedger
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
Mutably borrows from an owned value. Read more