@tigeropenapi/tigeropen 0.3.0 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/cjs/client/case-convert.js +4 -3
  2. package/dist/cjs/client/http-client.js +123 -6
  3. package/dist/cjs/config/client-config.js +56 -12
  4. package/dist/cjs/config/index.js +3 -1
  5. package/dist/cjs/config/token-manager.js +54 -4
  6. package/dist/cjs/index.js +51 -2
  7. package/dist/cjs/model/enums.js +89 -7
  8. package/dist/cjs/model/order-status.js +46 -0
  9. package/dist/cjs/model/quote-requests.js +11 -0
  10. package/dist/cjs/model/trade-requests.js +13 -0
  11. package/dist/cjs/push/pb/OrderStatusData.js +24 -0
  12. package/dist/cjs/push/proto-message.js +6 -0
  13. package/dist/cjs/push/push-client.js +111 -16
  14. package/dist/cjs/push/push-message.js +4 -0
  15. package/dist/cjs/quote/quote-client.js +333 -9
  16. package/dist/cjs/trade/trade-client.js +204 -25
  17. package/dist/esm/client/api-request.js +1 -1
  18. package/dist/esm/client/api-response.js +1 -1
  19. package/dist/esm/client/case-convert.js +4 -3
  20. package/dist/esm/client/http-client.js +128 -11
  21. package/dist/esm/client/index.js +6 -6
  22. package/dist/esm/config/client-config.js +59 -15
  23. package/dist/esm/config/index.js +4 -3
  24. package/dist/esm/config/token-manager.js +55 -5
  25. package/dist/esm/index.js +15 -1
  26. package/dist/esm/logger/index.js +1 -1
  27. package/dist/esm/model/contract-helpers.js +1 -1
  28. package/dist/esm/model/enums.js +87 -6
  29. package/dist/esm/model/order-helpers.js +1 -1
  30. package/dist/esm/model/order-status.js +43 -0
  31. package/dist/esm/model/quote-requests.js +10 -0
  32. package/dist/esm/model/trade-requests.js +12 -0
  33. package/dist/esm/push/index.js +5 -5
  34. package/dist/esm/push/pb/OrderStatusData.js +24 -0
  35. package/dist/esm/push/pb/PushData.js +11 -11
  36. package/dist/esm/push/pb/QuoteBasicData.js +1 -1
  37. package/dist/esm/push/pb/Response.js +1 -1
  38. package/dist/esm/push/pb/index.js +17 -17
  39. package/dist/esm/push/proto-message.js +9 -3
  40. package/dist/esm/push/push-client.js +118 -23
  41. package/dist/esm/push/push-message.js +4 -0
  42. package/dist/esm/quote/index.js +1 -1
  43. package/dist/esm/quote/quote-client.js +335 -11
  44. package/dist/esm/signer/index.js +2 -2
  45. package/dist/esm/trade/index.js +1 -1
  46. package/dist/esm/trade/trade-client.js +206 -27
  47. package/dist/types/client/case-convert.d.ts +3 -1
  48. package/dist/types/client/http-client.d.ts +32 -1
  49. package/dist/types/config/client-config.d.ts +16 -1
  50. package/dist/types/config/index.d.ts +2 -0
  51. package/dist/types/config/token-manager.d.ts +27 -3
  52. package/dist/types/index.d.ts +22 -1
  53. package/dist/types/model/enums.d.ts +60 -6
  54. package/dist/types/model/order-status.d.ts +14 -0
  55. package/dist/types/model/quote-requests.d.ts +344 -0
  56. package/dist/types/model/quote.d.ts +261 -0
  57. package/dist/types/model/trade-requests.d.ts +260 -0
  58. package/dist/types/model/trade.d.ts +214 -1
  59. package/dist/types/push/pb/OrderStatusData.d.ts +4 -0
  60. package/dist/types/push/push-client.d.ts +36 -3
  61. package/dist/types/push/push-message.d.ts +4 -0
  62. package/dist/types/quote/quote-client.d.ts +121 -6
  63. package/dist/types/trade/trade-client.d.ts +95 -12
  64. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Quote request interfaces (v0.4.0).
