@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.
- package/README.md +475 -104
- package/dist/cjs/client/api-request.js +16 -10
- package/dist/cjs/client/api-response.js +23 -3
- package/dist/cjs/client/case-convert.js +35 -0
- package/dist/cjs/client/http-client.js +46 -20
- package/dist/cjs/client/index.js +6 -2
- package/dist/cjs/config/client-config.js +130 -49
- package/dist/cjs/config/domain.js +21 -2
- package/dist/cjs/config/index.js +3 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/model/contract.js +1 -2
- package/dist/cjs/model/order-helpers.js +9 -9
- package/dist/cjs/model/order.js +5 -2
- package/dist/cjs/model/position.js +1 -2
- package/dist/cjs/model/quote.js +7 -0
- package/dist/cjs/model/trade.js +2 -0
- package/dist/cjs/push/index.js +6 -3
- package/dist/cjs/push/pb/AssetData.js +208 -0
- package/dist/cjs/push/pb/KlineData.js +184 -0
- package/dist/cjs/push/pb/OptionTopData.js +427 -0
- package/dist/cjs/push/pb/OrderStatusData.js +568 -0
- package/dist/cjs/push/pb/OrderTransactionData.js +256 -0
- package/dist/cjs/push/pb/PositionData.js +316 -0
- package/dist/cjs/push/pb/PushData.js +219 -0
- package/dist/cjs/push/pb/QuoteBBOData.js +160 -0
- package/dist/cjs/push/pb/QuoteBasicData.js +329 -0
- package/dist/cjs/push/pb/QuoteData.js +507 -0
- package/dist/cjs/push/pb/QuoteDepthData.js +220 -0
- package/dist/cjs/push/pb/Request.js +278 -0
- package/dist/cjs/push/pb/Response.js +97 -0
- package/dist/cjs/push/pb/SocketCommon.js +86 -0
- package/dist/cjs/push/pb/StockTopData.js +199 -0
- package/dist/cjs/push/pb/TickData.js +202 -0
- package/dist/cjs/push/pb/TradeTickData.js +308 -0
- package/dist/cjs/push/pb/index.js +49 -0
- package/dist/cjs/push/proto-message.js +129 -0
- package/dist/cjs/push/push-client.js +292 -164
- package/dist/cjs/push/push-message.js +4 -60
- package/dist/cjs/push/varint.js +76 -0
- package/dist/cjs/quote/index.js +3 -2
- package/dist/cjs/quote/quote-client.js +128 -94
- package/dist/cjs/signer/signer.js +10 -10
- package/dist/cjs/trade/trade-client.js +56 -62
- package/dist/esm/client/api-request.js +14 -8
- package/dist/esm/client/api-response.js +22 -3
- package/dist/esm/client/case-convert.js +31 -0
- package/dist/esm/client/http-client.js +47 -21
- package/dist/esm/client/index.js +3 -2
- package/dist/esm/config/client-config.js +131 -51
- package/dist/esm/config/domain.js +20 -2
- package/dist/esm/config/index.js +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/model/contract.js +1 -2
- package/dist/esm/model/order-helpers.js +9 -9
- package/dist/esm/model/order.js +5 -2
- package/dist/esm/model/position.js +1 -2
- package/dist/esm/model/quote.js +6 -0
- package/dist/esm/model/trade.js +1 -0
- package/dist/esm/push/index.js +4 -2
- package/dist/esm/push/pb/AssetData.js +205 -0
- package/dist/esm/push/pb/KlineData.js +181 -0
- package/dist/esm/push/pb/OptionTopData.js +424 -0
- package/dist/esm/push/pb/OrderStatusData.js +565 -0
- package/dist/esm/push/pb/OrderTransactionData.js +253 -0
- package/dist/esm/push/pb/PositionData.js +313 -0
- package/dist/esm/push/pb/PushData.js +216 -0
- package/dist/esm/push/pb/QuoteBBOData.js +157 -0
- package/dist/esm/push/pb/QuoteBasicData.js +326 -0
- package/dist/esm/push/pb/QuoteData.js +504 -0
- package/dist/esm/push/pb/QuoteDepthData.js +217 -0
- package/dist/esm/push/pb/Request.js +275 -0
- package/dist/esm/push/pb/Response.js +94 -0
- package/dist/esm/push/pb/SocketCommon.js +83 -0
- package/dist/esm/push/pb/StockTopData.js +196 -0
- package/dist/esm/push/pb/TickData.js +199 -0
- package/dist/esm/push/pb/TradeTickData.js +305 -0
- package/dist/esm/push/pb/index.js +25 -0
- package/dist/esm/push/proto-message.js +121 -0
- package/dist/esm/push/push-client.js +260 -165
- package/dist/esm/push/push-message.js +3 -56
- package/dist/esm/push/varint.js +72 -0
- package/dist/esm/quote/index.js +2 -2
- package/dist/esm/quote/quote-client.js +127 -94
- package/dist/esm/signer/signer.js +10 -10
- package/dist/esm/trade/trade-client.js +56 -62
- package/dist/types/client/api-request.d.ts +12 -11
- package/dist/types/client/api-response.d.ts +15 -7
- package/dist/types/client/case-convert.d.ts +16 -0
- package/dist/types/client/http-client.d.ts +26 -14
- package/dist/types/client/index.d.ts +3 -2
- package/dist/types/config/client-config.d.ts +29 -13
- package/dist/types/config/domain.d.ts +9 -0
- package/dist/types/config/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/model/contract.d.ts +13 -29
- package/dist/types/model/order-helpers.d.ts +21 -20
- package/dist/types/model/order.d.ts +101 -55
- package/dist/types/model/position.d.ts +26 -24
- package/dist/types/model/quote.d.ts +311 -0
- package/dist/types/model/trade.d.ts +113 -0
- package/dist/types/push/callbacks.d.ts +32 -51
- package/dist/types/push/index.d.ts +5 -3
- package/dist/types/push/pb/AssetData.d.ts +47 -0
- package/dist/types/push/pb/KlineData.d.ts +43 -0
- package/dist/types/push/pb/OptionTopData.d.ts +76 -0
- package/dist/types/push/pb/OrderStatusData.d.ts +96 -0
- package/dist/types/push/pb/OrderTransactionData.d.ts +51 -0
- package/dist/types/push/pb/PositionData.d.ts +63 -0
- package/dist/types/push/pb/PushData.d.ts +46 -0
- package/dist/types/push/pb/QuoteBBOData.d.ts +35 -0
- package/dist/types/push/pb/QuoteBasicData.d.ts +66 -0
- package/dist/types/push/pb/QuoteData.d.ts +94 -0
- package/dist/types/push/pb/QuoteDepthData.d.ts +37 -0
- package/dist/types/push/pb/Request.d.ts +44 -0
- package/dist/types/push/pb/Response.d.ts +30 -0
- package/dist/types/push/pb/SocketCommon.d.ts +64 -0
- package/dist/types/push/pb/StockTopData.d.ts +37 -0
- package/dist/types/push/pb/TickData.d.ts +44 -0
- package/dist/types/push/pb/TradeTickData.d.ts +53 -0
- package/dist/types/push/pb/index.d.ts +39 -0
- package/dist/types/push/proto-message.d.ts +33 -0
- package/dist/types/push/push-client.d.ts +69 -68
- package/dist/types/push/push-message.d.ts +3 -147
- package/dist/types/push/varint.d.ts +23 -0
- package/dist/types/quote/index.d.ts +2 -2
- package/dist/types/quote/quote-client.d.ts +41 -47
- package/dist/types/signer/signer.d.ts +6 -6
- package/dist/types/trade/trade-client.d.ts +34 -38
- package/package.json +11 -6
|
@@ -1,58 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QuoteClient
|
|
3
|
-
*
|
|
2
|
+
* QuoteClient — market-data client.
|
|
3
|
+
*
|
|
4
|
+
* All methods return strongly-typed responses from the `model` package.
|
|
5
|
+
* Request parameters are written in camelCase in TypeScript and are
|
|
6
|
+
* converted to snake_case on the wire automatically.
|
|
4
7
|
*/
|
|
5
8
|
import type { HttpClient } from '../client/http-client';
|
|
9
|
+
import type { MarketState, Brief, Kline, Timeline, TradeTick, Depth, OptionExpiration, OptionChain, FutureExchange, FutureContractInfo, FutureQuote, FutureKline, FinancialDailyItem, FinancialReportItem, CorporateAction, CapitalFlow, CapitalDistribution, ScannerResult, QuotePermission, FinancialDailyRequest, FinancialReportRequest, CorporateActionRequest, FutureKlineRequest, MarketScannerRequest } from '../model/quote';
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* Parse an OCC-style option identifier like "AAPL 260619C00150000"
|
|
12
|
+
* into its component parts.
|
|
8
13
|
*/
|
|
14
|
+
export declare function parseOptionIdentifier(identifier: string): {
|
|
15
|
+
symbol: string;
|
|
16
|
+
expiryMs: number;
|
|
17
|
+
right: string;
|
|
18
|
+
strike: number;
|
|
19
|
+
};
|
|
20
|
+
/** Market data client wrapping all quote-related APIs. */
|
|
9
21
|
export declare class QuoteClient {
|
|
10
22
|
private httpClient;
|
|
11
23
|
constructor(httpClient: HttpClient);
|
|
24
|
+
private callInto;
|
|
25
|
+
getMarketState(market: string): Promise<MarketState[]>;
|
|
26
|
+
getBrief(symbols: string[]): Promise<Brief[]>;
|
|
27
|
+
getKline(symbol: string, period: string): Promise<Kline[]>;
|
|
28
|
+
getTimeline(symbols: string[]): Promise<Timeline[]>;
|
|
29
|
+
getTradeTick(symbols: string[]): Promise<TradeTick[]>;
|
|
30
|
+
/** Depth snapshot. market is required (US / HK supported). */
|
|
31
|
+
getQuoteDepth(symbol: string, market: string): Promise<Depth[]>;
|
|
32
|
+
getOptionExpiration(symbol: string): Promise<OptionExpiration[]>;
|
|
33
|
+
/** Option chain; `expiry` is "YYYY-MM-DD". */
|
|
34
|
+
getOptionChain(symbol: string, expiry: string): Promise<OptionChain[]>;
|
|
35
|
+
getOptionBrief(identifiers: string[]): Promise<Brief[]>;
|
|
36
|
+
getOptionKline(identifier: string, period: string): Promise<Kline[]>;
|
|
37
|
+
getFutureExchange(): Promise<FutureExchange[]>;
|
|
38
|
+
getFutureContracts(exchange: string): Promise<FutureContractInfo[]>;
|
|
39
|
+
getFutureRealTimeQuote(contractCodes: string[]): Promise<FutureQuote[]>;
|
|
40
|
+
/** Futures K-line; use -1 for unbounded beginTime / endTime. */
|
|
41
|
+
getFutureKline(req: FutureKlineRequest): Promise<FutureKline[]>;
|
|
42
|
+
getFinancialDaily(req: FinancialDailyRequest): Promise<FinancialDailyItem[]>;
|
|
43
|
+
getFinancialReport(req: FinancialReportRequest): Promise<FinancialReportItem[]>;
|
|
12
44
|
/**
|
|
13
|
-
*
|
|
45
|
+
* Corporate actions. Server returns {symbol: [...]}, this method flattens into a single list.
|
|
14
46
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/** 获取 K 线数据 */
|
|
21
|
-
kline(symbol: string, period: string): Promise<unknown>;
|
|
22
|
-
/** 获取分时数据 */
|
|
23
|
-
timeline(symbols: string[]): Promise<unknown>;
|
|
24
|
-
/** 获取逐笔成交数据 */
|
|
25
|
-
tradeTick(symbols: string[]): Promise<unknown>;
|
|
26
|
-
/** 获取深度行情 */
|
|
27
|
-
quoteDepth(symbol: string): Promise<unknown>;
|
|
28
|
-
/** 获取期权到期日 */
|
|
29
|
-
optionExpiration(symbol: string): Promise<unknown>;
|
|
30
|
-
/** 获取期权链 */
|
|
31
|
-
optionChain(symbol: string, expiry: string): Promise<unknown>;
|
|
32
|
-
/** 获取期权报价 */
|
|
33
|
-
optionBrief(identifiers: string[]): Promise<unknown>;
|
|
34
|
-
/** 获取期权 K 线 */
|
|
35
|
-
optionKline(identifier: string, period: string): Promise<unknown>;
|
|
36
|
-
/** 获取期货交易所列表 */
|
|
37
|
-
futureExchange(): Promise<unknown>;
|
|
38
|
-
/** 获取期货合约列表 */
|
|
39
|
-
futureContracts(exchange: string): Promise<unknown>;
|
|
40
|
-
/** 获取期货实时报价 */
|
|
41
|
-
futureRealTimeQuote(symbols: string[]): Promise<unknown>;
|
|
42
|
-
/** 获取期货 K 线 */
|
|
43
|
-
futureKline(symbol: string, period: string): Promise<unknown>;
|
|
44
|
-
/** 获取财务日报 */
|
|
45
|
-
financialDaily(symbol: string): Promise<unknown>;
|
|
46
|
-
/** 获取财务报告 */
|
|
47
|
-
financialReport(symbol: string): Promise<unknown>;
|
|
48
|
-
/** 获取公司行动 */
|
|
49
|
-
corporateAction(symbol: string): Promise<unknown>;
|
|
50
|
-
/** 获取资金流向 */
|
|
51
|
-
capitalFlow(symbol: string): Promise<unknown>;
|
|
52
|
-
/** 获取资金分布 */
|
|
53
|
-
capitalDistribution(symbol: string): Promise<unknown>;
|
|
54
|
-
/** 选股器 */
|
|
55
|
-
marketScanner(params: Record<string, unknown>): Promise<unknown>;
|
|
56
|
-
/** 获取行情权限 */
|
|
57
|
-
grabQuotePermission(): Promise<unknown>;
|
|
47
|
+
getCorporateAction(req: CorporateActionRequest): Promise<CorporateAction[]>;
|
|
48
|
+
getCapitalFlow(symbol: string, market: string, period: string): Promise<CapitalFlow | undefined>;
|
|
49
|
+
getCapitalDistribution(symbol: string, market: string): Promise<CapitalDistribution | undefined>;
|
|
50
|
+
marketScanner(req: MarketScannerRequest): Promise<ScannerResult | undefined>;
|
|
51
|
+
grabQuotePermission(): Promise<QuotePermission[]>;
|
|
58
52
|
}
|
|
@@ -26,11 +26,11 @@ export declare function loadPrivateKey(keyStr: string): KeyObject;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function signWithRSA(privateKeyStr: string, content: string): string;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Verify a SHA1WithRSA signature using an RSA public key.
|
|
30
30
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param content -
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
31
|
+
* @param publicKeyBase64 - Base64-encoded public key (DER / PKCS#1 or SPKI)
|
|
32
|
+
* @param content - Original content that was signed
|
|
33
|
+
* @param signatureBase64 - Base64-encoded signature
|
|
34
|
+
* @returns Whether the signature is valid
|
|
35
35
|
*/
|
|
36
|
-
export declare function verifyWithRSA(
|
|
36
|
+
export declare function verifyWithRSA(publicKeyBase64: string, content: string, signatureBase64: string): boolean;
|
|
@@ -1,48 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TradeClient
|
|
3
|
-
*
|
|
2
|
+
* TradeClient — trading client.
|
|
3
|
+
*
|
|
4
|
+
* All methods return strongly-typed responses; request parameters are
|
|
5
|
+
* written in camelCase in TypeScript and converted to snake_case on the wire.
|
|
4
6
|
*/
|
|
5
7
|
import type { HttpClient } from '../client/http-client';
|
|
6
|
-
import type { Order } from '../model/order';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import type { OrderRequest, Order } from '../model/order';
|
|
9
|
+
import type { Contract } from '../model/contract';
|
|
10
|
+
import type { Position } from '../model/position';
|
|
11
|
+
import type { Asset, PrimeAsset, PreviewResult, PlaceOrderResult, OrderIdResult, Transaction } from '../model/trade';
|
|
12
|
+
/** Trading client wrapping all trade-related APIs. */
|
|
10
13
|
export declare class TradeClient {
|
|
11
14
|
private httpClient;
|
|
12
15
|
private account;
|
|
13
16
|
constructor(httpClient: HttpClient, account: string);
|
|
17
|
+
private callInto;
|
|
18
|
+
/** Strip `{items: [...]}` envelope used by most trade read endpoints. */
|
|
19
|
+
private callIntoItems;
|
|
20
|
+
getContract(symbol: string, secType: string): Promise<Contract[]>;
|
|
21
|
+
getContracts(symbols: string[], secType: string): Promise<Contract[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Derivative contracts (OPT / WAR / IOPT only).
|
|
24
|
+
* `symbol` is the underlying (e.g. "AAPL"); `expiry` is "YYYYMMDD".
|
|
25
|
+
*/
|
|
26
|
+
getQuoteContract(symbol: string, secType: string, expiry: string): Promise<Contract[]>;
|
|
27
|
+
placeOrder(order: OrderRequest): Promise<PlaceOrderResult | undefined>;
|
|
28
|
+
previewOrder(order: OrderRequest): Promise<PreviewResult | undefined>;
|
|
29
|
+
modifyOrder(id: number, order: OrderRequest): Promise<OrderIdResult | undefined>;
|
|
30
|
+
cancelOrder(id: number): Promise<OrderIdResult | undefined>;
|
|
31
|
+
getOrders(): Promise<Order[]>;
|
|
32
|
+
getActiveOrders(): Promise<Order[]>;
|
|
33
|
+
getInactiveOrders(): Promise<Order[]>;
|
|
14
34
|
/**
|
|
15
|
-
*
|
|
35
|
+
* Filled orders in a time range (ms timestamps required by the server).
|
|
36
|
+
* Use `Date.now() - 30*24*3600*1000` for "last 30 days".
|
|
16
37
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
quoteContract(symbol: string, secType: string): Promise<unknown>;
|
|
24
|
-
/** 下单 */
|
|
25
|
-
placeOrder(order: Order): Promise<unknown>;
|
|
26
|
-
/** 预览订单 */
|
|
27
|
-
previewOrder(order: Order): Promise<unknown>;
|
|
28
|
-
/** 修改订单 */
|
|
29
|
-
modifyOrder(id: number, order: Order): Promise<unknown>;
|
|
30
|
-
/** 取消订单 */
|
|
31
|
-
cancelOrder(id: number): Promise<unknown>;
|
|
32
|
-
/** 查询全部订单 */
|
|
33
|
-
orders(): Promise<unknown>;
|
|
34
|
-
/** 查询待成交订单 */
|
|
35
|
-
activeOrders(): Promise<unknown>;
|
|
36
|
-
/** 查询已撤销订单 */
|
|
37
|
-
inactiveOrders(): Promise<unknown>;
|
|
38
|
-
/** 查询已成交订单 */
|
|
39
|
-
filledOrders(): Promise<unknown>;
|
|
40
|
-
/** 查询持仓 */
|
|
41
|
-
positions(): Promise<unknown>;
|
|
42
|
-
/** 查询资产 */
|
|
43
|
-
assets(): Promise<unknown>;
|
|
44
|
-
/** 查询综合账户资产 */
|
|
45
|
-
primeAssets(): Promise<unknown>;
|
|
46
|
-
/** 查询订单成交明细 */
|
|
47
|
-
orderTransactions(id: number): Promise<unknown>;
|
|
38
|
+
getFilledOrders(startDateMs: number, endDateMs: number): Promise<Order[]>;
|
|
39
|
+
/** Transactions for a specific order; `symbol` and `secType` are required. */
|
|
40
|
+
getOrderTransactions(id: number, symbol: string, secType: string): Promise<Transaction[]>;
|
|
41
|
+
getPositions(): Promise<Position[]>;
|
|
42
|
+
getAssets(): Promise<Asset[]>;
|
|
43
|
+
getPrimeAssets(): Promise<PrimeAsset | undefined>;
|
|
48
44
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tigeropenapi/tigeropen",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Tiger Brokers OpenAPI TypeScript SDK for market data, trading, and real-time push",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
7
|
"types": "./dist/types/index.d.ts",
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
"build:esm": "tsc -p tsconfig.json",
|
|
29
29
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
|
+
"publish:all": "npm run build && npm publish --registry https://registry.npmjs.org --access public && npm pkg set name=tigeropen && npm publish --registry https://registry.npmjs.org && npm pkg set name=@tigeropenapi/tigeropen",
|
|
31
32
|
"test": "vitest run",
|
|
32
33
|
"test:watch": "vitest",
|
|
33
|
-
"clean": "rm -rf dist"
|
|
34
|
+
"clean": "rm -rf dist",
|
|
35
|
+
"proto:generate": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/push/pb --ts_proto_opt=esModuleInterop=true,outputEncodeMethods=true,outputJsonMethods=false,outputClientImpl=false -I=./proto ./proto/*.proto"
|
|
34
36
|
},
|
|
35
37
|
"keywords": [
|
|
36
38
|
"tiger",
|
|
@@ -45,10 +47,13 @@
|
|
|
45
47
|
"node": ">=16.0.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@types/
|
|
50
|
+
"@types/node": "^25.6.0",
|
|
49
51
|
"fast-check": "^3.15.0",
|
|
52
|
+
"ts-proto": "^2.11.6",
|
|
50
53
|
"typescript": "^5.3.0",
|
|
51
|
-
"vitest": "^1.2.0"
|
|
52
|
-
|
|
54
|
+
"vitest": "^1.2.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@bufbuild/protobuf": "^2.12.0"
|
|
53
58
|
}
|
|
54
59
|
}
|