Skip to content

Update pybinbot#984

Open
carkod wants to merge 1 commit intomasterfrom
update-pybinbot
Open

Update pybinbot#984
carkod wants to merge 1 commit intomasterfrom
update-pybinbot

Conversation

@carkod
Copy link
Copy Markdown
Owner

@carkod carkod commented Apr 25, 2026

No description provided.

@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

if flip_contracts <= current_contracts:
self.active_bot.add_log(
"Insufficient balance to reverse position after hitting stop loss, closing position with stop loss order."
)
self.execute_stop_loss()

P1 Badge Return after stop-loss fallback in reversal path

With the new <= check, insufficient-balance cases now enter this branch, call execute_stop_loss(), and then continue into new-bot creation and reversal orders. In this flow, _is_reversal_possible(...) returns current_contracts when reversal is not affordable, so continuing after stop-loss can still submit unintended reversal orders immediately after closing, which contradicts the fallback message and can produce extra trades/fees in live futures accounts.


latestPortfolioValue !== undefined &&
lastBenchmarkValue !== undefined &&
Math.abs(lastBenchmarkValue - latestPortfolioValue) < 0.0001
? previousStoredPortfolioValue
: lastBenchmarkValue;

P2 Badge Use a stable prior point for live PnL comparison

This equality heuristic (abs(lastBenchmarkValue - latestPortfolioValue) < 0.0001) is brittle now that the backend appends a live point per benchmark request: when /balance and /benchmark-series are fetched at slightly different times, small market moves frequently make the values differ by more than the threshold. In that case, previousPortfolioValue falls back to the last benchmark value (another live sample) instead of the prior stored snapshot, so displayed PnL becomes near-zero/noisy rather than reflecting the intended last-snapshot delta.

ℹ️ 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".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant