-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
问题描述
使用 Node.js SDK longbridge@4.0.0,并通过 OAuth 2.0 接入 Longbridge OpenAPI。
- OAuth 登录成功 (模拟账号)
- Quote API 可正常使用
TradeContext.new(...)可正常创建- 但所有交易资产相关的只读接口持续失败
典型报错如下:
accountBalance()返回code=202201: get userinfo errorstockPositions()返回code=500: internal server error- 其他部分交易只读接口返回
code=602001: user not found
代码例子
import { OAuth, Config, QuoteContext, TradeContext } from 'longbridge';
const oauth = await OAuth.build(clientId, () => {}, 60355);
const config = Config.fromOAuth(oauth);
const quoteCtx = await QuoteContext.new(config);
const tradeCtx = await TradeContext.new(config);
await tradeCtx.accountBalance();
await tradeCtx.stockPositions();实际结果:
OAuth.build(...):成功Config.fromOAuth(...):成功QuoteContext.new(...):成功TradeContext.new(...):成功- 行情权限包可以正常打印
accountBalance():失败,报错openapi error: code=202201: get userinfo errorstockPositions():失败,报错openapi error: code=500: internal server error
直接调用官方 HTTP API 的复现结果
1. Quote API 正常
请求:
curl -H "Authorization: Bearer <oauth_access_token>" \
"https://openapi.longbridge.com/v1/quote/get_security_list?market=US&category=Overnight"响应:
{"code":0,"message":"success", ...}2. 账户资产接口失败
请求:
curl -H "Authorization: Bearer <oauth_access_token>" \
"https://openapi.longbridge.com/v1/asset/account"响应:
{"code":202201,"message":"获取用户信息失败","data":null}3. 股票持仓接口失败
请求:
curl -H "Authorization: Bearer <oauth_access_token>" \
"https://openapi.longbridge.com/v1/asset/stock"响应:
{"code":500,"message":"internal server error","data":null}4. 其他交易只读接口同样失败
请求:
curl -H "Authorization: Bearer <oauth_access_token>" \
"https://openapi.longbridge.com/v1/trade/execution/today"响应:
{"code":602001,"message":"user not found","data":null}你的环境信息
- 操作系统:Windows
- 运行时:Node
- 官方 SDK:
longbridge@4.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels