pub fn relative_strength_index(gain: f64, loss: f64) -> Result<f64> {
	if gain < 0. {
		return Err(AnalysisError::GainLessThanZero);
	}
	if loss < 0. {
		return Err(AnalysisError::LossLessThanZero);
	}
	Ok(match loss {
		0. => 100.,
		_ => 100. - 100. / (1. + gain / loss),
	})
}
/// Relative strength index (RSI) is a momentum oscillator developed by J.
/// Welles Wilder Jr. that measures the speed and change of movements. The
/// output of the function oscillates between 0 and 100.
///
/// Wilder suggested in his book that RSI calculation should be based on 14
/// periods. gain and loss arguments are averages for the used period.
///
/// # Arguments
///
/// * `gain` - averege gain for the period
/// * `loss` - averege loss for the period
///
/// # Example
///
/// ```
/// use stat::analysis::momentum;
///
/// let value = momentum::relative_strength_index(60., 20.);
/// assert_eq!(value.ok(), Some(75.));
/// ```
Relative strength index (RSI) is a momentum oscillator developed by J.
Welles Wilder Jr. that measures the speed and change of movements. The
output of the function oscillates between 0 and 100.

Wilder suggested in his book that RSI calculation should be based on 14
periods. gain and loss arguments are averages for the used period.
Relative strength index ( RSI ) is a momentum oscillator developed by J . Welles Wilder Jr . that measures the speed and change of movements . The output of the function oscillates between 0 and 100 . Wilder suggested in his book that RSI calculation should be based on 14 periods . gain and loss arguments are averages for the used period .
pub fn relative_strength_index(gain: f64, loss: f64) -> Result<f64> {
	if gain < 0. {
		return Err(AnalysisError::GainLessThanZero);
	}
	if loss < 0. {
		return Err(AnalysisError::LossLessThanZero);
	}
	Ok(match loss {
		0. => 100.,
		_ => 100. - 100. / (1. + gain / loss),
	})
}
pub fn relative_strength_index ( gain : f64 , loss : f64 ) -> Result < f64 > { if gain < 0. { return Err ( AnalysisError :: GainLessThanZero ) ; } if loss < 0. { return Err ( AnalysisError :: LossLessThanZero ) ; } Ok ( match loss { 0. => 100. , _ => 100. - 100. / ( 1. + gain / loss ) , } ) }
Relative strength index (RSI) is a momentum oscillator developed by J.
Welles Wilder Jr. that measures the speed and change of movements.
Relative strength index ( RSI ) is a momentum oscillator developed by J . Welles Wilder Jr . that measures the speed and change of movements .
gain
f64
loss
f64
example
```
use stat::analysis::momentum.


` ` ` use stat :: analysis :: momentum .