A unified SDK for Polygon and TradingEconomics with LangGraph integration
Project description
Epoch Data Research Tools
A unified SDK for accessing Polygon.io and TradingEconomics market data with LangGraph integration.
๐ Documentation | ๐๏ธ Architecture | โ Tests (31/31) | ๐ค Contributing | ๐ Status
โจ Key Features
Universal Asset Layer
from common.models.asset import EpochAsset, AssetType
# Provider-agnostic representation
asset = EpochAsset(symbol="BTC-USD", asset_type=AssetType.CRYPTO)
asset.to_epoch_asset_id() # โ "^BTCUSD-Crypto"
Polygon Integration
from epoch_polygon.registry import get_tools
# Get 8 LangGraph tools
tools = get_tools()
# Use with agent
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(llm, tools)
Generic Execution
Single _execute() method handles ALL Polygon endpoints:
- โ Stocks, Crypto, Forex, Options, Indices, Futures
- โ Type-based detection (no field name assumptions)
- โ market_type injection, pair splitting, date filters
๐ Quick Start
1. Installation
# Clone repository
git clone <repo-url>
cd EpochDataResearchTools
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install package
pip install -e ".[dev]"
2. Set up API keys
cp .env.example .env
# Edit .env and add:
# POLYGON_API_KEY=your_key_here
3. Run tests
pytest # 31/31 tests passing โ
4. Try examples
python examples/polygon/basic_aggregates.py
๐ฆ Package Structure
EpochDataResearchTools/
โโโ src/
โ โโโ common/ # Universal models (EpochAsset)
โ โโโ epoch_polygon/ # Polygon adapter
โ โโโ tradingeconomics/ # TradingEconomics adapter
โ
โโโ tests/ # 31 passing tests
โ โโโ common/ # 13 EpochAsset tests
โ โโโ polygon/ # 18 Polygon tests
โ
โโโ examples/ # Ready-to-run examples
โโโ docs/ # Comprehensive documentation
โโโ [config files]
๐ฏ Usage Examples
Basic: Get Stock Data
from common.models.asset import EpochAsset, AssetType
from epoch_polygon.models.asset import PolygonAsset
from epoch_polygon.models.requests import AggregatesRequest
from epoch_polygon.models.filters import DateFilter
from epoch_polygon.registry import get_tools
# 1. Create universal asset
epoch_asset = EpochAsset(symbol="AAPL", asset_type=AssetType.STOCK)
# 2. Convert to Polygon format
polygon_asset = PolygonAsset.from_epoch_asset(epoch_asset)
# 3. Create request
request = AggregatesRequest(
asset=polygon_asset,
date_filter=DateFilter.last_n_days(30),
timespan="day",
multiplier=1
)
# 4. Use with tools
tools = get_tools()
# tools[0].invoke(request.model_dump())
Advanced: LangGraph Agent
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from epoch_polygon.registry import get_tools
# Create agent with Polygon tools
llm = ChatOpenAI(model="gpt-4")
tools = get_tools()
agent = create_react_agent(llm, tools)
# Ask questions
result = agent.invoke({
"messages": [("user", "What was AAPL's closing price yesterday?")]
})
๐๏ธ Architecture
EpochAsset Flow
Agent โ EpochAsset โ PolygonAsset.from_epoch_asset() โ Polygon API
โ TEAsset.from_epoch_asset() โ TE API
Asset Conventions
- Stocks:
AAPL,TSLAโ"AAPL-Stock" - Crypto:
BTC-USD,BTC(defaults to USD) โ"^BTCUSD-Crypto" - Forex:
EUR-USDโ"^EURUSD-Forex" - Futures:
ESโ"ES-Future" - Indices:
SPXโ"^SPX-Index"
See EPOCH_ASSET_ARCHITECTURE.md for details.
โ Testing
# All tests
pytest
# Specific suite
pytest tests/common/ # EpochAsset tests
pytest tests/polygon/ # Polygon tests
# With coverage
pytest --cov=src --cov-report=html
# Verbose
pytest -v
Current Status: 31/31 tests passing (0.88s)
See TEST_RESULTS.md for details.
๐ Documentation
- Documentation Index - Start here
- Architecture Guide - Universal asset layer
- Package Structure - Code organization
- Test Results - Coverage details
- Summary - Implementation overview
- Contributing - Development guidelines
- Project Status - Current state & roadmap
๐ฃ๏ธ Roadmap
Completed โ
- Universal asset layer (EpochAsset)
- Polygon integration (4 clients, 8 tools)
- Generic
_execute()for all endpoints - Comprehensive test suite (31 tests)
- Organized documentation
In Progress ๐ง
- TradingEconomics integration
Planned ๐
- More Polygon endpoints (indicators, financials, reference)
from_epoch_asset_id()parser- Real-world integration tests
- Performance benchmarks
See TODO.md for detailed roadmap.
๐ค Contributing
See CONTRIBUTING.md for:
- Development setup
- Code standards
- Architecture patterns
- Testing guidelines
- PR process
๐ License
MIT License
๐ Links
- Polygon.io API - Stock market data
- TradingEconomics - Economic data
- LangGraph - Agent framework
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file market_data_sdk-0.1.0.tar.gz.
File metadata
- Download URL: market_data_sdk-0.1.0.tar.gz
- Upload date:
- Size: 30.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b199757bde13b96d73de7919a125c21dee8d458975a3b0e2099cdee82c014ae
|
|
| MD5 |
134b0af29ae5d8f31f4d64417d5cc7bb
|
|
| BLAKE2b-256 |
26bce708d7db5ba404818b472441c5200bb33bcfaa1a65b49c29fd3decfe900d
|
File details
Details for the file market_data_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: market_data_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4cf53e4ec91d277213fb75f3255391b54446eb0c51ed2a6b9f2cc395d5ace2b
|
|
| MD5 |
59eefbd2dcfc55052df56bde90759686
|
|
| BLAKE2b-256 |
e9a8dd3ba7caecbb4d23b52a46452028e7f9de39b13ce869e5bb327808655710
|