forked from magnaopus1/Synthron-Crypto-Trader
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_live_trading.py
More file actions
113 lines (88 loc) · 3.72 KB
/
start_live_trading.py
File metadata and controls
113 lines (88 loc) · 3.72 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
#!/usr/bin/env python3
"""
Start Live Trading with Encrypted Wallet
Properly loads the encrypted wallet private key and starts the enhanced live trading system
"""
import sys
import os
from pathlib import Path
# Add main project to path for encryption access
main_project_path = Path(__file__).parent.parent
sys.path.insert(0, str(main_project_path))
def load_encrypted_wallet():
"""Load the encrypted wallet private key into environment"""
try:
print("🔐 Loading encrypted wallet private key...")
# Import encryption utilities from main project
from utils.encryption import get_encryption_password, decrypt_env_file
# Get encryption password
password = get_encryption_password()
if not password:
print("❌ Could not retrieve encryption password")
return False
print("✅ Retrieved encryption password")
# Decrypt the main encrypted file
encrypted_path = main_project_path / "config" / ".env.encrypted"
if not encrypted_path.exists():
print(f"❌ Encrypted file not found: {encrypted_path}")
return False
print(f"📁 Decrypting: {encrypted_path}")
decrypted_content = decrypt_env_file(encrypted_path, password)
if not decrypted_content:
print("❌ Failed to decrypt environment file")
return False
print("✅ Successfully decrypted environment file")
# Load environment variables from decrypted content
wallet_key_found = False
for line in decrypted_content.split('\n'):
line = line.strip()
if line and '=' in line and not line.startswith('#'):
key, value = line.split('=', 1)
key = key.strip()
value = value.strip()
# Set in environment (don't override existing)
if key not in os.environ:
os.environ[key] = value
if key == 'WALLET_PRIVATE_KEY':
wallet_key_found = True
print(f"✅ WALLET_PRIVATE_KEY loaded (length: {len(value)})")
if not wallet_key_found:
print("❌ WALLET_PRIVATE_KEY not found in encrypted file")
return False
print("✅ Encrypted wallet successfully loaded into environment")
return True
except Exception as e:
print(f"❌ Error loading encrypted wallet: {e}")
return False
def start_live_trading():
"""Start the enhanced live trading system"""
try:
print("\n🚀 Starting Enhanced Live Trading System...")
# Import and run the enhanced live trader
from enhanced_live_trader import main
import asyncio
# Run the live trading system
return asyncio.run(main())
except Exception as e:
print(f"❌ Error starting live trading: {e}")
return 1
def main():
"""Main function"""
print("🔥 SUPERTRADEX LIVE TRADING STARTUP")
print("=" * 50)
# Step 1: Load encrypted wallet
if not load_encrypted_wallet():
print("\n❌ FAILED TO LOAD WALLET")
print("Please ensure:")
print("1. config/.env.encrypted contains WALLET_PRIVATE_KEY")
print("2. Encryption password is available")
return 1
# Step 2: Start live trading
print("\n🎯 Wallet loaded successfully!")
print("🔥 Starting live trading with real money...")
print("💰 Maximum $1 USD per trade")
print("🛡️ All safety features active")
print("=" * 50)
return start_live_trading()
if __name__ == "__main__":
sys.exit(main())