55and multiple testing corrections for robust statistical inference.
66"""
77
8- from typing import List , Tuple , Optional
8+ from typing import List , Tuple , Optional , Any
99import numpy as np
10+ from numpy .typing import NDArray
1011from scipy import stats
1112from statsmodels .stats .multitest import multipletests
1213
1314
1415def bootstrap_confidence_interval (
15- returns : np . ndarray ,
16+ returns : NDArray [ Any ] ,
1617 statistic : str = "median" ,
1718 n_bootstrap : int = 10000 ,
1819 confidence_level : float = 0.95 ,
@@ -65,7 +66,7 @@ def bootstrap_confidence_interval(
6566 return (point_est , lower_bound , upper_bound )
6667
6768
68- def wilcoxon_test (returns : np . ndarray , alternative : str = "greater" ) -> Tuple [float , float ]:
69+ def wilcoxon_test (returns : NDArray [ Any ] , alternative : str = "greater" ) -> Tuple [float , float ]:
6970 """
7071 Wilcoxon signed-rank test for returns vs. zero.
7172
@@ -92,7 +93,7 @@ def wilcoxon_test(returns: np.ndarray, alternative: str = "greater") -> Tuple[fl
9293 return (np .nan , np .nan )
9394
9495
95- def t_test (returns : np . ndarray , alternative : str = "greater" ) -> Tuple [float , float ]:
96+ def t_test (returns : NDArray [ Any ] , alternative : str = "greater" ) -> Tuple [float , float ]:
9697 """
9798 One-sample t-test for returns vs. zero.
9899
@@ -115,7 +116,7 @@ def t_test(returns: np.ndarray, alternative: str = "greater") -> Tuple[float, fl
115116
116117def benjamini_hochberg_correction (
117118 p_values : List [float ], alpha : float = 0.05
118- ) -> Tuple [np . ndarray , np . ndarray ]:
119+ ) -> Tuple [NDArray [ Any ], NDArray [ Any ] ]:
119120 """
120121 Apply Benjamini-Hochberg FDR correction for multiple testing.
121122
@@ -142,7 +143,7 @@ def benjamini_hochberg_correction(
142143 return (reject , corrected_pvals )
143144
144145
145- def compute_effect_size (returns : np . ndarray ) -> float :
146+ def compute_effect_size (returns : NDArray [ Any ] ) -> float :
146147 """
147148 Compute Cohen's d effect size for returns vs. zero.
148149
@@ -170,7 +171,7 @@ def compute_effect_size(returns: np.ndarray) -> float:
170171 return float (mean_return / std_return )
171172
172173
173- def sharpe_ratio (returns : np . ndarray , risk_free_rate : float = 0.0 ) -> float :
174+ def sharpe_ratio (returns : NDArray [ Any ] , risk_free_rate : float = 0.0 ) -> float :
174175 """
175176 Compute annualized Sharpe ratio for strategy.
176177
0 commit comments