3
+ *
4
+ * 所有字段可选(用户调用时传一个空对象即可);字段名用 camelCase,
5
+ * client 层通过 keysToSnakeCase 转成服务端 wire 真名的 snake_case。
6
+ * **字段名设计规则:camelCase → snake_case 后必须等于服务端 wire 真名。**
7
+ *
8
+ * 参考 Go SDK model/quote_requests.go。
9
+ */
10
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Trade request interfaces (v0.4.0).
3
+ *
4
+ * 所有字段可选(用户调用时传一个空对象即可);字段名用 camelCase,
5
+ * client 层通过 keysToSnakeCase 转成服务端 wire 真名的 snake_case。
6
+ * **字段名设计规则:camelCase → snake_case 后必须等于服务端 wire 真名。**
7
+ * 比如 Trade 用 `startDate`/`endDate`(wire `start_date`/`end_date`),
8
+ * 不用 `startTime`/`endTime`(会被转成 `start_time`/`end_time`,与 wire 不符)。
9
+ *
10
+ * 参考 Go SDK model/trade_requests.go。
11
+ */
12
+ export {};
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Push module exports
3
3
  */
4
- export { SubjectType } from './push-message';
5
- export * from './callbacks';
6
- export * from './varint';
7
- export * from './proto-message';
8
- export { PushClient, ConnectionState } from './push-client';
4
+ export { SubjectType } from './push-message.js';
5
+ export * from './callbacks.js';
6
+ export * from './varint.js';
7
+ export * from './proto-message.js';
8
+ export { PushClient, ConnectionState } from './push-client.js';
@@ -51,6 +51,8 @@ function createBaseOrderStatusData() {
51
51
  gst: 0,
52
52
  attrList: [],
53
53
  timeInForce: "",
54
+ updateTime: 0,
55
+ latestTime: 0,
54
56
  };
55
57
  }
56
58
  export const OrderStatusData = {
@@ -184,6 +186,12 @@ export const OrderStatusData = {
184
186
  if (message.timeInForce !== "") {
185
187
  writer.uint32(346).string(message.timeInForce);
186
188
  }
189
+ if (message.updateTime !== 0) {
190
+ writer.uint32(352).uint64(message.updateTime);
191
+ }
192
+ if (message.latestTime !== 0) {
193
+ writer.uint32(360).uint64(message.latestTime);
194
+ }
187
195
  return writer;
188
196
  },
189
197
  decode(input, length) {
@@ -494,6 +502,20 @@ export const OrderStatusData = {
494
502
  message.timeInForce = reader.string();
495
503
  continue;
496
504
  }
505
+ case 44: {
506
+ if (tag !== 352) {
507
+ break;
508
+ }
509
+ message.updateTime = longToNumber(reader.uint64());
510
+ continue;
511
+ }
512
+ case 45: {
513
+ if (tag !== 360) {
514
+ break;
515
+ }
516
+ message.latestTime = longToNumber(reader.uint64());
517
+ continue;
518
+ }
497
519
  }
498
520
  if ((tag & 7) === 4 || tag === 0) {
499
521
  break;
@@ -550,6 +572,8 @@ export const OrderStatusData = {
550
572
  message.gst = object.gst ?? 0;
551
573
  message.attrList = object.attrList?.map((e) => e) || [];
552
574
  message.timeInForce = object.timeInForce ?? "";
575
+ message.updateTime = object.updateTime ?? 0;
576
+ message.latestTime = object.latestTime ?? 0;
553
577
  return message;
554
578
  },
555
579
  };
@@ -5,17 +5,17 @@
5
5
  // source: PushData.proto
6
6
  /* eslint-disable */
7
7
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
- import { AssetData } from "./AssetData";
9
- import { KlineData } from "./KlineData";
10
- import { OptionTopData } from "./OptionTopData";
11
- import { OrderStatusData } from "./OrderStatusData";
12
- import { OrderTransactionData } from "./OrderTransactionData";
13
- import { PositionData } from "./PositionData";
14
- import { QuoteData } from "./QuoteData";
15
- import { QuoteDepthData } from "./QuoteDepthData";
16
- import { StockTopData } from "./StockTopData";
17
- import { TickData } from "./TickData";
18
- import { TradeTickData } from "./TradeTickData";
8
+ import { AssetData } from "./AssetData.js";
9
+ import { KlineData } from "./KlineData.js";
10
+ import { OptionTopData } from "./OptionTopData.js";
11
+ import { OrderStatusData } from "./OrderStatusData.js";
12
+ import { OrderTransactionData } from "./OrderTransactionData.js";
13
+ import { PositionData } from "./PositionData.js";
14
+ import { QuoteData } from "./QuoteData.js";
15
+ import { QuoteDepthData } from "./QuoteDepthData.js";
16
+ import { StockTopData } from "./StockTopData.js";
17
+ import { TickData } from "./TickData.js";
18
+ import { TradeTickData } from "./TradeTickData.js";
19
19
  export const protobufPackage = "com.tigerbrokers.stock.openapi.client.socket.data.pb";
20
20
  function createBasePushData() {
21
21
  return {
@@ -5,7 +5,7 @@
5
5
  // source: QuoteBasicData.proto
6
6
  /* eslint-disable */
7
7
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
- import { QuoteData_Minute } from "./QuoteData";
8
+ import { QuoteData_Minute } from "./QuoteData.js";
9
9
  export const protobufPackage = "com.tigerbrokers.stock.openapi.client.socket.data.pb";
10
10
  function createBaseQuoteBasicData() {
11
11
  return {
@@ -5,7 +5,7 @@
5
5
  // source: Response.proto
6
6
  /* eslint-disable */
7
7
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
- import { PushData } from "./PushData";
8
+ import { PushData } from "./PushData.js";
9
9
  export const protobufPackage = "com.tigerbrokers.stock.openapi.client.socket.data.pb";
10
10
  function createBaseResponse() {
11
11
  return { command: 0, id: undefined, code: undefined, msg: undefined, body: undefined };
@@ -4,22 +4,22 @@
4
4
  * 由 ts-proto 从 proto 文件生成的所有类型、枚举和编解码函数
5
5
  */
6
6
  // 基础层:命令和数据类型枚举
7
- export { SocketCommon_Command, SocketCommon_DataType, SocketCommon_QuoteType, } from './SocketCommon';
7
+ export { SocketCommon_Command, SocketCommon_DataType, SocketCommon_QuoteType, } from './SocketCommon.js';
8
8
  // 协议层:请求和响应消息
9
- export { Request, Request_Connect, Request_Subscribe } from './Request';
10
- export { Response } from './Response';
11
- export { PushData } from './PushData';
9
+ export { Request, Request_Connect, Request_Subscribe } from './Request.js';
10
+ export { Response } from './Response.js';
11
+ export { PushData } from './PushData.js';
12
12
  // 数据层:业务数据消息
13
- export { QuoteData } from './QuoteData';
14
- export { QuoteBasicData } from './QuoteBasicData';
15
- export { QuoteBBOData } from './QuoteBBOData';
16
- export { QuoteDepthData } from './QuoteDepthData';
17
- export { TradeTickData } from './TradeTickData';
18
- export { TickData } from './TickData';
19
- export { AssetData } from './AssetData';
20
- export { PositionData } from './PositionData';
21
- export { OrderStatusData } from './OrderStatusData';
22
- export { OrderTransactionData } from './OrderTransactionData';
23
- export { StockTopData } from './StockTopData';
24
- export { OptionTopData } from './OptionTopData';
25
- export { KlineData } from './KlineData';
13
+ export { QuoteData } from './QuoteData.js';
14
+ export { QuoteBasicData } from './QuoteBasicData.js';
15
+ export { QuoteBBOData } from './QuoteBBOData.js';
16
+ export { QuoteDepthData } from './QuoteDepthData.js';
17
+ export { TradeTickData } from './TradeTickData.js';
18
+ export { TickData } from './TickData.js';
19
+ export { AssetData } from './AssetData.js';
20
+ export { PositionData } from './PositionData.js';
21
+ export { OrderStatusData } from './OrderStatusData.js';
22
+ export { OrderTransactionData } from './OrderTransactionData.js';
23
+ export { StockTopData } from './StockTopData.js';
24
+ export { OptionTopData } from './OptionTopData.js';
25
+ export { KlineData } from './KlineData.js';
@@ -4,9 +4,9 @@
4
4
  * 对齐 Java SDK 的 ProtoMessageUtil,提供构建各种 Request 消息的工具函数。
5
5
  * 所有构建函数共享一个递增的 requestId 计数器。
6
6
  */
7
- import { Request, Request_Connect, Request_Subscribe, } from './pb/Request';
8
- import { SocketCommon_Command, SocketCommon_DataType, } from './pb/SocketCommon';
9
- import { SubjectType } from './push-message';
7
+ import { Request, Request_Connect, Request_Subscribe, } from './pb/Request.js';
8
+ import { SocketCommon_Command, SocketCommon_DataType, } from './pb/SocketCommon.js';
9
+ import { SubjectType } from './push-message.js';
10
10
  /** 递增请求 ID 计数器(单线程环境,简单递增变量) */
11
11
  let requestId = 0;
12
12
  /**
@@ -115,6 +115,12 @@ export function subjectToDataType(subject) {
115
115
  return SocketCommon_DataType.TradeTick;
116
116
  case SubjectType.QuoteBBO:
117
117
  return SocketCommon_DataType.Quote;
118
+ case SubjectType.Cc:
119
+ // 加密货币推送
120
+ return SocketCommon_DataType.Cc;
121
+ case SubjectType.Market:
122
+ // 市场状态推送协议上 dataType=Quote,只设置 market 字段
123
+ return SocketCommon_DataType.Quote;
118
124
  default:
119
125
  return SocketCommon_DataType.Unknown;
120
126
  }
@@ -9,13 +9,13 @@
9
9
  * heartbeat keep-alive, and automatic reconnection.
10
10
  */
11
11
  import * as tls from 'tls';
12
- import { signWithRSA } from '../signer/signer';
13
- import { SubjectType } from './push-message';
14
- import { Request } from './pb/Request';
15
- import { Response } from './pb/Response';
16
- import { SocketCommon_Command, SocketCommon_DataType } from './pb/SocketCommon';
17
- import { encodeVarint32, decodeVarint32 } from './varint';
18
- import { buildConnectMessage, buildHeartBeatMessage, buildSubscribeMessage, buildUnSubscribeMessage, buildDisconnectMessage, subjectToDataType, } from './proto-message';
12
+ import { signWithRSA } from '../signer/signer.js';
13
+ import { SubjectType } from './push-message.js';
14
+ import { Request } from './pb/Request.js';
15
+ import { Response } from './pb/Response.js';
16
+ import { SocketCommon_Command, SocketCommon_DataType } from './pb/SocketCommon.js';
17
+ import { encodeVarint32, decodeVarint32 } from './varint.js';
18
+ import { buildConnectMessage, buildHeartBeatMessage, buildSubscribeMessage, buildUnSubscribeMessage, buildDisconnectMessage, subjectToDataType, } from './proto-message.js';
19
19
  /** Default push server host */
20
20
  const DEFAULT_PUSH_HOST = 'openapi.tigerfintech.com';
21
21
  /** Default push server port */
@@ -29,7 +29,7 @@ const MAX_RECONNECT_INTERVAL = 60000;
29
29
  /** Default connect timeout (ms) */
30
30
  const DEFAULT_CONNECT_TIMEOUT = 30000;
31
31
  /** SDK version identifier */
32
- const SDK_VERSION = 'typescript/0.1.0';
32
+ const SDK_VERSION = 'typescript/0.4.0';
33
33
  /** Protocol version */
34
34
  const ACCEPT_VERSION = '1.0';
35
35
  /** Default send heartbeat interval (ms) */
@@ -50,11 +50,13 @@ export class PushClient {
50
50
  constructor(config, options) {
51
51
  this.socket = null;
52
52
  this._state = ConnectionState.Disconnected;
53
+ /** Whether this connect attempt already fell back to unverified TLS */
54
+ this.tlsFallback = false;
53
55
  this.callbacks = {};
54
56
  /** Subscription state: subject -> Set<symbol> */
55
57
  this.subscriptions = new Map();
56
- /** Account-level subscriptions */
57
- this.accountSubs = new Set();
58
+ /** Account-level subscriptions: subject -> account string used at subscribe time */
59
+ this.accountSubs = new Map();
58
60
  this.heartbeatTimer = null;
59
61
  this.reconnectTimer = null;
60
62
  this.stopped = false;
@@ -88,6 +90,7 @@ export class PushClient {
88
90
  }
89
91
  this._state = ConnectionState.Connecting;
90
92
  this.stopped = false;
93
+ this.tlsFallback = false;
91
94
  this.recvBuffer = Buffer.alloc(0);
92
95
  const socket = this.createSocket(this.pushHost, this.pushPort);
93
96
  this.socket = socket;
@@ -144,6 +147,24 @@ export class PushClient {
144
147
  });
145
148
  socket.on('error', (err) => {
146
149
  if (!settled) {
150
+ // If this is a TLS certificate error, warn and retry without verification.
151
+ const isTlsCertError = err.message.includes('certificate') ||
152
+ err.message.includes('CERT') ||
153
+ err.code === 'DEPTH_ZERO_SELF_SIGNED_CERT' ||
154
+ err.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' ||
155
+ err.code === 'CERT_HAS_EXPIRED';
156
+ if (isTlsCertError && !this.tlsFallback) {
157
+ this.tlsFallback = true;
158
+ settled = true;
159
+ clearTimeout(timeout);
160
+ socket.destroy();
161
+ this.socket = null;
162
+ this._state = ConnectionState.Disconnected;
163
+ console.warn(`[TigerOpen] TLS certificate verification failed: ${err.message}. Retrying without verification.`);
164
+ // Retry immediately using unverified TLS
165
+ this.connect().then(resolve).catch(reject);
166
+ return;
167
+ }
147
168
  settled = true;
148
169
  clearTimeout(timeout);
149
170
  this._state = ConnectionState.Disconnected;
@@ -196,7 +217,7 @@ export class PushClient {
196
217
  createSocket(host, port) {
197
218
  if (this.socketFactory)
198
219
  return this.socketFactory(host, port);
199
- return tls.connect({ host, port, rejectUnauthorized: false });
220
+ return tls.connect({ host, port, rejectUnauthorized: !this.tlsFallback });
200
221
  }
201
222
  /** Handle incoming TCP data: buffer + decode varint32 frames */
202
223
  handleData(chunk, onConnected) {
@@ -295,8 +316,8 @@ export class PushClient {
295
316
  for (const [subject, symbols] of this.subscriptions) {
296
317
  this.doSubscribe(subject, Array.from(symbols));
297
318
  }
298
- for (const subject of this.accountSubs) {
299
- this.doSubscribe(subject, undefined, this.config.account);
319
+ for (const [subject, account] of this.accountSubs) {
320
+ this.doSubscribe(subject, undefined, account);
300
321
  }
301
322
  }
302
323
  /** Dispatch push data to the appropriate callback based on dataType */
@@ -351,6 +372,11 @@ export class PushClient {
351
372
  if (pushData.klineData)
352
373
  cb.onKline?.(pushData.klineData);
353
374
  break;
375
+ case SocketCommon_DataType.Cc:
376
+ // 加密货币(Cc)推送复用 QuoteData body,路由到 onQuote 回调
377
+ if (pushData.quoteData)
378
+ cb.onQuote?.(pushData.quoteData);
379
+ break;
354
380
  default:
355
381
  // FullTick and QuoteBBO use TradeTick/Quote dataType
356
382
  // TickData (fullTick) via tickData field
@@ -457,11 +483,77 @@ export class PushClient {
457
483
  this.doUnsubscribe(SubjectType.Kline, symbols);
458
484
  this.removeSubscription(SubjectType.Kline, symbols);
459
485
  }
486
+ // ===== v0.4.0: stock_top / option_top / cc / market =====
487
+ /**
488
+ * Subscribe to stock top rankings (v0.4.0).
489
+ * @param market US / HK / CN
490
+ * @param indicators LATEST_PRICE / HIGHER / LOWER / VOLUME / AMOUNT / AMPLITUDE / TURNOVER_RATE
491
+ */
492
+ subscribeStockTop(market, indicators) {
493
+ this.doSubscribe(SubjectType.StockTop, indicators, undefined, market);
494
+ this.addSubscription(SubjectType.StockTop, indicators);
495
+ }
496
+ /** Unsubscribe from stock top rankings (v0.4.0). */
497
+ unsubscribeStockTop(market, indicators) {
498
+ const dataType = subjectToDataType(SubjectType.StockTop);
499
+ const symbolsStr = indicators.join(',');
500
+ const req = buildUnSubscribeMessage(dataType, symbolsStr, undefined, market);
501
+ this.sendMessage(req);
502
+ this.removeSubscription(SubjectType.StockTop, indicators);
503
+ }
504
+ /**
505
+ * Subscribe to option top rankings (v0.4.0).
506
+ * @param market US / HK / CN
507
+ */
508
+ subscribeOptionTop(market, indicators) {
509
+ this.doSubscribe(SubjectType.OptionTop, indicators, undefined, market);
510
+ this.addSubscription(SubjectType.OptionTop, indicators);
511
+ }
512
+ /** Unsubscribe from option top rankings (v0.4.0). */
513
+ unsubscribeOptionTop(market, indicators) {
514
+ const dataType = subjectToDataType(SubjectType.OptionTop);
515
+ const symbolsStr = indicators.join(',');
516
+ const req = buildUnSubscribeMessage(dataType, symbolsStr, undefined, market);
517
+ this.sendMessage(req);
518
+ this.removeSubscription(SubjectType.OptionTop, indicators);
519
+ }
520
+ /**
521
+ * Subscribe to crypto realtime quotes (v0.4.0).
522
+ * Data is delivered via the `onQuote` callback (same QuoteData body).
523
+ * @param symbols e.g. ["BTCUSD", "ETHUSD"]
524
+ */
525
+ subscribeCc(symbols) {
526
+ this.doSubscribe(SubjectType.Cc, symbols);
527
+ this.addSubscription(SubjectType.Cc, symbols);
528
+ }
529
+ /** Unsubscribe from crypto realtime quotes (v0.4.0). */
530
+ unsubscribeCc(symbols) {
531
+ this.doUnsubscribe(SubjectType.Cc, symbols);
532
+ this.removeSubscription(SubjectType.Cc, symbols);
533
+ }
534
+ /**
535
+ * Subscribe to market status updates (v0.4.0).
536
+ * Protocol uses dataType=Quote with only the `market` field set.
537
+ * Data is delivered via the `onQuote` callback.
538
+ */
539
+ subscribeMarket(market) {
540
+ // symbols 为空,只带 market 字段
541
+ this.doSubscribe(SubjectType.Market, undefined, undefined, market);
542
+ this.addSubscription(SubjectType.Market, [market]);
543
+ }
544
+ /** Unsubscribe from market status (v0.4.0). */
545
+ unsubscribeMarket(market) {
546
+ const dataType = subjectToDataType(SubjectType.Market);
547
+ const req = buildUnSubscribeMessage(dataType, undefined, undefined, market);
548
+ this.sendMessage(req);
549
+ this.removeSubscription(SubjectType.Market, [market]);
550
+ }
460
551
  // ===== Account push subscribe/unsubscribe =====
461
552
  /** Subscribe to asset changes */
462
553
  subscribeAsset(account) {
463
- this.doSubscribe(SubjectType.Asset, undefined, account || this.config.account);
464
- this.accountSubs.add(SubjectType.Asset);
554
+ const acct = account || this.config.account;
555
+ this.doSubscribe(SubjectType.Asset, undefined, acct);
556
+ this.accountSubs.set(SubjectType.Asset, acct);
465
557
  }
466
558
  /** Unsubscribe from asset changes */
467
559
  unsubscribeAsset() {
@@ -470,8 +562,9 @@ export class PushClient {
470
562
  }
471
563
  /** Subscribe to position changes */
472
564
  subscribePosition(account) {
473
- this.doSubscribe(SubjectType.Position, undefined, account || this.config.account);
474
- this.accountSubs.add(SubjectType.Position);
565
+ const acct = account || this.config.account;
566
+ this.doSubscribe(SubjectType.Position, undefined, acct);
567
+ this.accountSubs.set(SubjectType.Position, acct);
475
568
  }
476
569
  /** Unsubscribe from position changes */
477
570
  unsubscribePosition() {
@@ -480,8 +573,9 @@ export class PushClient {
480
573
  }
481
574
  /** Subscribe to order status */
482
575
  subscribeOrder(account) {
483
- this.doSubscribe(SubjectType.Order, undefined, account || this.config.account);
484
- this.accountSubs.add(SubjectType.Order);
576
+ const acct = account || this.config.account;
577
+ this.doSubscribe(SubjectType.Order, undefined, acct);
578
+ this.accountSubs.set(SubjectType.Order, acct);
485
579
  }
486
580
  /** Unsubscribe from order status */
487
581
  unsubscribeOrder() {
@@ -490,8 +584,9 @@ export class PushClient {
490
584
  }
491
585
  /** Subscribe to transaction details */
492
586
  subscribeTransaction(account) {
493
- this.doSubscribe(SubjectType.Transaction, undefined, account || this.config.account);
494
- this.accountSubs.add(SubjectType.Transaction);
587
+ const acct = account || this.config.account;
588
+ this.doSubscribe(SubjectType.Transaction, undefined, acct);
589
+ this.accountSubs.set(SubjectType.Transaction, acct);
495
590
  }
496
591
  /** Unsubscribe from transaction details */
497
592
  unsubscribeTransaction() {
@@ -507,8 +602,8 @@ export class PushClient {
507
602
  }
508
603
  return result;
509
604
  }
510
- /** Get account-level subscriptions */
605
+ /** Get account-level subscriptions: subject -> account */
511
606
  getAccountSubscriptions() {
512
- return Array.from(this.accountSubs);
607
+ return new Map(this.accountSubs);
513
608
  }
514
609
  }
@@ -17,6 +17,10 @@ export var SubjectType;
17
17
  SubjectType["OptionTop"] = "option_top";
18
18
  SubjectType["FullTick"] = "full_tick";
19
19
  SubjectType["QuoteBBO"] = "quote_bbo";
20
+ /** 加密货币实时行情 (v0.4.0) */
21
+ SubjectType["Cc"] = "cc";
22
+ /** 市场状态 (v0.4.0) */
23
+ SubjectType["Market"] = "market";
20
24
  SubjectType["Asset"] = "asset";
21
25
  SubjectType["Position"] = "position";
22
26
  SubjectType["Order"] = "order";
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Quote module exports
3
3
  */
4
- export { QuoteClient, parseOptionIdentifier } from './quote-client';
4
+ export { QuoteClient, parseOptionIdentifier } from './quote-client.js';