-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_credential_setup.py
More file actions
200 lines (158 loc) Β· 5.72 KB
/
simple_credential_setup.py
File metadata and controls
200 lines (158 loc) Β· 5.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
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
#!/usr/bin/env python3
"""
Simple credential setup without external dependencies.
This creates a basic configuration file for testing.
"""
import json
import os
from pathlib import Path
def create_simple_config():
"""Create a simple configuration file."""
print("π§ Creating Simple Configuration...")
# Get API credentials
print("\nPlease enter your Binance API credentials:")
api_key = input("API Key: ").strip()
if not api_key:
print("β API Key cannot be empty")
return False
api_secret = input("API Secret: ").strip()
if not api_secret:
print("β API Secret cannot be empty")
return False
# Create config directory
config_dir = Path("config")
config_dir.mkdir(exist_ok=True)
# Create simple config
config = {
"testnet": True,
"symbols": ["BTCUSDT", "ETHUSDT"],
"strategies": {
"liquidity": {"enabled": True, "weight": 1.0},
"momentum": {"enabled": True, "weight": 1.0},
"chart_patterns": {"enabled": True, "weight": 1.0},
"candlestick_patterns": {"enabled": True, "weight": 1.0}
},
"risk_config": {
"max_position_size": 0.02,
"daily_loss_limit": 0.05,
"max_drawdown": 0.15,
"stop_loss_pct": 0.02,
"take_profit_pct": 0.04
},
"notification_config": {
"enabled": True,
"channels": ["console"]
},
"logging_config": {
"level": "INFO",
"log_dir": "logs"
}
}
# Save main config
config_file = config_dir / "bot_config.json"
with open(config_file, 'w') as f:
json.dump(config, f, indent=2)
# Save credentials separately (unencrypted for now)
credentials = {
"api_key": api_key,
"api_secret": api_secret
}
cred_file = config_dir / "credentials.json"
with open(cred_file, 'w') as f:
json.dump(credentials, f, indent=2)
print(f"β
Configuration saved to {config_file}")
print(f"β
Credentials saved to {cred_file}")
print("β οΈ Note: Credentials are stored unencrypted for now")
return True
def test_config():
"""Test the created configuration."""
print("\nπ Testing Configuration...")
try:
config_file = Path("config/bot_config.json")
cred_file = Path("config/credentials.json")
if not config_file.exists():
print("β Configuration file not found")
return False
if not cred_file.exists():
print("β Credentials file not found")
return False
# Load and validate config
with open(config_file, 'r') as f:
config = json.load(f)
with open(cred_file, 'r') as f:
credentials = json.load(f)
print(f"β
Configuration loaded: {len(config)} sections")
print(f"β
Credentials loaded: API key length {len(credentials['api_key'])}")
print(f" Testnet mode: {config['testnet']}")
print(f" Symbols: {config['symbols']}")
return True
except Exception as e:
print(f"β Configuration test failed: {e}")
return False
def create_requirements_installer():
"""Create a batch file to install requirements."""
print("\nπ¦ Creating Requirements Installer...")
# Create a batch file for Windows
batch_content = """@echo off
echo Installing Python dependencies...
echo.
REM Try different Python commands
py -m pip install --upgrade pip
if %errorlevel% neq 0 (
python -m pip install --upgrade pip
if %errorlevel% neq 0 (
python3 -m pip install --upgrade pip
)
)
echo.
echo Installing required packages...
py -m pip install cryptography aiohttp websockets pandas numpy
if %errorlevel% neq 0 (
python -m pip install cryptography aiohttp websockets pandas numpy
if %errorlevel% neq 0 (
python3 -m pip install cryptography aiohttp websockets pandas numpy
)
)
echo.
echo Installation complete!
pause
"""
with open("install_requirements.bat", 'w') as f:
f.write(batch_content)
print("β
Created install_requirements.bat")
print(" Run this file to install Python dependencies")
return True
def main():
"""Main function."""
print("π Simple Crypto Trading Bot Setup\n")
# Create configuration
config_success = create_simple_config()
if config_success:
# Test configuration
test_success = test_config()
# Create installer
installer_success = create_requirements_installer()
if test_success:
print("\nπ Setup Complete!")
print("\nπ Next Steps:")
print(" 1. Run install_requirements.bat to install dependencies")
print(" 2. Run: py simple_test.py (to test core functionality)")
print(" 3. Run: py test_binance_api.py (to test API connection)")
print(" 4. Continue with bot development")
print("\nβ οΈ Security Note:")
print(" Your credentials are currently stored unencrypted.")
print(" After installing dependencies, the bot will use encrypted storage.")
return True
print("\nβ Setup failed. Please try again.")
return False
if __name__ == "__main__":
try:
success = main()
input("\nPress Enter to exit...")
except KeyboardInterrupt:
print("\nβΉοΈ Setup cancelled by user")
except Exception as e:
print(f"\nπ₯ Setup crashed: {e}")
import traceback
traceback.print_exc()
input("\nPress Enter to exit...")