6.3.1513 • Published 3 years ago

futu-api-js v6.3.1513

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

futu-api

npm Futu Websocket API for Node.js

Install

npm install --save futu-api-js

Usage

Example:

import ftWebsocket from "futu-api-js";

let websocket = new ftWebsocket();
//参数1指定监听地址
//参数2指定Websocket服务端口
//参数3指定是否启用SSL,如果需要启用则需要在FutuOpenD配置相关选项
//参数4指定连接的密钥,否则会连接超时,密钥在在FutuOpenD可配置,UI版本在不指定的情况下会随机指定
websocket.start("127.0.0.1", 33333, false, null);
websocket.onlogin = (ret, msg) => {
  if (ret) {
    const req = {
      c2s: {
        securityList: [{
          market: 1,
          code: "00700",
        }]
      },
    };
  websocket
    .GetSecuritySnapshot(req)
    .then((res) => {
      console.log("res", res)
    })
    .catch((error) => {
      console.log("error:", error);
    });

    //关闭行情连接,连接不再使用之后,要关闭,否则占用不必要资源
    //同时OpenD也限制了最多128条连接
    //也可以一个页面或者一个项目维护一条连接,这里范例请求一次创建一条连接
    websocket.stop();
  } else {
    console.log("error:", msg);
  }
};
6.3.1513

3 years ago

5.3.1512

3 years ago

5.3.1513

3 years ago

5.3.1511

3 years ago

5.3.1510

3 years ago

5.3.1509

3 years ago

5.3.1508

3 years ago