fix: validate selfRegister positions and refresh market-intel quotes#233
Open
haidrrrry wants to merge 1 commit into
Open
fix: validate selfRegister positions and refresh market-intel quotes#233haidrrrry wants to merge 1 commit into
haidrrrry wants to merge 1 commit into
Conversation
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>
This was referenced May 23, 2026
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 passedScope 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. |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two open upstream issues:
selfRegisterinitial positionquantityandentry_pricewith Pydantic instead of accepting raw dicts (prevents invalid/zero values and type errors)./api/market-intel/stocks/{symbol}/latestsocurrent_priceis same-day instead of 1–2 day old snapshot data. Addsprice_as_of,price_stale, andprice_statushandling for the yfinance source.Also normalizes short positions registered via
selfRegisterto 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 fallbackpytest service/server/tests/test_agent_register_positions.py— validation + short qty signpytest service/server/tests/test_services.py— short add weighted entry price (existing)Notes