finhay-portfolio
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFinhay Portfolio
Finhay Portfolio
Read-only trading data via the Finhay Securities Open API. All endpoints use signed requests.
GETMANDATORY: Before any action, read and complete pre-flight checks. Required:,FINHAY_API_KEY,FINHAY_API_SECRET, and the relevantUSER_IDvariable. Do not skip or defer.SUB_ACCOUNT_*
通过Finhay证券开放API获取只读交易数据。所有端点均使用带签名的请求。
GET强制要求:执行任何操作前,请阅读并完成预检检查。需要配置:、FINHAY_API_KEY、FINHAY_API_SECRET以及相关的USER_ID变量。请勿跳过或推迟该步骤。SUB_ACCOUNT_*
Setup
配置
If or variables are missing, run once:
USER_IDSUB_ACCOUNT_*bash
./_shared/scripts/infer-sub-account.shThis writes , , and/or to .
USER_IDSUB_ACCOUNT_NORMALSUB_ACCOUNT_MARGIN~/.finhay/credentials/.env如果缺少或变量,请执行一次以下命令:
USER_IDSUB_ACCOUNT_*bash
./_shared/scripts/infer-sub-account.sh该命令会将、和/或写入文件。
USER_IDSUB_ACCOUNT_NORMALSUB_ACCOUNT_MARGIN~/.finhay/credentials/.envMaking a Request
发起请求
Always use . Resolve all path variables (, ) before calling — the signed path must be the final, fully resolved path.
request.sh{subAccountId}{userId}bash
source ~/.finhay/credentials/.env
./_shared/scripts/request.sh GET "/trading/accounts/$SUB_ACCOUNT_NORMAL/summary"
./_shared/scripts/request.sh GET "/users/v4/users/$USER_ID/assets/summary"
./_shared/scripts/request.sh GET "/trading/sub-accounts/$SUB_ACCOUNT_MARGIN/orders" "fromDate=2024-01-01&toDate=2024-01-31"
./_shared/scripts/request.sh GET "/trading/v2/sub-accounts/$SUB_ACCOUNT_NORMAL/portfolio"
./_shared/scripts/request.sh GET "/trading/pnl-today/$USER_ID"
./_shared/scripts/request.sh GET "/trading/market/session" "exchange=HOSE"始终使用脚本。调用前请解析所有路径变量(、)——签名路径必须是最终的完全解析后的路径。
request.sh{subAccountId}{userId}bash
source ~/.finhay/credentials/.env
./_shared/scripts/request.sh GET "/trading/accounts/$SUB_ACCOUNT_NORMAL/summary"
./_shared/scripts/request.sh GET "/users/v4/users/$USER_ID/assets/summary"
./_shared/scripts/request.sh GET "/trading/sub-accounts/$SUB_ACCOUNT_MARGIN/orders" "fromDate=2024-01-01&toDate=2024-01-31"
./_shared/scripts/request.sh GET "/trading/v2/sub-accounts/$SUB_ACCOUNT_NORMAL/portfolio"
./_shared/scripts/request.sh GET "/trading/pnl-today/$USER_ID"
./_shared/scripts/request.sh GET "/trading/market/session" "exchange=HOSE"Sub-account Selection
子账户选择
When is required, ask the user whether to use NORMAL or MARGIN, then substitute the corresponding env variable:
{subAccountId}- NORMAL →
$SUB_ACCOUNT_NORMAL - MARGIN →
$SUB_ACCOUNT_MARGIN
当需要传入时,询问用户要使用NORMAL还是MARGIN账户,然后替换为对应的环境变量:
{subAccountId}- NORMAL →
$SUB_ACCOUNT_NORMAL - MARGIN →
$SUB_ACCOUNT_MARGIN
Endpoints
端点
| Endpoint | Use when | Path param | Query params | Res key |
|---|---|---|---|---|
| Account detail, margin, debt | | — | |
| Balance, total assets, NAV | | | |
| Order history | | | |
| Today's order book | | — | |
| Single order detail | | — | |
| Stock holdings | | — | |
| Today's P&L | | — | |
| Trading permissions | | — | |
| Market open/close | — | | |
Path versions (, , , ) are fixed. Always use the exact versions listed above.
v1v2v4v5| 端点 | 使用场景 | 路径参数 | 查询参数 | 响应键 |
|---|---|---|---|---|
| 账户详情、保证金、负债 | | — | |
| 余额、总资产、资产净值 | | | |
| 订单历史 | | | |
| 当日订单簿 | | — | |
| 单个订单详情 | | — | |
| 股票持仓 | | — | |
| 当日盈亏 | | — | |
| 交易权限 | | — | |
| 市场开闭市状态 | — | | |
路径版本(、、、)是固定的,请始终使用上方列出的准确版本。
v1v2v4v5Parameter rules
参数规则
- Each endpoint accepts only the parameters listed in its path and query columns above. Do not add extra parameters.
- All in the URL are path variables — substitute them into the URL, never pass as query params.
{variables}
Details & response schemas: references/endpoints.md. Enums: references/enums.md.
- 每个端点仅接受上方路径和查询列中列出的参数,请勿添加额外参数。
- URL中的所有都是路径变量——请将其替换到URL中,切勿作为查询参数传递。
{variables}
详情与响应结构:references/endpoints.md。枚举值:references/enums.md。
Constraints
约束
See shared constraints, plus:
- Never substitute without first confirming the sub-account type with the user.
{subAccountId}
请参见通用约束,同时额外遵循以下规则:
- 未先向用户确认子账户类型的情况下,切勿替换参数。
{subAccountId}