performance

package
v0.0.0-...-b314203 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

是在未来将会废弃的基于天收益序列计算指标的模块,由于大量不恰当的使用了sliding window,导致性能不佳

Index

Constants

This section is empty.

Variables

View Source
var PerformanceMap map[string]Performance

Functions

func ActivePremium

func ActivePremium(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64) (float64, error)

/ <summary> /Active Premium / The return on an investment's annualized return minus the benchmark's / annualized return. / Active Premium = Investment's annualized return - Benchmark's annualized / </summary>

func AdjustedSharpeRatio

func AdjustedSharpeRatio(Ra *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

/ <summary> / Adjusted Sharpe ratio of the return distribution / Adjusted Sharpe ratio was introduced by Pezier and White (2006) to adjusts / for skewness and kurtosis by incorporating a penalty factor for negative skewness / and excess kurtosis. / </summary>

func Alpha

func Alpha(Ra, Rb, Rf *utils.SlidingWindow) (float64, error)

/ <summary> / 阿尔法 / </summary> / <param name="Ra"></param> / <param name="Rb"></param> / <param name="Rf"></param> / <returns></returns>????

func Alpha2

func Alpha2(Ra, Rb *utils.SlidingWindow, Rf float64) (float64, error)

func Annualized

func Annualized(returns *utils.SlidingWindow, scale float64, geometric bool) (float64, error)

/ <param name="returns"></param> / <param name="scale"></param> / <param name="geometric"></param> / <returns></returns>

func AppraisalRatio

func AppraisalRatio(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64, method string) (float64, error)

/ <summary> / Appraisal ratio is the Jensen's alpha adjusted for specific risk. The numerator / is divided by specific risk instead of total risk. / </summary>

func AverageDrawdown

func AverageDrawdown(Ra *utils.SlidingWindow) (float64, error)

func AverageLength

func AverageLength(Ra *utils.SlidingWindow) (float64, error)

func AverageRecovery

func AverageRecovery(Ra *utils.SlidingWindow) (float64, error)

func BernardoLedoitRatio

func BernardoLedoitRatio(Ra *utils.SlidingWindow) (float64, error)

/ <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 Beta

func Beta(Ra, Rb, Rf *utils.SlidingWindow) (float64, error)

func Beta2

func Beta2(Ra, Rb *utils.SlidingWindow, Rf float64) (float64, error)

func BurkeRatio

func BurkeRatio(Ra *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

/ <summary> / To calculate Burke ratio we take the difference between the portfolio / return and the risk free rate and we divide it by the square root of the / sum of the square of the drawdowns. To calculate the modified Burke ratio / we just multiply the Burke ratio by the square root of the number of datas. / (一种调整收益率的计算方式,调整是通过drawdown的平方和进行的) / </summary>

func CMLSlope

func CMLSlope(Rb *utils.SlidingWindow, Rf float64) (float64, error)

func CMLSlope2

func CMLSlope2(Rb *utils.SlidingWindow, Rf float64) (float64, error)

/ <summary> / 斜率 / </summary> / <param name="Rb"></param> / <param name="Rf"></param> / <returns></returns>

func Calculate

func Calculate(prices *utils.SlidingWindow, method string) (*utils.SlidingWindow, error)

/ <param name="prices"></param> / <param name="method"></param> / <returns></returns>

func CalmarRatio

func CalmarRatio(Ra *utils.SlidingWindow, scale float64) (float64, error)

func Centered

func Centered(returns *utils.SlidingWindow) (*utils.SlidingWindow, error)

/ <param name="returns"></param> / <returns></returns>

func Cumulative

func Cumulative(returns *utils.SlidingWindow, geometric bool) (float64, error)

/ <param name="returns"></param> / <param name="geometric"></param> / <returns></returns>

func DRatio

func DRatio(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / d ratio of the return distribution / The d ratio is similar to the Bernado Ledoit ratio but inverted and / taking into account the frequency of positive and negative returns. / </summary>

func DownsideDeviation

func DownsideDeviation(Ra *utils.SlidingWindow, MAR *utils.SlidingWindow) (float64, error)

/ <summary> / downside risk (deviation, variance) of the return distribution / Downside deviation, semideviation, and semivariance are measures of downside / risk. / </summary> = "full" = false func DownsideDeviation(Ra *utils.SlidingWindow, MAR *utils.SlidingWindow, method string, potential bool) float64 {

func DownsideDeviation2

func DownsideDeviation2(Ra *utils.SlidingWindow, MAR float64) (float64, error)

= "full" = false

func DownsideFrequency

func DownsideFrequency(Ra *utils.SlidingWindow, MAR *utils.SlidingWindow) (float64, error)

/ <summary> / downside frequency of the return distribution / To calculate Downside Frequency, we take the subset of returns that are / less than the target (or Minimum Acceptable Returns (MAR)) returns and / divide the length of this subset by the total number of returns. / </summary>

func DownsideFrequency2

func DownsideFrequency2(Ra *utils.SlidingWindow, MAR float64) (float64, error)

func Drawdowns

func Drawdowns(Rb *utils.SlidingWindow) ([]float64, error)

/ <summary> / Calculate the drawdown levels in a timeseries / </summary> = true

func Epsilon

func Epsilon(Ra, Rb, Rf *utils.SlidingWindow, scale float64) (float64, error)

/ <summary> / Epsilon / </summary>

func Epsilon2

func Epsilon2(Ra, Rb *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

func Excess

func Excess(returns, Rf *utils.SlidingWindow) (*utils.SlidingWindow, error)

func Excess2

func Excess2(returns *utils.SlidingWindow, Rf float64) (*utils.SlidingWindow, error)

/ <param name="returns"></param> / <param name="Rf"></param> / <returns></returns>

func FamaBeta

func FamaBeta(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, Ra_sclae float64, Rb_scale float64) (float64, error)

/ <summary> / Fama beta is a beta used to calculate the loss of diversification. It is made / so that the systematic risk is equivalent to the total portfolio risk. / </summary>

func FindDrawdowns

func FindDrawdowns(Ra *utils.SlidingWindow) map[string][]float64

func InformationRatio

func InformationRatio(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64) (float64, error)

/ <summary> / InformationRatio:ActivePremium/TrackingError / (经TrackingError调整的超额收益率) / </summary>

func JensenAlpha

func JensenAlpha(Ra, Rb, Rf *utils.SlidingWindow, scale float64) (float64, error)

func JensenAlpha2

func JensenAlpha2(Ra, Rb *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

func Kappa

func Kappa(Ra *utils.SlidingWindow, MAR float64, l float64) (float64, error)

/ <summary> / Kappa is a generalized downside risk-adjusted performance measure. / To calculate it, we take the difference of the mean of the distribution / to the target and we divide it by the l-root of the lth lower partial / moment. To calculate the lth lower partial moment we take the subset of / returns below the target and we sum the differences of the target to / these returns. We then return return this sum divided by the length of / the whole distribution. / (非年化的超MAR平均收益率通过l阶根的低于MAR的收益率序列的l阶矩) / </summary>

func KellyRatio_Full

func KellyRatio_Full(Ra *utils.SlidingWindow, Rf float64) (float64, error)

/ <summary> / the Kelly criterion is equal to the expected excess return of the strategy / divided by the expected variance of the excess return / (非年化的平均超额收益除以非年化的方差) / </summary>

func KellyRatio_Half

func KellyRatio_Half(Ra *utils.SlidingWindow, Rf float64) (float64, error)

func Kurtosis

func Kurtosis(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 峰度 / </summary> = "sample"

func M2Sortino

func M2Sortino(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, MAR float64) (float64, error)

/ <summary> / M squared for Sortino is a M^2 calculated for Downside risk instead of Total Risk / (基于SortinoRatio进行的收益率调整) / </summary>

func MSquared

func MSquared(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / M squared is a risk adjusted return useful to judge the size of relative / performance between differents portfolios. With it you can compare portfolios / with different levels of risk. / (使得不同组合的收益率可比的调整措施) / </summary>

func MSquaredExcess

func MSquaredExcess(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64, method string) (float64, error)

/ <summary> / M squared excess is the quantity above the standard M. / There is a geometric excess return which is better for Bacon and an arithmetic excess return / (是与Rb的年化收益率进行的excess比较) / </summary>

func MaxDrawdown

func MaxDrawdown(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 最大回撤,默认为返回其相反数 / </summary>

func MeanAbsoluteDeviation

func MeanAbsoluteDeviation(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / To calculate Mean absolute deviation we take / the sum of the absolute value of the difference between the returns and the mean of the returns / and we divide it by the number of returns. / (描述收益率偏离均值得一个指标) / </summary>

func MeanGeometric

func MeanGeometric(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 收益率序列的几何均值,非年化 / </summary>

func OmegaExcessReturn

func OmegaExcessReturn(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, MAR float64) (float64, error)

/ <summary> / Omega excess return is another form of downside risk-adjusted return. It is / calculated by multiplying the downside variance of the style benchmark by 3 / times the style beta. / (经过Ra,Rb的DownsideDeviation调整后的年化收益率,严格意义并不十分明确) / </summary>

func PainIndex

func PainIndex(Ra *utils.SlidingWindow) (float64, error)

func PainRatio

func PainRatio(Ra *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

func ProspectRatio

func ProspectRatio(Ra *utils.SlidingWindow, MAR float64) (float64, error)

/ <summary> / Prospect ratio is a ratio used to penalise loss since most people feel loss / greater than gain / (经验类型调整收益率,给损失赋予更大的权重) / </summary>

func Relative

func Relative(Ra, Rb *utils.SlidingWindow) (*utils.SlidingWindow, error)

/ <param name="Ra"></param> / <param name="Rb"></param> / <returns></returns>

func Selectivity

func Selectivity(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / Selectivity is the same as Jensen's alpha / </summary>

func SharpeRatio

func SharpeRatio(Ra *utils.SlidingWindow, Rf_val float64, scale float64) (float64, error)

/ <summary> / calculate a traditional or modified Sharpe Ratio of Return over StdDev or / VaR or ES / / The Sharpe ratio is simply the return per unit of risk (represented by / variability). In the classic case, the unit of risk is the standard / deviation of the returns. / </summary>

func SharpeRatio_Annualized

func SharpeRatio_Annualized(Ra *utils.SlidingWindow, Rf float64, scale float64) (float64, error)

/ <summary> / calculate annualized Sharpe Ratio / The Sharpe Ratio is a risk-adjusted measure of return that uses standard / deviation to represent risk. / </summary>

func Skewness

func Skewness(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 偏度 / </summary> default = "moment"

func SkewnessKurtosisRatio

func SkewnessKurtosisRatio(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 偏度峰度比 / </summary>

func SortinoRatio

func SortinoRatio(Ra *utils.SlidingWindow, MAR float64) (float64, error)

/ <summary> / Sortino proposed an improvement on the Sharpe Ratio to better account for / skill and excess performance by using only downside semivariance as the / measure of risk.Sortino contends that risk should be measured in terms of not meeting the / investment goal. / (引入MAR,并开始在调整收益率的分子分母进行Excess return与DownsideDeviation的MAR调整) / </summary>

func SpecificRisk

func SpecificRisk(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / epsilon与R中不同,但似乎没有影响 / Specific risk is the standard deviation of the error term in the / regression equation. / </summary>

func StdDev

func StdDev(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 标准差 / </summary>

func StdDev_Annualized

func StdDev_Annualized(Ra *utils.SlidingWindow, scale float64) (float64, error)

/ <summary> / 年化标准差 / </summary>

func SterlingRatio

func SterlingRatio(Ra *utils.SlidingWindow, scale, excess float64) (float64, error)

func SystematicRisk

func SystematicRisk(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / Systematic risk as defined by Bacon(2008) is the product of beta by market / risk. Be careful ! It's not the same definition as the one given by Michael / Jensen. Market risk is the standard deviation of the benchmark. The systematic / risk is annualized / </summary>

func TotalRisk

func TotalRisk(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / The square of total risk is the sum of the square of systematic risk and the square / of specific risk. Specific risk is the standard deviation of the error term in the / regression equation. Both terms are annualized to calculate total risk. / (总风险,注意这是一个经过开方之后的数值:SystematicRisk+SpecificRisk) / </summary>

func TrackingError

func TrackingError(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64) (float64, error)

/ <summary> / A measure of the unexplained portion of performance relative to a benchmark. / (年化的超指数收益率序列标准差) / </summary>

func TreynorRatio

func TreynorRatio(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, scale float64, Rf float64) (float64, error)

/ <summary> / The Treynor ratio is similar to the Sharpe Ratio, except it uses beta as the / volatility measure (to divide the investment's excess return over the beta). / (组合诸多的风险调整收益率之一) / </summary>

func UpDownRatios

func UpDownRatios(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow) (float64, error)

/ <summary> / 只测试了默认参数 / Calculate metrics on how the asset in R performed in up and down markets, / measured by periods when the benchmark asset was up or down. / Up (Down) Capture Ratio: this is a measure of an investment's compound / return when the benchmark was up (down) divided by the benchmark's compound / return when the benchmark was up (down). The greater (lower) the value, the / better.(Up越大越好,Down越小越好) / / Up (Down) Number Ratio: similarly, this is a measure of the number of / periods that the investment was up (down) when the benchmark was up (down), / divided by the number of periods that the Benchmark was up (down).(Up越大越好,Down越小越好) / / Up (Down) Percentage Ratio: this is a measure of the number of periods that / the investment outperformed the benchmark when the benchmark was up (down), / divided by the number of periods that the benchmark was up (down). Unlike / the prior two metrics, in both cases a higher value is better.(Up、Down均为越大越好) / (当市场涨跌时,组合收益率涨跌所占比率,) / </summary>

func UpsideFrequency

func UpsideFrequency(Ra *utils.SlidingWindow, MAR float64) (float64, error)

/ <summary> / subset of returns that are / more than the target (or Minimum Acceptable Returns (MAR)) returns and / divide the length of this subset by the total number of returns. / (超过MAR的频率) / </summary>

func UpsidePotentialRatio

func UpsidePotentialRatio(Ra *utils.SlidingWindow, MAR float64) (float64, error)

/ <summary> / Upside Potential Ratio,compared to Sortino, was a further improvement, extending the / measurement of only upside on the numerator, and only downside of the / denominator of the ratio equation. / (分子只考虑超过MAR部分,分母只考虑DownsideDeviation的下跌风险) / </summary>

func UpsideRisk

func UpsideRisk(Ra *utils.SlidingWindow, MAR float64, stat string) (float64, error)

/ <summary> / Upside Risk is the similar of semideviation taking the return above the / Minimum Acceptable Return instead of using the mean return or zero. / (一般来说,非对称类的比较,单求此统计量意义有限) / </summary>

func Variance

func Variance(Ra *utils.SlidingWindow) (float64, error)

/ <summary> / 方差 / </summary>

func VolatilitySkewness_Risk

func VolatilitySkewness_Risk(Ra *utils.SlidingWindow, MAR float64) (float64, error)

func VolatilitySkewness_Variance

func VolatilitySkewness_Variance(Ra *utils.SlidingWindow, MAR float64) (float64, error)

/ <summary> / Volatility skewness is a similar measure to omega but using the second / partial moment. It's the ratio of the upside variance compared to the / downside variance. Variability skewness is the ratio of the upside risk / compared to the downside risk. / (评价收益率分布的偏度,应该是越大越好,与1的关系要看UpsideRisk与DownsideDeviation定义是否一致) / </summary>

func Y2Scale

func Y2Scale(R float64, scale int, geometric bool) (float64, error)

/ <param name="R"></param> / <param name="scale"></param> / <param name="geometric"></param> / <returns></returns>

Types

type Func1Sliding

type Func1Sliding func(Ra *utils.SlidingWindow) (float64, error)

type Func1Sliding1F

type Func1Sliding1F func(Ra *utils.SlidingWindow, param float64) (float64, error)

type Func1Sliding1F1B

type Func1Sliding1F1B func(Ra *utils.SlidingWindow, param float64, flag bool) (float64, error)

type Func1Sliding1F1S

type Func1Sliding1F1S func(Ra *utils.SlidingWindow, param float64, str string) (float64, error)

type Func1Sliding2F

type Func1Sliding2F func(Ra *utils.SlidingWindow, param1 float64, param2 float64) (float64, error)

type Func2Sliding

type Func2Sliding func(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow) (float64, error)

type Func2Sliding1F

type Func2Sliding1F func(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, param float64) (float64, error)

type Func2Sliding2F

type Func2Sliding2F func(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, param1 float64, param2 float64) (float64, error)

type Func2Sliding2F1S

type Func2Sliding2F1S func(Ra *utils.SlidingWindow, Rb *utils.SlidingWindow, param1 float64, param2 float64, str string) (float64, error)

type P1S1F1BWrapper

type P1S1F1BWrapper struct {
	// contains filtered or unexported fields
}

func (*P1S1F1BWrapper) Process

func (this *P1S1F1BWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P1S1F1SWrapper

type P1S1F1SWrapper struct {
	// contains filtered or unexported fields
}

func (*P1S1F1SWrapper) Process

func (this *P1S1F1SWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P1S1FWrapper

type P1S1FWrapper struct {
	// contains filtered or unexported fields
}

func (*P1S1FWrapper) Process

func (this *P1S1FWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P1S2FWrapper

type P1S2FWrapper struct {
	// contains filtered or unexported fields
}

func (*P1S2FWrapper) Process

func (this *P1S2FWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P1SWrapper

type P1SWrapper struct {
	// contains filtered or unexported fields
}

func (*P1SWrapper) Process

func (this *P1SWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P2S1FWrapper

type P2S1FWrapper struct {
	// contains filtered or unexported fields
}

func (*P2S1FWrapper) Process

func (this *P2S1FWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P2S2F1SWrapper

type P2S2F1SWrapper struct {
	// contains filtered or unexported fields
}

func (*P2S2F1SWrapper) Process

func (this *P2S2F1SWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P2S2FWrapper

type P2S2FWrapper struct {
	// contains filtered or unexported fields
}

func (*P2S2FWrapper) Process

func (this *P2S2FWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type P2SWrapper

type P2SWrapper struct {
	// contains filtered or unexported fields
}

func (*P2SWrapper) Process

func (this *P2SWrapper) Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)

type Performance

type Performance interface {
	Process(AssetPriceReturns, AssetPriceBenchMark []float64, date []time.Time) (float64, error)
}

Directories

Path Synopsis
提供了一些其余的工具,包括sliding window 以及由unixtime判断北京时间的函数
提供了一些其余的工具,包括sliding window 以及由unixtime判断北京时间的函数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL