Skip to content

fix: validate selfRegister positions and refresh market-intel quotes#233

Open
haidrrrry wants to merge 1 commit into
HKUDS:mainfrom
haidrrrry:contribute/hkuds-issue-fixes
Open

fix: validate selfRegister positions and refresh market-intel quotes#233
haidrrrry wants to merge 1 commit into
HKUDS:mainfrom
haidrrrry:contribute/hkuds-issue-fixes

Conversation

@haidrrrry
Copy link
Copy Markdown

Summary

Fixes two open upstream issues:

Also normalizes short positions registered via selfRegister to negative quantity (consistent with trade signal position updates).

Related issues

Fixes #188
Related to #141, #185

Test plan

  • pytest service/server/tests/test_market_intel.py — yfinance fallback
  • pytest service/server/tests/test_agent_register_positions.py — validation + short qty sign
  • pytest service/server/tests/test_services.py — short add weighted entry price (existing)

Notes

Addresses HKUDS/AI-Trader HKUDS#141 and HKUDS#188.

- Validate initial position quantity/entry_price with Pydantic
- Store short selfRegister positions with negative quantity
- Fall back to yfinance when Alpha Vantage intraday quotes are unavailable
- Expose price_as_of / price_stale metadata for yfinance quotes

Co-authored-by: Cursor <cursoragent@cursor.com>
@haidrrrry
Copy link
Copy Markdown
Author

Maintainer note — verification run locally:

cd service/server
ALLOW_SQLITE=true pytest tests/test_market_intel.py tests/test_agent_register_positions.py tests/test_services.py -q
# 18 passed

Scope is intentionally small (5 files). No MCP/Docker/README changes.

If you prefer yfinance fallback behind an env flag, happy to adjust in a follow-up commit.

@haidrrrry
Copy link
Copy Markdown
Author

@TianyuFan0504 friendly ping when you have a moment — small bugfix PR for #188/#141. Happy to split or adjust scope if easier to review.

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.

Market Intelligence API returns stale prices (1-2 days delayed)

1 participant