0.2.0 • Published 10 months ago

futu-sdk v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

说明

本 SDK 用于对接富途 OpenAPI 量化接口的网关程序 OpenD. 虽然富途官方提供了配套的futu-api,但如果你在使用 futu-api 过程中遇到了一些卡点,可以尝试选择futu-sdk来对接。这些卡点可能是:

  • 依赖缺失(如 long, WebSocket, memcpy)、不兼容(node >=0.8 <=0.12)或过于老旧(如 bytebuffer)
  • 模块化接口不一致(commonjsesm 混用)
  • 缺少类型支持和提示等

使用

1. 安装

本 SDK 提供可直接执行的 commonjsesm 模块,也可以在 nextjs, nestjs, create-react-app 等开发环境下安装使用。

$ npm install --save futu-sdk

2. 使用

对应官方获取交易业务账户列表的例子,futu-sdk 简化了建立连接逻辑,提供了基于 Promise / Generator(SubSubAccPush 两个接口返回是 Generator,其他都是 Promise) 的接口和类型支持。

import { getFutuApi } from 'futu-sdk';
// import { Trd_Common } from 'futu-sdk/proto';

const { webRequest, webSocket } = getFutuApi('ws://127.0.0.1:33333', '9d261112869397f0');
try {
  const { accList } = await webRequest.GetAccList({ userID: 0, needGeneralSecAccount: true });
  console.log({ accList });
} finally {
  webSocket.close();
}

其他接口的使用方式如此类推,需要特别注意的是 futu-sdk 统一简化了两个数据结构:

  • 请求参数:只需传入 req, 自动将 req 装箱为 { c2s: req };
  • 响应结果:直接使用 res, 自动将 { s2c: res } 拆箱为 res.
0.2.0

10 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago