market-data
Market data retrieval with OpenAlgo - real-time quotes, historical OHLCV, market depth, option chains, WebSocket streaming, and symbol search
What this skill does
# OpenAlgo Market Data
Access real-time and historical market data using OpenAlgo's unified Python SDK. Supports REST API for on-demand data and WebSocket for real-time streaming.
## Environment Setup
```python
from openalgo import api
# REST API only
client = api(
api_key='your_api_key_here',
host='http://127.0.0.1:5000'
)
# With WebSocket streaming
client = api(
api_key='your_api_key_here',
host='http://127.0.0.1:5000',
ws_url='ws://127.0.0.1:8765',
verbose=True # Enable connection logs
)
```
## Quick Start Scripts
### Get Quotes
```bash
python scripts/quotes.py --symbol RELIANCE --exchange NSE
python scripts/quotes.py --symbols RELIANCE,TCS,INFY --exchange NSE
```
### Get Historical Data
```bash
python scripts/history.py --symbol SBIN --exchange NSE --interval 5m --start 2025-01-01 --end 2025-01-15
```
### Get Market Depth
```bash
python scripts/depth.py --symbol SBIN --exchange NSE
```
### Stream Live Data
```bash
python scripts/stream.py --symbols NIFTY,BANKNIFTY --exchange NSE_INDEX --mode ltp
```
---
## REST API Methods
### 1. Single Quote
Get current market quote for a symbol:
```python
response = client.quotes(symbol="RELIANCE", exchange="NSE")
```
**Response:**
```json
{
"status": "success",
"data": {
"open": 1172.0,
"high": 1196.6,
"low": 1163.3,
"ltp": 1187.75,
"ask": 1188.0,
"bid": 1187.85,
"prev_close": 1165.7,
"volume": 14414545
}
}
```
### 2. Multiple Quotes
Get quotes for multiple symbols in one call:
```python
response = client.multiquotes(symbols=[
{"symbol": "RELIANCE", "exchange": "NSE"},
{"symbol": "TCS", "exchange": "NSE"},
{"symbol": "INFY", "exchange": "NSE"},
{"symbol": "NIFTY", "exchange": "NSE_INDEX"}
])
```
**Response:**
```json
{
"status": "success",
"results": [
{
"symbol": "RELIANCE",
"exchange": "NSE",
"data": {
"open": 1542.3,
"high": 1571.6,
"low": 1540.5,
"ltp": 1569.9,
"prev_close": 1539.7,
"ask": 1569.9,
"bid": 1569.8,
"oi": 0,
"volume": 14054299
}
},
...
]
}
```
### 3. Market Depth (Level 2)
Get order book with 5 best bid/ask levels:
```python
response = client.depth(symbol="SBIN", exchange="NSE")
```
**Response:**
```json
{
"status": "success",
"data": {
"open": 760.0,
"high": 774.0,
"low": 758.15,
"ltp": 769.6,
"ltq": 205,
"prev_close": 746.9,
"volume": 9362799,
"oi": 161265750,
"totalbuyqty": 591351,
"totalsellqty": 835701,
"asks": [
{"price": 769.6, "quantity": 767},
{"price": 769.65, "quantity": 115},
{"price": 769.7, "quantity": 162},
{"price": 769.75, "quantity": 1121},
{"price": 769.8, "quantity": 430}
],
"bids": [
{"price": 769.4, "quantity": 886},
{"price": 769.35, "quantity": 212},
{"price": 769.3, "quantity": 351},
{"price": 769.25, "quantity": 343},
{"price": 769.2, "quantity": 399}
]
}
}
```
### 4. Historical Data (OHLCV)
Get historical candlestick data:
```python
response = client.history(
symbol="SBIN",
exchange="NSE",
interval="5m",
start_date="2025-01-01",
end_date="2025-01-15"
)
```
**Response (Pandas DataFrame):**
```
close high low open volume
timestamp
2025-01-01 09:15:00+05:30 772.50 774.00 763.20 766.50 318625
2025-01-01 09:20:00+05:30 773.20 774.95 772.10 772.45 197189
2025-01-01 09:25:00+05:30 775.15 775.60 772.60 773.20 227544
...
```
**Available Intervals:**
```python
response = client.intervals()
# Returns: {'minutes': ['1m', '3m', '5m', '10m', '15m', '30m'],
# 'hours': ['1h'], 'days': ['D']}
```
### 5. Option Chain
Get complete option chain for an underlying:
```python
chain = client.optionchain(
underlying="NIFTY",
exchange="NSE_INDEX",
expiry_date="30JAN25",
strike_count=10 # ±10 strikes from ATM (optional)
)
```
**Response:**
```json
{
"status": "success",
"underlying": "NIFTY",
"underlying_ltp": 26215.55,
"expiry_date": "30JAN25",
"atm_strike": 26200.0,
"chain": [
{
"strike": 26100.0,
"ce": {
"symbol": "NIFTY30JAN2526100CE",
"label": "ITM2",
"ltp": 490,
"bid": 490,
"ask": 491,
"volume": 1195800,
"oi": 5000000,
"lotsize": 75
},
"pe": {
"symbol": "NIFTY30JAN2526100PE",
"label": "OTM2",
"ltp": 193,
"bid": 191.2,
"ask": 193,
"volume": 1832700,
"oi": 4500000,
"lotsize": 75
}
},
...
]
}
```
### 6. Expiry Dates
Get available expiry dates:
```python
response = client.expiry(
symbol="NIFTY",
exchange="NFO",
instrumenttype="options" # or "futures"
)
# Returns: ['30-JAN-25', '06-FEB-25', '13-FEB-25', ...]
```
---
## Symbol Search & Discovery
### Search Symbols
```python
response = client.search(query="NIFTY 26000 JAN CE", exchange="NFO")
```
**Response:**
```json
{
"status": "success",
"message": "Found 7 matching symbols",
"data": [
{
"symbol": "NIFTY30JAN2526000CE",
"exchange": "NFO",
"expiry": "30-JAN-25",
"strike": 26000,
"instrumenttype": "CE",
"lotsize": 75
},
...
]
}
```
### Get Symbol Details
```python
response = client.symbol(symbol="NIFTY30JAN25FUT", exchange="NFO")
```
**Response:**
```json
{
"status": "success",
"data": {
"symbol": "NIFTY30JAN25FUT",
"exchange": "NFO",
"name": "NIFTY",
"expiry": "30-JAN-25",
"instrumenttype": "FUT",
"lotsize": 75,
"freeze_qty": 1800,
"tick_size": 10
}
}
```
### Get All Instruments
Download complete instrument list for an exchange:
```python
instruments = client.instruments(exchange="NSE")
# Returns Pandas DataFrame with all symbols
```
---
## WebSocket Streaming
### Connection Setup
```python
from openalgo import api
import time
client = api(
api_key='your_api_key',
host='http://127.0.0.1:5000',
ws_url='ws://127.0.0.1:8765',
verbose=True # Show connection logs
)
# Connect to WebSocket
client.connect()
```
### Verbose Levels
| Level | Value | Description |
|-------|-------|-------------|
| Silent | `False` or `0` | Errors only (default) |
| Basic | `True` or `1` | Connection, auth, subscription logs |
| Debug | `2` | All market data updates |
### Stream LTP (Last Traded Price)
```python
instruments = [
{"exchange": "NSE", "symbol": "RELIANCE"},
{"exchange": "NSE", "symbol": "INFY"},
{"exchange": "NSE_INDEX", "symbol": "NIFTY"}
]
def on_ltp(data):
print(f"{data['symbol']}: {data['data']['ltp']}")
client.subscribe_ltp(instruments, on_data_received=on_ltp)
# Run for 60 seconds
time.sleep(60)
# Cleanup
client.unsubscribe_ltp(instruments)
client.disconnect()
```
### Stream Quotes (OHLC + Bid/Ask)
```python
def on_quote(data):
d = data['data']
print(f"{data['symbol']}: O={d['open']} H={d['high']} L={d['low']} LTP={d['ltp']}")
client.subscribe_quote(instruments, on_data_received=on_quote)
```
### Stream Market Depth
```python
def on_depth(data):
d = data['data']
print(f"{data['symbol']}: Best Bid={d['bids'][0]['price']} Best Ask={d['asks'][0]['price']}")
client.subscribe_depth(instruments, on_data_received=on_depth)
```
### Get Cached Data
Access latest cached data without callback:
```python
# After subscribing
ltp_data = client.get_ltp()
quote_data = client.get_quotes()
depth_data = client.get_depth()
# Access specific symbol
nifty_ltp = ltp_data['ltp']['NSE_INDEX']['NIFTY']['ltp']
```
---
## Market Information
### Trading Holidays
```python
response = client.holidays(year=2025)
```
**Response:**
```json
{
"data": [
{
"date": "2025-01-26",
"description": "Republic Day",
"holiday_type": "TRADING_HOLIDAY",
"closed_exchanges": ["NSE", "BSE", "NFO", "MCX"]
},
...
]
}
```
### Exchange Timings
``Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.