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.0.tar.gz (30.9 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.0-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

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

Hashes for market_data_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b199757bde13b96d73de7919a125c21dee8d458975a3b0e2099cdee82c014ae
MD5 134b0af29ae5d8f31f4d64417d5cc7bb
BLAKE2b-256 26bce708d7db5ba404818b472441c5200bb33bcfaa1a65b49c29fd3decfe900d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for market_data_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4cf53e4ec91d277213fb75f3255391b54446eb0c51ed2a6b9f2cc395d5ace2b
MD5 59eefbd2dcfc55052df56bde90759686
BLAKE2b-256 e9a8dd3ba7caecbb4d23b52a46452028e7f9de39b13ce869e5bb327808655710

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