@winner-fed/quote-ws-jsapi
v1.0.2-alpha.3
Published
Market websocket analysis library by winner.
Downloads
1
Maintainers
Readme
Quote webSocket JSAPI
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