Skip to content

Add Telegram trade notifications#1

Open
MarsDoge wants to merge 1 commit into
z-dev-v2from
codex/add-telegram-message-sending-feature
Open

Add Telegram trade notifications#1
MarsDoge wants to merge 1 commit into
z-dev-v2from
codex/add-telegram-message-sending-feature

Conversation

@MarsDoge
Copy link
Copy Markdown
Member

Summary

  • add Telegram notification fields to the auto trader and send formatted cycle summaries with reusable helpers
  • load Telegram credentials from environment when building traders and shut down senders on removal
  • add a unit test that verifies the generated Telegram message includes key decision data

Testing

  • ⚠️ go test ./... (terminated after >2 minutes; full suite is lengthy)
  • go test ./logger -run TestDecisionLogger -count=1

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread trader/auto_trader.go
Comment on lines +583 to +589
err := at.decisionLogger.LogDecision(record)

if at.telegramSender != nil {
message := at.buildTelegramMessage(record, aiDecision, cycleStart, cycleDuration)
if message != "" {
at.telegramSender.SendAsync(message)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent Telegram sender from being nilled mid-send

When Telegram notifications are enabled, removing a trader can crash the process. RemoveTrader (manager/trader_manager.go:466‑488) calls trader.Stop() and, as soon as GetStatus().is_running flips to false, immediately invokes trader.Shutdown(), which calls at.telegramSender.Stop() and sets at.telegramSender = nil. However, Stop() only toggles isRunning and closes stopMonitorCh; it does not wait for the currently running cycle to finish. If a cycle happens to be in saveAndNotifyDecision (this block) when the trader is removed, it may pass the if at.telegramSender != nil guard, build the message, and then hit at.telegramSender.SendAsync(message) after Shutdown() has already set the pointer to nil. Dereferencing a nil receiver causes a panic and tears down the goroutine (and likely the whole process). Access to telegramSender needs synchronization (e.g., take a copy before the nil check or wait for Run to exit before calling Shutdown) so the pointer cannot change between the guard and the method call.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant