Add startup summary snapshot and per-poll console ticker logging - #12
Conversation
- Emit initial position summary at bot startup with full console output - Log per-position PNL deltas (up/down, current, max/min) at every poll - Add logSummaryToConsole() for human-readable summary in node logs - Remove unused pollLogged field Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
|
|
||
| // Emit an initial summary snapshot to both console and Telegram. | ||
| try { | ||
| await this.summaryMonitor.emitSummary(); |
There was a problem hiding this comment.
@copilot there seems to be a major issue with the summaryMonitor class, as this is, nor any other polling activity are ever logged to SIGINT, nor persisted to the logs. can you please debug?
There was a problem hiding this comment.
The root cause was that summaryMonitor was only instantiated when SUMMARY_NOTIFICATION_CHANNEL (or PNL_NOTIFICATION_CHANNEL) was set — so without a Telegram channel configured, no polling, ticker logging, or summary snapshots would ever run.
Fixed in the latest commit: the summaryMonitor now always starts regardless of Telegram config, so all polling activity (per-position PNL ticker, summary snapshots, ticker log persistence) flows through node console logs and ./logs files unconditionally. Telegram delivery is skipped gracefully when no channel is set.
Also fixed: stop() is now async and flushes a final sample + summary before the process exits on SIGINT/SIGTERM, and ticker log files are included in the retention cleanup.
There was a problem hiding this comment.
@copilot could it also display a summary right on script startup? not after the first poll?
There was a problem hiding this comment.
Moved emitSummary() to run before start(), so the summary snapshot displays immediately on script startup without waiting for the first poll/sample cycle.
- summaryMonitor.stop() now async: runs a final sample() + emitSummary() so polling data and the summary are persisted before process exits - Shutdown handler awaits summaryMonitor.stop() and logs completion - Logger cleanupOldFiles now includes ticker-*.log in retention cleanup Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
The summaryMonitor (polling, ticker logging, per-position PNL, summary snapshots) was only created when a Telegram notification channel was configured. Now it always starts so polling activity appears in node console logs and is persisted to ./logs regardless of Telegram config. Telegram delivery is skipped gracefully when no channel is set. Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
|
@copilot no polling activity or logging is happening at the default/set 30s interval. can you please review what triggers it, and make sure it is always triggered during node app startup? |
Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
Two issues found and fixed:
|
|
@copilot when the node app starts it stucks at MEXC connection OK, and only when I press Ctrl C that SIGINT is triggered. Could there be a misunderstanding on what SIGINT should do in this system? These actions should always be interpreted as the start of the node service and the invoked script (dist/index.js for bot:start or src/index.js for npm run bot). |
I likely was trying to say STDOUT and said SIGINT by mistake. Please fix @copilot |
Co-authored-by: angeloreale <12191809+angeloreale@users.noreply.github.com>
Fixed by making |
Understood — this was already addressed in commit |
|
This worked. Thanks |


npm run botwas missing two behaviors: no summary snapshot on startup, and no per-position PNL output in node logs during polling. The polling timer, local log persistence, SL/TP alerts, and min/max tracking already existed.Changes
emitSummary()called immediately after monitor starts, so operators see current account state without waiting for the first scheduled intervallogSummaryToConsole()renders the full summary (positions, pending orders, balance, equity) to stdout via the Logger, mirroring what Telegram receivessample()cycle now logs every open position with PNL delta since last poll, current PNL, and rolling max/min:prevPnlmap; first sample omits delta.pollLoggedfield