Execute trades, manage portfolios, access real-time market data, browse and search market assets, scan volatility, and answer questions about Finam Trade API
---
name: finam
description: Execute trades, manage portfolios, access real-time market data, browse and search market assets, scan volatility, and answer questions about Finam Trade API
metadata: '{"openclaw": {"emoji": "📈", "homepage": "https://tradeapi.finam.ru/", "requires": {"bins": ["curl", "jq", "python3"], "env": ["FINAM_API_KEY", "FINAM_ACCOUNT_ID"]}}}'
---
# Finam Trade API Skill
## Setup
**Prerequisites:** `$FINAM_API_KEY` and `$FINAM_ACCOUNT_ID` must be already set in your environment.
If not configured by environment, follow these steps:
1. Register and obtain your API Key from [tokens page](https://tradeapi.finam.ru/docs/tokens)
2. Obtain your Account ID from your [Finam account dashboard](https://lk.finam.ru/)
3. Set environment variables:
```shell
export FINAM_API_KEY="your_api_key_here"
export FINAM_ACCOUNT_ID="your_account_id_here"
```
Obtain JWT token before using the API:
```shell
export FINAM_JWT_TOKEN=$(curl -sL "https://api.finam.ru/v1/sessions" \
--header "Content-Type: application/json" \
--data '{"secret": "'"$FINAM_API_KEY"'"}' | jq -r '.token')
```
**Note:** Token expires after 15 minutes. Re-run this command if you receive authentication errors.
## Market assets
### List Available Exchanges and Equities
**Symbol Format:** All symbols must be in `ticker@mic` format (e.g., `SBER@MISX`)
**Base MIC Codes:**
- `MISX` - Moscow Exchange
- `RUSX` - RTS
- `XNGS` - NASDAQ/NGS
- `XNMS` - NASDAQ/NNS
- `XNYS` - New York Stock Exchange
View all supported exchanges with their MIC codes:
```shell
jq -r '.exchanges[] | "\(.mic) - \(.name)"' assets/exchanges.json
```
List stocks available on a specific exchange:
```shell
MIC="MISX"
LIMIT=20
jq -r ".$MIC[:$LIMIT] | .[] | \"\(.symbol) - \(.name)\"" assets/equities.json
```
### Get Asset Specification
Fetch detailed specification for a specific instrument (lot size, price step, decimals, trading schedule, etc.):
```shell
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/assets/$SYMBOL?account_id=$FINAM_ACCOUNT_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
`account_id` is optional but recommended — returns account-specific fields (margin, available quantity, etc.).
### Search Assets
Search instruments by ticker glob pattern and/or name substring:
```shell
# By ticker glob
python3 scripts/asset_search.py 'SBER*'
# By name (case-insensitive substring)
python3 scripts/asset_search.py --name 'apple'
# By ticker glob + type filter
python3 scripts/asset_search.py 'NG*' --type FUTURES
# Search across all instruments (including archived) via /assets/all
python3 scripts/asset_search.py 'NG*' --type FUTURES --active false
```
Available types: `EQUITIES`, `FUTURES`, `BONDS`, `FUNDS`, `SPREADS`, `OTHER`, `CURRENCIES`, `OPTIONS`, `SWAPS`, `INDICES`
`--max=N` switches to `GET /v1/assets/all` with pagination (rate limit: 200 req/min). `--active false` includes archived instruments.
### Get Top N Stocks by Volume
Pre-ranked lists of the 100 most liquid equities for each market, ordered by trading volume descending:
```shell
N=10
jq -r ".[:$N] | .[] | \"\(.ticker) - \(.name)\"" assets/top_ru_equities.json
```
```shell
N=10
jq -r ".[:$N] | .[] | \"\(.ticker) - \(.name)\"" assets/top_us_equities.json
```
## Account Management
### Get Account Portfolio
Retrieve portfolio information including positions, balances, and P&L:
```shell
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
## Market Data
### Get Latest Quote
Retrieve current bid/ask prices and last trade:
```shell
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/quotes/latest" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
### Get Order Book (Depth)
View current market depth with bid/ask levels:
```shell
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/orderbook" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
### Get Recent Trades
List the most recent executed trades:
```shell
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/trades/latest" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
### Get Historical Candles (OHLCV)
Retrieve historical price data with specified timeframe:
```shell
SYMBOL="SBER@MISX"
TIMEFRAME="TIME_FRAME_D"
START_TIME="2024-01-01T00:00:00Z"
END_TIME="2024-04-01T00:00:00Z"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/bars?timeframe=$TIMEFRAME&interval.start_time=$START_TIME&interval.end_time=$END_TIME" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
**Available Timeframes:**
| Timeframe | Description | Max data depth (end_time - start_time) |
|---|---|---|
| `TIME_FRAME_UNSPECIFIED` | Not specified | — |
| `TIME_FRAME_M1` | 1 minute | 7 days |
| `TIME_FRAME_M5` | 5 minutes | 30 days |
| `TIME_FRAME_M15` | 15 minutes | 30 days |
| `TIME_FRAME_M30` | 30 minutes | 30 days |
| `TIME_FRAME_H1` | 1 hour | 30 days |
| `TIME_FRAME_H2` | 2 hours | 30 days |
| `TIME_FRAME_H4` | 4 hours | 30 days |
| `TIME_FRAME_H8` | 8 hours | 30 days |
| `TIME_FRAME_D` | Day | 365 days |
| `TIME_FRAME_W` | Week | ~5 years |
| `TIME_FRAME_MN` | Month | ~5 years |
| `TIME_FRAME_QR` | Quarter | ~5 years |
> **Note:** The max data depth is the maximum allowed range for `end_time - start_time`. If the range exceeds the limit, the API returns empty data.
**Date Format (RFC 3339):**
- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DDTHH:MM:SS+HH:MM`
- `start_time` - Inclusive (interval start, included in results)
- `end_time` - Exclusive (interval end, NOT included in results)
- Examples:
- `2024-01-15T10:30:00Z` (UTC)
- `2024-01-15T10:30:00+03:00` (Moscow time, UTC+3)
## News
### Get Latest Market News
Fetch and display the latest news headlines. No JWT token required.
Russian market news
```shell
curl -sL "https://www.finam.ru/analysis/conews/rsspoint/" | python3 -c "
import sys, xml.etree.ElementTree as ET
root = ET.parse(sys.stdin).getroot()
for item in reversed(root.findall('.//item')):
print(f'* {item.findtext('title','')}. {item.findtext('description','').split('...')[0]}')
"
```
US market news
```shell
curl -sL "https://www.finam.ru/international/advanced/rsspoint/" | python3 -c "
import sys, xml.etree.ElementTree as ET
root = ET.parse(sys.stdin).getroot()
for item in reversed(root.findall('.//item')):
print(f'* {item.findtext('title','')}. {item.findtext('description','').split('...')[0]}')
"
```
**Parameters:**
- Change `[:10]` to any number to control how many headlines to display
## Order Management
> **IMPORTANT:** Before placing or cancelling any order, you MUST explicitly confirm the details with the user and
> receive their approval. State the full order parameters (symbol, side, quantity, type, price) and wait for confirmation
> before executing.
### Place Order
**Order Types:**
- `ORDER_TYPE_MARKET` - Market order (executes immediately, no `limit_price` required)
- `ORDER_TYPE_LIMIT` - Limit order (requires `limit_price`)
```shell
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders" \
--header "Authorization: $FINAM_JWT_TOKEN" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg symbol "SBER@MISX" \
--arg quantity "10" \
--arg side "SIDE_BUY" \
--arg type "ORDER_TYPE_LIMIT" \
--arg price "310.50" \
'{symbol: $symbol, quantity: {value: $quantity}, side: $side, type: $type, limit_price: {value: $price}}')" \
| jq
```
**Parameters:**
- `symbol` - Instrument (e.g., `SBER@MISX`)
- `quantity.value` - Number of shares/contracts
- `side` - `SIDE_BUY` or `SIDE_SELL`
- `type` - `ORDER_TYPE_MARKET` or `ORDER_TYPE_LIMIT`
- `limit_price` - Only for `ORDER_TYPE_LIMIT` (omit for market orders)
### Get Order Status
Check the status of a specific order:
```shell
ORDER_ID="12345678"
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders/$ORDER_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
### Cancel Order
Cancel a pending order:
```shell
ORDER_ID="12345678"
curl -sL --request DELETE "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders/$ORDER_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
```
## Volatility Scanner
Scans the top-100 stocks for a given market and prints the most volatile ones based on annualized historical volatility (close-to-close, last 60 days).
**Usage:**
```shell
python3 scripts/volatility.py [ru|us] [N]
```
**Arguments:**
- `ru` / `us` — market to scan (default: `ru`)
- `N` — number of top results to display (default: `10`)
**Examples:**
```shell
# Top 10 most volatile Russian stocks
python3 scripts/volatility.py ru 10
# Top 5 most volatile US stocks
python3 scripts/volatility.py us 5
```
All scripts support `--help` for usage details (e.g. `python3 scripts/volatility.py --help`).
## REST vs gRPC — When to Use Which
**Use REST when:**
- Fetching historical OHLCV data for backtesting or analysis
- Retrieving account info, positions, balances, and trade history
- Searching instruments or fetching asset specifications
- Placing or cancelling a one-off order where 100–200 ms latency is acceptable
- Checking order status after placement
**Use gRPC when:**
- Subscribing to real-time market data: quotes, order book, trade feed
- Processing live bar data (M1, M5) for signal generation in event-driven strategies
- Monitoring own orders and trades in real time via subscription
- Your strategy requires minimal latency for rapid order placement/cancellation
- Building long-running trading bots that need persistent, auto-reconnecting connections
For gRPC, use the [FinamPy](https://github.com/cia76/FinamPy) Python library (
`pip install git+https://github.com/cia76/FinamPy.git`).
Full usage reference: [gRPC Python Reference](references/GRPC.md)
---
For full REST API details, use the local file: [REST Reference](references/REST.md)
For extra gRPC API details, fetch from: [gRPC Reference](https://tradeapi.finam.ru/docs/grpc/)don't have the plugin yet? install it then click "run inline in claude" again.
execute trades and manage portfolios on Finam, fetch real-time and historical market data (quotes, order book, candles), search and browse market assets across Russian and US exchanges, scan volatility, and get market news. use this skill when you need to trade equities, futures, bonds, or funds on Finam; check positions and balances; retrieve price data for analysis; or monitor market conditions. requires active Finam account with API credentials and active JWT session (refreshed every 15 minutes).
required environment variables:
FINAM_API_KEY - API secret key from tokens page. scope: full trading and data access.FINAM_ACCOUNT_ID - your numeric account ID from Finam dashboard. used in all account and order endpoints.runtime token:
FINAM_JWT_TOKEN - obtained by exchanging API key for JWT. expires after 15 minutes. regenerate before use if stale.binaries required:
curl - HTTP client for API callsjq - JSON parser and formatterpython3 - for asset search, volatility scanning, and news parsingexternal connections:
https://api.finam.ru/v1/) - primary endpoint for trades, quotes, historical datagrpc.finam.ru:443) - optional, for real-time subscriptions (requires FinamPy library)finam.ru/analysis/conews/rsspoint/, finam.ru/international/advanced/rsspoint/) - news RSS (no auth required)inputs: FINAM_API_KEY
steps:
export FINAM_JWT_TOKEN=$(curl -sL "https://api.finam.ru/v1/sessions" \
--header "Content-Type: application/json" \
--data '{"secret": "'"$FINAM_API_KEY"'"}' | jq -r '.token')
outputs: FINAM_JWT_TOKEN environment variable set. token valid for 15 minutes.
edge cases:
jq -r '.token' returns nulljq fails to parse, token is empty string; subsequent API calls will fail with 401--max-time 10 to enforce timeoutinputs: FINAM_JWT_TOKEN, FINAM_ACCOUNT_ID
steps:
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON object with fields: balance, equity, open_positions[], cash, margin_used, etc.
edge cases:
open_positions array is empty but presentinputs: optional ticker glob pattern, name substring, asset type filter, active/archived flag
steps (option A: by ticker glob):
python3 scripts/asset_search.py 'SBER*'
steps (option B: by name substring, case-insensitive):
python3 scripts/asset_search.py --name 'apple'
steps (option C: by type filter):
python3 scripts/asset_search.py 'NG*' --type FUTURES
steps (option D: include archived instruments):
python3 scripts/asset_search.py 'NG*' --type FUTURES --active false
outputs: list of matching instruments with symbol, name, type, MIC code. format: TICKER@MIC
asset types: EQUITIES, FUTURES, BONDS, FUNDS, SPREADS, OTHER, CURRENCIES, OPTIONS, SWAPS, INDICES
available exchanges (MIC codes):
MISX - Moscow ExchangeRUSX - RTSXNGS - NASDAQ/NGSXNMS - NASDAQ/NMSXNYS - New York Stock Exchangeedge cases:
--max=N flag and switches to /v1/assets/all endpoint (rate limit: 200 req/min)--active false to include theminputs: symbol in format TICKER@MIC, optional FINAM_ACCOUNT_ID for account-specific fields
steps:
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/assets/$SYMBOL?account_id=$FINAM_ACCOUNT_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON object with fields: lot_size, price_step, decimals, trading_schedule, margin_buy, margin_sell, available_for_short_sell, etc.
edge cases:
inputs: symbol in TICKER@MIC format, FINAM_JWT_TOKEN
steps:
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/quotes/latest" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON object with: bid, ask, last_price, last_trade_time, volume, open_interest
edge cases:
last_price, bid, ask may be stale (from last session close)bid/ask spreads wide or missinghalted: trueinputs: symbol, FINAM_JWT_TOKEN
steps:
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/orderbook" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON object with bids[] and asks[] arrays. each level contains price, quantity, and order count.
edge cases:
inputs: symbol, FINAM_JWT_TOKEN
steps:
SYMBOL="SBER@MISX"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/trades/latest" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON array of recent trades with: price, quantity, time, side (buyer or seller aggressor)
edge cases:
inputs: symbol, timeframe, start time (RFC 3339, inclusive), end time (RFC 3339, exclusive), FINAM_JWT_TOKEN
steps:
SYMBOL="SBER@MISX"
TIMEFRAME="TIME_FRAME_D"
START_TIME="2024-01-01T00:00:00Z"
END_TIME="2024-04-01T00:00:00Z"
curl -sL "https://api.finam.ru/v1/instruments/$SYMBOL/bars?timeframe=$TIMEFRAME&interval.start_time=$START_TIME&interval.end_time=$END_TIME" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON array of candles with fields: time, open, high, low, close, volume
available timeframes and max data depth:
| timeframe | max range |
|---|---|
| TIME_FRAME_M1 | 7 days |
| TIME_FRAME_M5 | 30 days |
| TIME_FRAME_M15 | 30 days |
| TIME_FRAME_M30 | 30 days |
| TIME_FRAME_H1 | 30 days |
| TIME_FRAME_H2 | 30 days |
| TIME_FRAME_H4 | 30 days |
| TIME_FRAME_H8 | 30 days |
| TIME_FRAME_D | 365 days |
| TIME_FRAME_W | 5 years |
| TIME_FRAME_MN | 5 years |
| TIME_FRAME_QR | 5 years |
date format (RFC 3339): YYYY-MM-DDTHH:MM:SSZ (UTC) or YYYY-MM-DDTHH:MM:SS+HH:MM (with offset). start_time inclusive, end_time exclusive.
edge cases:
inputs: none (no JWT required)
steps (Russian market news):
curl -sL "https://www.finam.ru/analysis/conews/rsspoint/" | python3 -c "
import sys, xml.etree.ElementTree as ET
root = ET.parse(sys.stdin).getroot()
for item in reversed(root.findall('.//item')):
print(f'* {item.findtext(\"title\",\"\")}. {item.findtext(\"description\",\"\").split(\"...\")[0]}')
"
steps (US market news):
curl -sL "https://www.finam.ru/international/advanced/rsspoint/" | python3 -c "
import sys, xml.etree.ElementTree as ET
root = ET.parse(sys.stdin).getroot()
for item in reversed(root.findall('.//item')):
print(f'* {item.findtext(\"title\",\"\")}. {item.findtext(\"description\",\"\").split(\"...\")[0]}')
"
outputs: plain text headlines with snippet from description. one per line.
edge cases:
inputs: symbol, quantity, side (BUY/SELL), order type (MARKET or LIMIT), optional limit price, FINAM_JWT_TOKEN, FINAM_ACCOUNT_ID
prerequisite: user must explicitly confirm order details (symbol, side, qty, price, type) before execution.
steps (limit order):
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders" \
--header "Authorization: $FINAM_JWT_TOKEN" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg symbol "SBER@MISX" \
--arg quantity "10" \
--arg side "SIDE_BUY" \
--arg type "ORDER_TYPE_LIMIT" \
--arg price "310.50" \
'{symbol: $symbol, quantity: {value: $quantity}, side: $side, type: $type, limit_price: {value: $price}}')" \
| jq
steps (market order):
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders" \
--header "Authorization: $FINAM_JWT_TOKEN" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg symbol "SBER@MISX" \
--arg quantity "10" \
--arg side "SIDE_BUY" \
--arg type "ORDER_TYPE_MARKET" \
'{symbol: $symbol, quantity: {value: $quantity}, side: $side, type: $type}')" \
| jq
outputs: JSON object with fields: order_id, symbol, quantity, side, type, status (typically ACCEPTED), created_at
order parameters:
symbol - format: TICKER@MIC (e.g. SBER@MISX)quantity.value - integer shares or contractsside - SIDE_BUY or SIDE_SELLtype - ORDER_TYPE_MARKET or ORDER_TYPE_LIMITlimit_price - required for LIMIT orders only; omit for MARKET ordersedge cases:
inputs: order ID, FINAM_JWT_TOKEN, FINAM_ACCOUNT_ID
steps:
ORDER_ID="12345678"
curl -sL "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders/$ORDER_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: JSON object with fields: order_id, status (ACCEPTED, PENDING, EXECUTED, CANCELLED, REJECTED), filled_quantity, remaining_quantity, executed_price, created_at, executed_at
edge cases:
inputs: order ID, FINAM_JWT_TOKEN, FINAM_ACCOUNT_ID
steps:
ORDER_ID="12345678"
curl -sL --request DELETE "https://api.finam.ru/v1/accounts/$FINAM_ACCOUNT_ID/orders/$ORDER_ID" \
--header "Authorization: $FINAM_JWT_TOKEN" | jq
outputs: HTTP 200 on success. returns cancelled order details or confirmation.
edge cases:
inputs: market (ru or us), number of results (default 10)
steps:
python3 scripts/volatility.py ru 10
steps (US market):
python3 scripts/volatility.py us 5
outputs: ranked list of top-N most volatile stocks by annualized historical volatility (close-to-close, last 60 days). format: ticker, name, volatility percentage.
edge cases:
decision: token expired or invalid?
null after step 1, API key is invalid; abort and ask user to verify FINAM_API_KEY.decision: symbol not found (HTTP 404)?
decision: insufficient funds for order placement?
decision: order type chosen?
decision: market open or closed?
trading_schedule for exact open/close times.**decision: date range exceeds max depth for time