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
- Obtain your Account ID from your Finam account dashboard
- Set environment variables:
CODEBLOCK0
Obtain JWT token before using the API:
CODEBLOCK1
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 - INLINECODE5 - RTS
- INLINECODE6 - NASDAQ/NGS
- INLINECODE7 - NASDAQ/NNS
- INLINECODE8 - New York Stock Exchange
View all supported exchanges with their MIC codes:
CODEBLOCK2
List stocks available on a specific exchange:
CODEBLOCK3
Get Asset Specification
Fetch detailed specification for a specific instrument (lot size, price step, decimals, trading schedule, etc.):
CODEBLOCK4
INLINECODE9 is optional but recommended — returns account-specific fields (margin, available quantity, etc.).
Search Assets
Search instruments by ticker glob pattern and/or name substring:
CODEBLOCK5
Available types: EQUITIES, FUTURES, BONDS, FUNDS, SPREADS, OTHER, CURRENCIES, OPTIONS, SWAPS, INLINECODE19
INLINECODE20 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:
CODEBLOCK6
CODEBLOCK7
Account Management
Get Account Portfolio
Retrieve portfolio information including positions, balances, and P&L:
CODEBLOCK8
Market Data
Get Latest Quote
Retrieve current bid/ask prices and last trade:
CODEBLOCK9
Get Order Book (Depth)
View current market depth with bid/ask levels:
CODEBLOCK10
Get Recent Trades
List the most recent executed trades:
CODEBLOCK11
Get Historical Candles (OHLCV)
Retrieve historical price data with specified timeframe:
CODEBLOCK12
Available Timeframes:
| Timeframe | Description | Max data depth (endtime - starttime) |
|---|
| INLINECODE23 | Not specified | — |
| INLINECODE24 |
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 INLINECODE38 - INLINECODE39 - Inclusive (interval start, included in results)
- INLINECODE40 - 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
CODEBLOCK13
US market news
CODEBLOCK14
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) - INLINECODE46 - Limit order (requires
limit_price)
CODEBLOCK15
Parameters:
- -
symbol - Instrument (e.g., SBER@MISX) - INLINECODE50 - Number of shares/contracts
- INLINECODE51 -
SIDE_BUY or INLINECODE53 - INLINECODE54 -
ORDER_TYPE_MARKET or INLINECODE56 - INLINECODE57 - Only for
ORDER_TYPE_LIMIT (omit for market orders)
Get Order Status
Check the status of a specific order:
CODEBLOCK16
Cancel Order
Cancel a pending order:
CODEBLOCK17
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:
CODEBLOCK18
Arguments:
- -
ru / us — market to scan (default: ru) - INLINECODE62 — number of top results to display (default:
10)
Examples:
CODEBLOCK19
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 Python library (
pip install git+https://github.com/cia76/FinamPy.git).
Full usage reference: gRPC Python Reference
For full REST API details, use the local file:
REST Reference
For extra gRPC API details, fetch from:
gRPC Reference
Finam Trade API 技能
设置
前提条件: 环境中必须已设置 $FINAMAPIKEY 和 $FINAMACCOUNTID。
如果未通过环境变量配置,请按以下步骤操作:
- 1. 从令牌页面注册并获取您的 API 密钥
- 从您的 Finam 账户仪表板获取您的账户 ID
- 设置环境变量:
shell
export FINAMAPIKEY=yourapikey_here
export FINAMACCOUNTID=youraccountid_here
使用 API 前获取 JWT 令牌:
shell
export FINAMJWTTOKEN=$(curl -sL https://api.finam.ru/v1/sessions \
--header Content-Type: application/json \
--data {secret: $FINAMAPIKEY} | jq -r .token)
注意: 令牌 15 分钟后过期。如果收到身份验证错误,请重新运行此命令。
市场资产
列出可用的交易所和股票
代码格式: 所有代码必须采用 ticker@mic 格式(例如 SBER@MISX)
基础 MIC 代码:
- - MISX - 莫斯科交易所
- RUSX - RTS
- XNGS - 纳斯达克/NGS
- XNMS - 纳斯达克/NNS
- XNYS - 纽约证券交易所
查看所有支持的交易所及其 MIC 代码:
shell
jq -r .exchanges[] | \(.mic) - \(.name) assets/exchanges.json
列出特定交易所可用的股票:
shell
MIC=MISX
LIMIT=20
jq -r .$MIC[:$LIMIT] | .[] | \\(.symbol) - \(.name)\ assets/equities.json
获取资产规格
获取特定工具的详细规格(手数、价格步长、小数位数、交易时间表等):
shell
SYMBOL=SBER@MISX
curl -sL https://api.finam.ru/v1/assets/$SYMBOL?accountid=$FINAMACCOUNT_ID \
--header Authorization: $FINAMJWTTOKEN | jq
account_id 为可选但推荐使用——返回账户特定字段(保证金、可用数量等)。
搜索资产
通过股票代码通配符模式和/或名称子字符串搜索工具:
shell
按股票代码通配符
python3 scripts/asset_search.py SBER*
按名称(不区分大小写的子字符串)
python3 scripts/asset_search.py --name apple
按股票代码通配符 + 类型筛选
python3 scripts/asset_search.py NG* --type FUTURES
通过 /assets/all 搜索所有工具(包括已归档的)
python3 scripts/asset_search.py NG* --type FUTURES --active false
可用类型:EQUITIES、FUTURES、BONDS、FUNDS、SPREADS、OTHER、CURRENCIES、OPTIONS、SWAPS、INDICES
--max=N 切换到 GET /v1/assets/all 并支持分页(速率限制:200 次/分钟)。--active false 包含已归档的工具。
按成交量获取前 N 只股票
每个市场流动性最高的 100 只股票的预排名列表,按交易量降序排列:
shell
N=10
jq -r .[:$N] | .[] | \\(.ticker) - \(.name)\ assets/topruequities.json
shell
N=10
jq -r .[:$N] | .[] | \\(.ticker) - \(.name)\ assets/topusequities.json
账户管理
获取账户投资组合
检索投资组合信息,包括持仓、余额和盈亏:
shell
curl -sL https://api.finam.ru/v1/accounts/$FINAMACCOUNTID \
--header Authorization: $FINAMJWTTOKEN | jq
市场数据
获取最新报价
检索当前买入/卖出价格和最后一笔交易:
shell
SYMBOL=SBER@MISX
curl -sL https://api.finam.ru/v1/instruments/$SYMBOL/quotes/latest \
--header Authorization: $FINAMJWTTOKEN | jq
获取订单簿(深度)
查看当前市场深度,包含买入/卖出层级:
shell
SYMBOL=SBER@MISX
curl -sL https://api.finam.ru/v1/instruments/$SYMBOL/orderbook \
--header Authorization: $FINAMJWTTOKEN | jq
获取最近交易
列出最近执行的交易:
shell
SYMBOL=SBER@MISX
curl -sL https://api.finam.ru/v1/instruments/$SYMBOL/trades/latest \
--header Authorization: $FINAMJWTTOKEN | jq
获取历史 K 线(OHLCV)
检索指定时间框架的历史价格数据:
shell
SYMBOL=SBER@MISX
TIMEFRAME=TIMEFRAMED
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.starttime=$STARTTIME&interval.endtime=$ENDTIME \
--header Authorization: $FINAMJWTTOKEN | jq
可用时间框架:
| 时间框架 | 描述 | 最大数据深度(endtime - starttime) |
|---|
| TIMEFRAMEUNSPECIFIED | 未指定 | — |
| TIMEFRAMEM1 |
1 分钟 | 7 天 |
| TIME
FRAMEM5 | 5 分钟 | 30 天 |
| TIME
FRAMEM15 | 15 分钟 | 30 天 |
| TIME
FRAMEM30 | 30 分钟 | 30 天 |
| TIME
FRAMEH1 | 1 小时 | 30 天 |
| TIME
FRAMEH2 | 2 小时 | 30 天 |
| TIME
FRAMEH4 | 4 小时 | 30 天 |
| TIME
FRAMEH8 | 8 小时 | 30 天 |
| TIME
FRAMED | 日 | 365 天 |
| TIME
FRAMEW | 周 | ~5 年 |
| TIME
FRAMEMN | 月 | ~5 年 |
| TIME
FRAMEQR | 季度 | ~5 年 |
注意: 最大数据深度是 endtime - starttime 允许的最大范围。如果范围超过限制,API 将返回空数据。
日期格式(RFC 3339):
- - 格式:YYYY-MM-DDTHH:MM:SSZ 或 YYYY-MM-DDTHH:MM:SS+HH:MM
- starttime - 包含(区间开始,包含在结果中)
- endtime - 排除(区间结束,不包含在结果中)
- 示例:
- 2024-01-15T10:30:00Z(UTC)
- 2024-01-15T10:30:00+03:00(莫斯科时间,UTC+3)
新闻
获取最新市场新闻
获取并显示最新新闻标题。无需 JWT 令牌。
俄罗斯市场新闻
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]})
美国市场新闻
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]})