-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify_task2.py
More file actions
63 lines (49 loc) · 2.38 KB
/
Copy pathverify_task2.py
File metadata and controls
63 lines (49 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
"""
Verification script for Task 2: Trend and Momentum Indicators
"""
import sys
import os
# Add project root to path
project_root = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, project_root)
def main():
try:
from src.features.regime_features import TrendIndicators, MomentumIndicators
print("✓ Successfully imported TrendIndicators and MomentumIndicators")
# Test Trend Indicators
tf = TrendIndicators()
print("✓ Successfully created TrendIndicators instance")
trend_features = tf.calculate('SPY')
print(f"✓ Trend features calculated: shape {trend_features.shape}")
print(f"✓ Trend columns: {list(trend_features.columns)}")
# Verify trend features shape
assert trend_features.shape[1] == 9, f"Expected 9 trend features, got {trend_features.shape[1]}"
print("✓ Correct number of trend features (9)")
# Test Momentum Indicators
mf = MomentumIndicators()
print("✓ Successfully created MomentumIndicators instance")
momentum_features = mf.calculate('SPY')
print(f"✓ Momentum features calculated: shape {momentum_features.shape}")
print(f"✓ Momentum columns: {list(momentum_features.columns)}")
# Verify momentum features shape
assert momentum_features.shape[1] == 6, f"Expected 6 momentum features, got {momentum_features.shape[1]}"
print("✓ Correct number of momentum features (6)")
# Check for NaNs
assert not trend_features.isnull().any().any(), "Trend features contain NaN values"
assert not momentum_features.isnull().any().any(), "Momentum features contain NaN values"
print("✓ No NaN values in trend or momentum features")
# Total should be 15 (9 + 6)
total_features = trend_features.shape[1] + momentum_features.shape[1]
assert total_features == 15, f"Expected 15 total features, got {total_features}"
print(f"✓ Total trend + momentum features: {total_features}")
print("\n🎉 Task 2 verification PASSED!")
print(f"Trend and momentum indicators successfully return {total_features} features for SPY")
except Exception as e:
print(f"❌ Task 2 verification FAILED: {e}")
import traceback
traceback.print_exc()
return False
return True
if __name__ == "__main__":
main()