Skip to content

Commit 37d465b

Browse files
Teerapat-Vatpitakcodex
authored andcommitted
fix(mcp): unresolved symbols, finite options validation, row cap (HKUDS#120)
* fix(mcp): surface unresolved market-data symbols A typo / wrong-suffix / delisted / no-data code vanished from get_market_data's result (the dict only held winners), so it was indistinguishable from "no data", and a loader exception lost every already-resolved symbol (P05). Report any requested code that produced nothing under a reserved `_unresolved` key (additive — omitted when all codes resolve, so the all-resolved payload is byte-identical to before) and wrap the per-group loader.fetch so a blow-up is contained, not opaque. Richer per-symbol status objects are a deliberate breaking follow-up. (cherry picked from commit eba2044e982c5d467c808bad05386de3d856d635) * fix(tools): reject invalid analyze_options inputs Invalid inputs (volatility<=0, spot/strike<=0, negative expiry, bad option_type) and T=0 all returned status:"ok" with silently wrong / zeroed Greeks, and NaN could leak into the JSON (P06). Validate at the boundary and reject invalid inputs with an error envelope; flag the legitimate T=0 expiry as status:"degenerate" with a warning (intrinsic value still returned); serialize with allow_nan=False. The normal path is numerically unchanged. The Greeks-convention rework (delta=0.5 at expiry) is a larger follow-up, out of scope here. (cherry picked from commit 823dc2382d73b97919807cf14a3644073886247d) * fix(mcp): cap get_market_data row output Every row of every symbol was emitted, so the canonical "1 symbol, 1 year, daily" request (~251 rows) breached the MCP token budget and had to spool to a file, defeating an inline data tool (P07). Add a max_rows cap (default 250): a symbol exceeding it returns a head+tail window plus truncation metadata (rows/returned/truncated/ hint); symbols within the cap are unchanged (plain list, so small queries are byte-identical); max_rows=0 restores the unbounded legacy behavior. Columnar encoding and envelope de-duplication are broader follow-ups, out of scope here. (cherry picked from commit 0e426b1d0523e8c8144c699f89cd4847199e6448) * fix(options): reject nan/inf + log dropped loader options_pricing previously accepted NaN/Inf numeric inputs and silently produced unreliable Greeks. Reject any non-finite spot, strike, expiry_days, volatility, or risk_free_rate at the validation boundary before pricing, and treat a missing result key as non-finite so a dropped field is flagged degenerate instead of defaulting to a confident 0.0. mcp_server.get_market_data: the contained loader-failure path (P05) now logs the swallowed exception with logger.exception instead of vanishing silently; the _unresolved fallthrough is unchanged. * fix(mcp): stride row cap, reject neg max_rows _cap_rows previously returned a head+tail window with a synthetic {_gap: N} sentinel, hiding the middle of the series and emitting a fake non-bar record. Replace with an even-stride downsample (every step-th bar, last bar pinned) so the capped series spans the full date range with only real bars. A negative max_rows now enforces the default cap instead of being treated as <=0 (which silently disabled the cap and returned an unbounded payload). max_rows=0 still means unbounded; the in-cap plain-list path is unchanged.
1 parent cd24f99 commit 37d465b

5 files changed

Lines changed: 525 additions & 50 deletions

File tree

0 commit comments

Comments
 (0)