コード例 #1
0
ファイル: test_miscellaneous.py プロジェクト: quarkfin/qf-lib
 def test_sharpe_ratio(self):
     actual_sharpe_ratio = sharpe_ratio(self.test_returns_tms,
                                        frequency=Frequency.DAILY)
     expected_sharpe_ratio = 23.059159631739007
     self.assertAlmostEqual(expected_sharpe_ratio,
                            actual_sharpe_ratio,
                            places=10)
コード例 #2
0
def minTRL(returns_timeseries: QFSeries,
           target_sharpe_ratio: float = 1.0,
           confidence_level: float = 0.95) -> float:
    """
    Computes the Minimum Track Record Length measure. The aim of computing is the possibility of answering the
    following question: 'How long should a track record be in order to have statistical confidence that its Sharpe ratio
    is above a given threshold?'

    The concept of Minimum Track Record Length is presented by Bailey and Prado in 'The Sharpe Ratio Efficient Frontier'
    """
    returns_series = returns_timeseries.to_simple_returns()
    skewness = returns_series.skew()
    kurtosis = returns_series.kurt()
    sharpe_ratio_value = sharpe_ratio(returns_series,
                                      frequency=Frequency.DAILY)

    minTRL_value = 1 + ((1 - skewness * sharpe_ratio_value + (kurtosis - 1) / 4.0) * sharpe_ratio_value ** 2) * \
        (stats.norm.ppf(confidence_level) / (sharpe_ratio_value - target_sharpe_ratio)) ** 2
    return minTRL_value
コード例 #3
0
 def _calculate_ratios(self):
     self.sharpe_ratio = sharpe_ratio(self.returns_tms, self.frequency)
     self.omega_ratio = omega_ratio(self.returns_tms)
     self.calmar_ratio = calmar_ratio(self.returns_tms, self.frequency)
     self.gain_to_pain_ratio = gain_to_pain_ratio(self.returns_tms)
     self.sorino_ratio = sorino_ratio(self.returns_tms, self.frequency)