-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathci_cd_example.py
More file actions
66 lines (48 loc) · 1.78 KB
/
ci_cd_example.py
File metadata and controls
66 lines (48 loc) · 1.78 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
64
65
66
"""Example: CI/CD pipeline usage."""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from forexsmartbot.testing import StrategyTestPipeline
def main():
"""Example: Using CI/CD pipeline."""
print("=" * 70)
print("CI/CD Pipeline Example")
print("=" * 70)
# Test configuration
test_config = {
'symbol': 'EURUSD=X',
'start_date': '2023-01-01',
'end_date': '2023-12-31',
'initial_balance': 10000.0,
'min_sharpe': 0.5,
'max_drawdown': 0.3,
'min_trades': 10,
'min_win_rate': 0.4
}
# Create pipeline
pipeline = StrategyTestPipeline(test_config)
# Test specific strategies
strategies_to_test = ['SMA_Crossover', 'RSI_Reversion', 'BreakoutATR']
print(f"\nTesting {len(strategies_to_test)} strategies...")
print(f"Criteria:")
print(f" Min Sharpe: {test_config['min_sharpe']}")
print(f" Max Drawdown: {test_config['max_drawdown']:.0%}")
print(f" Min Trades: {test_config['min_trades']}")
print(f" Min Win Rate: {test_config['min_win_rate']:.0%}")
print()
# Run tests
results = pipeline.run_tests(strategies_to_test)
# Generate report
report = pipeline.generate_report(results)
print(report)
# Export JSON
pipeline.export_json(results, 'ci_cd_test_results.json')
# Exit with appropriate code
exit_code = pipeline.exit_with_code(results)
print(f"\nExit code: {exit_code} ({'PASS' if exit_code == 0 else 'FAIL'})")
print("\n" + "=" * 70)
print("CI/CD pipeline example complete!")
print("=" * 70)
return exit_code
if __name__ == "__main__":
sys.exit(main())