Installation
pip install vectrade
pip install vectrade[telemetry] # OpenTelemetry integration
pip install vectrade[pandas] # DataFrame helpers
Quick Start
from vectrade import VecTrade
client = VecTrade() # reads VECTRADE_API_KEY env var
quote = client.quotes.get("AAPL")
print(f"{quote.symbol}: ${quote.price}")
Async Client
from vectrade import AsyncVecTrade
async def main():
client = AsyncVecTrade()
quote = await client.quotes.get("AAPL")
print(f"{quote.symbol}: ${quote.price}")
Configuration
client = VecTrade(
api_key="vq_live_...", # or VECTRADE_API_KEY env var
base_url="https://...", # custom endpoint
timeout=30, # request timeout (seconds)
max_retries=2, # automatic retries on 429/5xx
sandbox=True, # use sandbox environment
)
Resources
All 12 resource groups available:| Resource | Methods |
|---|---|
client.quotes | get(symbol), batch(symbols) |
client.fundamentals | get(symbol), statements(symbol) |
client.technicals | get(symbol) |
client.news | list(symbol) |
client.options | chain(symbol) |
client.analyst | consensus(symbol), price_targets(symbol), ratings(symbol) |
client.earnings | history(symbol) |
client.insider | transactions(symbol) |
client.profile | get(symbol) |
client.sentiment | get(symbol) |
client.historical | get(symbol, period="5d") |
client.etf | get(symbol) |
Usage Examples
Real-Time Quote
quote = client.quotes.get("AAPL")
print(f"{quote.symbol}: ${quote.price:.2f} ({quote.change_pct:+.2f}%)")
Batch Quotes
quotes = client.quotes.batch(["AAPL", "MSFT", "GOOGL"])
for q in quotes:
print(f"{q.symbol}: ${q.price:.2f}")
Technical Analysis
tech = client.technicals.get("AAPL")
print(f"Score: {tech.technical_score}/100")
print(f"RSI: {tech.indicators['rsi']['value']:.1f} ({tech.indicators['rsi']['signal']})")
print(f"Trend: {tech.summary['trend']}")
Analyst Consensus
analyst = client.analyst.consensus("AAPL")
print(f"Rating: {analyst.consensus} | Signal: {analyst.signal}")
print(f"Analysts: {analyst.total_analysts}")
Error Handling
from vectrade import RateLimitError, NotFoundError
try:
quote = client.quotes.get("INVALID")
except NotFoundError as e:
print(f"Not found: {e} (request_id: {e.request_id})")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
Requirements
- Python 3.9+
- Dependencies:
httpx,pydantic
GitHub
Source code, issues, and contributions