Skip to content

Guard zero-equity weight target translation - #123

Merged
Pigbibi merged 1 commit into
mainfrom
fix/zero-equity-decision-guard
Jun 3, 2026
Merged

Guard zero-equity weight target translation#123
Pigbibi merged 1 commit into
mainfrom
fix/zero-equity-decision-guard

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • convert zero-equity weight decisions into value-mode no_execute plans before target translation
  • keep weight translation annotations for diagnostics while preventing total_equity=0 validation errors
  • add regression coverage for empty/new accounts

Validation

  • PYTHONPATH=.:../QuantPlatformKit/src:../UsEquityStrategies/src:../HkEquityStrategies/src uv run --no-project --with pytest --with pandas pytest tests/test_decision_mapper.py -q
  • PYTHONPATH=.:../QuantPlatformKit/src:../UsEquityStrategies/src:../HkEquityStrategies/src uv run --no-project --with ruff ruff check decision_mapper.py tests/test_decision_mapper.py

@Pigbibi
Pigbibi merged commit 7c98af8 into main Jun 3, 2026
1 check passed
@Pigbibi
Pigbibi deleted the fix/zero-equity-decision-guard branch June 3, 2026 04:52

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

Copy link
Copy Markdown

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.

Reviewed commit: c27da7ed87

ℹ️ 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 decision_mapper.py
positions.append(
PositionTarget(
symbol=position.symbol,
target_value=0.0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve holdings for blocked zero-equity plans

When a margin or loan-backed account reports total_equity <= 0 while still holding strategy symbols, this branch converts the blocked weight decision into zero-dollar targets. The generated plan does not carry a consumable no_execute guard for execution; the rebalance loop reads allocation["targets"] and sells whenever target_values[symbol] - market_values[symbol] is below the threshold (application/execution_service.py:606, application/execution_service.py:693). Previously this input failed before any executable plan was produced, but now it can submit liquidation sells for those symbols. For a no-execute fallback, keep current market values as targets or add an execution block that downstream code actually honors.

Useful? React with 👍 / 👎.

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