pub struct RiskManager { /* private fields */ }Expand description
Risk manager for portfolio risk calculations
Implementations§
Source§impl RiskManager
impl RiskManager
Source§impl RiskManager
impl RiskManager
pub fn into_reference( val: RiskManager, env: Env, ) -> Result<Reference<RiskManager>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<RiskManager>>
Source§impl RiskManager
impl RiskManager
Sourcepub fn new(config: RiskConfig) -> Self
pub fn new(config: RiskConfig) -> Self
Create a new risk manager
Sourcepub fn calculate_var(
&self,
returns: Vec<f64>,
portfolio_value: f64,
) -> Result<VaRResult>
pub fn calculate_var( &self, returns: Vec<f64>, portfolio_value: f64, ) -> Result<VaRResult>
Calculate Value at Risk
Sourcepub fn calculate_cvar(
&self,
returns: Vec<f64>,
portfolio_value: f64,
) -> Result<CVaRResult>
pub fn calculate_cvar( &self, returns: Vec<f64>, portfolio_value: f64, ) -> Result<CVaRResult>
Calculate Conditional VaR (Expected Shortfall)
Sourcepub fn calculate_kelly(
&self,
win_rate: f64,
avg_win: f64,
avg_loss: f64,
) -> Result<KellyResult>
pub fn calculate_kelly( &self, win_rate: f64, avg_win: f64, avg_loss: f64, ) -> Result<KellyResult>
Calculate Kelly Criterion for position sizing
Sourcepub fn calculate_drawdown(
&self,
equity_curve: Vec<f64>,
) -> Result<DrawdownMetrics>
pub fn calculate_drawdown( &self, equity_curve: Vec<f64>, ) -> Result<DrawdownMetrics>
Calculate drawdown metrics
Sourcepub fn calculate_position_size(
&self,
portfolio_value: f64,
price_per_share: f64,
risk_per_trade: f64,
stop_loss_distance: f64,
) -> Result<PositionSize>
pub fn calculate_position_size( &self, portfolio_value: f64, price_per_share: f64, risk_per_trade: f64, stop_loss_distance: f64, ) -> Result<PositionSize>
Calculate recommended position size
Trait Implementations§
Source§impl FromNapiMutRef for RiskManager
impl FromNapiMutRef for RiskManager
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for RiskManager
impl FromNapiRef for RiskManager
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &RiskManager
impl FromNapiValue for &RiskManager
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut RiskManager
impl FromNapiValue for &mut RiskManager
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for RiskManager
impl ToNapiValue for RiskManager
Source§unsafe fn to_napi_value(env: napi_env, val: RiskManager) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: RiskManager) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &RiskManager
impl TypeName for &RiskManager
Source§impl TypeName for &mut RiskManager
impl TypeName for &mut RiskManager
Source§impl TypeName for RiskManager
impl TypeName for RiskManager
Source§impl ValidateNapiValue for &RiskManager
impl ValidateNapiValue for &RiskManager
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut RiskManager
impl ValidateNapiValue for &mut RiskManager
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for RiskManager
impl RefUnwindSafe for RiskManager
impl Send for RiskManager
impl Sync for RiskManager
impl Unpin for RiskManager
impl UnwindSafe for RiskManager
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