Repository navigation
polish(resources): positions_all, lookback enum, multivariate @deprecated, event_ticker list helper - #290
Conversation
…lidation
The spec marks GET /multivariate_event_collections/{ticker}/lookup,
PUT .../lookup, and POST .../{ticker} (create_market) as 'deprecated: true'
with the message 'This endpoint predates RFQs and should not be used for
new integrations.' Decorate the three sync + three async methods with
typing_extensions.deprecated so callers see a DeprecationWarning at
runtime and a type-checker hint (PEP 702).
Also reject lookback_seconds outside the spec enum {10, 60, 300, 3600}
client-side via _validate_lookback_seconds — server returns 400 for any
other value; failing before the GET mirrors the limit-bounds ergonomic
fix landed in #229.
Adds typing-extensions>=4.5 dep (3.12 lacks typing.deprecated which is
3.13+ only). Adds filterwarnings to silence the new DeprecationWarning
in existing tests that intentionally exercise these endpoints; user
callers still see it.
Bundled in this commit: drop the stale '{event_ticker} but spec uses
{ticker}' NOTE in tests/_contract_support.py — the SeriesResource rename
it forecast is long done.
Items 2, 3, 5 of #269 polish bundle.
Every other cursor-paginated endpoint on PortfolioResource (settlements, deposits, withdrawals) and FcmResource (orders) ships a *_all() iterator that wraps the cursor loop and exposes max_pages as a safety cap. positions() did not, so callers walking the full book had to hand-roll the loop and re-derive the _validate_max_pages guard. Add positions_all() to PortfolioResource + AsyncPortfolioResource and FcmResource + AsyncFcmResource, yielding MarketPosition. Reuses the shared _list_all paginator with 'market_positions' as the items key. EventPosition aggregates from the response envelope are intentionally not surfaced — see docstring rationale (page boundaries split aggregates arbitrarily so concatenating across pages would not reconstruct a meaningful event-level total). Register the four new methods in tests/_contract_support.py (MethodEndpointEntry + cursor Exclusion + _MAX_PAGES_FQNS) so the contract-drift suite covers them. Item 1 of #269 polish bundle.
…-10 guard GET /portfolio/orders is the one route whose event_ticker param refs MultipleEventTickerQuery in the spec (openapi.yaml:3961-3967): comma- joined string, server max 10. The SDK accepted only str, forcing callers either to hand-join the list (and forget the max-10 cap until the server 400's) or to fall back to client-side filtering. Widen OrdersResource.list / list_all + AsyncOrdersResource.list / list_all kwarg to list[str] | str | None and run it through _join_tickers(..., max_items=10). _join_tickers grows a keyword-only max_items cap that rejects oversize lists before the wire (pre-joined strings opt out — caller owns wire format). Not widened on HistoricalResource.markets or FcmResource.orders despite the issue suggesting otherwise: their spec refs are SingleEventTickerQuery (openapi.yaml:3769, :3448) — passing multiple is undefined behaviour server-side. Item 4 stays narrow to /portfolio/orders. Item 4 of #269 polish bundle. Closes #269
Code Review — PR #290Summary: Wave 3 of the post-v2.4 audit. Adds ✅ What's done well
🐛 Bugs / correctness issuesNone found. The async 🔍 Issues / suggestions1. Missing async deprecation-warning tests (gap)
class TestAsyncMultivariateDeprecationWarnings:
@pytest.mark.asyncio
async def test_lookup_history_emits_deprecation_warning(self, async_mv): ...
@pytest.mark.asyncio
async def test_lookup_tickers_emits_deprecation_warning(self, async_mv): ...
@pytest.mark.asyncio
async def test_create_market_emits_deprecation_warning(self, async_mv): ...2.
3. The test comment says "Eager validation — must fire at call time, not on iteration", but the test just calls 4.
📋 Nit / style
🔒 SecurityNo concerns. No new endpoints, no user-input paths, no serialization changes outside the established patterns. OverallThe functional additions are correct, well-tested (sync side), and follow conventions closely. The two coverage gaps (async deprecation tests, fcm |
Closes #269
Part of #273 (post-v2.4 audit), Wave 3.