Skip to content

可正常访问 Quote API,但所有 Trade 资产接口持续返回 202201 get userinfo error / 602001 user not found #468

@zhengyongjie16

Description

@zhengyongjie16

问题描述

使用 Node.js SDK longbridge@4.0.0,并通过 OAuth 2.0 接入 Longbridge OpenAPI。

  • OAuth 登录成功 (模拟账号)
  • Quote API 可正常使用
  • TradeContext.new(...) 可正常创建
  • 但所有交易资产相关的只读接口持续失败

典型报错如下:

  • accountBalance() 返回 code=202201: get userinfo error
  • stockPositions() 返回 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 error
  • stockPositions():失败,报错 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions