-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_optimize_cli.py
More file actions
31 lines (24 loc) · 1.08 KB
/
Copy pathrun_optimize_cli.py
File metadata and controls
31 lines (24 loc) · 1.08 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
"""Optional CLI optimizer, useful before Telegram is configured.
Example:
python run_optimize_cli.py binance BTC/USDT 15m 1h 180 spot 10000 0.5
"""
from __future__ import annotations
import asyncio
import sys
from core.config import load_config
from core.models import MarketType
from crypto_bot.optimizer import StrategyOptimizer
from crypto_bot.results_io import save_optimizer_result
async def main() -> None:
if len(sys.argv) < 7:
print("Usage: python run_optimize_cli.py <exchange> <symbol> <tf> <trend_tf> <days> <spot|futures> [capital] [risk_pct]")
raise SystemExit(1)
exchange, symbol, tf, trend_tf, days_s, mt_s = sys.argv[1:7]
capital = float(sys.argv[7]) if len(sys.argv) > 7 else None
risk_pct = float(sys.argv[8]) if len(sys.argv) > 8 else None
cfg = load_config()
result = await StrategyOptimizer(cfg).run_remote(exchange, symbol, tf, trend_tf, int(days_s), MarketType(mt_s), capital, risk_pct)
print(result.to_text(top_n=10))
print(f"\nSaved: {save_optimizer_result(cfg, result)}")
if __name__ == "__main__":
asyncio.run(main())