5.4 KiB
5.4 KiB
Phase 1: Tradier Data Layer - Context
Gathered: 2026-03-29 Status: Ready for planning
## Phase BoundaryIntegrate Tradier as a new data vendor for options chain retrieval with 1st-order Greeks and IV. Register options-specific tools and categories in the existing vendor routing system. Provide filtered, structured chain data for downstream options analysis agents.
## Implementation DecisionsAPI Authentication
- D-01: Use
TRADIER_API_KEYenv var for credentials, matching existing pattern (OPENAI_API_KEY,ALPHA_VANTAGE_KEY) - D-02: Support sandbox via
TRADIER_SANDBOX=trueenv var — auto-detect base URL (sandbox.tradier.comvsapi.tradier.com)
Data Fetching Strategy
- D-03: Pre-fetch all expirations within DTE range upfront at the start of an analysis run, cache for the session. Do NOT let individual agents make separate API calls for the same data.
- D-04: Default DTE filter range: 0-50 DTE (covers Tastytrade methodology sweet spot ~30–50 DTE plus weeklies and near-term options)
- D-05: Always pass
greeks=trueon chain requests. Sandbox: Tradier sandbox often returns no Greeks (empty/nullgreeks object). Implementations must still call withgreeks=trueand treat missing fields asNonewithout failing. Production: expect populated Greeks. Do not gategreeks=trueonTRADIER_SANDBOX— only the response handling differs.
Data Structure
- D-06: Canonical representation: typed
OptionsContract/OptionsChainin memory; bulk analysis usesOptionsChain.to_dataframe()(pandas). Optional helpers may addfrom_dataframe/ reconstruction utilities if a round-trip is needed; avoid maintaining two divergent sources of truth — derive the DataFrame from the dataclass list.
Claude's Discretion
- Caching strategy: Claude picks the best caching approach. In-memory per-session is simpler; disk TTL helps during development. Choose based on what fits the existing architecture best.
- Rate limit handling: Claude picks the best approach based on existing
AlphaVantageRateLimitErrorfallback pattern. Options include retry with backoff, pre-emptive throttling, or both.
<canonical_refs>
Canonical References
Downstream agents MUST read these before planning or implementing.
Existing Data Layer (follow these patterns)
tradingagents/dataflows/interface.py— Vendor routing system:TOOLS_CATEGORIES,VENDOR_METHODS,VENDOR_LIST,route_to_vendor()tradingagents/dataflows/config.py— Config module pattern for vendor settingstradingagents/default_config.py— Default config withdata_vendorsandtool_vendorsdictstradingagents/dataflows/y_finance.py— Reference implementation for a data vendor moduletradingagents/dataflows/alpha_vantage.py— Second vendor reference with rate limit error handling
Tradier API
https://docs.tradier.com/reference/brokerage-api-markets-get-options-chains— Options chains endpointhttps://docs.tradier.com/reference/brokerage-api-markets-get-options-expirations— Expirations endpointhttps://docs.tradier.com/reference/brokerage-api-markets-get-options-strikes— Strikes endpointhttps://docs.tradier.com/docs/rate-limiting— Rate limiting (120 req/min for market data)
Project Research
.planning/research/STACK.md— Stack recommendations including Tradier integration approach.planning/research/PITFALLS.md— Data quality pitfalls (stale Greeks, hourly update frequency)
</canonical_refs>
<code_context>
Existing Code Insights
Reusable Assets
interface.py::route_to_vendor()— Vendor routing with automatic fallback on rate limit errorsinterface.py::TOOLS_CATEGORIES— Tool category registration pattern (add newoptions_chaincategory)interface.py::VENDOR_METHODS— Method-to-vendor mapping (add new options methods)config.py— Config management withget_config(),set_config()patternAlphaVantageRateLimitError— Rate limit error pattern to replicate for Tradier
Established Patterns
- Vendor module: One Python file per vendor (
y_finance.py,alpha_vantage.py) with exported functions - Function naming:
get_*prefix for data retrieval (get_stock_data,get_fundamentals) - Config: Category-level defaults in
data_vendorsdict, tool-level overrides intool_vendors - No SDK dependency: Use
requestsdirectly for Tradier (consistent with keeping deps lean)
Integration Points
interface.py— Register newoptions_chaincategory inTOOLS_CATEGORIES, add"tradier"toVENDOR_LIST, add options methods toVENDOR_METHODSdefault_config.py— Add"options_chain": "tradier"todata_vendorstradingagents/agents/utils/— New tool functions for options data (likecore_stock_tools.pypattern)
</code_context>
## Specific Ideas- Tradier OCC symbology format:
AAPL220617C00270000(symbol + date + C/P + strike*1000) - Greeks fields from Tradier:
delta,gamma,theta,vega,rho,phi,bid_iv,mid_iv,ask_iv,smv_vol - Response format:
{"data": {"options": {"option": [...]}}}— nested JSON requiring extraction - Sandbox has no Greeks — production account required for full testing
None — discussion stayed within phase scope
Phase: 01-tradier-data-layer Context gathered: 2026-03-29