-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (26 loc) · 1.41 KB
/
main.py
File metadata and controls
34 lines (26 loc) · 1.41 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
# main.py
import os
import signal
import datetime
from analytics.graphs import vol_cone, iv_vs_rv
from analytics.telegram import notify, send_eod_summary
from zoneinfo import ZoneInfo
IST = ZoneInfo("Asia/Kolkata")
def on_stop(signum, frame):
notify(f"🔴 Trading system stopped — {datetime.datetime.now(tz=IST).strftime('%H:%M:%S')} IST")
send_eod_summary()
exit(0)
signal.signal(signal.SIGTERM, on_stop)
signal.signal(signal.SIGINT, on_stop)
# Write PID
with open("trading.pid", "w") as f:
f.write(str(os.getpid()))
# ── Pre-market ──────────────────────────────────────────────────────────────────────────
iv_vs_rv()
vol_cone()
# ── Start dashboard ───────────────────────────────────────────────────────────
notify(f"🟢 Trading system started — {datetime.datetime.now(tz=IST).strftime('%H:%M:%S')} IST")
from dashboard.app import app
app.run(debug=False, host="0.0.0.0", port=8050)
# ── Post-market (runs after app is stopped) ───────────────────────────────────
notify(f"🔴 Trading system stopped — {datetime.datetime.now().strftime('%H:%M:%S')} IST")