Skip to main content

Module margin

Module margin 

Source
Expand description

Margin borrowing: the borrow and repay policy a margin account applies to its orders, the simulated venue’s spot margin configuration, and the interest it charges on its loans.

MarginEffect is what an order does to a margin account’s loans: borrow what it lacks, repay from what it receives, or neither. A live margin client sends it with each order, and the simulated venue applies it when SpotMarginConfig turns its spot margin on. A MarginInterestModel prices those loans over time; PeriodicMarginInterest is the built-in one. A margin client that learns what an order borrowed reports it as a MarginBorrow, in a MarginPlacement.

Structs§

InterestCharge
One charge a MarginInterestModel makes on one loan.
MarginBorrow
A loan a margin order took out when it was placed: amount of asset.
MarginPlacement
The answer to placing a margin order: the order, and what it borrowed.
PeriodicMarginInterest
Margin interest charged a period at a time, at an annualised rate per asset: a crypto margin account’s hourly interest.
SpotMarginConfig
Spot margin on the simulated venue: what it lends a spot order, how much, and what it repays.
SpotMarginLiquidation
When the simulated venue liquidates a spot margin account, what it charges for it, and whether it warns first. Set by SpotMarginConfig::with_liquidation.

Enums§

InterestDue
When a MarginInterestModel is asked to charge a loan.
InterestSchedule
When a PeriodicMarginInterest charges a loan.
MarginEffect
What an order does to a margin account’s loans: borrow what it lacks, repay from what it receives, or touch neither.
SpotMarginConfigError
Why a SpotMarginConfig was refused.

Traits§

MarginInterestModel
Charges interest on a simulated margin loan: once when the loan is taken, and at boundaries in time while it stays open.