pub struct RiskGuard { /* private fields */ }Implementations§
Source§impl RiskGuard
impl RiskGuard
pub fn new(config: RiskConfig) -> Self
Sourcepub fn with_ta_rules(config: RiskConfig, ta_rules: Vec<TaRiskRule>) -> Self
pub fn with_ta_rules(config: RiskConfig, ta_rules: Vec<TaRiskRule>) -> Self
Create a RiskGuard with both standard config and TA-based risk rules.
Sourcepub fn set_ta_rules(&mut self, rules: Vec<TaRiskRule>)
pub fn set_ta_rules(&mut self, rules: Vec<TaRiskRule>)
Replace the current TA risk rules.
Sourcepub fn update_config(&mut self, config: RiskConfig)
pub fn update_config(&mut self, config: RiskConfig)
Update the risk config (e.g. when user saves new settings).
Sourcepub fn check_order_with_ta(
&self,
order: &OrderRequest,
current_state: &AccountState,
indicators: &TechnicalIndicators,
) -> Result<(), RiskViolation>
pub fn check_order_with_ta( &self, order: &OrderRequest, current_state: &AccountState, indicators: &TechnicalIndicators, ) -> Result<(), RiskViolation>
Check an order against all enabled risk rules including TA-based rules.
Returns Ok(()) if the order is allowed, or Err with the first
blocking violation. If you only want TA violations without blocking
the order, call check_ta_risk directly.
Sourcepub fn check_order(
&self,
order: &OrderRequest,
current_state: &AccountState,
) -> Result<(), RiskViolation>
pub fn check_order( &self, order: &OrderRequest, current_state: &AccountState, ) -> Result<(), RiskViolation>
Check an order against all enabled risk rules. Returns Ok(()) if the order is allowed, Err(RiskViolation) if blocked.
Sourcepub fn is_circuit_breaker_tripped(&self) -> bool
pub fn is_circuit_breaker_tripped(&self) -> bool
Returns whether the circuit breaker is currently tripped.
Auto Trait Implementations§
impl !Freeze for RiskGuard
impl RefUnwindSafe for RiskGuard
impl Send for RiskGuard
impl Sync for RiskGuard
impl Unpin for RiskGuard
impl UnsafeUnpin for RiskGuard
impl UnwindSafe for RiskGuard
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