@winner-fed/quote-ws-jsapi
TypeScript icon, indicating that this package has built-in type declarations

1.0.2-alpha.3 • Public • Published

Quote webSocket JSAPI

NPM version

Install package programmatically. Detect package managers automatically (npm, yarn and pnpm).

npm i @winner-fed/quote-ws-jsapi

使用

Webpack or Vite(CJS/ESM)

import OpenAPIWS from '@winner-fed/quote-ws-jsapi';

// 初始化
this.openAPIWS = new OpenAPIWS({
  url: 'ws://ip:port/xxx',
  authId: 'xxx',
  authPassword: 'xxx',
  appKey: 'xxx',
  publicKeyX: 'xxx',
  publicKeyY: 'xxx',
  debug: true // 是否打印日志
});

// 调用
this.openAPIWS
  .subscribeReal(
    // 接口入参
    {
      codes: ['600570.XSHG'],
      fields: ['hq_type_code', 'prod_code']
    },
    // 成功后回调函数
    (data) => {
      console.log(data);
    }
  )
  .then((anwser) => {
    console.log(anwser); // { handleId: 'xxxxxx-xxxxxx-xxxxxx-xxxxxx' }
  });

浏览器(IIFE)

<script src="https://unpkg.com/@winner-fed/quote-ws-jsapi/dist/index.global.js"></script>
<script>
  // 初始化
  const openAPIWS = new window.jQuoteWs.OpenAPI({
    url: 'ws://ip:port/xxx',
    authId: 'xxx',
    authPassword: 'xxx',
    appKey: 'xxx',
    publicKeyX: 'xxx',
    publicKeyY: 'xxx',
    debug: true // 是否打印日志
  });

  // 调用
  OpenAPI.subscribeReal(
    // 接口入参
    {
      codes: ['600570.XSHG'],
      fields: ['hq_type_code', 'prod_code']
    },
    // 成功后回调函数
    (data) => {
      console.log(data);
    }
  ).then((anwser) => {
    console.log(anwser); // { handleId: 'xxxxxx-xxxxxx-xxxxxx-xxxxxx' }
  });
</script>

目录结构

  .
├── index.d.ts       # 声明文件
├── index.global.js  # iife
├── index.js         # esm
└── index.cjs        # cjs

Package Sidebar

Install

npm i @winner-fed/quote-ws-jsapi

Weekly Downloads

4

Version

1.0.2-alpha.3

License

ISC

Unpacked Size

124 kB

Total Files

6

Last publish

Collaborators

  • winner-fed