Example #1
0
/// <summary>
/// BernardoLedoitRatio:take the sum of the subset of
/// returns that are above 0 and we divide it by the opposite of the sum of
/// the subset of returns that are below 0
/// (正收益率汇总/负收益率汇总;粗略描述胜败比率的总体水平,但注意,负收益率的力量更大,不能满足于1)
/// </summary>
func BernardoLedoitRatio(Ra *utils.SlidingWindow) (float64, error) {
	positivevalues, negativevalues, err := utils.PosNegValues(Ra)
	if err != nil {
		return math.NaN(), err
	}
	return -positivevalues.Sum() / negativevalues.Sum(), nil
}
Example #2
0
/// <summary>
/// Prospect ratio is a ratio used to penalise loss since most people feel loss
/// greater than gain
/// (经验类型调整收益率,给损失赋予更大的权重)
/// </summary>
func ProspectRatio(Ra *utils.SlidingWindow, MAR float64) (float64, error) {
	var n = Ra.Count()
	SigD, err := DownsideDeviation2(Ra, MAR)
	if err != nil {
		return math.NaN(), err
	}

	positivevalues, negativevalues, err := utils.PosNegValues(Ra)
	if err != nil {
		return math.NaN(), err
	}

	var result = ((positivevalues.Sum()+2.25*negativevalues.Sum())/float64(n) - MAR) / SigD
	return result, nil
}