pub struct RiskEngine;Implementations§
Source§impl RiskEngine
impl RiskEngine
Sourcepub fn assess_risk_level(utilization_pct: u8) -> RiskLevel
pub fn assess_risk_level(utilization_pct: u8) -> RiskLevel
Assess overall risk level based on utilization
Sourcepub fn get_leverage_multiplier(risk_level: RiskLevel) -> u8
pub fn get_leverage_multiplier(risk_level: RiskLevel) -> u8
Calculate dynamic leverage multiplier based on risk level
Sourcepub fn calculate_max_leverage(utilization_pct: u8, base_leverage: u8) -> u8
pub fn calculate_max_leverage(utilization_pct: u8, base_leverage: u8) -> u8
Calculate maximum allowed leverage based on utilization
Sourcepub fn calculate_margin_requirement(
position_value: u64,
leverage: u8,
) -> Result<u64>
pub fn calculate_margin_requirement( position_value: u64, leverage: u8, ) -> Result<u64>
Calculate margin requirement for a position
Sourcepub fn calculate_liquidation_price(
entry_price: u64,
leverage: u8,
is_long: bool,
) -> Result<u64>
pub fn calculate_liquidation_price( entry_price: u64, leverage: u8, is_long: bool, ) -> Result<u64>
Calculate liquidation price considering fees
Sourcepub fn calculate_var_95(position_value: u64, volatility_bps: u16) -> Result<u64>
pub fn calculate_var_95(position_value: u64, volatility_bps: u16) -> Result<u64>
Calculate Value at Risk (95% confidence)
Sourcepub fn stress_test_position(
position: &Position,
price_shock_bps: u16,
) -> Result<(i64, bool)>
pub fn stress_test_position( position: &Position, price_shock_bps: u16, ) -> Result<(i64, bool)>
Stress test a portfolio
Sourcepub fn calculate_funding_fee(
open_interest: u64,
available_liquidity: u64,
time_passed_hours: u32,
) -> Result<u64>
pub fn calculate_funding_fee( open_interest: u64, available_liquidity: u64, time_passed_hours: u32, ) -> Result<u64>
Calculate funding fee impact
Sourcepub fn calculate_insurance_requirement(
total_open_interest: u64,
current_insurance: u64,
) -> Result<(u64, bool)>
pub fn calculate_insurance_requirement( total_open_interest: u64, current_insurance: u64, ) -> Result<(u64, bool)>
Calculate insurance fund requirement
Auto Trait Implementations§
impl Freeze for RiskEngine
impl RefUnwindSafe for RiskEngine
impl Send for RiskEngine
impl Sync for RiskEngine
impl Unpin for RiskEngine
impl UnsafeUnpin for RiskEngine
impl UnwindSafe for RiskEngine
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
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>
Converts
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>
Converts
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