Skip to main content

Installation

pip install vectrade
Optional extras:
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:
ResourceMethods
client.quotesget(symbol), batch(symbols)
client.fundamentalsget(symbol), statements(symbol)
client.technicalsget(symbol)
client.newslist(symbol)
client.optionschain(symbol)
client.analystconsensus(symbol), price_targets(symbol), ratings(symbol)
client.earningshistory(symbol)
client.insidertransactions(symbol)
client.profileget(symbol)
client.sentimentget(symbol)
client.historicalget(symbol, period="5d")
client.etfget(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