@dshtrading/connector-hithink 0.6.1 → 0.6.2
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/lib/dataplane.d.ts +2 -2
- package/lib/dataplane.js +5 -3
- package/lib/futures-dataplane.d.ts +2 -2
- package/lib/futures-dataplane.js +5 -2
- package/lib/index.d.ts +2 -7
- package/lib/index.js +0 -6
- package/lib/rest.d.ts +1 -8
- package/lib/rest.js +0 -11
- package/lib/types.d.ts +1 -40
- package/package.json +4 -4
package/lib/dataplane.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { Config } from "./index.js";
|
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/dataplane.d.ts
|
|
4
4
|
declare const inject: string[];
|
|
5
|
-
declare function apply(ctx: Context, config
|
|
5
|
+
declare function apply(ctx: Context, config?: Config): void;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { apply, inject };
|
|
7
|
+
export { Config, apply, inject };
|
package/lib/dataplane.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { HiThinkMarketDataService, TRADING_CN_MARKET_DATA_KEY } from "./index.js";
|
|
1
|
+
import { Config, HiThinkMarketDataService, TRADING_CN_MARKET_DATA_KEY } from "./index.js";
|
|
2
2
|
//#region src/dataplane.ts
|
|
3
3
|
const inject = [];
|
|
4
|
+
/** schema 的运行时可调用形态(校验即补默认值);手工构造 ctx 不传 config 时按 schema 默认值处理。 */
|
|
5
|
+
const withDefaults = (value) => Config(value);
|
|
4
6
|
function resolveMarketDataRegistry(ctx) {
|
|
5
7
|
const candidate = ctx.get?.("tradingMarketDataRegistry", false);
|
|
6
8
|
return candidate !== void 0 ? candidate : void 0;
|
|
7
9
|
}
|
|
8
10
|
const ROUTER_PROVIDER = "hithink";
|
|
9
11
|
const MARKET = "cn";
|
|
10
|
-
function apply(ctx, config) {
|
|
12
|
+
function apply(ctx, config = withDefaults(void 0)) {
|
|
11
13
|
if (!config.enabled) return;
|
|
12
14
|
const apiKeyProvider = () => {
|
|
13
15
|
return (ctx.get?.("tradingMarketRouter", false))?.getCredential?.("hithink")?.apiKey || process.env[config.apiKeyRef];
|
|
@@ -23,4 +25,4 @@ function apply(ctx, config) {
|
|
|
23
25
|
ctx.effect(() => registry.register(MARKET, ROUTER_PROVIDER, service));
|
|
24
26
|
}
|
|
25
27
|
//#endregion
|
|
26
|
-
export { apply, inject };
|
|
28
|
+
export { Config, apply, inject };
|
|
@@ -2,6 +2,6 @@ import { Config } from "./index.js";
|
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/futures-dataplane.d.ts
|
|
4
4
|
declare const inject: string[];
|
|
5
|
-
declare function apply(ctx: Context, config
|
|
5
|
+
declare function apply(ctx: Context, config?: Config): void;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { apply, inject };
|
|
7
|
+
export { Config, apply, inject };
|
package/lib/futures-dataplane.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { Config } from "./index.js";
|
|
1
2
|
import { HiThinkFuturesMarketDataService, TRADING_FUTURES_MARKET_DATA_KEY } from "./futures.js";
|
|
2
3
|
//#region src/futures-dataplane.ts
|
|
3
4
|
const inject = [];
|
|
5
|
+
/** schema 的运行时可调用形态(校验即补默认值);手工构造 ctx 不传 config 时按 schema 默认值处理。 */
|
|
6
|
+
const withDefaults = (value) => Config(value);
|
|
4
7
|
function resolveMarketDataRegistry(ctx) {
|
|
5
8
|
const candidate = ctx.get?.("tradingMarketDataRegistry", false);
|
|
6
9
|
return candidate !== void 0 ? candidate : void 0;
|
|
7
10
|
}
|
|
8
11
|
const ROUTER_PROVIDER = "hithink";
|
|
9
12
|
const MARKET = "futures";
|
|
10
|
-
function apply(ctx, config) {
|
|
13
|
+
function apply(ctx, config = withDefaults(void 0)) {
|
|
11
14
|
if (!config.enabled) return;
|
|
12
15
|
const apiKeyProvider = () => {
|
|
13
16
|
return (ctx.get?.("tradingMarketRouter", false))?.getCredential?.("hithink")?.apiKey || process.env[config.apiKeyRef];
|
|
@@ -23,4 +26,4 @@ function apply(ctx, config) {
|
|
|
23
26
|
ctx.effect(() => registry.register(MARKET, ROUTER_PROVIDER, service));
|
|
24
27
|
}
|
|
25
28
|
//#endregion
|
|
26
|
-
export { apply, inject };
|
|
29
|
+
export { Config, apply, inject };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData,
|
|
1
|
+
import { HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData, HiThinkLimitUpItem, HiThinkLimitUpPoolData, HiThinkMetaTickerData, HiThinkMetaTickerItem, HiThinkPriceBarItem, HiThinkPriceSnapshotData, HiThinkPriceSnapshotItem, HiThinkValuationData, HiThinkValuationItem } from "./types.js";
|
|
2
2
|
import { HiThinkRestClient, HiThinkRestOptions, TradingServiceError, normalizeThsCode } from "./rest.js";
|
|
3
3
|
import { aggregateDailyKlines, aggregateMinutePoints, dailyBarToKline, shanghaiDateKey } from "./kline.js";
|
|
4
4
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
@@ -29,15 +29,10 @@ declare class HiThinkMarketDataService extends Service implements MarketDataServ
|
|
|
29
29
|
page?: number;
|
|
30
30
|
size?: number;
|
|
31
31
|
}): Promise<LimitUpPoolItem[]>;
|
|
32
|
-
getLimitUpLadder(): Promise<HiThinkLadderData>;
|
|
33
|
-
searchTickers(query: string): Promise<{
|
|
34
|
-
symbol: string;
|
|
35
|
-
name: string;
|
|
36
|
-
}[]>;
|
|
37
32
|
subscribeTicker(symbol: string, cb: (ticker: Ticker) => void, options?: {
|
|
38
33
|
intervalMs?: number;
|
|
39
34
|
}): Disposable;
|
|
40
35
|
}
|
|
41
36
|
declare function apply(ctx: Context, config: Config): void;
|
|
42
37
|
//#endregion
|
|
43
|
-
export { Config, HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData,
|
|
38
|
+
export { Config, HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData, HiThinkLimitUpItem, HiThinkLimitUpPoolData, HiThinkMarketDataService, HiThinkMetaTickerData, HiThinkMetaTickerItem, HiThinkPriceBarItem, HiThinkPriceSnapshotData, HiThinkPriceSnapshotItem, HiThinkRestClient, HiThinkRestOptions, HiThinkValuationData, HiThinkValuationItem, TRADING_CN_MARKET_DATA_KEY, TradingServiceError, aggregateDailyKlines, aggregateMinutePoints, apply, dailyBarToKline, name, normalizeThsCode, shanghaiDateKey };
|
package/lib/index.js
CHANGED
|
@@ -39,12 +39,6 @@ var HiThinkMarketDataService = class extends Service {
|
|
|
39
39
|
async getLimitUpPool(options) {
|
|
40
40
|
return this.client.getLimitUpPool(options);
|
|
41
41
|
}
|
|
42
|
-
async getLimitUpLadder() {
|
|
43
|
-
return this.client.getLimitUpLadder();
|
|
44
|
-
}
|
|
45
|
-
async searchTickers(query) {
|
|
46
|
-
return this.client.searchTickers(query);
|
|
47
|
-
}
|
|
48
42
|
subscribeTicker(symbol, cb, options) {
|
|
49
43
|
const ms = Math.max(options?.intervalMs ?? 5e3, 1e3);
|
|
50
44
|
const tick = () => {
|
package/lib/rest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HiThinkFuturesDailyData, HiThinkFuturesIntradayData, HiThinkHistoricalData,
|
|
1
|
+
import { HiThinkFuturesDailyData, HiThinkFuturesIntradayData, HiThinkHistoricalData, HiThinkMetaTickerData, HiThinkValuationData } from "./types.js";
|
|
2
2
|
import { AuctionSnapshot, LimitUpPoolItem, StockFundamentals, Ticker, TradingErrorCode } from "@dshtrading/api";
|
|
3
3
|
//#region src/rest.d.ts
|
|
4
4
|
declare class TradingServiceError extends Error {
|
|
@@ -36,15 +36,8 @@ declare class HiThinkRestClient {
|
|
|
36
36
|
page?: number;
|
|
37
37
|
size?: number;
|
|
38
38
|
}): Promise<LimitUpPoolItem[]>;
|
|
39
|
-
/** 获取连板天梯数据。 */
|
|
40
|
-
getLimitUpLadder(): Promise<HiThinkLadderData>;
|
|
41
39
|
/** 获取集合竞价快照与强弱基准。 */
|
|
42
40
|
getAuctionSnapshot(symbol: string): Promise<AuctionSnapshot | undefined>;
|
|
43
|
-
/** 模糊搜索股票代码与全称(消歧)。 */
|
|
44
|
-
searchTickers(keyword: string): Promise<Array<{
|
|
45
|
-
symbol: string;
|
|
46
|
-
name: string;
|
|
47
|
-
}>>;
|
|
48
41
|
/**
|
|
49
42
|
* A 股历史日K(上游仅开放 1d,start/end 毫秒必填,窗口最长 10 年)。
|
|
50
43
|
* 以 end=now 反推覆盖窗口取数后截尾最近 limit 根(升序)。
|
package/lib/rest.js
CHANGED
|
@@ -125,10 +125,6 @@ var HiThinkRestClient = class {
|
|
|
125
125
|
...item.limit_up_reason !== void 0 ? { sectorConcept: item.limit_up_reason } : {}
|
|
126
126
|
}));
|
|
127
127
|
}
|
|
128
|
-
/** 获取连板天梯数据。 */
|
|
129
|
-
async getLimitUpLadder() {
|
|
130
|
-
return this.request("/api/a-share/special-data/limit-up-ladder");
|
|
131
|
-
}
|
|
132
128
|
/** 获取集合竞价快照与强弱基准。 */
|
|
133
129
|
async getAuctionSnapshot(symbol) {
|
|
134
130
|
const thscode = normalizeThsCode(symbol);
|
|
@@ -148,13 +144,6 @@ var HiThinkRestClient = class {
|
|
|
148
144
|
timestamp: data?.timestamp ?? Date.now()
|
|
149
145
|
};
|
|
150
146
|
}
|
|
151
|
-
/** 模糊搜索股票代码与全称(消歧)。 */
|
|
152
|
-
async searchTickers(keyword) {
|
|
153
|
-
return ((await this.request("/api/a-share/instruments/search", { keyword: keyword.trim() }))?.item ?? []).map((item) => ({
|
|
154
|
-
symbol: item.thscode,
|
|
155
|
-
name: item.name
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
147
|
/**
|
|
159
148
|
* A 股历史日K(上游仅开放 1d,start/end 毫秒必填,窗口最长 10 年)。
|
|
160
149
|
* 以 end=now 反推覆盖窗口取数后截尾最近 limit 根(升序)。
|
package/lib/types.d.ts
CHANGED
|
@@ -66,34 +66,6 @@ interface HiThinkLimitUpPoolData {
|
|
|
66
66
|
};
|
|
67
67
|
item: HiThinkLimitUpItem[];
|
|
68
68
|
}
|
|
69
|
-
interface HiThinkLadderBoardItem {
|
|
70
|
-
thscode: string;
|
|
71
|
-
ticker: string;
|
|
72
|
-
name: string;
|
|
73
|
-
board_num: number;
|
|
74
|
-
sign_level?: string;
|
|
75
|
-
seal_nextday?: string | null;
|
|
76
|
-
}
|
|
77
|
-
interface HiThinkLadderDayItem {
|
|
78
|
-
date: string;
|
|
79
|
-
boards: {
|
|
80
|
-
two_board?: HiThinkLadderBoardItem[];
|
|
81
|
-
three_board?: HiThinkLadderBoardItem[];
|
|
82
|
-
four_board?: HiThinkLadderBoardItem[];
|
|
83
|
-
five_board?: HiThinkLadderBoardItem[];
|
|
84
|
-
six_board?: HiThinkLadderBoardItem[];
|
|
85
|
-
seven_over?: HiThinkLadderBoardItem[];
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
interface HiThinkLadderData {
|
|
89
|
-
timestamp: number;
|
|
90
|
-
window?: {
|
|
91
|
-
length: number;
|
|
92
|
-
date_list: string[];
|
|
93
|
-
board_caps: Record<string, number>;
|
|
94
|
-
};
|
|
95
|
-
item: HiThinkLadderDayItem[];
|
|
96
|
-
}
|
|
97
69
|
interface HiThinkAuctionItem {
|
|
98
70
|
thscode: string;
|
|
99
71
|
ticker: string;
|
|
@@ -108,17 +80,6 @@ interface HiThinkAuctionData {
|
|
|
108
80
|
timestamp: number | null;
|
|
109
81
|
item: HiThinkAuctionItem[];
|
|
110
82
|
}
|
|
111
|
-
interface HiThinkTickerSearchItem {
|
|
112
|
-
thscode: string;
|
|
113
|
-
ticker: string;
|
|
114
|
-
name: string;
|
|
115
|
-
asset_type?: string;
|
|
116
|
-
exchange?: string;
|
|
117
|
-
}
|
|
118
|
-
interface HiThinkTickerSearchData {
|
|
119
|
-
total: number;
|
|
120
|
-
item: HiThinkTickerSearchItem[];
|
|
121
|
-
}
|
|
122
83
|
/** A 股历史日K条目(/api/a-share/prices/historical,date_ms 为东八区交易日零点)。 */
|
|
123
84
|
interface HiThinkPriceBarItem {
|
|
124
85
|
date_ms?: number | null;
|
|
@@ -181,4 +142,4 @@ interface HiThinkMetaTickerData {
|
|
|
181
142
|
item: HiThinkMetaTickerItem[];
|
|
182
143
|
}
|
|
183
144
|
//#endregion
|
|
184
|
-
export { HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData,
|
|
145
|
+
export { HiThinkAuctionData, HiThinkAuctionItem, HiThinkEnvelope, HiThinkFuturesDailyData, HiThinkFuturesDailyItem, HiThinkFuturesIntradayData, HiThinkFuturesIntradayItem, HiThinkHistoricalData, HiThinkLimitUpItem, HiThinkLimitUpPoolData, HiThinkMetaTickerData, HiThinkMetaTickerItem, HiThinkPriceBarItem, HiThinkPriceSnapshotData, HiThinkPriceSnapshotItem, HiThinkValuationData, HiThinkValuationItem };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/connector-hithink",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.6.
|
|
3
|
+
"description": "同花顺(问财)OpenAPI A 股与期货数据连接器(BYOK,凭证 ref 为 HITHINK_FINANCE_API_KEY):实现 tradingCnMarketData 与 tradingFuturesMarketData 行情服务(ticker / K 线 / 基本面 / 集合竞价 / 连板池);仅数据面,无交易通道、不注册工具。",
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
],
|
|
34
34
|
"license": "PolyForm-Noncommercial-1.0.0",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dshtrading/api": "^0.6.
|
|
36
|
+
"@dshtrading/api": "^0.6.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/cordis": ">=4.0.0",
|
|
40
|
-
"@deepseek-ai/dsh-tools": ">=0.2.
|
|
40
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.2",
|
|
41
41
|
"@deepseek-ai/schemastery": ">=3.18.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|