Coverage for src/jsharpe/sharpe/__init__.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-11 10:09 +0000

1"""Sharpe-related utilities for statistical analysis and hypothesis testing. 

2 

3This package provides comprehensive tools for Sharpe ratio analysis, including: 

4 - Variance estimation under non-Gaussian returns 

5 - Statistical significance testing 

6 - Multiple testing corrections (FDR, FWER) 

7 - Portfolio optimization utilities 

8 

9The implementation is split across topical sub-modules: 

10 - :mod:`jsharpe.sharpe.linalg`: probability points and covariance helpers 

11 - :mod:`jsharpe.sharpe.clustering`: effective rank and clustering 

12 - :mod:`jsharpe.sharpe.quadrature`: Gauss-Hermite expectation and moments 

13 - :mod:`jsharpe.sharpe.psr`: Sharpe variance, track record and PSR core 

14 - :mod:`jsharpe.sharpe.corrections`: FWER/FDR multiple-testing corrections 

15 - :mod:`jsharpe.sharpe.generators`: synthetic data and autocorrelation 

16 

17Layering (imports only ever point *downward*, so the import graph stays an 

18acyclic DAG; see ``ARCHITECTURE.md`` for the rationale and the guard test):: 

19 

20 corrections -> psr -> quadrature (statistics core) 

21 generators -> linalg (simulation + base numerics) 

22 clustering (self-contained) 

23 

24Lower layers (``linalg``, ``quadrature``) never import upper layers 

25(``psr``, ``corrections``, ``generators``). This module is the top facade: it 

26re-exports the full public API so existing imports such as 

27``from jsharpe.sharpe import sharpe_ratio_variance`` keep resolving unchanged, 

28and ``jsharpe/__init__.py`` re-exports the identical set of symbols. 

29""" 

30 

31from .clustering import effective_rank, number_of_clusters 

32from .corrections import ( 

33 FDR_critical_value, 

34 adjusted_p_values_bonferroni, 

35 adjusted_p_values_holm, 

36 adjusted_p_values_sidak, 

37 control_for_FDR, 

38 oFDR, 

39 pFDR, 

40) 

41from .generators import ( 

42 autocorrelation, 

43 generate_autocorrelated_non_gaussian_data, 

44 generate_non_gaussian_data, 

45 get_random_correlation_matrix, 

46) 

47from .linalg import ( 

48 minimum_variance_weights_for_correlated_assets, 

49 ppoints, 

50 robust_covariance_inverse, 

51) 

52from .psr import ( 

53 critical_sharpe_ratio, 

54 expected_maximum_sharpe_ratio, 

55 minimum_track_record_length, 

56 probabilistic_sharpe_ratio, 

57 sharpe_ratio_power, 

58 sharpe_ratio_variance, 

59 variance_of_the_maximum_of_k_Sharpe_ratios, 

60) 

61from .quadrature import make_expectation_gh 

62 

63__all__ = [ 

64 "FDR_critical_value", 

65 "adjusted_p_values_bonferroni", 

66 "adjusted_p_values_holm", 

67 "adjusted_p_values_sidak", 

68 "autocorrelation", 

69 "control_for_FDR", 

70 "critical_sharpe_ratio", 

71 "effective_rank", 

72 "expected_maximum_sharpe_ratio", 

73 "generate_autocorrelated_non_gaussian_data", 

74 "generate_non_gaussian_data", 

75 "get_random_correlation_matrix", 

76 "make_expectation_gh", 

77 "minimum_track_record_length", 

78 "minimum_variance_weights_for_correlated_assets", 

79 "number_of_clusters", 

80 "oFDR", 

81 "pFDR", 

82 "ppoints", 

83 "probabilistic_sharpe_ratio", 

84 "robust_covariance_inverse", 

85 "sharpe_ratio_power", 

86 "sharpe_ratio_variance", 

87 "variance_of_the_maximum_of_k_Sharpe_ratios", 

88]