Skip to main content

Module risk

Module risk 

Source
Expand description

Standalone risk analytics.

Requires the risk feature flag (which implies indicators).

Provides Value at Risk, Sharpe/Sortino/Calmar ratios, beta, and max drawdown as standalone metrics — independent of the backtesting engine.

§Quick Start

use finance_query::{Ticker, Interval, TimeRange};

let ticker = Ticker::new("AAPL").await?;
let summary = ticker.risk(Interval::OneDay, TimeRange::OneYear, None).await?;

println!("VaR (95%):      {:.2}%", summary.var_95 * 100.0);
println!("Max drawdown:   {:.2}%", summary.max_drawdown * 100.0);
if let Some(sharpe) = summary.sharpe {
    println!("Sharpe ratio:   {sharpe:.2}");
}

Structs§

RiskSummary
Comprehensive risk summary for a symbol.

Functions§

beta
Compute the beta of an asset relative to a benchmark.
calmar_ratio
Compute the Calmar Ratio: annualised return divided by maximum drawdown.
historical_var
Compute historical VaR at the given confidence level.
max_drawdown
Compute the maximum drawdown from a return series.
parametric_var
Compute parametric (variance-covariance) VaR assuming normally distributed returns.
sharpe_ratio
Compute the annualised Sharpe Ratio.
sortino_ratio
Compute the annualised Sortino Ratio (penalises only downside volatility).