@v587d/capital-generation 2.24.0 → 2.25.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/CHANGELOG.md +21 -0
- package/README.md +9 -4
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/client.js +21 -5
- package/config/client.src.cjs +264 -0
- package/config/package.json +1 -1
- package/cordis.patch.yml +9 -2
- package/lib/agents/role-tool-policy.d.ts +1 -1
- package/lib/agents/root-tool-policy.d.ts +3 -3
- package/lib/agents/root-tool-policy.js +2 -2
- package/lib/data-collector/catalog-taxonomy.js +4 -0
- package/lib/python-runtime/child-env.d.ts +11 -0
- package/lib/python-runtime/child-env.js +39 -0
- package/lib/python-runtime/errors.d.ts +8 -0
- package/lib/python-runtime/errors.js +34 -0
- package/lib/python-runtime/lock.d.ts +11 -0
- package/lib/python-runtime/lock.js +68 -0
- package/lib/python-runtime/manager.d.ts +61 -0
- package/lib/python-runtime/manager.js +517 -0
- package/lib/python-runtime/manifest.d.ts +5 -0
- package/lib/python-runtime/manifest.js +160 -0
- package/lib/python-runtime/paths.d.ts +20 -0
- package/lib/python-runtime/paths.js +156 -0
- package/lib/python-runtime/platform.d.ts +32 -0
- package/lib/python-runtime/platform.js +145 -0
- package/lib/python-runtime/pnpm.d.ts +24 -0
- package/lib/python-runtime/pnpm.js +115 -0
- package/lib/python-runtime/probe.d.ts +13 -0
- package/lib/python-runtime/probe.js +101 -0
- package/lib/python-runtime/routes.d.ts +6 -0
- package/lib/python-runtime/routes.js +152 -0
- package/lib/python-runtime/types.d.ts +105 -0
- package/lib/python-runtime/types.js +3 -0
- package/lib/python-runtime-entry.d.ts +10 -0
- package/lib/python-runtime-entry.js +60 -0
- package/lib/sources/eastmoney-http.js +346 -1
- package/lib/sources/tencent-http.js +248 -2
- package/lib/sources/tencent-public-core.js +1 -1
- package/lib/sources-entry.d.ts +1 -1
- package/lib/time/tools.js +2 -0
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/sources.d.ts +16 -1
- package/lib/web-retriever/sources.js +133 -1
- package/lib/web-retriever/tools.js +41 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +13 -1
- package/plugin-page/README.en.md +1 -7
- package/plugin-page/README.zh.md +1 -8
- package/preset/capital-generation/agent.patch.yml +12 -13
- package/preset/capital-generation/skills/capital-web-protocol/SKILL.md +10 -4
- package/python/worker.py +154 -0
- package/runtime/manifest.json +75 -0
- package/scripts/python-runtime.mjs +139 -0
- package/watchlist/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { getDataTimeContract } from '../time/tools.js';
|
|
|
3
3
|
import { isLikelyIndex, normalizeSecurityCodes, parseSecurityCode, requireTencentSecurity } from './security-code.js';
|
|
4
4
|
// Shared core holds HK/US snapshots, smartbox and the one throttle chain; this file only defines
|
|
5
5
|
// capabilities and K-line/tick orchestration. Two throttles = no throttle.
|
|
6
|
-
import { QUOTE_URL, aShareQuoteTime, fetchOffshoreIndexQuotes, fetchOffshoreQuotes, isRecord, normalizeHkCode, normalizeOffshoreIndexCode, normalizeUsCode, numberOrNull, requiredNumber, resolveUsKlineSymbol, sourceError, tencentGetText as getText, } from './tencent-public-core.js';
|
|
6
|
+
import { QUOTE_URL, aShareQuoteTime, fetchOffshoreIndexQuotes, fetchOffshoreQuotes, isRecord, normalizeHkCode, normalizeOffshoreIndexCode, normalizeUsCode, numberOrNull, offshoreQuoteTime, requiredNumber, resolveUsKlineSymbol, sourceError, US_QUOTE_FIELDS, tencentGetText as getText, } from './tencent-public-core.js';
|
|
7
7
|
const TICK_URL = 'https://stock.gtimg.cn/data/index.php';
|
|
8
8
|
const KLINE_HOSTS = [
|
|
9
9
|
'https://web.ifzq.gtimg.cn',
|
|
@@ -590,6 +590,238 @@ async function executeOffshoreKline(params, signal, market) {
|
|
|
590
590
|
const items = await callOffshoreKline(path, param, tencentSymbol, signal);
|
|
591
591
|
return { data: parseOffshoreKlineRows(items, canonical, tencentSymbol, period, adjust, market), schema: market === 'hk' ? hkKlineOutput : usKlineOutput };
|
|
592
592
|
}
|
|
593
|
+
const US_PREPOST_MAX_CODES = 20;
|
|
594
|
+
/** The K-line endpoint only attaches `pandata` when a recent bar is requested; 10 is a stable floor. */
|
|
595
|
+
const US_PREPOST_BARS = 10;
|
|
596
|
+
function normalizeUsPrepostCodes(params) {
|
|
597
|
+
if (!isRecord(params))
|
|
598
|
+
throw new Error('params must be an object');
|
|
599
|
+
assertKnown(params, ['codes']);
|
|
600
|
+
const rawValues = Array.isArray(params.codes)
|
|
601
|
+
? params.codes
|
|
602
|
+
: typeof params.codes === 'string'
|
|
603
|
+
? params.codes.split(',').map((item) => item.trim()).filter(Boolean)
|
|
604
|
+
: undefined;
|
|
605
|
+
if (!rawValues || rawValues.length === 0)
|
|
606
|
+
throw new Error('parameter codes must contain at least one US ticker');
|
|
607
|
+
if (rawValues.length > US_PREPOST_MAX_CODES)
|
|
608
|
+
throw new Error(`parameter codes accepts at most ${US_PREPOST_MAX_CODES} tickers`);
|
|
609
|
+
const codes = [];
|
|
610
|
+
for (const item of rawValues) {
|
|
611
|
+
const code = normalizeUsCode(item, 'codes');
|
|
612
|
+
if (!codes.includes(code))
|
|
613
|
+
codes.push(code);
|
|
614
|
+
}
|
|
615
|
+
return { codes };
|
|
616
|
+
}
|
|
617
|
+
function textOrNull(value) {
|
|
618
|
+
if (value === undefined || value === null)
|
|
619
|
+
return null;
|
|
620
|
+
const text = String(value).trim();
|
|
621
|
+
return text.length === 0 ? null : text;
|
|
622
|
+
}
|
|
623
|
+
function roundPrice(value) {
|
|
624
|
+
return Number(value.toFixed(4));
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Exchange wall clock -> UTC. `pandata.time` is ET but `season` is only a display label
|
|
628
|
+
* (`EST` even when DST is in force elsewhere); resolve DST through Intl instead of trusting it.
|
|
629
|
+
*/
|
|
630
|
+
function exchangeTimeToUtcMs(local) {
|
|
631
|
+
const match = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/.exec(local);
|
|
632
|
+
if (match === null)
|
|
633
|
+
return null;
|
|
634
|
+
const [year, month, day, hour, minute, second] = match.slice(1).map(Number);
|
|
635
|
+
const target = Date.UTC(year, month - 1, day, hour, minute, second);
|
|
636
|
+
if (!Number.isFinite(target))
|
|
637
|
+
return null;
|
|
638
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
639
|
+
timeZone: 'America/New_York',
|
|
640
|
+
year: 'numeric', month: '2-digit', day: '2-digit',
|
|
641
|
+
hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23',
|
|
642
|
+
});
|
|
643
|
+
let guess = target;
|
|
644
|
+
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
645
|
+
const parts = Object.fromEntries(formatter.formatToParts(new Date(guess)).map((part) => [part.type, part.value]));
|
|
646
|
+
const rendered = Date.UTC(Number(parts.year), Number(parts.month) - 1, Number(parts.day), Number(parts.hour), Number(parts.minute), Number(parts.second));
|
|
647
|
+
const delta = target - rendered;
|
|
648
|
+
if (delta === 0)
|
|
649
|
+
return guess;
|
|
650
|
+
guess += delta;
|
|
651
|
+
}
|
|
652
|
+
return guess;
|
|
653
|
+
}
|
|
654
|
+
function emptyUsPrepostRow(code, reason) {
|
|
655
|
+
return {
|
|
656
|
+
code,
|
|
657
|
+
tencent_symbol: null,
|
|
658
|
+
name: null,
|
|
659
|
+
currency: null,
|
|
660
|
+
session: null,
|
|
661
|
+
price: null,
|
|
662
|
+
prev_close: null,
|
|
663
|
+
change_amt: null,
|
|
664
|
+
change_pct: null,
|
|
665
|
+
volume_shares: null,
|
|
666
|
+
session_time: null,
|
|
667
|
+
session_time_zone: null,
|
|
668
|
+
exchange_time_zone: null,
|
|
669
|
+
quote_time_utc: null,
|
|
670
|
+
regular_price: null,
|
|
671
|
+
regular_prev_close: null,
|
|
672
|
+
regular_quote_time: null,
|
|
673
|
+
delay: false,
|
|
674
|
+
available: false,
|
|
675
|
+
reason,
|
|
676
|
+
source: 'tencent',
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function parseUsPrepostRow(data, symbol, requested) {
|
|
680
|
+
const node = data[symbol];
|
|
681
|
+
if (!isRecord(node))
|
|
682
|
+
throw sourceError(`Tencent pre/post ${symbol} response has no symbol node`, 'tencent_invalid_response');
|
|
683
|
+
const qt = node.qt;
|
|
684
|
+
if (!isRecord(qt))
|
|
685
|
+
throw sourceError(`Tencent pre/post ${symbol} response has no qt node`, 'tencent_invalid_response');
|
|
686
|
+
const fields = qt[symbol];
|
|
687
|
+
if (!Array.isArray(fields) || fields.length < US_QUOTE_FIELDS) {
|
|
688
|
+
throw sourceError(`Tencent pre/post ${symbol} quote row changed (${Array.isArray(fields) ? fields.length : 'non-array'} fields)`, 'tencent_invalid_response');
|
|
689
|
+
}
|
|
690
|
+
const regularQuoteTime = offshoreQuoteTime(fields[30]);
|
|
691
|
+
if (regularQuoteTime === null)
|
|
692
|
+
throw sourceError(`Tencent pre/post ${symbol} has an unreadable regular timestamp`, 'tencent_invalid_response');
|
|
693
|
+
const code = textOrNull(fields[2]) ?? requested;
|
|
694
|
+
const base = {
|
|
695
|
+
code,
|
|
696
|
+
tencent_symbol: symbol,
|
|
697
|
+
name: textOrNull(fields[1]),
|
|
698
|
+
currency: textOrNull(fields[35]),
|
|
699
|
+
regular_price: numberOrNull(fields[3]),
|
|
700
|
+
regular_prev_close: numberOrNull(fields[4]),
|
|
701
|
+
regular_quote_time: regularQuoteTime,
|
|
702
|
+
delay: fields[0] === 'delay',
|
|
703
|
+
source: 'tencent',
|
|
704
|
+
};
|
|
705
|
+
const pandata = node.pandata;
|
|
706
|
+
if (pandata !== undefined && pandata !== null && !isRecord(pandata)) {
|
|
707
|
+
throw sourceError(`Tencent pre/post ${symbol} pandata is ${typeof pandata}, expected an object`, 'tencent_invalid_response');
|
|
708
|
+
}
|
|
709
|
+
if (!isRecord(pandata)) {
|
|
710
|
+
return {
|
|
711
|
+
...base,
|
|
712
|
+
session: null,
|
|
713
|
+
price: null,
|
|
714
|
+
prev_close: null,
|
|
715
|
+
change_amt: null,
|
|
716
|
+
change_pct: null,
|
|
717
|
+
volume_shares: null,
|
|
718
|
+
session_time: null,
|
|
719
|
+
session_time_zone: null,
|
|
720
|
+
exchange_time_zone: null,
|
|
721
|
+
quote_time_utc: null,
|
|
722
|
+
available: false,
|
|
723
|
+
reason: 'no_extended_session',
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
const tag = textOrNull(pandata.tag)?.toLowerCase();
|
|
727
|
+
if (tag !== 'pre' && tag !== 'after') {
|
|
728
|
+
throw sourceError(`Tencent pre/post ${symbol} returned an unknown session tag ${JSON.stringify(pandata.tag ?? null)}`, 'tencent_invalid_response');
|
|
729
|
+
}
|
|
730
|
+
const sessionTime = textOrNull(pandata.time);
|
|
731
|
+
if (sessionTime === null)
|
|
732
|
+
throw sourceError(`Tencent pre/post ${symbol} has an empty session time`, 'tencent_invalid_response');
|
|
733
|
+
const utcMs = exchangeTimeToUtcMs(sessionTime);
|
|
734
|
+
if (utcMs === null)
|
|
735
|
+
throw sourceError(`Tencent pre/post ${symbol} has an unreadable session time ${JSON.stringify(sessionTime)}`, 'tencent_invalid_response');
|
|
736
|
+
const last = numberOrNull(pandata.last);
|
|
737
|
+
if (last !== null && last <= 0)
|
|
738
|
+
throw sourceError(`Tencent pre/post ${symbol} returned a non-positive price`, 'tencent_invalid_response');
|
|
739
|
+
const netChange = numberOrNull(pandata.netchange);
|
|
740
|
+
const pct = numberOrNull(pandata.pct);
|
|
741
|
+
const volume = numberOrNull(pandata.volume);
|
|
742
|
+
if (volume !== null && (!Number.isSafeInteger(volume) || volume < 0)) {
|
|
743
|
+
throw sourceError(`Tencent pre/post ${symbol} returned an invalid volume ${JSON.stringify(pandata.volume)}`, 'tencent_invalid_response');
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
...base,
|
|
747
|
+
session: tag,
|
|
748
|
+
price: last,
|
|
749
|
+
// `netchange` is quoted against the regular-session close, not necessarily yesterday's close.
|
|
750
|
+
prev_close: last !== null && netChange !== null ? roundPrice(last - netChange) : null,
|
|
751
|
+
change_amt: netChange,
|
|
752
|
+
change_pct: pct,
|
|
753
|
+
volume_shares: volume,
|
|
754
|
+
session_time: sessionTime,
|
|
755
|
+
session_time_zone: textOrNull(pandata.season),
|
|
756
|
+
exchange_time_zone: 'America/New_York',
|
|
757
|
+
quote_time_utc: new Date(utcMs).toISOString(),
|
|
758
|
+
available: last !== null,
|
|
759
|
+
reason: last === null ? 'empty_extended_price' : null,
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
async function fetchUsPrepostRow(ticker, signal) {
|
|
763
|
+
const symbol = await resolveUsKlineSymbol(ticker, signal);
|
|
764
|
+
const data = await callKlineHosts({
|
|
765
|
+
path: '/appstock/app/usfqkline/get',
|
|
766
|
+
param: `${symbol},day,,,${US_PREPOST_BARS},qfq`,
|
|
767
|
+
label: `${symbol} pre/post`,
|
|
768
|
+
isEmpty: (payload) => {
|
|
769
|
+
const node = payload[symbol];
|
|
770
|
+
return !isRecord(node) || !isRecord(node.qt);
|
|
771
|
+
},
|
|
772
|
+
isParamRejection: (payload) => /param/i.test(String(payload.msg ?? '')) || Number(payload.code) === 1 || Number(payload.code) === 11,
|
|
773
|
+
}, signal);
|
|
774
|
+
return parseUsPrepostRow(data, symbol, ticker);
|
|
775
|
+
}
|
|
776
|
+
async function executeUsPrepost(params, signal) {
|
|
777
|
+
const rows = [];
|
|
778
|
+
for (const ticker of params.codes) {
|
|
779
|
+
try {
|
|
780
|
+
rows.push(await fetchUsPrepostRow(ticker, signal));
|
|
781
|
+
}
|
|
782
|
+
catch (error) {
|
|
783
|
+
// An unknown ticker is one bad row, not a broken batch; transport/shape errors still fail loudly.
|
|
784
|
+
if (error.code === 'tencent_unknown_ticker') {
|
|
785
|
+
rows.push(emptyUsPrepostRow(ticker, 'ticker_not_found'));
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
throw error;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
if (rows.length === 0)
|
|
792
|
+
throw sourceError('Tencent pre/post returned no rows', 'tencent_empty_response');
|
|
793
|
+
return { data: rows, schema: usPrepostOutput };
|
|
794
|
+
}
|
|
795
|
+
const usPrepostOutput = {
|
|
796
|
+
type: 'array',
|
|
797
|
+
items: {
|
|
798
|
+
type: 'object',
|
|
799
|
+
properties: {
|
|
800
|
+
code: { type: 'string' },
|
|
801
|
+
tencent_symbol: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
802
|
+
name: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
803
|
+
currency: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
804
|
+
session: { oneOf: [{ enum: ['pre', 'after'] }, { type: 'null' }] },
|
|
805
|
+
price: { oneOf: [{ type: 'number' }, { type: 'null' }] },
|
|
806
|
+
prev_close: { oneOf: [{ type: 'number' }, { type: 'null' }], description: '盘前/盘后的涨跌基准(last − netchange),盘后时是当日正规收盘,不等于昨收' },
|
|
807
|
+
change_amt: { oneOf: [{ type: 'number' }, { type: 'null' }] },
|
|
808
|
+
change_pct: { oneOf: [{ type: 'number' }, { type: 'null' }], description: '百分数原值(-0.24 表示 -0.24%)' },
|
|
809
|
+
volume_shares: { oneOf: [{ type: 'number' }, { type: 'null' }], description: '延长时段成交量(股)' },
|
|
810
|
+
session_time: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '延长时段最后成交时间(美东当地时间)' },
|
|
811
|
+
session_time_zone: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '上游 season 原值(EST/EDT),只作展示;换算用 exchange_time_zone' },
|
|
812
|
+
exchange_time_zone: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
813
|
+
quote_time_utc: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '由美东墙钟换算的 UTC ISO 时刻' },
|
|
814
|
+
regular_price: { oneOf: [{ type: 'number' }, { type: 'null' }], description: '最近正规时段成交价,用于对照' },
|
|
815
|
+
regular_prev_close: { oneOf: [{ type: 'number' }, { type: 'null' }] },
|
|
816
|
+
regular_quote_time: { oneOf: [{ type: 'string' }, { type: 'null' }], description: '正规时段最后成交时间(美东当地时间)' },
|
|
817
|
+
delay: { type: 'boolean' },
|
|
818
|
+
available: { type: 'boolean', description: '是否有延长时段成交;false 时 price 为 null,不补 0' },
|
|
819
|
+
reason: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
820
|
+
source: { type: 'string' },
|
|
821
|
+
},
|
|
822
|
+
additionalProperties: true,
|
|
823
|
+
},
|
|
824
|
+
};
|
|
593
825
|
const hkQuoteOutput = {
|
|
594
826
|
type: 'array',
|
|
595
827
|
items: {
|
|
@@ -793,7 +1025,7 @@ export function createTencentSources() {
|
|
|
793
1025
|
cacheMaxAgeMs: 60_000,
|
|
794
1026
|
name: 'get_tencent_us_quote',
|
|
795
1027
|
summary: '腾讯美股快照(美元,交易所当地时间)',
|
|
796
|
-
description: '批量获取美股与在美上市 ADR 的腾讯快照(一次最多 50 只)。代码是字母 ticker(BRK.B 这类带点的级别码可用)。⛔ 写法上有两点是实测出来的:腾讯**快照只认不带交易所后缀的形式**(`usBABA.N` 整行不回、`usBABA` 回),所以两位以上的尾段(.OQ/.AM/.NS)在参数层直接剥掉;**单字母尾段分不清是级别码还是交易所码**(BRK.B 与 BABA.N 都是真实写法),就照原样先问一次、没回行再剥一段重问——猜错只多一轮请求,猜错第二次才是把数据挂到别的标的上。currency 回 USD,price / amount_usd 是**美元(元级)**,float_market_cap_yi_usd 与 market_cap_yi_usd 是**亿美元**(实测两列分别等于流通股本 / 总股本 × 现价 ÷ 1e8:苹果 14,585,108,878 → 48,669.05、14,594,180,000 → 48,699.32)。code 回上游给的带后缀身份(AAPL.OQ / BABA.N),exchange_code 单列后缀(实测只出现 OQ 与 N,是腾讯自有交易所编码,本表不翻译)。⛔ **这不是实时撮合价**:实测 2026-10-05(周一)北京清早取到的最新成交时间是 2026-10-02 16:00:01,收盘后不给新数;腾讯在 K 线响应内嵌的行情节点 0 号位标 `delay`。quote_time 是**交易所当地时间(美东)**,与北京时间差 12/13 小时,跨市场同日比较前先对齐。turnover_pct 的分母是**总股本**(实测 GOOGL 给 0.19 = 23,772,148 ÷ 12,229,934,831,BRK.B 给 0.20 = 4,193,461 ÷ 2,140,709,794;按流通股本算是 0.41 与 0.34,对不上——多级股票类别下两个分母能差一倍,苹果与阿里因为两者接近所以看不出区别)。avg_price = amount_usd ÷ volume_shares(实测 11,087,245,013 / 33,278,552 = 333.16 相符)。美股无涨跌停,不提供相关列。52 周高低两列口径与日线序列对不上(实测苹果 345.34/242.76,近 252 个交易日是 345.34/243.42),**不收录**;PE/PB 一类列因口径未核验同样不收录。盘前盘后行情本表不透出(实测只出现在 K 线响应的 pandata
|
|
1028
|
+
description: '批量获取美股与在美上市 ADR 的腾讯快照(一次最多 50 只)。代码是字母 ticker(BRK.B 这类带点的级别码可用)。⛔ 写法上有两点是实测出来的:腾讯**快照只认不带交易所后缀的形式**(`usBABA.N` 整行不回、`usBABA` 回),所以两位以上的尾段(.OQ/.AM/.NS)在参数层直接剥掉;**单字母尾段分不清是级别码还是交易所码**(BRK.B 与 BABA.N 都是真实写法),就照原样先问一次、没回行再剥一段重问——猜错只多一轮请求,猜错第二次才是把数据挂到别的标的上。currency 回 USD,price / amount_usd 是**美元(元级)**,float_market_cap_yi_usd 与 market_cap_yi_usd 是**亿美元**(实测两列分别等于流通股本 / 总股本 × 现价 ÷ 1e8:苹果 14,585,108,878 → 48,669.05、14,594,180,000 → 48,699.32)。code 回上游给的带后缀身份(AAPL.OQ / BABA.N),exchange_code 单列后缀(实测只出现 OQ 与 N,是腾讯自有交易所编码,本表不翻译)。⛔ **这不是实时撮合价**:实测 2026-10-05(周一)北京清早取到的最新成交时间是 2026-10-02 16:00:01,收盘后不给新数;腾讯在 K 线响应内嵌的行情节点 0 号位标 `delay`。quote_time 是**交易所当地时间(美东)**,与北京时间差 12/13 小时,跨市场同日比较前先对齐。turnover_pct 的分母是**总股本**(实测 GOOGL 给 0.19 = 23,772,148 ÷ 12,229,934,831,BRK.B 给 0.20 = 4,193,461 ÷ 2,140,709,794;按流通股本算是 0.41 与 0.34,对不上——多级股票类别下两个分母能差一倍,苹果与阿里因为两者接近所以看不出区别)。avg_price = amount_usd ÷ volume_shares(实测 11,087,245,013 / 33,278,552 = 333.16 相符)。美股无涨跌停,不提供相关列。52 周高低两列口径与日线序列对不上(实测苹果 345.34/242.76,近 252 个交易日是 345.34/243.42),**不收录**;PE/PB 一类列因口径未核验同样不收录。盘前盘后行情本表不透出(实测只出现在 K 线响应的 pandata 节点);需要延长时段请用 `tencent_us_prepost_quote`。不认识的 ticker 被上游静默丢弃,行数少于请求数即那几个代码无效。成交额为 0 且现价等于昨收时标 is_stale=true。',
|
|
797
1029
|
inputSchema: { type: 'object', properties: { codes: { type: 'array', minItems: 1, maxItems: 50, items: { type: 'string', description: '美股 ticker,如 AAPL 或 BRK.B' } } }, required: ['codes'], additionalProperties: false },
|
|
798
1030
|
outputSchema: usQuoteOutput,
|
|
799
1031
|
paginated: false,
|
|
@@ -858,5 +1090,19 @@ export function createTencentSources() {
|
|
|
858
1090
|
normalize: (params) => normalizeOffshoreKline(params, 'us'),
|
|
859
1091
|
execute: (params, signal) => executeOffshoreKline(params, signal, 'us'),
|
|
860
1092
|
}),
|
|
1093
|
+
createSource({
|
|
1094
|
+
capability: 'tencent_us_prepost_quote',
|
|
1095
|
+
cacheMaxAgeMs: 30_000,
|
|
1096
|
+
name: 'get_tencent_us_prepost_quote',
|
|
1097
|
+
summary: '腾讯美股盘前/盘后最近成交(美东时间,含延迟标记)',
|
|
1098
|
+
description: '批量获取美股/ETF/ADR 的**盘前或盘后最近一笔成交**(一次最多 20 只;数据来自腾讯美股 K 线响应内嵌的 `pandata` 节点,普通的 `tencent_us_quote` 快照不透出延长时段)。返回 `session`(实测为 `pre` / `after`)、`price`、`change_amt`、`change_pct`、`volume_shares`、`session_time`(美东墙钟)与 `quote_time_utc`。⛔ **`prev_close` 不是昨收**:它是 `last − netchange` 得到的涨跌基准,盘后时等于当日正规收盘;昨收另在 `regular_prev_close`,正规时段最后价在 `regular_price`。⛔ **只保留最近一段延长时段**:上游一次只给一个 `pandata`,不能同时承诺盘前和盘后;没有延长成交(例如盘中)时返回 `available=false` + `reason=no_extended_session`,**不拿正规时段价格冒充**。⛔ 没有 high/low、没有盘前盘后成交量以外的明细;`pct` 是百分数原值(-0.24 表示 -0.24%),不是比例。`delay` 直接取腾讯快照第 0 位(`delay`),免费公开源**不承诺实时**。未知 ticker 返回单行 `available=false` + `reason=ticker_not_found`,不静默丢行;网络/形状错误仍整批失败。交易所后缀先由快照解析,再打 K 线,`tencent_symbol` 回显解析结果。',
|
|
1099
|
+
inputSchema: { type: 'object', properties: { codes: { type: 'array', minItems: 1, maxItems: 20, items: { type: 'string', description: '美股 ticker,如 AAPL、BRK.B 或 BABA.N' } } }, required: ['codes'], additionalProperties: false },
|
|
1100
|
+
outputSchema: usPrepostOutput,
|
|
1101
|
+
paginated: false,
|
|
1102
|
+
rowShape: { rootArray: true },
|
|
1103
|
+
allowed: ['codes'],
|
|
1104
|
+
normalize: normalizeUsPrepostCodes,
|
|
1105
|
+
execute: executeUsPrepost,
|
|
1106
|
+
}),
|
|
861
1107
|
];
|
|
862
1108
|
}
|
|
@@ -286,7 +286,7 @@ export async function resolveUsKlineSymbol(ticker, signal) {
|
|
|
286
286
|
throw sourceError(`Tencent returned an unreadable US code ${JSON.stringify(code)}`, 'tencent_invalid_response');
|
|
287
287
|
return `us${code}`;
|
|
288
288
|
}
|
|
289
|
-
throw
|
|
289
|
+
throw sourceError(`Tencent does not recognize US ticker ${ticker}; no spelling of it returned a snapshot to resolve an exchange`, 'tencent_unknown_ticker');
|
|
290
290
|
}
|
|
291
291
|
export function parseSmartbox(text) {
|
|
292
292
|
const match = /v_hint="([\s\S]*)"/.exec(text);
|
package/lib/sources-entry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `tools/retrieve-sources` row: the
|
|
2
|
+
* `tools/retrieve-sources` row: the twelve named-source tools, gated by
|
|
3
3
|
* `localFetch.enabled`. When disabled they stay registered and fail loudly per call;
|
|
4
4
|
* unregistering at boot would freeze one config read for the process lifetime.
|
|
5
5
|
*/
|
package/lib/time/tools.js
CHANGED
|
@@ -47,6 +47,8 @@ const DATA_TIME_CONTRACTS = {
|
|
|
47
47
|
eastmoney_mutual_flow: { kind: 'date_range', fields: ['start_date', 'end_date'] },
|
|
48
48
|
eastmoney_dividend_plan: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**除权除息日**,不是报告期' },
|
|
49
49
|
eastmoney_margin_trading: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '两融披露沪市比深市快一个交易日:跨市场同日比较前先对齐到共同日期' },
|
|
50
|
+
eastmoney_margin_total: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '市场级两融同样按交易所分别披露:深市/北交所 T+1,同一日期可能只有沪市有行,不能把不完整日期加总' },
|
|
51
|
+
eastmoney_global_kline: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '全球指数/商品/汇率的历史长度不一,早于各符号起点的日期返回空数组,不是取数失败' },
|
|
50
52
|
eastmoney_convertible_bond_list: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**起息日**(实测与网上申购日恒等),不是上市日也不是摘牌日' },
|
|
51
53
|
auction_benchmark: { kind: 'date', fields: ['date'], warning: '显式日期必须是交易日;工具不会自动回退到最近交易日' },
|
|
52
54
|
limit_up_pool: { kind: 'date_ms', fields: ['date_ms'], warning: 'date_ms 必须对应交易日;工具不会自动回退到最近交易日' },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Known limit: DNS resolves per request but the IP is not pinned to the connection,
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
|
-
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.
|
|
6
|
+
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.25.0";
|
|
7
7
|
export declare const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
8
8
|
export type LocalFetchErrorCode = 'ABORTED' | 'TIMEOUT' | 'INVALID_URL' | 'BLOCKED_URL' | 'DNS' | 'REDIRECT' | 'HTTP' | 'TOO_LARGE' | 'UNSUPPORTED_CONTENT_TYPE';
|
|
9
9
|
export declare class LocalFetchError extends Error {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
6
|
import { htmlToMarkdown, stripInvisibleText } from './html-markdown.js';
|
|
7
|
-
export const LOCAL_FETCH_CLIENT_VERSION = '2.
|
|
7
|
+
export const LOCAL_FETCH_CLIENT_VERSION = '2.25.0';
|
|
8
8
|
export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
9
9
|
export class LocalFetchError extends Error {
|
|
10
10
|
code;
|
|
@@ -7,7 +7,7 @@ import { createHttpRequester } from './local-fetch.js';
|
|
|
7
7
|
import type { EastmoneyClient, EastmoneyTransport } from '../net/eastmoney-client.js';
|
|
8
8
|
import type { LocalFetchOptions } from './local-fetch.js';
|
|
9
9
|
/** Upstream name used in error envelopes and as the `provider_tally` key. */
|
|
10
|
-
export type SourceId = 'cls' | 'wscn' | 'cninfo_irm' | 'sseinfo' | 'eastmoney' | 'ths' | 'sina';
|
|
10
|
+
export type SourceId = 'cls' | 'wscn' | 'cninfo_irm' | 'cninfo' | 'sseinfo' | 'eastmoney' | 'ths' | 'sina';
|
|
11
11
|
export declare const SOURCE_IDS: readonly SourceId[];
|
|
12
12
|
/** Per-item text cap; item count is capped separately by each tool's limit. */
|
|
13
13
|
export declare const MAX_ITEM_CHARS = 1200;
|
|
@@ -24,6 +24,8 @@ export interface SourceOutcome {
|
|
|
24
24
|
next_cursor?: string;
|
|
25
25
|
/** Record upstream scope / known gaps so an empty result is not read as fact. */
|
|
26
26
|
note?: string;
|
|
27
|
+
/** Extra envelope fields (total/page/pages/truncated) for list sources; never item data. */
|
|
28
|
+
meta?: Record<string, unknown>;
|
|
27
29
|
}
|
|
28
30
|
export declare class SourceError extends Error {
|
|
29
31
|
readonly source: SourceId;
|
|
@@ -64,6 +66,19 @@ export declare function cninfoIrm(transport: Requester, input: {
|
|
|
64
66
|
pageNum: number;
|
|
65
67
|
signal?: AbortSignal;
|
|
66
68
|
}): Promise<SourceOutcome>;
|
|
69
|
+
export declare const CNINFO_PAGE_SIZE_MAX = 30;
|
|
70
|
+
/**
|
|
71
|
+
* Day-scoped all-market list from CNINFO (the official A-share disclosure platform).
|
|
72
|
+
* Returns metadata only: the caller must not fetch/parse `document_url` in bulk.
|
|
73
|
+
*/
|
|
74
|
+
export declare function cninfoAnnouncements(transport: Requester, input: {
|
|
75
|
+
date: string;
|
|
76
|
+
market?: 'all' | 'sz' | 'sh' | 'bj';
|
|
77
|
+
keyword?: string;
|
|
78
|
+
page: number;
|
|
79
|
+
pageSize: number;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
}): Promise<SourceOutcome>;
|
|
67
82
|
/**
|
|
68
83
|
* Company list page: 32 companies, ascending by code. uid and code come from the same
|
|
69
84
|
* `<a>` element, so cross-item mispairing is structurally impossible (a windowed regex
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createHttpRequester, safeUrl } from './local-fetch.js';
|
|
7
7
|
import { stripInvisibleText } from './html-markdown.js';
|
|
8
|
-
export const SOURCE_IDS = ['cls', 'wscn', 'cninfo_irm', 'sseinfo', 'eastmoney', 'ths', 'sina'];
|
|
8
|
+
export const SOURCE_IDS = ['cls', 'wscn', 'cninfo_irm', 'cninfo', 'sseinfo', 'eastmoney', 'ths', 'sina'];
|
|
9
9
|
/** Per-item text cap; item count is capped separately by each tool's limit. */
|
|
10
10
|
export const MAX_ITEM_CHARS = 1200;
|
|
11
11
|
/** Max items per output (must match the tool schema maximum). */
|
|
@@ -289,6 +289,138 @@ export async function cninfoIrm(transport, input) {
|
|
|
289
289
|
note: `深市专用:互动易对沪市公司返回 0 条,沪市问答请用 sseinfo_qa${total === undefined ? '' : `;公司累计问答 ${total} 条`}`,
|
|
290
290
|
};
|
|
291
291
|
}
|
|
292
|
+
const CNINFO_ANNOUNCEMENT_URL = 'https://www.cninfo.com.cn/new/hisAnnouncement/query';
|
|
293
|
+
const CNINFO_REFERER = 'https://www.cninfo.com.cn/new/commonUrl?url=disclosure/list/notice';
|
|
294
|
+
export const CNINFO_PAGE_SIZE_MAX = 30;
|
|
295
|
+
/** CNINFO often encodes a date-only disclosure as Beijing midnight; keep that precision instead of inventing a time. */
|
|
296
|
+
function cninfoStamp(ms, fallbackDate) {
|
|
297
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
298
|
+
return { date: fallbackDate, publishedAt: null, precision: null, ms: null };
|
|
299
|
+
const stamp = Math.round(ms);
|
|
300
|
+
const iso = new Date(stamp + 8 * 3600 * 1000).toISOString();
|
|
301
|
+
const date = iso.slice(0, 10);
|
|
302
|
+
const time = iso.slice(11, 19);
|
|
303
|
+
// SH/BJ often encode a date-only disclosure as Beijing midnight; keep that precision explicit.
|
|
304
|
+
if (time === '00:00:00')
|
|
305
|
+
return { date, publishedAt: date, precision: 'date', ms: stamp };
|
|
306
|
+
return { date, publishedAt: `${date} ${time}`, precision: 'minute', ms: stamp };
|
|
307
|
+
}
|
|
308
|
+
function cninfoMarket(pageColumn) {
|
|
309
|
+
const value = typeof pageColumn === 'string' ? pageColumn.trim().toUpperCase() : '';
|
|
310
|
+
if (value.startsWith('SH'))
|
|
311
|
+
return 'sh';
|
|
312
|
+
if (value.startsWith('SZ'))
|
|
313
|
+
return 'sz';
|
|
314
|
+
if (value.startsWith('BJ'))
|
|
315
|
+
return 'bj';
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
function cninfoDocumentUrl(adjunctUrl) {
|
|
319
|
+
const raw = typeof adjunctUrl === 'string' ? adjunctUrl.trim() : '';
|
|
320
|
+
if (raw.length === 0)
|
|
321
|
+
return null;
|
|
322
|
+
const full = /^https?:\/\//iu.test(raw) ? raw : `https://static.cninfo.com.cn/${raw.replace(/^\/+/u, '')}`;
|
|
323
|
+
const safe = itemUrl(full);
|
|
324
|
+
return safe.length === 0 ? null : safe;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Day-scoped all-market list from CNINFO (the official A-share disclosure platform).
|
|
328
|
+
* Returns metadata only: the caller must not fetch/parse `document_url` in bulk.
|
|
329
|
+
*/
|
|
330
|
+
export async function cninfoAnnouncements(transport, input) {
|
|
331
|
+
const date = announcementDate(input.date, 'date');
|
|
332
|
+
const market = input.market ?? 'all';
|
|
333
|
+
if (!['all', 'sz', 'sh', 'bj'].includes(market))
|
|
334
|
+
throw new Error("parameter market must be 'all', 'sz', 'sh' or 'bj'");
|
|
335
|
+
if (!Number.isSafeInteger(input.page) || input.page < 1)
|
|
336
|
+
throw new Error('parameter page must be a positive integer');
|
|
337
|
+
if (!Number.isSafeInteger(input.pageSize) || input.pageSize < 1 || input.pageSize > CNINFO_PAGE_SIZE_MAX) {
|
|
338
|
+
throw new Error(`parameter page_size must be an integer from 1 to ${CNINFO_PAGE_SIZE_MAX}`);
|
|
339
|
+
}
|
|
340
|
+
const keyword = input.keyword?.trim() ?? '';
|
|
341
|
+
if (keyword.length > 50)
|
|
342
|
+
throw new Error('parameter keyword exceeds 50 characters');
|
|
343
|
+
const body = new URLSearchParams({
|
|
344
|
+
pageNum: String(input.page),
|
|
345
|
+
pageSize: String(input.pageSize),
|
|
346
|
+
column: 'szse',
|
|
347
|
+
tabName: 'fulltext',
|
|
348
|
+
plate: market === 'all' ? 'sz;sh;bj' : market,
|
|
349
|
+
stock: '',
|
|
350
|
+
searchkey: keyword,
|
|
351
|
+
secid: '',
|
|
352
|
+
category: '',
|
|
353
|
+
trade: '',
|
|
354
|
+
seDate: `${date}~${date}`,
|
|
355
|
+
sortName: '',
|
|
356
|
+
sortType: '',
|
|
357
|
+
isHLtitle: 'true',
|
|
358
|
+
});
|
|
359
|
+
const response = await transport.request({
|
|
360
|
+
url: CNINFO_ANNOUNCEMENT_URL,
|
|
361
|
+
method: 'POST',
|
|
362
|
+
body: body.toString(),
|
|
363
|
+
headers: { referer: CNINFO_REFERER, 'x-requested-with': 'XMLHttpRequest' },
|
|
364
|
+
}, input.signal);
|
|
365
|
+
const payload = asRecord(parseJson(response.text, 'cninfo', '巨潮公告列表响应', response.truncated));
|
|
366
|
+
if (!payload)
|
|
367
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', '巨潮公告列表响应不是对象');
|
|
368
|
+
const total = payload.totalAnnouncement;
|
|
369
|
+
if (typeof total !== 'number' || !Number.isFinite(total) || total < 0) {
|
|
370
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', '巨潮公告列表缺少 totalAnnouncement');
|
|
371
|
+
}
|
|
372
|
+
const rows = payload.announcements;
|
|
373
|
+
if (rows !== null && rows !== undefined && !Array.isArray(rows)) {
|
|
374
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', '巨潮公告列表 announcements 不是数组');
|
|
375
|
+
}
|
|
376
|
+
const items = [];
|
|
377
|
+
for (const raw of Array.isArray(rows) ? rows : []) {
|
|
378
|
+
const row = asRecord(raw);
|
|
379
|
+
if (!row)
|
|
380
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', '巨潮公告条目不是对象');
|
|
381
|
+
const code = typeof row.secCode === 'string' ? row.secCode.trim() : '';
|
|
382
|
+
if (!/^\d{6}$/u.test(code))
|
|
383
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', `巨潮公告条目 secCode 非法:${JSON.stringify(code)}`);
|
|
384
|
+
const announcementId = typeof row.announcementId === 'string' ? row.announcementId.trim() : '';
|
|
385
|
+
if (announcementId.length === 0)
|
|
386
|
+
throw new SourceError('cninfo', 'INVALID_RESPONSE', '巨潮公告条目缺少 announcementId');
|
|
387
|
+
const stamp = typeof row.announcementTime === 'number' ? row.announcementTime : 0;
|
|
388
|
+
const published = cninfoStamp(stamp, date);
|
|
389
|
+
const title = clip(stripHtml(typeof row.announcementTitle === 'string' ? row.announcementTitle : ''));
|
|
390
|
+
const name = clip(typeof row.secName === 'string' ? row.secName : '');
|
|
391
|
+
const pageColumn = typeof row.pageColumn === 'string' ? row.pageColumn : '';
|
|
392
|
+
items.push({
|
|
393
|
+
code,
|
|
394
|
+
name,
|
|
395
|
+
title,
|
|
396
|
+
date: published.date,
|
|
397
|
+
published_at: published.publishedAt,
|
|
398
|
+
published_at_precision: published.precision,
|
|
399
|
+
announcement_time_ms: published.ms,
|
|
400
|
+
market: cninfoMarket(pageColumn),
|
|
401
|
+
exchange: pageColumn,
|
|
402
|
+
announcement_id: announcementId,
|
|
403
|
+
document_type: clip(typeof row.adjunctType === 'string' ? row.adjunctType : ''),
|
|
404
|
+
document_url: cninfoDocumentUrl(row.adjunctUrl),
|
|
405
|
+
source: 'cninfo',
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
const pages = total === 0 ? 0 : Math.ceil(total / input.pageSize);
|
|
409
|
+
return {
|
|
410
|
+
source: 'cninfo',
|
|
411
|
+
operation: 'announcements',
|
|
412
|
+
items: clipItems(items),
|
|
413
|
+
meta: {
|
|
414
|
+
total,
|
|
415
|
+
page: input.page,
|
|
416
|
+
page_size: input.pageSize,
|
|
417
|
+
pages,
|
|
418
|
+
truncated: input.page * input.pageSize < total,
|
|
419
|
+
...(input.page < pages ? { next_page: input.page + 1 } : {}),
|
|
420
|
+
},
|
|
421
|
+
note: `巨潮按披露日列全市场 A 股公告;本工具只返回清单,不读取也不解析 document_url 的 PDF/HTML 正文,禁止把清单链接批量交给 web_retriever_fetch/ocr;单日全市场可达 1,400+ 条,按 market/keyword/page_size 收窄。当前 page_size=${input.pageSize},共 ${total} 条。`,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
292
424
|
const SSE_BASE = 'https://sns.sseinfo.com';
|
|
293
425
|
const SSE_REFERER = `${SSE_BASE}/`;
|
|
294
426
|
const SSE_KIND = { answered: 11, questions: 10 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_ITEMS, SourceError, clsTelegraph, cninfoIrm, createGatedEastmoneyTransport, createSourceTransport, eastmoneyAnnouncementBody, eastmoneyAnnouncements, eastmoneyFastNews, eastmoneyReports, eastmoneyStockNews, normalizeAnnouncementCodes, sinaReports, sseinfoQa, thsEpsForecast, wscnLives, } from './sources.js';
|
|
1
|
+
import { MAX_ITEMS, SourceError, clsTelegraph, cninfoAnnouncements, cninfoIrm, CNINFO_PAGE_SIZE_MAX, createGatedEastmoneyTransport, createSourceTransport, eastmoneyAnnouncementBody, eastmoneyAnnouncements, eastmoneyFastNews, eastmoneyReports, eastmoneyStockNews, normalizeAnnouncementCodes, sinaReports, sseinfoQa, thsEpsForecast, wscnLives, } from './sources.js';
|
|
2
2
|
import { assertPublicUrlTarget } from './local-fetch.js';
|
|
3
3
|
import { createEastmoneyClient, sharedEastmoneyThrottle } from '../net/eastmoney-client.js';
|
|
4
4
|
import { bareAshareDigits } from '../sources/security-code.js';
|
|
@@ -808,6 +808,7 @@ function sourceOutput(outcome, recent, tally, adjustCursor) {
|
|
|
808
808
|
operation: outcome.operation,
|
|
809
809
|
ok: true,
|
|
810
810
|
count: items.length,
|
|
811
|
+
...(outcome.meta ?? {}),
|
|
811
812
|
...(nextCursor !== undefined ? { next_cursor: nextCursor } : {}),
|
|
812
813
|
...(notes.length > 0 ? { note: notes.join(';') } : {}),
|
|
813
814
|
items,
|
|
@@ -1019,6 +1020,45 @@ export function registerSourceTools(ctx, localFetchOptions) {
|
|
|
1019
1020
|
return run(exec, 'eastmoney', 'reports', `code=${code} page=${pageNo}`, () => eastmoneyReports(eastmoneyClient, { code, pageSize, pageNo, signal: exec.signal }));
|
|
1020
1021
|
},
|
|
1021
1022
|
},
|
|
1023
|
+
{
|
|
1024
|
+
name: 'cninfo_announcements',
|
|
1025
|
+
description: '按披露日获取巨潮资讯网全市场 A 股公告清单(确定性来源查询,零 key;一次一个披露日)。date 必填 YYYY-MM-DD;market 默认 all,可收窄 sz/sh/bj;keyword 是标题关键词(上游 searchkey,不是分类枚举);page/page_size 翻页,page_size 上游硬上限 30、默认 20。回执给 total/page/page_size/pages/truncated/next_page 与 items(code/name/title/date/published_at/published_at_precision/market/exchange/announcement_id/document_type/document_url/source)。⛔ 本工具**只返回公告清单**,不读取也不解析 document_url 的 PDF/HTML 正文;禁止把清单里的链接批量交给 web_retriever_fetch/ocr。单日全市场可达 1,400+ 条,先按 market/keyword 收窄;全市场按日扫描用本工具,按代码跟踪仍用 eastmoney_announcements。',
|
|
1026
|
+
parameters: jsonObject({
|
|
1027
|
+
date: { type: 'string', description: '披露日 YYYY-MM-DD(单日;不做跨日窗口)' },
|
|
1028
|
+
market: { type: 'string', enum: ['all', 'sz', 'sh', 'bj'], description: '可选,默认 all;sz 深市 / sh 沪市 / bj 北交所' },
|
|
1029
|
+
keyword: { type: 'string', description: '可选,标题关键词(上游 searchkey;不是分类枚举)' },
|
|
1030
|
+
page: { type: 'integer', description: '可选,页码从 1 开始,默认 1' },
|
|
1031
|
+
page_size: { type: 'integer', description: `可选,每页 1~${CNINFO_PAGE_SIZE_MAX},默认 20` },
|
|
1032
|
+
}, ['date']),
|
|
1033
|
+
output: {
|
|
1034
|
+
schema: envelope({
|
|
1035
|
+
total: { type: 'integer' },
|
|
1036
|
+
page: { type: 'integer' },
|
|
1037
|
+
page_size: { type: 'integer' },
|
|
1038
|
+
pages: { type: 'integer' },
|
|
1039
|
+
truncated: { type: 'boolean' },
|
|
1040
|
+
next_page: { type: 'integer' },
|
|
1041
|
+
}),
|
|
1042
|
+
render,
|
|
1043
|
+
},
|
|
1044
|
+
async execute(args, exec) {
|
|
1045
|
+
const date = strictCalendarDate(args.date, 'date');
|
|
1046
|
+
const market = args.market === undefined ? 'all' : String(args.market);
|
|
1047
|
+
if (!['all', 'sz', 'sh', 'bj'].includes(market))
|
|
1048
|
+
throw new Error("market must be 'all', 'sz', 'sh' or 'bj'");
|
|
1049
|
+
const keyword = args.keyword === undefined ? undefined : requiredString(args.keyword, 'keyword', 50);
|
|
1050
|
+
const page = integer(args.page, 'page', 1, 1000) ?? 1;
|
|
1051
|
+
const pageSize = integer(args.page_size, 'page_size', 1, CNINFO_PAGE_SIZE_MAX) ?? 20;
|
|
1052
|
+
return run(exec, 'cninfo', 'announcements', `date=${date} market=${market} page=${page}`, () => cninfoAnnouncements(transport, {
|
|
1053
|
+
date,
|
|
1054
|
+
market: market,
|
|
1055
|
+
...(keyword === undefined ? {} : { keyword }),
|
|
1056
|
+
page,
|
|
1057
|
+
pageSize,
|
|
1058
|
+
signal: exec.signal,
|
|
1059
|
+
}));
|
|
1060
|
+
},
|
|
1061
|
+
},
|
|
1022
1062
|
{
|
|
1023
1063
|
name: 'eastmoney_announcements',
|
|
1024
1064
|
description: '取东方财富公告列表(确定性来源查询,零 key;一次只查一个市场)。codes 传 1~50 只批量代码;start_date/end_date 是披露时间窗口(按 display_time 的北京时间日期,含首尾,最长 31 天)。返回 code/name/market/date/published_at/title/category/art_code/url,按发布时间倒序;published_at 是完整时分,盘前窗口按它过滤;翻页把回执的 next_cursor 原样传回 cursor。⛔ 公告清单默认走本工具,不要用 wind_docs 的语义检索代替:实测 Wind 会漏最新公告、混入关联方/其他公司。⛔ 东财公告是官方披露的转载;正文/PDF 可作公告事实的权威引用(authoritative_reprint),但 verified_official 仍只给官方域名核验;正文用 eastmoney_announcement_body。⛔ 盘前公告的 start_date 要取上一交易日(display_time 在收盘后仍算当日),end_date 取运行日;只查运行日会漏掉昨晚盘后披露。窗口内没有公告是合法空结果,不是失败。',
|
|
@@ -35,7 +35,7 @@ export interface WindCallResult {
|
|
|
35
35
|
code?: WindErrorCode;
|
|
36
36
|
}
|
|
37
37
|
/** Must match `package.json` version; a test pins the two together. */
|
|
38
|
-
export declare const WIND_CLIENT_VERSION = "2.
|
|
38
|
+
export declare const WIND_CLIENT_VERSION = "2.25.0";
|
|
39
39
|
export interface WindClient {
|
|
40
40
|
callTool(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<WindCallResult>;
|
|
41
41
|
}
|
|
@@ -19,7 +19,7 @@ export const WIND_SERVER_ENDPOINTS = {
|
|
|
19
19
|
analytics_data: 'https://mcp.wind.com.cn/vserver_analytics_data/mcp/',
|
|
20
20
|
};
|
|
21
21
|
/** Must match `package.json` version; a test pins the two together. */
|
|
22
|
-
export const WIND_CLIENT_VERSION = '2.
|
|
22
|
+
export const WIND_CLIENT_VERSION = '2.25.0';
|
|
23
23
|
function errorText(error) {
|
|
24
24
|
return error instanceof Error ? error.message : String(error);
|
|
25
25
|
}
|