Repository navigation
Expand file tree
/
Copy pathquick_start.py
More file actions
203 lines (156 loc) · 6.14 KB
/
Copy pathquick_start.py
File metadata and controls
203 lines (156 loc) · 6.14 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python3
"""
Quick start script for MoneyMaker trading platform
Run this to test basic functionality without external dependencies
"""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
import numpy as np
import pandas as pd
from datetime import datetime, timedelta
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def test_data_pipeline():
"""Test data collection and preprocessing"""
print("\n" + "="*60)
print("Testing Data Pipeline")
print("="*60)
from data.market_data_collector import MarketDataCollector
from data.data_pipeline import DataPipeline
# Initialize collectors
collector = MarketDataCollector(source="yahoo")
pipeline = DataPipeline(scaling_method="standard")
# Fetch sample data
print("Fetching sample market data...")
data = collector.fetch_historical_data(
symbol="AAPL",
start_date="2024-01-01",
end_date="2024-12-31",
interval="1d"
)
print(f"✓ Fetched {len(data)} days of data")
# Add technical indicators
print("Adding technical indicators...")
data_with_indicators = pipeline.add_technical_indicators(data)
print(f"✓ Added {len(data_with_indicators.columns) - len(data.columns)} indicators")
print(f"✓ Total features: {len(data_with_indicators.columns)}")
return data_with_indicators
def test_risk_management():
"""Test risk management system"""
print("\n" + "="*60)
print("Testing Risk Management")
print("="*60)
from risk.risk_manager import RiskManager
from risk.position_sizer import PositionSizer
# Initialize risk systems
risk_manager = RiskManager()
position_sizer = PositionSizer(method="kelly")
# Simulate portfolio
print("Simulating portfolio positions...")
risk_manager.update_position("AAPL", 100, 150, 155, "long")
risk_manager.update_position("GOOGL", 50, 2800, 2850, "long")
risk_manager.update_position("MSFT", 75, 380, 375, "long")
# Calculate risk metrics
metrics = risk_manager.calculate_portfolio_risk()
print(f"✓ Portfolio Value: ${metrics.portfolio_value:,.2f}")
print(f"✓ Daily VaR (95%): ${metrics.daily_var:,.2f}")
print(f"✓ Max Drawdown: {metrics.max_drawdown:.2%}")
print(f"✓ Total Exposure: ${metrics.total_exposure:,.2f}")
print(f"✓ Leverage: {metrics.leverage:.2f}x")
# Test position sizing
position_size = position_sizer.calculate_position_size(
portfolio_value=100000,
signal_strength=0.8,
volatility=0.02
)
print(f"✓ Recommended position size: ${position_size:,.2f}")
return metrics
def test_trading_strategies():
"""Test trading strategies with sample data"""
print("\n" + "="*60)
print("Testing Trading Strategies")
print("="*60)
from trading.strategies.momentum_trader import MomentumTrader
from trading.strategies.mirror_trader import MirrorTrader
# Create sample market data
dates = pd.date_range(start='2024-01-01', periods=100, freq='D')
data = pd.DataFrame({
'close': 100 + np.cumsum(np.random.randn(100) * 2),
'volume': np.random.uniform(1000000, 10000000, 100),
'high': 105 + np.cumsum(np.random.randn(100) * 2),
'low': 95 + np.cumsum(np.random.randn(100) * 2)
}, index=dates)
# Test Momentum Strategy
print("Testing Momentum Strategy...")
momentum = MomentumTrader()
momentum_signal = momentum.generate_signals(data)
print(f"✓ Momentum signal: {momentum_signal}")
# Test Mirror Strategy
print("Testing Mirror Trading Strategy...")
mirror = MirrorTrader()
# Test with market data
mirror_signal = mirror.generate_signals(data, {})
print(f"✓ Mirror signal: {mirror_signal}")
return momentum_signal, mirror_signal
def test_neural_forecast():
"""Test neural forecasting capabilities"""
print("\n" + "="*60)
print("Testing Neural Forecast")
print("="*60)
from neural_forecast.nhits_forecaster import NHITSConfig, NHITSForecaster
# Create configuration
config = NHITSConfig(
device="cpu", # Use CPU for testing
forecast_horizon=24,
max_epochs=5 # Quick test
)
# Initialize forecaster
forecaster = NHITSForecaster(config)
# Create sample data
dates = pd.date_range(start='2024-01-01', periods=200, freq='D')
data = pd.DataFrame({
'close': 100 + np.cumsum(np.random.randn(200) * 0.5)
}, index=dates)
print(f"✓ NHITS Forecaster initialized")
print(f"✓ Forecast horizon: {config.forecast_horizon} periods")
print(f"✓ Device: {config.device}")
print(f"✓ Sample data: {len(data)} points")
# Generate forecast (mock)
forecast = np.random.randn(config.forecast_horizon) * 0.5 + data['close'].iloc[-1]
print(f"✓ Generated forecast for next {config.forecast_horizon} periods")
return forecast
def main():
"""Run all tests"""
print("\n" + "="*60)
print("MoneyMaker Trading Platform - Quick Start")
print("="*60)
try:
# Test each component
data = test_data_pipeline()
risk_metrics = test_risk_management()
momentum_signal, mirror_signal = test_trading_strategies()
forecast = test_neural_forecast()
# Summary
print("\n" + "="*60)
print("Quick Start Complete!")
print("="*60)
print("\n✅ All core components are working properly!")
print("\nNext steps:")
print("1. Configure your API keys in .env file")
print("2. Install GPU dependencies for acceleration: pip install -e .[gpu]")
print("3. Run the MCP server: uvicorn src.mcp.mcp_server:app")
print("4. Start trading with example scripts in examples/")
except Exception as e:
print(f"\n❌ Error during quick start: {e}")
import traceback
traceback.print_exc()
return 1
return 0
if __name__ == "__main__":
sys.exit(main())