qis.PerfStat

class qis.PerfStat(*values)[source]

Bases: ColVar, Enum

the column set of every performance table in qis.

Performance output is a frame indexed by asset with PerfStat members as columns, so a statistic is selected by enum member rather than by a string literal that can drift.

Each member is a ColVar carrying its display name, its short and wrapped labels for table headers, and its ValueType, which fixes how the number is formatted — percent, ratio, date or count. Formatting therefore travels with the statistic instead of being reapplied at each call site.

Members whose name ends in _RF0 use a zero risk-free rate; the excess variants deduct PerfParams.rates_data and, without it, equal their zero-rate counterparts. The Sharpe members are fixed columns, one family per convention: SHARPE_RF0/SHARPE_EXCESS (compound p.a.), SHARPE_LOG_AN/SHARPE_LOG_EXCESS (log) and SHARPE_ARITH/SHARPE_ARITH_EXCESS (arithmetic). The labels ‘Sharpe (rf=0)’ and ‘Ex Sharpe’ denote the compound p.a. convention; the labels are column names that downstream code selects on, so the convention is stated here rather than added to them. PerfParams.sharpe_convention does not change these columns; it selects the convention of the regime-conditional Sharpe contributions (BEAR_SHARPE and its analogues), whose labels likewise do not carry it.

WORST and BEST are the extreme simple returns on the PerfParams.freq_drawdown grid (daily by default), not on freq_vol. SKEWNESS and KURTOSIS are sampled on freq_skewness.

A member’s name attribute is the ColVar display label, not the enumeration name: PerfStat.VOL.name == 'Vol'. The ColVar field shadows Enum.name and is kept because it is how the labels are read throughout qis; use PerfStat.VOL._name_ or PerfStat['VOL'] for the member name.

__init__(*args, **kwds)

Methods

to_str([short, short_n])

to_format([digits_to_show, sharpe_digits, ...])

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

__init__(*args, **kwds)

Attributes

