Skip to main content

total_return

Function total_return 

Source
pub fn total_return(equity: &[Decimal]) -> Result<Decimal, MetricsError>
Expand description

Calculate total return as a percentage.

Formula: (end - start) / start * 100

§Arguments

  • equity - Equity curve (NAV or portfolio value over time)

§Returns

Total percentage return, or error if insufficient data.

§Example

use quant_metrics::total_return;
use rust_decimal_macros::dec;

let equity = vec![dec!(10000), dec!(10500)];
assert_eq!(total_return(&equity).unwrap(), dec!(5)); // 5%