Skip to main content

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


๐Ÿ›ฃ๏ธ 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

market_data_sdk-0.1.1.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

market_data_sdk-0.1.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file market_data_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: market_data_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for market_data_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c971353359318a393618d1edceae8c76c67e6acdec166a3cb85db885396c9cc9
MD5 d39ea9ed8bed9b3e3248db74e18175bd
BLAKE2b-256 944d2db12d8afd340e3ec1293d2314e3afe78f519c3e8622d998656a9226b14f

See more details on using hashes here.

File details

Details for the file market_data_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for market_data_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46f77eb0abe2e833f62bd8125b072ff2f54156c28fb56fdab3dd9db9c8a95ed2
MD5 596e140a2798b37e4fc568b0e7b8c18b
BLAKE2b-256 e80463bc3a6df582e08c343ea7dae9882fb126971761f66bec22ee86c8f10819

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page