Skip to content

Commit 4ee74b2

Browse files
Fix all ruff errors: remove unused imports and format code
1 parent f5bd2a6 commit 4ee74b2

6 files changed

Lines changed: 52 additions & 40 deletions

File tree

meridianalgo/portfolio/__init__.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,44 @@
1717
RiskParityOptimizer,
1818
)
1919

20+
__all__ = [
21+
# Optimization
22+
"PortfolioOptimizer",
23+
"BlackLittermanOptimizer",
24+
"RiskParityOptimizer",
25+
"HierarchicalRiskParityOptimizer",
26+
"FactorModelOptimizer",
27+
"OptimizationResult",
28+
]
29+
30+
# Risk Management
2031
try:
21-
from .risk_management import RiskManager, RiskMetrics, StressTester, VaRCalculator # noqa: F401
32+
from .risk_management import ( # noqa: F401
33+
RiskManager,
34+
RiskMetrics,
35+
StressTester,
36+
VaRCalculator,
37+
)
2238

39+
__all__.extend(["RiskManager", "VaRCalculator", "StressTester", "RiskMetrics"])
2340
RISK_MANAGEMENT_AVAILABLE = True
2441
except ImportError:
2542
RISK_MANAGEMENT_AVAILABLE = False
2643

44+
# Performance Analysis
2745
try:
28-
from .performance import AttributionAnalyzer, FactorAnalyzer, PerformanceAnalyzer # noqa: F401
46+
from .performance import ( # noqa: F401
47+
AttributionAnalyzer,
48+
FactorAnalyzer,
49+
PerformanceAnalyzer,
50+
)
2951

52+
__all__.extend(["PerformanceAnalyzer", "AttributionAnalyzer", "FactorAnalyzer"])
3053
PERFORMANCE_AVAILABLE = True
3154
except ImportError:
3255
PERFORMANCE_AVAILABLE = False
3356

57+
# Transaction Costs
3458
try:
3559
from .transaction_costs import ( # noqa: F401
3660
LinearImpactModel,
@@ -39,10 +63,19 @@
3963
TransactionCostOptimizer,
4064
)
4165

66+
__all__.extend(
67+
[
68+
"TransactionCostOptimizer",
69+
"TaxLossHarvester",
70+
"LinearImpactModel",
71+
"SquareRootImpactModel",
72+
]
73+
)
4274
TRANSACTION_COSTS_AVAILABLE = True
4375
except ImportError:
4476
TRANSACTION_COSTS_AVAILABLE = False
4577

78+
# Rebalancing
4679
try:
4780
from .rebalancing import ( # noqa: F401
4881
CalendarRebalancer,
@@ -51,38 +84,9 @@
5184
ThresholdRebalancer,
5285
)
5386

54-
REBALANCING_AVAILABLE = True
55-
except ImportError:
56-
REBALANCING_AVAILABLE = False
57-
58-
__all__ = [
59-
# Optimization
60-
"PortfolioOptimizer",
61-
"BlackLittermanOptimizer",
62-
"RiskParityOptimizer",
63-
"HierarchicalRiskParityOptimizer",
64-
"FactorModelOptimizer",
65-
"OptimizationResult",
66-
]
67-
68-
# Add available modules to __all__
69-
if RISK_MANAGEMENT_AVAILABLE:
70-
__all__.extend(["RiskManager", "VaRCalculator", "StressTester", "RiskMetrics"])
71-
72-
if PERFORMANCE_AVAILABLE:
73-
__all__.extend(["PerformanceAnalyzer", "AttributionAnalyzer", "FactorAnalyzer"])
74-
75-
if TRANSACTION_COSTS_AVAILABLE:
76-
__all__.extend(
77-
[
78-
"TransactionCostOptimizer",
79-
"TaxLossHarvester",
80-
"LinearImpactModel",
81-
"SquareRootImpactModel",
82-
]
83-
)
84-
85-
if REBALANCING_AVAILABLE:
8687
__all__.extend(
8788
["Rebalancer", "CalendarRebalancer", "ThresholdRebalancer", "OptimalRebalancer"]
8889
)
90+
REBALANCING_AVAILABLE = True
91+
except ImportError:
92+
REBALANCING_AVAILABLE = False

meridianalgo/statistics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
# Check for optional dependencies
2222
try:
2323
import statsmodels.api as sm
24-
from statsmodels.tsa.stattools import adfuller, coint, grangercausalitytests # noqa: F401
24+
from statsmodels.tsa.stattools import (
25+
adfuller,
26+
coint,
27+
)
2528
from statsmodels.tsa.vector_ar.vecm import coint_johansen
2629

2730
STATSMODELS_AVAILABLE = True

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def read_requirements(filename):
188188
],
189189
},
190190
include_package_data=True,
191+
license_files = [], # ← this disables the automatic license-file metadata
191192
zip_safe=False,
192193
license="MIT",
193194
)

tests/test_data_infrastructure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
MissingDataHandler,
2222
OutlierDetector,
2323
)
24-
from meridianalgo.data.providers import AlphaVantageProvider, YahooFinanceProvider # noqa: F401
24+
from meridianalgo.data.providers import (
25+
AlphaVantageProvider,
26+
YahooFinanceProvider,
27+
) # noqa: F401
2528

2629
DATA_AVAILABLE = True
2730
except ImportError:

tests/test_machine_learning.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ def test_technical_features(self, sample_price_data):
8282
feature_names = features.columns.tolist()
8383

8484
# Should contain some technical indicators
85-
any(
86-
name.lower() in ["rsi", "sma", "ema", "macd"] for name in feature_names
87-
)
85+
any(name.lower() in ["rsi", "sma", "ema", "macd"] for name in feature_names)
8886

8987
print(" Technical features test passed")
9088
except Exception as e:

tests/test_risk_analysis.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ def test_error_handling(self, sample_returns):
347347
def test_risk_analysis_import():
348348
"""Test that risk analysis can be imported."""
349349
try:
350-
from meridianalgo.risk_analysis import ExpectedShortfall, VaRCalculator # noqa: F401
350+
from meridianalgo.risk_analysis import (
351+
ExpectedShortfall,
352+
VaRCalculator,
353+
) # noqa: F401
351354

352355
print(" Risk analysis import test passed")
353356
return True

0 commit comments

Comments
 (0)