@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,22 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HttpClient - HTTP
|
|
2
|
+
* HttpClient - HTTP client
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Handles HTTP requests, signing, retry, and timeout.
|
|
5
|
+
* Uses Node.js built-in fetch (Node 18+).
|
|
6
6
|
*/
|
|
7
7
|
import type { ClientConfig } from '../config/client-config';
|
|
8
8
|
import { RetryPolicy } from './retry';
|
|
9
9
|
import { type ApiResponse } from './api-response';
|
|
10
10
|
import type { ApiRequest } from './api-request';
|
|
11
11
|
/**
|
|
12
|
-
* HttpClient
|
|
12
|
+
* HttpClient handles HTTP requests, signing, retry, and timeout
|
|
13
13
|
*/
|
|
14
14
|
export declare class HttpClient {
|
|
15
15
|
private config;
|
|
16
16
|
private retryPolicy;
|
|
17
|
-
|
|
17
|
+
/** Override the target URL (used by quote client to hit quote server) */
|
|
18
|
+
private targetUrl;
|
|
19
|
+
constructor(config: ClientConfig, retryPolicy?: RetryPolicy, options?: {
|
|
20
|
+
useQuoteServerUrl?: boolean;
|
|
21
|
+
});
|
|
18
22
|
/**
|
|
19
|
-
*
|
|
23
|
+
* Build common request parameters
|
|
20
24
|
*/
|
|
21
25
|
private buildCommonParams;
|
|
22
26
|
/**
|
|
@@ -24,22 +28,30 @@ export declare class HttpClient {
|
|
|
24
28
|
*/
|
|
25
29
|
private signParams;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Send HTTP POST request
|
|
28
32
|
*/
|
|
29
33
|
private doHttpPost;
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
35
|
+
* Execute a structured API request, returning a parsed ApiResponse.
|
|
36
|
+
* Used internally by QuoteClient/TradeClient.
|
|
33
37
|
*/
|
|
34
38
|
executeRequest(request: ApiRequest): Promise<ApiResponse>;
|
|
35
39
|
/**
|
|
36
|
-
*
|
|
40
|
+
* General-purpose API call method.
|
|
37
41
|
*
|
|
38
|
-
* @param apiMethod - API
|
|
39
|
-
* @param requestJson -
|
|
40
|
-
* @returns
|
|
42
|
+
* @param apiMethod - API method name (e.g. "market_state", "place_order")
|
|
43
|
+
* @param requestJson - Raw biz_content JSON string
|
|
44
|
+
* @returns Raw response JSON string, unparsed
|
|
41
45
|
*/
|
|
42
46
|
execute(apiMethod: string, requestJson: string): Promise<string>;
|
|
43
|
-
/**
|
|
47
|
+
/** Delay for the specified milliseconds */
|
|
44
48
|
private sleep;
|
|
49
|
+
/**
|
|
50
|
+
* Verify the response signature using the tiger public key.
|
|
51
|
+
*
|
|
52
|
+
* @param timestamp - The timestamp sent in the request params
|
|
53
|
+
* @param signBase64 - The `sign` field from the response body
|
|
54
|
+
* @throws TigerError if the signature is missing or invalid
|
|
55
|
+
*/
|
|
56
|
+
private verifyResponseSign;
|
|
45
57
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Transport layer exports.
|
|
3
3
|
*/
|
|
4
4
|
export { HttpClient } from './http-client';
|
|
5
5
|
export { TigerError, classifyErrorCode, type ErrorCategory } from './errors';
|
|
6
6
|
export { RetryPolicy, defaultRetryPolicy, isTradeOperation } from './retry';
|
|
7
7
|
export { type ApiRequest, createApiRequest } from './api-request';
|
|
8
|
-
export { type ApiResponse, parseApiResponse } from './api-response';
|
|
8
|
+
export { type ApiResponse, parseApiResponse, unmarshalData } from './api-response';
|
|
9
|
+
export { camelToSnake, keysToSnakeCase } from './case-convert';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Client configuration interface */
|
|
2
2
|
export interface ClientConfig {
|
|
3
3
|
tigerId: string;
|
|
4
4
|
privateKey: string;
|
|
@@ -7,12 +7,16 @@ export interface ClientConfig {
|
|
|
7
7
|
language: string;
|
|
8
8
|
timezone?: string;
|
|
9
9
|
timeout: number;
|
|
10
|
-
sandboxDebug: boolean;
|
|
11
10
|
token?: string;
|
|
12
11
|
tokenRefreshDuration?: number;
|
|
13
12
|
serverUrl: string;
|
|
13
|
+
/** Quote server URL for quote-specific requests; falls back to serverUrl */
|
|
14
|
+
quoteServerUrl: string;
|
|
15
|
+
/** Device identifier (auto-detected MAC address) */
|
|
16
|
+
deviceId: string;
|
|
17
|
+
tigerPublicKey: string;
|
|
14
18
|
}
|
|
15
|
-
/**
|
|
19
|
+
/** Options for creating a client configuration */
|
|
16
20
|
export interface ClientConfigOptions {
|
|
17
21
|
tigerId?: string;
|
|
18
22
|
privateKey?: string;
|
|
@@ -21,23 +25,35 @@ export interface ClientConfigOptions {
|
|
|
21
25
|
language?: string;
|
|
22
26
|
timezone?: string;
|
|
23
27
|
timeout?: number;
|
|
24
|
-
sandboxDebug?: boolean;
|
|
25
28
|
token?: string;
|
|
26
29
|
tokenRefreshDuration?: number;
|
|
27
30
|
serverUrl?: string;
|
|
28
|
-
/**
|
|
31
|
+
/** Explicit quote server URL; resolved dynamically if not set */
|
|
32
|
+
quoteServerUrl?: string;
|
|
33
|
+
/** Enable dynamic domain resolution (default: true) */
|
|
29
34
|
enableDynamicDomain?: boolean;
|
|
30
|
-
/** properties
|
|
35
|
+
/** Explicit properties file path (synchronous read) */
|
|
31
36
|
propertiesFilePath?: string;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
39
|
+
* Load and parse a Java-style properties file.
|
|
35
40
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
41
|
+
* @param filePath - Absolute or relative path to the properties file
|
|
42
|
+
* @returns Parsed key-value pairs, or empty object if the file cannot be read
|
|
43
|
+
*/
|
|
44
|
+
export declare function loadPropertiesFile(filePath: string): Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Create a client configuration.
|
|
47
|
+
*
|
|
48
|
+
* When called with no arguments (or without `propertiesFilePath`), the function
|
|
49
|
+
* automatically searches for `tiger_openapi_config.properties` in the current
|
|
50
|
+
* directory and `~/.tigeropen/`. Discovered values serve as defaults; explicit
|
|
51
|
+
* options and environment variables take precedence.
|
|
52
|
+
*
|
|
53
|
+
* Priority: environment variables > code options > config file > defaults
|
|
38
54
|
*
|
|
39
|
-
* @param options -
|
|
40
|
-
* @returns
|
|
41
|
-
* @throws tigerId
|
|
55
|
+
* @param options - Configuration options (optional)
|
|
56
|
+
* @returns Complete client configuration object
|
|
57
|
+
* @throws When tigerId or privateKey is empty after all resolution
|
|
42
58
|
*/
|
|
43
|
-
export declare function createClientConfig(options
|
|
59
|
+
export declare function createClientConfig(options?: ClientConfigOptions): ClientConfig;
|
|
@@ -16,3 +16,12 @@ export declare function queryDomains(license?: string): Record<string, unknown>;
|
|
|
16
16
|
* 返回空字符串表示无法解析(应使用默认地址)。
|
|
17
17
|
*/
|
|
18
18
|
export declare function resolveDynamicServerUrl(domainConf: Record<string, unknown>, license?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the quote server URL from dynamic domain configuration.
|
|
21
|
+
* Uses the `{LICENSE}-QUOTE` key, falling back to empty string.
|
|
22
|
+
*
|
|
23
|
+
* @param domainConf - Domain configuration map from queryDomains
|
|
24
|
+
* @param license - License type (e.g. "TBNZ")
|
|
25
|
+
* @returns Quote server URL with gateway suffix, or empty string
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveDynamicQuoteServerUrl(domainConf: Record<string, unknown>, license?: string): string;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* 配置层导出
|
|
3
3
|
*/
|
|
4
4
|
export { parsePropertiesFile, parsePropertiesString } from './config-parser';
|
|
5
|
-
export { createClientConfig } from './client-config';
|
|
5
|
+
export { createClientConfig, loadPropertiesFile } from './client-config';
|
|
6
6
|
export type { ClientConfig, ClientConfigOptions } from './client-config';
|
|
7
|
-
export { queryDomains, resolveDynamicServerUrl } from './domain';
|
|
7
|
+
export { queryDomains, resolveDynamicServerUrl, resolveDynamicQuoteServerUrl } from './domain';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,60 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Contract
|
|
3
|
-
* 字段名 camelCase 与 API JSON 天然一致,不改名、不加封装层
|
|
2
|
+
* Contract / TickSize models.
|
|
4
3
|
*/
|
|
5
|
-
/**
|
|
4
|
+
/** Tick size tier */
|
|
6
5
|
export interface TickSize {
|
|
7
|
-
/** 起始价格(字符串,如 "0"、"1") */
|
|
8
6
|
begin?: string;
|
|
9
|
-
/** 结束价格(字符串,如 "1"、"Infinity") */
|
|
10
7
|
end?: string;
|
|
11
|
-
/** 最小报价单位 */
|
|
12
8
|
tickSize?: number;
|
|
13
|
-
/** 类型(CLOSED/OPEN) */
|
|
14
9
|
type?: string;
|
|
15
10
|
}
|
|
16
|
-
/**
|
|
11
|
+
/** Contract model (returned by contract / contracts / quoteContract / derivative queries) */
|
|
17
12
|
export interface Contract {
|
|
18
|
-
/** 合约 ID */
|
|
19
13
|
contractId?: number;
|
|
20
|
-
/** 标的代码(如 AAPL) */
|
|
21
14
|
symbol: string;
|
|
22
|
-
/** 证券类型(STK/OPT/FUT/WAR/CASH/FUND 等) */
|
|
23
15
|
secType: string;
|
|
24
|
-
/** 货币 */
|
|
25
16
|
currency?: string;
|
|
26
|
-
/** 交易所 */
|
|
27
17
|
exchange?: string;
|
|
28
|
-
|
|
18
|
+
primaryExchange?: string;
|
|
19
|
+
localSymbol?: string;
|
|
20
|
+
tradingClass?: string;
|
|
29
21
|
expiry?: string;
|
|
30
|
-
/** 行权价(期权) */
|
|
31
22
|
strike?: number;
|
|
32
|
-
/** 看涨/看跌(PUT/CALL),保持 API 原始名 right,不改为 putCall */
|
|
33
23
|
right?: string;
|
|
34
|
-
/** 合约乘数 */
|
|
35
24
|
multiplier?: number;
|
|
36
|
-
/** 合约标识符 */
|
|
37
25
|
identifier?: string;
|
|
38
|
-
/** 合约名称 */
|
|
39
26
|
name?: string;
|
|
40
|
-
/** 市场 */
|
|
41
27
|
market?: string;
|
|
42
|
-
/** 是否可交易,保持 API 原始名 tradeable,不改为 trade */
|
|
43
28
|
tradeable?: boolean;
|
|
44
|
-
/** 合约内部 ID,保持 API 原始名 conid,不改为 contractId */
|
|
45
29
|
conid?: number;
|
|
46
|
-
|
|
30
|
+
status?: number;
|
|
31
|
+
marginable?: boolean;
|
|
32
|
+
shortable?: boolean;
|
|
33
|
+
closeOnly?: boolean;
|
|
34
|
+
isEtf?: boolean;
|
|
35
|
+
supportOvernightTrading?: boolean;
|
|
36
|
+
supportFractionalShare?: boolean;
|
|
47
37
|
shortMargin?: number;
|
|
48
|
-
/** 做空初始保证金比例 */
|
|
49
38
|
shortInitialMargin?: number;
|
|
50
|
-
/** 做空维持保证金比例 */
|
|
51
39
|
shortMaintenanceMargin?: number;
|
|
52
|
-
/** 做多初始保证金 */
|
|
53
40
|
longInitialMargin?: number;
|
|
54
|
-
/** 做多维持保证金 */
|
|
55
41
|
longMaintenanceMargin?: number;
|
|
56
|
-
/** 最小报价单位价格区间 */
|
|
57
42
|
tickSizes?: TickSize[];
|
|
58
|
-
/** 每手数量 */
|
|
59
43
|
lotSize?: number;
|
|
60
44
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Order construction helpers.
|
|
3
|
+
* All helpers return an `OrderRequest` with sensible defaults.
|
|
3
4
|
*/
|
|
4
|
-
import type {
|
|
5
|
-
/**
|
|
6
|
-
export declare function marketOrder(account: string, symbol: string, secType: string, action: string, quantity: number):
|
|
7
|
-
/**
|
|
8
|
-
export declare function limitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number):
|
|
9
|
-
/**
|
|
10
|
-
export declare function stopOrder(account: string, symbol: string, secType: string, action: string, quantity: number, auxPrice: number):
|
|
11
|
-
/**
|
|
12
|
-
export declare function stopLimitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, auxPrice: number):
|
|
13
|
-
/**
|
|
14
|
-
export declare function trailOrder(account: string, symbol: string, secType: string, action: string, quantity: number, trailingPercent: number):
|
|
15
|
-
/**
|
|
16
|
-
export declare function auctionLimitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number):
|
|
17
|
-
/**
|
|
18
|
-
export declare function auctionMarketOrder(account: string, symbol: string, secType: string, action: string, quantity: number):
|
|
19
|
-
/**
|
|
20
|
-
export declare function algoOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, algoType: string, params:
|
|
21
|
-
/**
|
|
22
|
-
export declare function orderLeg(legType: string, price: number, timeInForce: string):
|
|
5
|
+
import type { OrderRequest, OrderLegRequest, AlgoParamsRequest } from './order';
|
|
6
|
+
/** Market order */
|
|
7
|
+
export declare function marketOrder(account: string, symbol: string, secType: string, action: string, quantity: number): OrderRequest;
|
|
8
|
+
/** Limit order */
|
|
9
|
+
export declare function limitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number): OrderRequest;
|
|
10
|
+
/** Stop order */
|
|
11
|
+
export declare function stopOrder(account: string, symbol: string, secType: string, action: string, quantity: number, auxPrice: number): OrderRequest;
|
|
12
|
+
/** Stop limit order */
|
|
13
|
+
export declare function stopLimitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, auxPrice: number): OrderRequest;
|
|
14
|
+
/** Trailing stop order */
|
|
15
|
+
export declare function trailOrder(account: string, symbol: string, secType: string, action: string, quantity: number, trailingPercent: number): OrderRequest;
|
|
16
|
+
/** Auction limit order */
|
|
17
|
+
export declare function auctionLimitOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number): OrderRequest;
|
|
18
|
+
/** Auction market order */
|
|
19
|
+
export declare function auctionMarketOrder(account: string, symbol: string, secType: string, action: string, quantity: number): OrderRequest;
|
|
20
|
+
/** Algo order (TWAP / VWAP) */
|
|
21
|
+
export declare function algoOrder(account: string, symbol: string, secType: string, action: string, quantity: number, limitPrice: number, algoType: string, params: AlgoParamsRequest): OrderRequest;
|
|
22
|
+
/** Attached profit / loss leg */
|
|
23
|
+
export declare function orderLeg(legType: string, price: number, timeInForce: string): OrderLegRequest;
|
|
@@ -1,95 +1,141 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Order
|
|
3
|
-
*
|
|
2
|
+
* Order response / request models.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript uses camelCase field names idiomatically. The client layer
|
|
5
|
+
* transparently converts request camelCase to snake_case before sending;
|
|
6
|
+
* server responses are already camelCase so they decode directly.
|
|
4
7
|
*/
|
|
5
|
-
/**
|
|
8
|
+
/** Attached leg order (profit / loss) — response side */
|
|
6
9
|
export interface OrderLeg {
|
|
7
|
-
/** 附加订单类型(PROFIT/LOSS) */
|
|
8
10
|
legType?: string;
|
|
9
|
-
/** 价格 */
|
|
10
11
|
price?: number;
|
|
11
|
-
/** 有效期 */
|
|
12
12
|
timeInForce?: string;
|
|
13
|
-
/** 数量 */
|
|
14
13
|
quantity?: number;
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
15
|
+
/** Algo order parameters — response side */
|
|
17
16
|
export interface AlgoParams {
|
|
18
|
-
/** 算法策略(TWAP/VWAP) */
|
|
19
17
|
algoStrategy?: string;
|
|
20
|
-
/** 开始时间 */
|
|
21
18
|
startTime?: string;
|
|
22
|
-
/** 结束时间 */
|
|
23
19
|
endTime?: string;
|
|
24
|
-
/** 参与率 */
|
|
25
20
|
participationRate?: number;
|
|
26
21
|
}
|
|
27
|
-
/**
|
|
22
|
+
/** Order response model (returned by order query methods). */
|
|
28
23
|
export interface Order {
|
|
29
|
-
|
|
30
|
-
account: string;
|
|
31
|
-
/** 全局订单 ID */
|
|
24
|
+
account?: string;
|
|
32
25
|
id?: number;
|
|
33
|
-
/** 账户自增订单号 */
|
|
34
26
|
orderId?: number;
|
|
35
|
-
|
|
36
|
-
action
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
externalId?: string;
|
|
28
|
+
action?: string;
|
|
29
|
+
orderType?: string;
|
|
30
|
+
totalQuantity?: number;
|
|
31
|
+
totalQuantityScale?: number;
|
|
32
|
+
filledQuantity?: number;
|
|
33
|
+
filledQuantityScale?: number;
|
|
34
|
+
filledCashAmount?: number;
|
|
42
35
|
limitPrice?: number;
|
|
43
|
-
/** 辅助价格(止损价) */
|
|
44
36
|
auxPrice?: number;
|
|
45
|
-
/** 跟踪止损百分比 */
|
|
46
37
|
trailingPercent?: number;
|
|
47
|
-
/** 订单状态 */
|
|
48
38
|
status?: string;
|
|
49
|
-
/** 已成交数量(API 返回字段名为 filledQuantity) */
|
|
50
|
-
filledQuantity?: number;
|
|
51
|
-
/** 平均成交价 */
|
|
52
39
|
avgFillPrice?: number;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/** 是否允许盘前盘后 */
|
|
56
|
-
outsideRth: boolean;
|
|
57
|
-
/** 附加订单(止盈/止损) */
|
|
40
|
+
timeInForce?: string;
|
|
41
|
+
outsideRth?: boolean;
|
|
58
42
|
orderLegs?: OrderLeg[];
|
|
59
|
-
/** 算法参数 */
|
|
60
43
|
algoParams?: AlgoParams;
|
|
61
|
-
|
|
62
|
-
symbol
|
|
63
|
-
|
|
64
|
-
secType: string;
|
|
65
|
-
/** 市场 */
|
|
44
|
+
algoStrategy?: string;
|
|
45
|
+
symbol?: string;
|
|
46
|
+
secType?: string;
|
|
66
47
|
market?: string;
|
|
67
|
-
/** 货币 */
|
|
68
48
|
currency?: string;
|
|
69
|
-
/** 到期日(期权/期货) */
|
|
70
49
|
expiry?: string;
|
|
71
|
-
/** 行权价(期权),API 返回为字符串 */
|
|
72
50
|
strike?: string;
|
|
73
|
-
/** 看涨/看跌(PUT/CALL),保持 API 原始名 right */
|
|
74
51
|
right?: string;
|
|
75
|
-
/** 合约标识符 */
|
|
76
52
|
identifier?: string;
|
|
77
|
-
/** 合约名称 */
|
|
78
53
|
name?: string;
|
|
79
|
-
/** 佣金 */
|
|
80
54
|
commission?: number;
|
|
81
|
-
|
|
55
|
+
gst?: number;
|
|
82
56
|
realizedPnl?: number;
|
|
83
|
-
/** 开仓时间(毫秒时间戳) */
|
|
84
57
|
openTime?: number;
|
|
85
|
-
/** 更新时间(毫秒时间戳) */
|
|
86
58
|
updateTime?: number;
|
|
87
|
-
/** 最新时间(毫秒时间戳) */
|
|
88
59
|
latestTime?: number;
|
|
89
|
-
|
|
60
|
+
latestPrice?: number;
|
|
90
61
|
remark?: string;
|
|
91
|
-
/** 订单来源 */
|
|
92
62
|
source?: string;
|
|
93
|
-
/** 用户标记 */
|
|
94
63
|
userMark?: string;
|
|
64
|
+
liquidation?: boolean;
|
|
65
|
+
discount?: number;
|
|
66
|
+
replaceStatus?: string;
|
|
67
|
+
cancelStatus?: string;
|
|
68
|
+
canModify?: boolean;
|
|
69
|
+
canCancel?: boolean;
|
|
70
|
+
isOpen?: boolean;
|
|
71
|
+
orderDiscount?: number;
|
|
72
|
+
tradingSessionType?: string;
|
|
73
|
+
attrDesc?: string;
|
|
74
|
+
attrList?: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* OrderRequest — order request model used by placeOrder / previewOrder / modifyOrder.
|
|
78
|
+
* Fields are camelCase in TypeScript; the client converts them to snake_case on the wire.
|
|
79
|
+
*/
|
|
80
|
+
export interface OrderRequest {
|
|
81
|
+
/** Account ID (client fills it in automatically) */
|
|
82
|
+
account?: string;
|
|
83
|
+
/** Global order ID (required for modify) */
|
|
84
|
+
id?: number;
|
|
85
|
+
/** Account-level order ID */
|
|
86
|
+
orderId?: number;
|
|
87
|
+
/** BUY / SELL */
|
|
88
|
+
action: string;
|
|
89
|
+
/** Order type: MKT / LMT / STP / STP_LMT / TRAIL / AM / AL / TWAP / VWAP / OCA */
|
|
90
|
+
orderType: string;
|
|
91
|
+
/** Total quantity */
|
|
92
|
+
totalQuantity: number;
|
|
93
|
+
/** Limit price (required for LMT / STP_LMT) */
|
|
94
|
+
limitPrice?: number;
|
|
95
|
+
/** Stop / trigger price (required for STP / STP_LMT / TRAIL) */
|
|
96
|
+
auxPrice?: number;
|
|
97
|
+
/** Trailing stop percent */
|
|
98
|
+
trailingPercent?: number;
|
|
99
|
+
/** DAY / GTC / GTD / OPG */
|
|
100
|
+
timeInForce: string;
|
|
101
|
+
/** Allow extended-hours trading */
|
|
102
|
+
outsideRth?: boolean;
|
|
103
|
+
/** Attached legs (profit / loss) */
|
|
104
|
+
orderLegs?: OrderLegRequest[];
|
|
105
|
+
/** Algo parameters */
|
|
106
|
+
algoParams?: AlgoParamsRequest;
|
|
107
|
+
/** Contract symbol */
|
|
108
|
+
symbol: string;
|
|
109
|
+
/** STK / OPT / FUT / WAR / IOPT */
|
|
110
|
+
secType: string;
|
|
111
|
+
/** Market */
|
|
112
|
+
market?: string;
|
|
113
|
+
/** Currency */
|
|
114
|
+
currency?: string;
|
|
115
|
+
/** Option expiry */
|
|
116
|
+
expiry?: string;
|
|
117
|
+
/** Option strike */
|
|
118
|
+
strike?: string;
|
|
119
|
+
/** CALL / PUT */
|
|
120
|
+
right?: string;
|
|
121
|
+
/** Contract identifier */
|
|
122
|
+
identifier?: string;
|
|
123
|
+
/** Remark */
|
|
124
|
+
remark?: string;
|
|
125
|
+
/** User mark */
|
|
126
|
+
userMark?: string;
|
|
127
|
+
}
|
|
128
|
+
/** Attached leg for request side */
|
|
129
|
+
export interface OrderLegRequest {
|
|
130
|
+
legType: string;
|
|
131
|
+
price?: number;
|
|
132
|
+
timeInForce?: string;
|
|
133
|
+
quantity?: number;
|
|
134
|
+
}
|
|
135
|
+
/** Algo parameters for request side */
|
|
136
|
+
export interface AlgoParamsRequest {
|
|
137
|
+
algoStrategy?: string;
|
|
138
|
+
startTime?: string;
|
|
139
|
+
endTime?: string;
|
|
140
|
+
participationRate?: number;
|
|
95
141
|
}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Position
|
|
3
|
-
* 字段名 camelCase 与 API JSON 天然一致,不改名、不加封装层
|
|
2
|
+
* Position model.
|
|
4
3
|
*/
|
|
5
|
-
/**
|
|
4
|
+
/** Position (returned by positions query) */
|
|
6
5
|
export interface Position {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
symbol: string;
|
|
11
|
-
/** 证券类型 */
|
|
12
|
-
secType: string;
|
|
13
|
-
/** 市场 */
|
|
6
|
+
account?: string;
|
|
7
|
+
symbol?: string;
|
|
8
|
+
secType?: string;
|
|
14
9
|
market?: string;
|
|
15
|
-
/** 货币 */
|
|
16
10
|
currency?: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
position?: number;
|
|
12
|
+
positionScale?: number;
|
|
13
|
+
positionQty?: number;
|
|
14
|
+
salableQty?: number;
|
|
15
|
+
averageCost?: number;
|
|
16
|
+
averageCostByAverage?: number;
|
|
17
|
+
averageCostOfCarry?: number;
|
|
22
18
|
marketValue?: number;
|
|
23
|
-
/** 已实现盈亏 */
|
|
24
19
|
realizedPnl?: number;
|
|
25
|
-
|
|
20
|
+
realizedPnlByAverage?: number;
|
|
26
21
|
unrealizedPnl?: number;
|
|
27
|
-
|
|
22
|
+
unrealizedPnlByAverage?: number;
|
|
23
|
+
unrealizedPnlByCostOfCarry?: number;
|
|
28
24
|
unrealizedPnlPercent?: number;
|
|
29
|
-
|
|
25
|
+
unrealizedPnlPercentByAverage?: number;
|
|
26
|
+
unrealizedPnlPercentByCostOfCarry?: number;
|
|
30
27
|
contractId?: number;
|
|
31
|
-
/** 合约标识符 */
|
|
32
28
|
identifier?: string;
|
|
33
|
-
/** 合约名称 */
|
|
34
29
|
name?: string;
|
|
35
|
-
/** 最新价格 */
|
|
36
30
|
latestPrice?: number;
|
|
37
|
-
|
|
31
|
+
lastClosePrice?: number;
|
|
38
32
|
multiplier?: number;
|
|
33
|
+
status?: number;
|
|
34
|
+
updateTimestamp?: number;
|
|
35
|
+
mmPercent?: number;
|
|
36
|
+
mmValue?: number;
|
|
37
|
+
todayPnl?: number;
|
|
38
|
+
todayPnlPercent?: number;
|
|
39
|
+
comboTypes?: string[];
|
|
40
|
+
categories?: string[];
|
|
39
41
|
}
|