@tigeropenapi/tigeropen 0.1.0 → 0.3.0

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 (129) hide show
  1. package/README.md +475 -104
  2. package/dist/cjs/client/api-request.js +16 -10
  3. package/dist/cjs/client/api-response.js +23 -3
  4. package/dist/cjs/client/case-convert.js +35 -0
  5. package/dist/cjs/client/http-client.js +46 -20
  6. package/dist/cjs/client/index.js +6 -2
  7. package/dist/cjs/config/client-config.js +130 -49
  8. package/dist/cjs/config/domain.js +21 -2
  9. package/dist/cjs/config/index.js +3 -1
  10. package/dist/cjs/index.js +1 -1
  11. package/dist/cjs/model/contract.js +1 -2
  12. package/dist/cjs/model/order-helpers.js +9 -9
  13. package/dist/cjs/model/order.js +5 -2
  14. package/dist/cjs/model/position.js +1 -2
  15. package/dist/cjs/model/quote.js +7 -0
  16. package/dist/cjs/model/trade.js +2 -0
  17. package/dist/cjs/push/index.js +6 -3
  18. package/dist/cjs/push/pb/AssetData.js +208 -0
  19. package/dist/cjs/push/pb/KlineData.js +184 -0
  20. package/dist/cjs/push/pb/OptionTopData.js +427 -0
  21. package/dist/cjs/push/pb/OrderStatusData.js +568 -0
  22. package/dist/cjs/push/pb/OrderTransactionData.js +256 -0
  23. package/dist/cjs/push/pb/PositionData.js +316 -0
  24. package/dist/cjs/push/pb/PushData.js +219 -0
  25. package/dist/cjs/push/pb/QuoteBBOData.js +160 -0
  26. package/dist/cjs/push/pb/QuoteBasicData.js +329 -0
  27. package/dist/cjs/push/pb/QuoteData.js +507 -0
  28. package/dist/cjs/push/pb/QuoteDepthData.js +220 -0
  29. package/dist/cjs/push/pb/Request.js +278 -0
  30. package/dist/cjs/push/pb/Response.js +97 -0
  31. package/dist/cjs/push/pb/SocketCommon.js +86 -0
  32. package/dist/cjs/push/pb/StockTopData.js +199 -0
  33. package/dist/cjs/push/pb/TickData.js +202 -0
  34. package/dist/cjs/push/pb/TradeTickData.js +308 -0
  35. package/dist/cjs/push/pb/index.js +49 -0
  36. package/dist/cjs/push/proto-message.js +129 -0
  37. package/dist/cjs/push/push-client.js +292 -164
  38. package/dist/cjs/push/push-message.js +4 -60
  39. package/dist/cjs/push/varint.js +76 -0
  40. package/dist/cjs/quote/index.js +3 -2
  41. package/dist/cjs/quote/quote-client.js +128 -94
  42. package/dist/cjs/signer/signer.js +10 -10
  43. package/dist/cjs/trade/trade-client.js +56 -62
  44. package/dist/esm/client/api-request.js +14 -8
  45. package/dist/esm/client/api-response.js +22 -3
  46. package/dist/esm/client/case-convert.js +31 -0
  47. package/dist/esm/client/http-client.js +47 -21
  48. package/dist/esm/client/index.js +3 -2
  49. package/dist/esm/config/client-config.js +131 -51
  50. package/dist/esm/config/domain.js +20 -2
  51. package/dist/esm/config/index.js +2 -2
  52. package/dist/esm/index.js +1 -1
  53. package/dist/esm/model/contract.js +1 -2
  54. package/dist/esm/model/order-helpers.js +9 -9
  55. package/dist/esm/model/order.js +5 -2
  56. package/dist/esm/model/position.js +1 -2
  57. package/dist/esm/model/quote.js +6 -0
  58. package/dist/esm/model/trade.js +1 -0
  59. package/dist/esm/push/index.js +4 -2
  60. package/dist/esm/push/pb/AssetData.js +205 -0
  61. package/dist/esm/push/pb/KlineData.js +181 -0
  62. package/dist/esm/push/pb/OptionTopData.js +424 -0
  63. package/dist/esm/push/pb/OrderStatusData.js +565 -0
  64. package/dist/esm/push/pb/OrderTransactionData.js +253 -0
  65. package/dist/esm/push/pb/PositionData.js +313 -0
  66. package/dist/esm/push/pb/PushData.js +216 -0
  67. package/dist/esm/push/pb/QuoteBBOData.js +157 -0
  68. package/dist/esm/push/pb/QuoteBasicData.js +326 -0
  69. package/dist/esm/push/pb/QuoteData.js +504 -0
  70. package/dist/esm/push/pb/QuoteDepthData.js +217 -0
  71. package/dist/esm/push/pb/Request.js +275 -0
  72. package/dist/esm/push/pb/Response.js +94 -0
  73. package/dist/esm/push/pb/SocketCommon.js +83 -0
  74. package/dist/esm/push/pb/StockTopData.js +196 -0
  75. package/dist/esm/push/pb/TickData.js +199 -0
  76. package/dist/esm/push/pb/TradeTickData.js +305 -0
  77. package/dist/esm/push/pb/index.js +25 -0
  78. package/dist/esm/push/proto-message.js +121 -0
  79. package/dist/esm/push/push-client.js +260 -165
  80. package/dist/esm/push/push-message.js +3 -56
  81. package/dist/esm/push/varint.js +72 -0
  82. package/dist/esm/quote/index.js +2 -2
  83. package/dist/esm/quote/quote-client.js +127 -94
  84. package/dist/esm/signer/signer.js +10 -10
  85. package/dist/esm/trade/trade-client.js +56 -62
  86. package/dist/types/client/api-request.d.ts +12 -11
  87. package/dist/types/client/api-response.d.ts +15 -7
  88. package/dist/types/client/case-convert.d.ts +16 -0
  89. package/dist/types/client/http-client.d.ts +26 -14
  90. package/dist/types/client/index.d.ts +3 -2
  91. package/dist/types/config/client-config.d.ts +29 -13
  92. package/dist/types/config/domain.d.ts +9 -0
  93. package/dist/types/config/index.d.ts +2 -2
  94. package/dist/types/index.d.ts +1 -1
  95. package/dist/types/model/contract.d.ts +13 -29
  96. package/dist/types/model/order-helpers.d.ts +21 -20
  97. package/dist/types/model/order.d.ts +101 -55
  98. package/dist/types/model/position.d.ts +26 -24
  99. package/dist/types/model/quote.d.ts +311 -0
  100. package/dist/types/model/trade.d.ts +113 -0
  101. package/dist/types/push/callbacks.d.ts +32 -51
  102. package/dist/types/push/index.d.ts +5 -3
  103. package/dist/types/push/pb/AssetData.d.ts +47 -0
  104. package/dist/types/push/pb/KlineData.d.ts +43 -0
  105. package/dist/types/push/pb/OptionTopData.d.ts +76 -0
  106. package/dist/types/push/pb/OrderStatusData.d.ts +96 -0
  107. package/dist/types/push/pb/OrderTransactionData.d.ts +51 -0
  108. package/dist/types/push/pb/PositionData.d.ts +63 -0
  109. package/dist/types/push/pb/PushData.d.ts +46 -0
  110. package/dist/types/push/pb/QuoteBBOData.d.ts +35 -0
  111. package/dist/types/push/pb/QuoteBasicData.d.ts +66 -0
  112. package/dist/types/push/pb/QuoteData.d.ts +94 -0
  113. package/dist/types/push/pb/QuoteDepthData.d.ts +37 -0
  114. package/dist/types/push/pb/Request.d.ts +44 -0
  115. package/dist/types/push/pb/Response.d.ts +30 -0
  116. package/dist/types/push/pb/SocketCommon.d.ts +64 -0
  117. package/dist/types/push/pb/StockTopData.d.ts +37 -0
  118. package/dist/types/push/pb/TickData.d.ts +44 -0
  119. package/dist/types/push/pb/TradeTickData.d.ts +53 -0
  120. package/dist/types/push/pb/index.d.ts +39 -0
  121. package/dist/types/push/proto-message.d.ts +33 -0
  122. package/dist/types/push/push-client.d.ts +69 -68
  123. package/dist/types/push/push-message.d.ts +3 -147
  124. package/dist/types/push/varint.d.ts +23 -0
  125. package/dist/types/quote/index.d.ts +2 -2
  126. package/dist/types/quote/quote-client.d.ts +41 -47
  127. package/dist/types/signer/signer.d.ts +6 -6
  128. package/dist/types/trade/trade-client.d.ts +34 -38
  129. package/package.json +11 -6
