pub trait MarginModel {
// Required methods
fn calculate_initial_margin(
&self,
instrument: &dyn Instrument,
quantity: Quantity,
price: Price,
leverage: Decimal,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>;
fn calculate_maintenance_margin(
&self,
instrument: &dyn Instrument,
quantity: Quantity,
price: Price,
leverage: Decimal,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>;
}Expand description
Determines how margin requirements are calculated for leveraged positions.
Required Methods§
Sourcefn calculate_initial_margin(
&self,
instrument: &dyn Instrument,
quantity: Quantity,
price: Price,
leverage: Decimal,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
fn calculate_initial_margin( &self, instrument: &dyn Instrument, quantity: Quantity, price: Price, leverage: Decimal, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Calculates the initial (order) margin requirement.
§Errors
Returns an error if margin cannot be computed (e.g. invalid instrument).
Sourcefn calculate_maintenance_margin(
&self,
instrument: &dyn Instrument,
quantity: Quantity,
price: Price,
leverage: Decimal,
use_quote_for_inverse: Option<bool>,
) -> Result<Money>
fn calculate_maintenance_margin( &self, instrument: &dyn Instrument, quantity: Quantity, price: Price, leverage: Decimal, use_quote_for_inverse: Option<bool>, ) -> Result<Money>
Calculates the maintenance (position) margin requirement.
§Errors
Returns an error if margin cannot be computed (e.g. invalid instrument).