START_DATE = ('Start date', None, 'Start\ndate', ValueType.DATE, None)
END_DATE = ('End date', None, 'End\ndate', ValueType.DATE, None)
START_PRICE = ('Start', None, 'Start\nprice', ValueType.PRICE, None)
END_PRICE = ('End', None, 'End\nprice', ValueType.PRICE, None)
NUM_OBS = ('Num Obs', None, 'Num\nObs', ValueType.INT, None)
TOTAL_RETURN = ('Total', None, 'Total\nreturn', ValueType.PERCT0, None)
NAV1 = ('1$ Invested', None, '1$ Invested', ValueType.FLOAT, None)
NUM_YEARS = ('Num Years', None, 'Num\nYears', ValueType.FLOAT, None)
PA_RETURN = ('P.a. return', 'P.a.', 'P.a.\nreturn', ValueType.PERCT, None)
PA_EXCESS_RETURN = ('P.a. excess return', None, 'P.a.\nexcess', ValueType.PERCT, None)
AN_LOG_RETURN = ('An. log return', None, 'An. log\nreturn', ValueType.PERCT, None)
AN_LOG_EXCESS_RETURN = ('An. log return ex', None, 'An ex\nlog-return', ValueType.PERCT, None)
AVG_LOG_RETURN = ('AvgLogReturn', None, 'AvgReturn', ValueType.PERCT, None)
AN_ARITH_RETURN = ('An. arith return', None, 'An. arith\nreturn', ValueType.PERCT, None)
AN_ARITH_EXCESS_RETURN = ('An. arith excess return', None, 'An. arith\nexcess', ValueType.PERCT, None)
AVG_ARITH_RETURN = ('Avg Arith Return', None, 'AvgArith\nReturn', ValueType.PERCT, None)
AVG_ARITH_EXCESS_RETURN = ('Avg Arith Ex return', None, 'Avg Arith\nEx return', ValueType.PERCT, None)
SHARPE_RF0 = ('Sharpe (rf=0)', 'Sharpe(rf=0)', 'Sharpe\n(rf=0)', ValueType.SHARPE, None)
SHARPE_EXCESS = ('Ex Sharpe', 'ExSharpe', 'Excess\nSharpe', ValueType.SHARPE, None)
SHARPE_LOG_AN = ('Log Sharpe', None, 'Log\nSharpe', ValueType.SHARPE, None)
SHARPE_LOG_EXCESS = ('Log Ex Sharpe', None, 'Log Ex\nSharpe', ValueType.SHARPE, None)
SHARPE_ARITH = ('Sharpe Arith', None, 'Sharpe\nArith', ValueType.SHARPE, None)
SHARPE_ARITH_EXCESS = ('Ex Sharpe Arith', None, 'ExSharpe\nArith', ValueType.SHARPE, None)
VOL = ('Vol', None, 'An. vol', ValueType.PERCT, None)
DOWNSIDE_VOL = ('DownVol', None, 'DownVol', ValueType.PERCT, None)
SORTINO_RATIO = ('Sortino', None, 'Sortino', ValueType.SHARPE, None)
CALMAR_RATIO = ('Calmar', None, 'Calmar', ValueType.SHARPE, None)
MAX_DD = ('Max DD', 'MaxDD', 'Max\nDD', ValueType.PERCT0, None)
CURRENT_DD = ('Current DD', 'CurDD', 'Current\nDD', ValueType.PERCT0, None)
MAX_DD_VOL = ('Max DD/Vol', 'MaxDD/Vol', 'Max DD\n/Vol', ValueType.FLOAT, None)
SKEWNESS = ('Skewness', 'Skew', 'Skew', ValueType.FLOAT2, None)
KURTOSIS = ('Kurtosis', None, 'Kurt', ValueType.FLOAT, None)
NORMTEST = ('P-val', None, 'P-val', ValueType.FLOAT4, None)
WORST = ('Worst', None, 'Worst', ValueType.PERCT, None)
BEST = ('Best', None, 'Best', ValueType.PERCT, None)
POSITIVE = ('Positive', None, 'Positive', ValueType.PERCT, None)
BEAR_AVG = ('Bear Average', None, 'Bear\nAvg', ValueType.PERCT, None)
NORMAL_AVG = ('Normal Average', None, 'Normal\nAvg', ValueType.PERCT, None)
BULL_AVG = ('Bull Average', None, 'Bull\nAvg', ValueType.PERCT, None)
BEAR_PA = ('Bear P.a.', None, 'Bear\nP.a.', ValueType.PERCT, None)
NORMAL_PA = ('Normal P.a.', None, 'Normal\nP.a.', ValueType.PERCT, None)
BULL_PA = ('Bull P.a.', None, 'Bull\nP.a.', ValueType.PERCT, None)
BEAR_SHARPE = ('Bear-Sharpe', None, 'Bear-\nSharpe', ValueType.SHARPE, None)
NORMAL_SHARPE = ('Normal-Sharpe', None, 'Normal-\nSharpe', ValueType.SHARPE, None)
BULL_SHARPE = ('Bull-Sharpe', None, 'Bull-\nSharpe', ValueType.SHARPE, None)
AVG = ('Avg', None, 'Avg', ValueType.FLOAT, None)
T_STAT = ('T-stat', None, 'T-stat', ValueType.FLOAT, None)
STD = ('Std', None, 'Std', ValueType.FLOAT, None)
STD_AN = ('Std An', None, 'Std AN', ValueType.FLOAT, None)
MEDIAN = ('Median', None, '50-Q', ValueType.FLOAT, None)
MIN = ('Min', None, 'Min', ValueType.FLOAT, None)
MAX = ('Max', None, 'Max', ValueType.FLOAT, None)
QUANT_M_1STD = ('-1std', None, '16-Q', ValueType.FLOAT, None)
QUANT_P1_STD = ('+1std', None, '84-Q', ValueType.FLOAT, None)
LAST = ('Last', None, 'Last', ValueType.PERCT, None)
RANK = ('Rank', None, 'Rank', ValueType.PERCT, None)
ALPHA = ('Alpha', None, 'Alpha', ValueType.PERCT, None)
ALPHA_AN = ('An Alpha', None, 'An\nAlpha', ValueType.PERCT, None)
BETA = ('Beta', None, 'Beta', ValueType.FLOAT2, None)
R2 = ('R2', None, 'R2', ValueType.PERCT0, None)
ALPHA_PVALUE = ('p-Alpha', None, 'p-Alpha', ValueType.FLOAT2, None)