Examples
The vectrade-examples repository contains runnable code samples for every major use case.
Repository Structure
vectrade-examples/
├── python/
│ ├── quickstart.py # First API call
│ ├── streaming_ai.py # Stream AI analysis
│ ├── portfolio_tracker.py # Live portfolio dashboard
│ ├── screener.py # Custom stock screener
│ └── webhook_server.py # Flask webhook receiver
├── typescript/
│ ├── quickstart.ts # First API call
│ ├── edge-function.ts # Vercel Edge streaming
│ ├── discord-bot.ts # Discord price alerts
│ └── ai-agent.ts # AI agent with tools
├── curl/
│ └── examples.sh # Raw HTTP examples
└── notebooks/
├── technical_analysis.ipynb
└── earnings_calendar.ipynb
Python Quickstart
from vectrade import VecTrade
client = VecTrade()
# Get a real-time quote
quote = client.quotes.get( "AAPL" )
print ( f " { quote.symbol } : $ { quote.price :.2f} ( { quote.change_pct :+.2f} %)" )
# Batch multiple tickers
batch = client.quotes.batch([ "AAPL" , "GOOGL" , "MSFT" , "NVDA" ])
for q in batch:
print ( f " { q.symbol } : $ { q.price :.2f} " )
# AI analysis with streaming
for chunk in client.ai.stream( "What's the bull case for NVDA?" ):
print (chunk.text, end = "" , flush = True )
TypeScript Quickstart
import { VecTrade } from "@vectrade/sdk" ;
const client = new VecTrade ();
// Real-time quote
const quote = await client . quotes . get ( "AAPL" );
console . log ( ` ${ quote . symbol } : $ ${ quote . price } ` );
// Screen for undervalued large-caps
const results = await client . screener . screen ({
marketCap: { min: 10_000_000_000 },
pe: { max: 15 },
sector: "Technology" ,
});
for ( const stock of results ) {
console . log ( ` ${ stock . symbol } — P/E: ${ stock . pe } , Market Cap: $ ${ stock . marketCap } B` );
}
import { createVecTrade } from "@vectrade/ai-provider" ;
import { generateText } from "ai" ;
import { openai } from "@ai-sdk/openai" ;
const vt = createVecTrade ();
const { text } = await generateText ({
model: openai ( "gpt-4o" ),
tools: vt . tools (),
maxSteps: 5 ,
prompt: "Compare AAPL and MSFT fundamentals. Which is better value?" ,
});
console . log ( text );
MCP Integration (Claude Desktop)
{
"mcpServers" : {
"vectrade" : {
"command" : "npx" ,
"args" : [ "-y" , "@vectrade/mcp-server" ],
"env" : { "VECTRADE_API_KEY" : "vq_live_..." }
}
}
}
Then ask Claude: “What’s TSLA trading at? Show me the options chain expiring this Friday.”
Webhook Receiver (Python)
from flask import Flask, request
from vectrade import verify_webhook
app = Flask( __name__ )
WEBHOOK_SECRET = "whsec_..."
@app.route ( "/webhook" , methods = [ "POST" ])
def handle ():
event = verify_webhook(
payload = request.data,
headers = request.headers,
secret = WEBHOOK_SECRET ,
)
if event.type == "price_alert.triggered" :
print ( f "🚨 { event.data.symbol } hit $ { event.data.price } " )
return "" , 200
Jupyter Notebook
# Technical analysis notebook
from vectrade import VecTrade
import pandas as pd
client = VecTrade()
technicals = client.technicals.get( "AAPL" , indicators = [ "RSI" , "MACD" , "BB" ])
df = pd.DataFrame({
"RSI" : [technicals.rsi.value],
"MACD" : [technicals.macd.value],
"Signal" : [technicals.macd.signal],
"BB Upper" : [technicals.bollinger.upper],
"BB Lower" : [technicals.bollinger.lower],
})
df.style.highlight_max( axis = 1 )
Run the Examples
git clone https://github.com/VecTrade-io/vectrade-examples.git
cd vectrade-examples
# Python
pip install vectrade
python python/quickstart.py
# TypeScript
npm install
npx tsx typescript/quickstart.ts
Bot Trading & AI Agent Examples
The use-cases/ai-agent-trading/ directory contains complete working examples for bot trading:
Example Description python_openai_agent.pyBuild your own GPT-4o agent that trades via MCP typescript_claude_agent.tsClaude-powered agent using Anthropic SDK + MCP cron_strategy_bot.pyScheduled mean-reversion strategy (no AI required) python/bot_trading.pyDirect Bot API client class typescript/bot-trading.tsDirect Bot API in TypeScript
VecTrade does NOT host or run AI models. You bring your own LLM (or use no AI at all).
The MCP server exposes trading tools that any MCP-compatible agent can discover and use.
See the Bot Trading Guide for full API reference.
vectrade-examples on GitHub Full source code with CI-tested examples for every SDK.