-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·121 lines (102 loc) · 3.54 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·121 lines (102 loc) · 3.54 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Setup script for Gold Trading Bot
"""
import os
import sys
import subprocess
from pathlib import Path
def create_directories():
"""Create necessary directories."""
directories = [
'logs',
'results',
'data'
]
for directory in directories:
Path(directory).mkdir(exist_ok=True)
print("Created directory: {}".format(directory))
def install_dependencies():
"""Install Python dependencies."""
print("Installing Python dependencies...")
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
print("Dependencies installed successfully")
except subprocess.CalledProcessError:
print("Failed to install dependencies")
return False
return True
def create_env_template():
"""Create environment template file."""
env_template = """# Gold Trading Bot Environment Variables
# Copy this file to .env and fill in your credentials
# MetaTrader 5 Credentials (for live trading)
MT5_LOGIN=your_mt5_login
MT5_PASSWORD=your_mt5_password
MT5_SERVER=your_mt5_server
# Email Notifications (optional)
EMAIL_SMTP_SERVER=smtp.gmail.com
EMAIL_SMTP_PORT=587
EMAIL_USERNAME=your_email@gmail.com
EMAIL_PASSWORD=your_app_password
# Telegram Notifications (optional)
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
# Webhook Notifications (optional)
WEBHOOK_URL=https://your-webhook-url.com
"""
with open('.env.template', 'w') as f:
f.write(env_template)
print("Created .env.template file")
def run_initial_test():
"""Run initial test to verify setup."""
print("Running initial test...")
try:
# Test strategy listing
result = subprocess.run([sys.executable, 'main.py', 'list-strategies'],
capture_output=True, text=True)
if result.returncode == 0:
print("Initial test passed")
print("Available strategies:")
print(result.stdout)
else:
print("Initial test failed")
print(result.stderr)
return False
except Exception as e:
print("Test failed: {}".format(e))
return False
return True
def main():
"""Main setup function."""
print("Gold Trading Bot Setup")
print("=" * 40)
# Check Python version
if sys.version_info < (3, 8):
print("Python 3.8 or higher is required")
sys.exit(1)
print("Python {}.{} detected".format(sys.version_info.major, sys.version_info.minor))
# Create directories
create_directories()
# Install dependencies
if not install_dependencies():
sys.exit(1)
# Create environment template
create_env_template()
# Run initial test
if not run_initial_test():
print("\nSetup completed with warnings. Check the error messages above.")
else:
print("\nSetup completed successfully!")
print("\n" + "=" * 40)
print("Next Steps:")
print("1. Copy .env.template to .env and fill in your credentials (optional)")
print("2. Review config/settings.yaml for strategy parameters")
print("3. Run a backtest: python main.py backtest --strategy ICC_Strategy --days 30")
print("4. Launch dashboard: python main.py dashboard")
print("5. Start paper trading: python main.py paper --strategy Gold_Scalper")
print("\nSee README.md for detailed usage instructions")
print("Remember: Test thoroughly with paper trading before live trading!")
if __name__ == "__main__":
main()