@@ -10,7 +10,7 @@ exports.auctionMarketOrder = auctionMarketOrder;
10
10
  exports.algoOrder = algoOrder;
11
11
  exports.orderLeg = orderLeg;
12
12
  const enums_1 = require("./enums");
13
- /** 构造市价单 */
13
+ /** Market order */
14
14
  function marketOrder(account, symbol, secType, action, quantity) {
15
15
  return {
16
16
  account, symbol, secType, action,
@@ -20,7 +20,7 @@ function marketOrder(account, symbol, secType, action, quantity) {
20
20
  outsideRth: false,
21
21
  };
22
22
  }
23
- /** 构造限价单 */
23
+ /** Limit order */
24
24
  function limitOrder(account, symbol, secType, action, quantity, limitPrice) {
25
25
  return {
26
26
  account, symbol, secType, action,
@@ -31,7 +31,7 @@ function limitOrder(account, symbol, secType, action, quantity, limitPrice) {
31
31
  outsideRth: false,
32
32
  };
33
33
  }
34
- /** 构造止损单 */
34
+ /** Stop order */
35
35
  function stopOrder(account, symbol, secType, action, quantity, auxPrice) {
36
36
  return {
37
37
  account, symbol, secType, action,
@@ -42,7 +42,7 @@ function stopOrder(account, symbol, secType, action, quantity, auxPrice) {
42
42
  outsideRth: false,
43
43
  };
44
44
  }
45
- /** 构造止损限价单 */
45
+ /** Stop limit order */
46
46
  function stopLimitOrder(account, symbol, secType, action, quantity, limitPrice, auxPrice) {
47
47
  return {
48
48
  account, symbol, secType, action,
@@ -54,7 +54,7 @@ function stopLimitOrder(account, symbol, secType, action, quantity, limitPrice,
54
54
  outsideRth: false,
55
55
  };
56
56
  }
57
- /** 构造跟踪止损单 */
57
+ /** Trailing stop order */
58
58
  function trailOrder(account, symbol, secType, action, quantity, trailingPercent) {
59
59
  return {
60
60
  account, symbol, secType, action,
@@ -65,7 +65,7 @@ function trailOrder(account, symbol, secType, action, quantity, trailingPercent)
65
65
  outsideRth: false,
66
66
  };
67
67
  }
68
- /** 构造竞价限价单 */
68
+ /** Auction limit order */
69
69
  function auctionLimitOrder(account, symbol, secType, action, quantity, limitPrice) {
70
70
  return {
71
71
  account, symbol, secType, action,
@@ -76,7 +76,7 @@ function auctionLimitOrder(account, symbol, secType, action, quantity, limitPric
76
76
  outsideRth: false,
77
77
  };
78
78
  }
79
- /** 构造竞价市价单 */
79
+ /** Auction market order */
80
80
  function auctionMarketOrder(account, symbol, secType, action, quantity) {
81
81
  return {
82
82
  account, symbol, secType, action,
@@ -86,7 +86,7 @@ function auctionMarketOrder(account, symbol, secType, action, quantity) {
86
86
  outsideRth: false,
87
87
  };
88
88
  }
89
- /** 构造算法订单(TWAP/VWAP) */
89
+ /** Algo order (TWAP / VWAP) */
90
90
  function algoOrder(account, symbol, secType, action, quantity, limitPrice, algoType, params) {
91
91
  return {
92
92
  account, symbol, secType, action,
@@ -98,7 +98,7 @@ function algoOrder(account, symbol, secType, action, quantity, limitPrice, algoT
98
98
  outsideRth: false,
99
99
  };
100
100
  }
101
- /** 构造附加订单(止盈/止损) */
101
+ /** Attached profit / loss leg */
102
102
  function orderLeg(legType, price, timeInForce) {
103
103
  return { legType, price, timeInForce };
104
104
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * Order 订单接口
4
- * 字段名 camelCase 与 API JSON 天然一致,不改名、不加封装层
3
+ * Order response / request models.
4
+ *
5
+ * TypeScript uses camelCase field names idiomatically. The client layer
6
+ * transparently converts request camelCase to snake_case before sending;
7
+ * server responses are already camelCase so they decode directly.
5
8
  */
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  /**
3
- * Position 持仓接口
4
- * 字段名 camelCase 与 API JSON 天然一致,不改名、不加封装层
3
+ * Position model.
5
4
  */
6
5
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Quote response & request models.
4
+ * All field names are camelCase (TypeScript idiom); request fields are
5
+ * converted to snake_case on the wire by the client layer.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,12 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ConnectionState = exports.PushClient = void 0;
17
+ exports.ConnectionState = exports.PushClient = exports.SubjectType = void 0;
18
18
  /**
19
- * 推送模块导出
19
+ * Push module exports
20
20
  */
21
- __exportStar(require("./push-message"), exports);
21
+ var push_message_1 = require("./push-message");
22
+ Object.defineProperty(exports, "SubjectType", { enumerable: true, get: function () { return push_message_1.SubjectType; } });
22
23
  __exportStar(require("./callbacks"), exports);
24
+ __exportStar(require("./varint"), exports);
25
+ __exportStar(require("./proto-message"), exports);
23
26
  var push_client_1 = require("./push-client");
24
27
  Object.defineProperty(exports, "PushClient", { enumerable: true, get: function () { return push_client_1.PushClient; } });
25
28
  Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return push_client_1.ConnectionState; } });
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.6
5
+ // protoc v5.28.3
6
+ // source: AssetData.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AssetData = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ exports.protobufPackage = "com.tigerbrokers.stock.openapi.client.socket.data.pb";
12
+ function createBaseAssetData() {
13
+ return {
14
+ account: "",
15
+ currency: "",
16
+ segType: "",
17
+ availableFunds: 0,
18
+ excessLiquidity: 0,
19
+ netLiquidation: 0,
20
+ equityWithLoan: 0,
21
+ buyingPower: 0,
22
+ cashBalance: 0,
23
+ grossPositionValue: 0,
24
+ initMarginReq: 0,
25
+ maintMarginReq: 0,
26
+ timestamp: 0,
27
+ };
28
+ }
29
+ exports.AssetData = {
30
+ encode(message, writer = new wire_1.BinaryWriter()) {
31
+ if (message.account !== "") {
32
+ writer.uint32(10).string(message.account);
33
+ }
34
+ if (message.currency !== "") {
35
+ writer.uint32(18).string(message.currency);
36
+ }
37
+ if (message.segType !== "") {
38
+ writer.uint32(26).string(message.segType);
39
+ }
40
+ if (message.availableFunds !== 0) {
41
+ writer.uint32(33).double(message.availableFunds);
42
+ }
43
+ if (message.excessLiquidity !== 0) {
44
+ writer.uint32(41).double(message.excessLiquidity);
45
+ }
46
+ if (message.netLiquidation !== 0) {
47
+ writer.uint32(49).double(message.netLiquidation);
48
+ }
49
+ if (message.equityWithLoan !== 0) {
50
+ writer.uint32(57).double(message.equityWithLoan);
51
+ }
52
+ if (message.buyingPower !== 0) {
53
+ writer.uint32(65).double(message.buyingPower);
54
+ }
55
+ if (message.cashBalance !== 0) {
56
+ writer.uint32(73).double(message.cashBalance);
57
+ }
58
+ if (message.grossPositionValue !== 0) {
59
+ writer.uint32(81).double(message.grossPositionValue);
60
+ }
61
+ if (message.initMarginReq !== 0) {
62
+ writer.uint32(89).double(message.initMarginReq);
63
+ }
64
+ if (message.maintMarginReq !== 0) {
65
+ writer.uint32(97).double(message.maintMarginReq);
66
+ }
67
+ if (message.timestamp !== 0) {
68
+ writer.uint32(104).uint64(message.timestamp);
69
+ }
70
+ return writer;
71
+ },
72
+ decode(input, length) {
73
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
74
+ const end = length === undefined ? reader.len : reader.pos + length;
75
+ const message = createBaseAssetData();
76
+ while (reader.pos < end) {
77
+ const tag = reader.uint32();
78
+ switch (tag >>> 3) {
79
+ case 1: {
80
+ if (tag !== 10) {
81
+ break;
82
+ }
83
+ message.account = reader.string();
84
+ continue;
85
+ }
86
+ case 2: {
87
+ if (tag !== 18) {
88
+ break;
89
+ }
90
+ message.currency = reader.string();
91
+ continue;
92
+ }
93
+ case 3: {
94
+ if (tag !== 26) {
95
+ break;
96
+ }
97
+ message.segType = reader.string();
98
+ continue;
99
+ }
100
+ case 4: {
101
+ if (tag !== 33) {
102
+ break;
103
+ }
104
+ message.availableFunds = reader.double();
105
+ continue;
106
+ }
107
+ case 5: {
108
+ if (tag !== 41) {
109
+ break;
110
+ }
111
+ message.excessLiquidity = reader.double();
112
+ continue;
113
+ }
114
+ case 6: {
115
+ if (tag !== 49) {
116
+ break;
117
+ }
118
+ message.netLiquidation = reader.double();
119
+ continue;
120
+ }
121
+ case 7: {
122
+ if (tag !== 57) {
123
+ break;
124
+ }
125
+ message.equityWithLoan = reader.double();
126
+ continue;
127
+ }
128
+ case 8: {
129
+ if (tag !== 65) {
130
+ break;
131
+ }
132
+ message.buyingPower = reader.double();
133
+ continue;
134
+ }
135
+ case 9: {
136
+ if (tag !== 73) {
137
+ break;
138
+ }
139
+ message.cashBalance = reader.double();
140
+ continue;
141
+ }
142
+ case 10: {
143
+ if (tag !== 81) {
144
+ break;
145
+ }
146
+ message.grossPositionValue = reader.double();
147
+ continue;
148
+ }
149
+ case 11: {
150
+ if (tag !== 89) {
151
+ break;
152
+ }
153
+ message.initMarginReq = reader.double();
154
+ continue;
155
+ }
156
+ case 12: {
157
+ if (tag !== 97) {
158
+ break;
159
+ }
160
+ message.maintMarginReq = reader.double();
161
+ continue;
162
+ }
163
+ case 13: {
164
+ if (tag !== 104) {
165
+ break;
166
+ }
167
+ message.timestamp = longToNumber(reader.uint64());
168
+ continue;
169
+ }
170
+ }
171
+ if ((tag & 7) === 4 || tag === 0) {
172
+ break;
173
+ }
174
+ reader.skip(tag & 7);
175
+ }
176
+ return message;
177
+ },
178
+ create(base) {
179
+ return exports.AssetData.fromPartial(base ?? {});
180
+ },
181
+ fromPartial(object) {
182
+ const message = createBaseAssetData();
183
+ message.account = object.account ?? "";
184
+ message.currency = object.currency ?? "";
185
+ message.segType = object.segType ?? "";
186
+ message.availableFunds = object.availableFunds ?? 0;
187
+ message.excessLiquidity = object.excessLiquidity ?? 0;
188
+ message.netLiquidation = object.netLiquidation ?? 0;
189
+ message.equityWithLoan = object.equityWithLoan ?? 0;
190
+ message.buyingPower = object.buyingPower ?? 0;
191
+ message.cashBalance = object.cashBalance ?? 0;
192
+ message.grossPositionValue = object.grossPositionValue ?? 0;
193
+ message.initMarginReq = object.initMarginReq ?? 0;
194
+ message.maintMarginReq = object.maintMarginReq ?? 0;
195
+ message.timestamp = object.timestamp ?? 0;
196
+ return message;
197
+ },
198
+ };
199
+ function longToNumber(int64) {
200
+ const num = globalThis.Number(int64.toString());
201
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
202
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
203
+ }
204
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
205
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
206
+ }
207
+ return num;
208
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.6
5
+ // protoc v5.28.3
6
+ // source: KlineData.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.KlineData = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ exports.protobufPackage = "com.tigerbrokers.stock.openapi.client.socket.data.pb";
12
+ function createBaseKlineData() {
13
+ return {
14
+ time: 0,
15
+ open: 0,
16
+ high: 0,
17
+ low: 0,
18
+ close: 0,
19
+ avg: 0,
20
+ volume: 0,
21
+ count: 0,
22
+ symbol: "",
23
+ amount: 0,
24
+ serverTimestamp: undefined,
25
+ };
26
+ }
27
+ exports.KlineData = {
28
+ encode(message, writer = new wire_1.BinaryWriter()) {
29
+ if (message.time !== 0) {
30
+ writer.uint32(8).int64(message.time);
31
+ }
32
+ if (message.open !== 0) {
33
+ writer.uint32(21).float(message.open);
34
+ }
35
+ if (message.high !== 0) {
36
+ writer.uint32(29).float(message.high);
37
+ }
38
+ if (message.low !== 0) {
39
+ writer.uint32(37).float(message.low);
40
+ }
41
+ if (message.close !== 0) {
42
+ writer.uint32(45).float(message.close);
43
+ }
44
+ if (message.avg !== 0) {
45
+ writer.uint32(53).float(message.avg);
46
+ }
47
+ if (message.volume !== 0) {
48
+ writer.uint32(56).int64(message.volume);
49
+ }
50
+ if (message.count !== 0) {
51
+ writer.uint32(64).int32(message.count);
52
+ }
53
+ if (message.symbol !== "") {
54
+ writer.uint32(74).string(message.symbol);
55
+ }
56
+ if (message.amount !== 0) {
57
+ writer.uint32(81).double(message.amount);
58
+ }
59
+ if (message.serverTimestamp !== undefined) {
60
+ writer.uint32(88).uint64(message.serverTimestamp);
61
+ }
62
+ return writer;
63
+ },
64
+ decode(input, length) {
65
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
66
+ const end = length === undefined ? reader.len : reader.pos + length;
67
+ const message = createBaseKlineData();
68
+ while (reader.pos < end) {
69
+ const tag = reader.uint32();
70
+ switch (tag >>> 3) {
71
+ case 1: {
72
+ if (tag !== 8) {
73
+ break;
74
+ }
75
+ message.time = longToNumber(reader.int64());
76
+ continue;
77
+ }
78
+ case 2: {
79
+ if (tag !== 21) {
80
+ break;
81
+ }
82
+ message.open = reader.float();
83
+ continue;
84
+ }
85
+ case 3: {
86
+ if (tag !== 29) {
87
+ break;
88
+ }
89
+ message.high = reader.float();
90
+ continue;
91
+ }
92
+ case 4: {
93
+ if (tag !== 37) {
94
+ break;
95
+ }
96
+ message.low = reader.float();
97
+ continue;
98
+ }
99
+ case 5: {
100
+ if (tag !== 45) {
101
+ break;
102
+ }
103
+ message.close = reader.float();
104
+ continue;
105
+ }
106
+ case 6: {
107
+ if (tag !== 53) {
108
+ break;
109
+ }
110
+ message.avg = reader.float();
111
+ continue;
112
+ }
113
+ case 7: {
114
+ if (tag !== 56) {
115
+ break;
116
+ }
117
+ message.volume = longToNumber(reader.int64());
118
+ continue;
119
+ }
120
+ case 8: {
121
+ if (tag !== 64) {
122
+ break;
123
+ }
124
+ message.count = reader.int32();
125
+ continue;
126
+ }
127
+ case 9: {
128
+ if (tag !== 74) {
129
+ break;
130
+ }
131
+ message.symbol = reader.string();
132
+ continue;
133
+ }
134
+ case 10: {
135
+ if (tag !== 81) {
136
+ break;
137
+ }
138
+ message.amount = reader.double();
139
+ continue;
140
+ }
141
+ case 11: {
142
+ if (tag !== 88) {
143
+ break;
144
+ }
145
+ message.serverTimestamp = longToNumber(reader.uint64());
146
+ continue;
147
+ }
148
+ }
149
+ if ((tag & 7) === 4 || tag === 0) {
150
+ break;
151
+ }
152
+ reader.skip(tag & 7);
153
+ }
154
+ return message;
155
+ },
156
+ create(base) {
157
+ return exports.KlineData.fromPartial(base ?? {});
158
+ },
159
+ fromPartial(object) {
160
+ const message = createBaseKlineData();
161
+ message.time = object.time ?? 0;
162
+ message.open = object.open ?? 0;
163
+ message.high = object.high ?? 0;
164
+ message.low = object.low ?? 0;
165
+ message.close = object.close ?? 0;
166
+ message.avg = object.avg ?? 0;
167
+ message.volume = object.volume ?? 0;
168
+ message.count = object.count ?? 0;
169
+ message.symbol = object.symbol ?? "";
170
+ message.amount = object.amount ?? 0;
171
+ message.serverTimestamp = object.serverTimestamp ?? undefined;
172
+ return message;
173
+ },
174
+ };
175
+ function longToNumber(int64) {
176
+ const num = globalThis.Number(int64.toString());
177
+ if (num > globalThis.Number.MAX_SAFE_INTEGER) {
178
+ throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
179
+ }
180
+ if (num < globalThis.Number.MIN_SAFE_INTEGER) {
181
+ throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
182
+ }
183
+ return num;
184
+ }