44 Commits

Author SHA1 Message Date
Thigazhezhilan J
ae3a335ea1 Harden server restart: remove import-time crashes, centralise secret validation
- auth_service.py: RESET_OTP_SECRET no longer crashes at import; read lazily
  inside _hash_otp() so the module always loads cleanly
- main.py: _validate_runtime_secrets() now checks both BROKER_TOKEN_KEY and
  RESET_OTP_SECRET together, reporting all missing vars in one clear message
- .env.example: documents every required/optional env var with generation commands

With load_dotenv() + .env file, all secrets survive pm2 restarts automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 12:58:22 +05:30
Thigazhezhilan J
0a7e038be9 Load .env file at startup and validate BROKER_TOKEN_KEY format
Adds python-dotenv so secrets survive pm2 restarts without relying on
PM2 env vars. Validates the Fernet key format at startup so a bad/missing
key fails immediately with a clear message rather than crashing mid-request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 12:49:33 +05:30
Thigazhezhilan J
6027dd3c6f Make auto-login optional at startup so backend always boots 2026-05-02 15:38:36 +05:30
Thigazhezhilan J
1b3be0437d Gracefully handle missing pyotp so backend always starts 2026-05-02 15:34:09 +05:30
Thigazhezhilan J
f5762de2b4 Fix startup crash by importing pyotp lazily inside function 2026-05-02 15:31:13 +05:30
Thigazhezhilan J
e1759b14fa Fix CORS to allow quantfortune.com alongside app.quantfortune.com 2026-05-02 15:23:24 +05:30
Thigazhezhilan J
94f175668a Add automated daily Zerodha token refresh (auto-login)
- New auto_login_service.py: stores encrypted credentials (login ID,
  password, TOTP secret), performs headless Zerodha login via pyotp,
  and refreshes the session daily at 6:05 AM IST via background thread
- New auto_login router: setup, status, remove, and manual trigger endpoints
- Scheduler started at app boot alongside existing daemons
- Added pyotp==2.9.0 dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 12:47:21 +05:30
Thigazhezhilan J
1b14e7b23e Fix broker session showing connected after Zerodha token expiry
- Set connected=FALSE (was TRUE) when expiring broker session so the
  dashboard correctly reflects disconnected state
- Notify user by email when their Zerodha session expires so they know
  to reconnect before the next SIP execution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 13:38:45 +05:30
Thigazhezhilan J
247a1c5107 Make engine event payloads JSON safe 2026-04-15 09:54:35 +05:30
Thigazhezhilan J
a90603f4f6 Fix broker reconnect dashboard redirect 2026-04-14 09:54:19 +05:30
Thigazhezhilan J
b5b759c5ed Fix Zerodha callback state propagation 2026-04-12 20:17:48 +05:30
root
988443f40f Made Changes from server by mohan 2026-04-10 00:08:23 +00:00
root
78aa2bf201 Made Changes from server by mohan 2026-04-10 00:06:30 +00:00
Thigazhezhilan J
d857f9d703 Stabilize admin API access and overview metrics 2026-04-10 00:37:07 +05:30
Thigazhezhilan J
9c171ba799 Fix broker reconciliation, health readiness, and live equity safety 2026-04-09 23:46:13 +05:30
Thigazhezhilan J
519addd78f Harden backend auth, execution safety, and market session logic 2026-04-08 22:02:24 +05:30
Thigazhezhilan J
8d1eaafebb Exclude sold positions from portfolio value 2026-04-07 09:51:52 +05:30
Thigazhezhilan J
652e5504c3 Normalize live position market values 2026-04-07 09:36:59 +05:30
Thigazhezhilan J
565de64459 Add live broker positions to portfolio API 2026-04-06 11:31:29 +05:30
Thigazhezhilan J
c41f6f2411 Reconcile stale running strategy state 2026-04-06 11:10:03 +05:30
Thigazhezhilan J
760eb6ea1a Fix Groww funds parsing 2026-04-05 20:39:17 +05:30
Thigazhezhilan J
28ec6c9a4d Add Groww live broker integration 2026-04-05 19:42:08 +05:30
Thigazhezhilan J
d5fa17b30d 2026-04-05 17:23:48 +05:30
Thigazhezhilan J
102f145553 Hide stale errors after strategy stop 2026-04-02 10:25:01 +05:30
Thigazhezhilan J
88ea093525 Fix live market time handling in strategy engine 2026-04-02 09:59:09 +05:30
Thigazhezhilan J
302edc5b79 Suppress stale market closed warnings 2026-04-01 21:07:40 +05:30
Thigazhezhilan J
1660b13778 Use run lifecycle for live strategy status 2026-04-01 10:12:03 +05:30
Thigazhezhilan J
4ae42baeb1 Make strategy stop idempotent 2026-04-01 09:49:42 +05:30
Thigazhezhilan J
c8edbf1a98 Ignore stale broker auth warnings after reconnect 2026-04-01 09:30:22 +05:30
Thigazhezhilan J
001731a3a9 Allow reconnect redirect override 2026-03-31 10:24:56 +05:30
Thigazhezhilan J
1a7466728a Preserve broker link on token expiry 2026-03-29 11:25:05 +05:30
Thigazhezhilan J
f92b5c5afc Fix resume lifecycle ordering 2026-03-28 14:37:42 +05:30
Thigazhezhilan J
2a75cec620 Return JSON for resume route failures 2026-03-28 14:32:08 +05:30
Thigazhezhilan J
bc79894cd1 Harden strategy resume failure handling 2026-03-28 14:25:42 +05:30
Thigazhezhilan J
382b5aa5f6 Improve resume strategy error handling and status updates 2026-03-28 13:45:51 +05:30
Thigazhezhilan J
79c036ca8b Add resume strategy functionality and update run status handling 2026-03-28 13:06:35 +05:30
Thigazhezhilan J
5f29d8c757 admin_page 2026-03-26 00:17:40 +05:30
Thigazhezhilan J
9770b7a338 Add live equity snapshots and improve broker handling 2026-03-25 23:33:09 +05:30
Thigazhezhilan J
c17222ad9c Refine live strategy execution flow 2026-03-24 21:59:17 +05:30
Thigazhezhilan J
7677895b05 thigal_test 2026-03-22 14:37:33 +05:30
root
f4b7575f00 Added CORS Origin 2026-02-21 10:33:37 +00:00
32191b59eb Update backend/requirements.txt 2026-02-15 10:06:19 +00:00
thigazhezhilan
82098ff9e5 Update run_backend.ps1 2026-02-01 14:10:08 +00:00
thigazhezhilan
53be845b6e Backend full repo clean 2026-02-01 13:57:30 +00:00