@v587d/capital-generation 2.28.0 → 2.30.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 +59 -0
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/collector-runtime.js +56 -1
- package/lib/data-collector/catalog-taxonomy.d.ts +1 -1
- package/lib/data-collector/catalog-taxonomy.js +33 -0
- package/lib/data-collector/tools.js +7 -7
- package/lib/host-version.d.ts +9 -0
- package/lib/host-version.js +57 -0
- package/lib/python-runtime/errors.d.ts +1 -1
- package/lib/python-runtime/errors.js +2 -0
- package/lib/python-runtime/manager.d.ts +28 -1
- package/lib/python-runtime/manager.js +141 -5
- package/lib/python-runtime/probe.d.ts +24 -0
- package/lib/python-runtime/probe.js +66 -50
- package/lib/runtime-entry.js +8 -0
- package/lib/sources/csindex-http.d.ts +4 -0
- package/lib/sources/csindex-http.js +233 -0
- package/lib/sources/eastmoney-http.js +1504 -1
- package/lib/sources/fuyao-rest.js +168 -8
- package/lib/sources/official-http.d.ts +4 -0
- package/lib/sources/official-http.js +477 -0
- package/lib/sources/python-remote.d.ts +25 -0
- package/lib/sources/python-remote.js +461 -0
- package/lib/sources/sina-http.d.ts +2 -0
- package/lib/sources/sina-http.js +484 -0
- package/lib/sources/tencent-http.js +23 -8
- package/lib/sources/ths-http.d.ts +2 -0
- package/lib/sources/ths-http.js +514 -0
- package/lib/time/tools.js +19 -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 +7 -0
- package/lib/web-retriever/sources.js +46 -21
- package/lib/web-retriever/throttle.d.ts +8 -0
- package/lib/web-retriever/throttle.js +13 -0
- package/lib/web-retriever/tools.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +6 -3
- package/preset/capital-generation/agent.patch.yml +7 -5
- package/preset/capital-generation/skills/capital-data-protocol/SKILL.md +16 -16
- package/python/scripts/baostock_stock_basic.py +129 -0
- package/python/scripts/baostock_valuation_history.py +141 -0
- package/python/scripts/pbc_social_financing.py +291 -0
- package/python/vendor/baostock/LICENSE +19 -0
- package/python/vendor/baostock/__init__.py +42 -0
- package/python/vendor/baostock/common/__init__.py +0 -0
- package/python/vendor/baostock/common/contants.py +189 -0
- package/python/vendor/baostock/common/context.py +4 -0
- package/python/vendor/baostock/corpreport/__init__.py +0 -0
- package/python/vendor/baostock/corpreport/corp_performance.py +202 -0
- package/python/vendor/baostock/data/__init__.py +0 -0
- package/python/vendor/baostock/data/messageheader.py +17 -0
- package/python/vendor/baostock/data/msg.py +21 -0
- package/python/vendor/baostock/data/resultset.py +200 -0
- package/python/vendor/baostock/demo/__init__.py +0 -0
- package/python/vendor/baostock/demo/demo_A_stock_5mk-data.py +34 -0
- package/python/vendor/baostock/demo/demo_A_stock_k_data.py +36 -0
- package/python/vendor/baostock/demo/demo_AllStock.py +27 -0
- package/python/vendor/baostock/demo/demo_Balance_data.py +22 -0
- package/python/vendor/baostock/demo/demo_CashFlow_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Dividend_data.py +35 -0
- package/python/vendor/baostock/demo/demo_Dupont_data.py +25 -0
- package/python/vendor/baostock/demo/demo_Forecast_report.py +24 -0
- package/python/vendor/baostock/demo/demo_Growth_data.py +22 -0
- package/python/vendor/baostock/demo/demo_Index_k_data.py +39 -0
- package/python/vendor/baostock/demo/demo_Operation_data.py +22 -0
- package/python/vendor/baostock/demo/demo_PerformanceExpress_report.py +25 -0
- package/python/vendor/baostock/demo/demo_Profit_data.py +22 -0
- package/python/vendor/baostock/demo/demo_TradeDates.py +27 -0
- package/python/vendor/baostock/demo/demo_adjust_factor_data.py +23 -0
- package/python/vendor/baostock/demo/demo_assignDayData.py +23 -0
- package/python/vendor/baostock/demo/demo_daily_adjust_factor_data.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_AStock.py +28 -0
- package/python/vendor/baostock/demo/demo_daily_k_4_ETF.py +28 -0
- package/python/vendor/baostock/demo/demo_depositRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_hs300_stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_loanRate_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataMonth_data.py +26 -0
- package/python/vendor/baostock/demo/demo_moneySupplyDataYear_data.py +26 -0
- package/python/vendor/baostock/demo/demo_requiredReserveRatio_data.py +26 -0
- package/python/vendor/baostock/demo/demo_set_API_key.py +37 -0
- package/python/vendor/baostock/demo/demo_stockBasic_data.py +27 -0
- package/python/vendor/baostock/demo/demo_stock_Valuation_indicator_data.py +34 -0
- package/python/vendor/baostock/demo/demo_stock_industry.py +26 -0
- package/python/vendor/baostock/demo/demo_sz50stocks.py +26 -0
- package/python/vendor/baostock/demo/demo_zz500_stock.py +26 -0
- package/python/vendor/baostock/evaluation/__init__.py +0 -0
- package/python/vendor/baostock/evaluation/season_index.py +758 -0
- package/python/vendor/baostock/login/__init__.py +0 -0
- package/python/vendor/baostock/login/loginout.py +230 -0
- package/python/vendor/baostock/macroscopic/__init__.py +0 -0
- package/python/vendor/baostock/macroscopic/economic_data.py +723 -0
- package/python/vendor/baostock/metadata/__init__.py +0 -0
- package/python/vendor/baostock/metadata/stock_metadata.py +207 -0
- package/python/vendor/baostock/security/__init__.py +0 -0
- package/python/vendor/baostock/security/history.py +265 -0
- package/python/vendor/baostock/security/sectorinfo.py +1024 -0
- package/python/vendor/baostock/util/__init__.py +0 -0
- package/python/vendor/baostock/util/socketutil.py +97 -0
- package/python/vendor/baostock/util/stringutil.py +83 -0
- package/python/vendor/et_xmlfile/LICENSE +23 -0
- package/python/vendor/et_xmlfile/LICENSE.python +298 -0
- package/python/vendor/et_xmlfile/__init__.py +8 -0
- package/python/vendor/et_xmlfile/incremental_tree.py +917 -0
- package/python/vendor/et_xmlfile/xmlfile.py +158 -0
- package/python/vendor/openpyxl/LICENSE +23 -0
- package/python/vendor/openpyxl/__init__.py +19 -0
- package/python/vendor/openpyxl/_constants.py +13 -0
- package/python/vendor/openpyxl/cell/__init__.py +4 -0
- package/python/vendor/openpyxl/cell/_writer.py +136 -0
- package/python/vendor/openpyxl/cell/cell.py +332 -0
- package/python/vendor/openpyxl/cell/read_only.py +136 -0
- package/python/vendor/openpyxl/cell/rich_text.py +202 -0
- package/python/vendor/openpyxl/cell/text.py +184 -0
- package/python/vendor/openpyxl/chart/_3d.py +105 -0
- package/python/vendor/openpyxl/chart/__init__.py +19 -0
- package/python/vendor/openpyxl/chart/_chart.py +199 -0
- package/python/vendor/openpyxl/chart/area_chart.py +106 -0
- package/python/vendor/openpyxl/chart/axis.py +401 -0
- package/python/vendor/openpyxl/chart/bar_chart.py +144 -0
- package/python/vendor/openpyxl/chart/bubble_chart.py +67 -0
- package/python/vendor/openpyxl/chart/chartspace.py +195 -0
- package/python/vendor/openpyxl/chart/data_source.py +246 -0
- package/python/vendor/openpyxl/chart/descriptors.py +43 -0
- package/python/vendor/openpyxl/chart/error_bar.py +62 -0
- package/python/vendor/openpyxl/chart/label.py +127 -0
- package/python/vendor/openpyxl/chart/layout.py +74 -0
- package/python/vendor/openpyxl/chart/legend.py +75 -0
- package/python/vendor/openpyxl/chart/line_chart.py +129 -0
- package/python/vendor/openpyxl/chart/marker.py +90 -0
- package/python/vendor/openpyxl/chart/picture.py +35 -0
- package/python/vendor/openpyxl/chart/pie_chart.py +177 -0
- package/python/vendor/openpyxl/chart/pivot.py +65 -0
- package/python/vendor/openpyxl/chart/plotarea.py +162 -0
- package/python/vendor/openpyxl/chart/print_settings.py +57 -0
- package/python/vendor/openpyxl/chart/radar_chart.py +55 -0
- package/python/vendor/openpyxl/chart/reader.py +32 -0
- package/python/vendor/openpyxl/chart/reference.py +124 -0
- package/python/vendor/openpyxl/chart/scatter_chart.py +53 -0
- package/python/vendor/openpyxl/chart/series.py +197 -0
- package/python/vendor/openpyxl/chart/series_factory.py +41 -0
- package/python/vendor/openpyxl/chart/shapes.py +89 -0
- package/python/vendor/openpyxl/chart/stock_chart.py +54 -0
- package/python/vendor/openpyxl/chart/surface_chart.py +119 -0
- package/python/vendor/openpyxl/chart/text.py +78 -0
- package/python/vendor/openpyxl/chart/title.py +76 -0
- package/python/vendor/openpyxl/chart/trendline.py +98 -0
- package/python/vendor/openpyxl/chart/updown_bars.py +31 -0
- package/python/vendor/openpyxl/chartsheet/__init__.py +3 -0
- package/python/vendor/openpyxl/chartsheet/chartsheet.py +107 -0
- package/python/vendor/openpyxl/chartsheet/custom.py +61 -0
- package/python/vendor/openpyxl/chartsheet/properties.py +28 -0
- package/python/vendor/openpyxl/chartsheet/protection.py +41 -0
- package/python/vendor/openpyxl/chartsheet/publish.py +58 -0
- package/python/vendor/openpyxl/chartsheet/relation.py +97 -0
- package/python/vendor/openpyxl/chartsheet/views.py +51 -0
- package/python/vendor/openpyxl/comments/__init__.py +4 -0
- package/python/vendor/openpyxl/comments/author.py +21 -0
- package/python/vendor/openpyxl/comments/comment_sheet.py +211 -0
- package/python/vendor/openpyxl/comments/comments.py +62 -0
- package/python/vendor/openpyxl/comments/shape_writer.py +112 -0
- package/python/vendor/openpyxl/compat/__init__.py +54 -0
- package/python/vendor/openpyxl/compat/abc.py +8 -0
- package/python/vendor/openpyxl/compat/numbers.py +43 -0
- package/python/vendor/openpyxl/compat/product.py +17 -0
- package/python/vendor/openpyxl/compat/singleton.py +40 -0
- package/python/vendor/openpyxl/compat/strings.py +25 -0
- package/python/vendor/openpyxl/descriptors/__init__.py +58 -0
- package/python/vendor/openpyxl/descriptors/base.py +272 -0
- package/python/vendor/openpyxl/descriptors/container.py +41 -0
- package/python/vendor/openpyxl/descriptors/excel.py +112 -0
- package/python/vendor/openpyxl/descriptors/namespace.py +12 -0
- package/python/vendor/openpyxl/descriptors/nested.py +129 -0
- package/python/vendor/openpyxl/descriptors/sequence.py +136 -0
- package/python/vendor/openpyxl/descriptors/serialisable.py +240 -0
- package/python/vendor/openpyxl/descriptors/slots.py +18 -0
- package/python/vendor/openpyxl/drawing/__init__.py +4 -0
- package/python/vendor/openpyxl/drawing/colors.py +435 -0
- package/python/vendor/openpyxl/drawing/connector.py +144 -0
- package/python/vendor/openpyxl/drawing/drawing.py +92 -0
- package/python/vendor/openpyxl/drawing/effect.py +407 -0
- package/python/vendor/openpyxl/drawing/fill.py +425 -0
- package/python/vendor/openpyxl/drawing/geometry.py +584 -0
- package/python/vendor/openpyxl/drawing/graphic.py +177 -0
- package/python/vendor/openpyxl/drawing/image.py +65 -0
- package/python/vendor/openpyxl/drawing/line.py +144 -0
- package/python/vendor/openpyxl/drawing/picture.py +144 -0
- package/python/vendor/openpyxl/drawing/properties.py +174 -0
- package/python/vendor/openpyxl/drawing/relation.py +17 -0
- package/python/vendor/openpyxl/drawing/spreadsheet_drawing.py +382 -0
- package/python/vendor/openpyxl/drawing/text.py +717 -0
- package/python/vendor/openpyxl/drawing/xdr.py +33 -0
- package/python/vendor/openpyxl/formatting/__init__.py +3 -0
- package/python/vendor/openpyxl/formatting/formatting.py +114 -0
- package/python/vendor/openpyxl/formatting/rule.py +291 -0
- package/python/vendor/openpyxl/formula/__init__.py +3 -0
- package/python/vendor/openpyxl/formula/tokenizer.py +446 -0
- package/python/vendor/openpyxl/formula/translate.py +166 -0
- package/python/vendor/openpyxl/packaging/__init__.py +3 -0
- package/python/vendor/openpyxl/packaging/core.py +115 -0
- package/python/vendor/openpyxl/packaging/custom.py +289 -0
- package/python/vendor/openpyxl/packaging/extended.py +137 -0
- package/python/vendor/openpyxl/packaging/interface.py +56 -0
- package/python/vendor/openpyxl/packaging/manifest.py +194 -0
- package/python/vendor/openpyxl/packaging/relationship.py +158 -0
- package/python/vendor/openpyxl/packaging/workbook.py +185 -0
- package/python/vendor/openpyxl/pivot/__init__.py +1 -0
- package/python/vendor/openpyxl/pivot/cache.py +965 -0
- package/python/vendor/openpyxl/pivot/fields.py +326 -0
- package/python/vendor/openpyxl/pivot/record.py +111 -0
- package/python/vendor/openpyxl/pivot/table.py +1261 -0
- package/python/vendor/openpyxl/reader/__init__.py +1 -0
- package/python/vendor/openpyxl/reader/drawings.py +71 -0
- package/python/vendor/openpyxl/reader/excel.py +349 -0
- package/python/vendor/openpyxl/reader/strings.py +44 -0
- package/python/vendor/openpyxl/reader/workbook.py +133 -0
- package/python/vendor/openpyxl/styles/__init__.py +11 -0
- package/python/vendor/openpyxl/styles/alignment.py +62 -0
- package/python/vendor/openpyxl/styles/borders.py +103 -0
- package/python/vendor/openpyxl/styles/builtins.py +1397 -0
- package/python/vendor/openpyxl/styles/cell_style.py +206 -0
- package/python/vendor/openpyxl/styles/colors.py +172 -0
- package/python/vendor/openpyxl/styles/differential.py +95 -0
- package/python/vendor/openpyxl/styles/fills.py +224 -0
- package/python/vendor/openpyxl/styles/fonts.py +113 -0
- package/python/vendor/openpyxl/styles/named_styles.py +282 -0
- package/python/vendor/openpyxl/styles/numbers.py +200 -0
- package/python/vendor/openpyxl/styles/protection.py +17 -0
- package/python/vendor/openpyxl/styles/proxy.py +62 -0
- package/python/vendor/openpyxl/styles/styleable.py +151 -0
- package/python/vendor/openpyxl/styles/stylesheet.py +274 -0
- package/python/vendor/openpyxl/styles/table.py +94 -0
- package/python/vendor/openpyxl/utils/__init__.py +17 -0
- package/python/vendor/openpyxl/utils/bound_dictionary.py +26 -0
- package/python/vendor/openpyxl/utils/cell.py +240 -0
- package/python/vendor/openpyxl/utils/dataframe.py +87 -0
- package/python/vendor/openpyxl/utils/datetime.py +140 -0
- package/python/vendor/openpyxl/utils/escape.py +43 -0
- package/python/vendor/openpyxl/utils/exceptions.py +34 -0
- package/python/vendor/openpyxl/utils/formulas.py +24 -0
- package/python/vendor/openpyxl/utils/indexed_list.py +49 -0
- package/python/vendor/openpyxl/utils/inference.py +60 -0
- package/python/vendor/openpyxl/utils/protection.py +22 -0
- package/python/vendor/openpyxl/utils/units.py +108 -0
- package/python/vendor/openpyxl/workbook/__init__.py +4 -0
- package/python/vendor/openpyxl/workbook/_writer.py +197 -0
- package/python/vendor/openpyxl/workbook/child.py +166 -0
- package/python/vendor/openpyxl/workbook/defined_name.py +189 -0
- package/python/vendor/openpyxl/workbook/external_link/__init__.py +3 -0
- package/python/vendor/openpyxl/workbook/external_link/external.py +190 -0
- package/python/vendor/openpyxl/workbook/external_reference.py +18 -0
- package/python/vendor/openpyxl/workbook/function_group.py +36 -0
- package/python/vendor/openpyxl/workbook/properties.py +151 -0
- package/python/vendor/openpyxl/workbook/protection.py +163 -0
- package/python/vendor/openpyxl/workbook/smart_tags.py +56 -0
- package/python/vendor/openpyxl/workbook/views.py +155 -0
- package/python/vendor/openpyxl/workbook/web.py +98 -0
- package/python/vendor/openpyxl/workbook/workbook.py +438 -0
- package/python/vendor/openpyxl/worksheet/__init__.py +1 -0
- package/python/vendor/openpyxl/worksheet/_read_only.py +190 -0
- package/python/vendor/openpyxl/worksheet/_reader.py +472 -0
- package/python/vendor/openpyxl/worksheet/_write_only.py +160 -0
- package/python/vendor/openpyxl/worksheet/_writer.py +390 -0
- package/python/vendor/openpyxl/worksheet/cell_range.py +512 -0
- package/python/vendor/openpyxl/worksheet/cell_watch.py +34 -0
- package/python/vendor/openpyxl/worksheet/controls.py +107 -0
- package/python/vendor/openpyxl/worksheet/copier.py +70 -0
- package/python/vendor/openpyxl/worksheet/custom.py +35 -0
- package/python/vendor/openpyxl/worksheet/datavalidation.py +202 -0
- package/python/vendor/openpyxl/worksheet/dimensions.py +306 -0
- package/python/vendor/openpyxl/worksheet/drawing.py +14 -0
- package/python/vendor/openpyxl/worksheet/errors.py +93 -0
- package/python/vendor/openpyxl/worksheet/filters.py +486 -0
- package/python/vendor/openpyxl/worksheet/formula.py +51 -0
- package/python/vendor/openpyxl/worksheet/header_footer.py +270 -0
- package/python/vendor/openpyxl/worksheet/hyperlink.py +46 -0
- package/python/vendor/openpyxl/worksheet/merge.py +141 -0
- package/python/vendor/openpyxl/worksheet/ole.py +133 -0
- package/python/vendor/openpyxl/worksheet/page.py +174 -0
- package/python/vendor/openpyxl/worksheet/pagebreak.py +94 -0
- package/python/vendor/openpyxl/worksheet/picture.py +8 -0
- package/python/vendor/openpyxl/worksheet/print_settings.py +184 -0
- package/python/vendor/openpyxl/worksheet/properties.py +97 -0
- package/python/vendor/openpyxl/worksheet/protection.py +120 -0
- package/python/vendor/openpyxl/worksheet/related.py +17 -0
- package/python/vendor/openpyxl/worksheet/scenario.py +105 -0
- package/python/vendor/openpyxl/worksheet/smart_tag.py +78 -0
- package/python/vendor/openpyxl/worksheet/table.py +385 -0
- package/python/vendor/openpyxl/worksheet/views.py +155 -0
- package/python/vendor/openpyxl/worksheet/worksheet.py +907 -0
- package/python/vendor/openpyxl/writer/__init__.py +1 -0
- package/python/vendor/openpyxl/writer/excel.py +295 -0
- package/python/vendor/openpyxl/writer/theme.py +291 -0
- package/python/vendor/openpyxl/xml/__init__.py +42 -0
- package/python/vendor/openpyxl/xml/constants.py +129 -0
- package/python/vendor/openpyxl/xml/functions.py +87 -0
- package/watchlist/package.json +1 -1
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { buildDataKey } from '../data-collector/hub.js';
|
|
2
|
+
import { getDataTimeContract } from '../time/tools.js';
|
|
3
|
+
import { createRequestThrottle } from '../net/throttle.js';
|
|
4
|
+
const HOT_LIST_URL = 'https://dq.10jqka.com.cn/fuyao/hot_list_data/out/hot_list/v1/stock';
|
|
5
|
+
const LIMIT_UP_URL = 'https://data.10jqka.com.cn/dataapi/limit_up/limit_up_pool';
|
|
6
|
+
const USER_AGENT = 'Mozilla/5.0';
|
|
7
|
+
const MIN_INTERVAL_MS = 300;
|
|
8
|
+
// THS-internal field ids, not derivable. Without them the reply drops latest / change_rate and the
|
|
9
|
+
// other price columns; writing a different list changes which fields exist.
|
|
10
|
+
const LIMIT_UP_FIELDS = '199112,10,9001,330323,330324,330325,9002,330329,133971,133970,1968584,3475914,9003,9004';
|
|
11
|
+
// Board whitelist: main boards + GEM + STAR only. No BJ token is accepted upstream, so BSE limit-ups
|
|
12
|
+
// are structurally out of reach for this endpoint.
|
|
13
|
+
const LIMIT_UP_FILTER = 'HS,GEM2STAR';
|
|
14
|
+
const LIMIT_UP_ORDER_FIELD = '330324';
|
|
15
|
+
const LIMIT_UP_ORDER_TYPE = '0';
|
|
16
|
+
const MAX_PAGE_SIZE = 200;
|
|
17
|
+
const DEFAULT_PAGE_SIZE = 200;
|
|
18
|
+
const HOT_TYPES = ['day', 'hour'];
|
|
19
|
+
// Beijing has no DST: shift the Unix seconds by +08:00 and read the UTC parts.
|
|
20
|
+
const BEIJING_OFFSET_SECONDS = 8 * 3600;
|
|
21
|
+
const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
22
|
+
const COMPACT_DATE_PATTERN = /^\d{8}$/;
|
|
23
|
+
const NUMERIC_TEXT_PATTERN = /^\d+(?:\.\d+)?$/;
|
|
24
|
+
const CLOCK_PATTERN = /^\d{2}:\d{2}:\d{2}$/;
|
|
25
|
+
// One serial chain per upstream host: the two hosts share the same anti-crawl budget, and stacking
|
|
26
|
+
// requests on either one is what gets 10jqka to answer 401.
|
|
27
|
+
const hotListThrottle = createRequestThrottle(MIN_INTERVAL_MS);
|
|
28
|
+
const limitUpThrottle = createRequestThrottle(MIN_INTERVAL_MS);
|
|
29
|
+
function isRecord(value) {
|
|
30
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
function thsError(message, code = 'ths_source_error') {
|
|
33
|
+
const error = new Error(message);
|
|
34
|
+
error.code = code;
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
function assertKnown(values, allowed) {
|
|
38
|
+
for (const key of Object.keys(values))
|
|
39
|
+
if (!allowed.includes(key))
|
|
40
|
+
throw new Error(`unsupported parameter: ${key}`);
|
|
41
|
+
}
|
|
42
|
+
function isCalendarDate(text) {
|
|
43
|
+
if (!DATE_PATTERN.test(text))
|
|
44
|
+
return false;
|
|
45
|
+
const parsed = new Date(`${text}T00:00:00Z`);
|
|
46
|
+
return !Number.isNaN(parsed.getTime()) && parsed.toISOString().slice(0, 10) === text;
|
|
47
|
+
}
|
|
48
|
+
function isoDateFromCompact(compact) {
|
|
49
|
+
return `${compact.slice(0, 4)}-${compact.slice(4, 6)}-${compact.slice(6, 8)}`;
|
|
50
|
+
}
|
|
51
|
+
function compactDate(iso) {
|
|
52
|
+
return iso.replaceAll('-', '');
|
|
53
|
+
}
|
|
54
|
+
/** The model may send YYYY-MM-DD or YYYYMMDD; canonical output is always YYYY-MM-DD (idempotent). */
|
|
55
|
+
function tradeDateParam(value) {
|
|
56
|
+
if (typeof value !== 'string')
|
|
57
|
+
throw new Error('parameter date must be a YYYY-MM-DD string');
|
|
58
|
+
const text = value.trim();
|
|
59
|
+
if (COMPACT_DATE_PATTERN.test(text)) {
|
|
60
|
+
const iso = isoDateFromCompact(text);
|
|
61
|
+
if (isCalendarDate(iso))
|
|
62
|
+
return iso;
|
|
63
|
+
}
|
|
64
|
+
else if (isCalendarDate(text)) {
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`parameter date must be a valid YYYY-MM-DD date, got ${JSON.stringify(value)}`);
|
|
68
|
+
}
|
|
69
|
+
function integerParam(value, name) {
|
|
70
|
+
const parsed = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : Number.NaN;
|
|
71
|
+
if (!Number.isSafeInteger(parsed))
|
|
72
|
+
throw new Error(`parameter ${name} must be an integer`);
|
|
73
|
+
return parsed;
|
|
74
|
+
}
|
|
75
|
+
function pageParam(value) {
|
|
76
|
+
const page = integerParam(value, 'page');
|
|
77
|
+
if (page < 1)
|
|
78
|
+
throw new Error('parameter page must be an integer >= 1');
|
|
79
|
+
return page;
|
|
80
|
+
}
|
|
81
|
+
function sizeParam(value) {
|
|
82
|
+
const size = integerParam(value, 'size');
|
|
83
|
+
if (size < 1 || size > MAX_PAGE_SIZE)
|
|
84
|
+
throw new Error(`parameter size must be an integer from 1 to ${MAX_PAGE_SIZE}`);
|
|
85
|
+
return size;
|
|
86
|
+
}
|
|
87
|
+
async function fetchJson(url, throttle, label, signal) {
|
|
88
|
+
signal.throwIfAborted();
|
|
89
|
+
return throttle(async () => {
|
|
90
|
+
let response;
|
|
91
|
+
try {
|
|
92
|
+
response = await fetch(url, { headers: { 'User-Agent': USER_AGENT, Accept: 'application/json, text/plain, */*' }, signal });
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof Error && error.name === 'AbortError')
|
|
96
|
+
throw error;
|
|
97
|
+
throw thsError(`${label} request failed: ${error instanceof Error ? error.message : String(error)}`, 'ths_http_error');
|
|
98
|
+
}
|
|
99
|
+
const text = await response.text();
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
const hint = response.status === 401 || response.status === 403 ? ' (10jqka anti-crawl challenge: do not retry in a loop)' : '';
|
|
102
|
+
throw thsError(`${label} returned HTTP ${response.status}${hint}`, response.status === 429 ? 'ths_rate_limit' : 'ths_http_error');
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
return JSON.parse(text);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
throw thsError(`${label} returned non-JSON: ${JSON.stringify(text.slice(0, 120))}`, 'ths_invalid_response');
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Success is `{status_code:0, status_msg:"success", data}`; parameter errors come back as
|
|
114
|
+
* `{code:-1, msg:"Param Error."}` under HTTP 200. Both shapes must fail loudly.
|
|
115
|
+
*/
|
|
116
|
+
function assertEnvelope(payload, label) {
|
|
117
|
+
if (!isRecord(payload))
|
|
118
|
+
throw thsError(`${label} response is not a JSON object`, 'ths_invalid_response');
|
|
119
|
+
if (payload.status_code !== undefined && Number(payload.status_code) !== 0) {
|
|
120
|
+
throw thsError(`${label} failed: ${String(payload.status_msg ?? payload.status_code)} (status_code ${String(payload.status_code)})`, 'ths_upstream_error');
|
|
121
|
+
}
|
|
122
|
+
if (payload.status_code === undefined && payload.code !== undefined && Number(payload.code) !== 0) {
|
|
123
|
+
throw thsError(`${label} failed: ${String(payload.msg ?? payload.message ?? payload.code)} (code ${String(payload.code)})`, 'ths_upstream_error');
|
|
124
|
+
}
|
|
125
|
+
return payload;
|
|
126
|
+
}
|
|
127
|
+
function requiredText(value, field, label) {
|
|
128
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
129
|
+
throw thsError(`${label} has an empty ${field}`, 'ths_invalid_response');
|
|
130
|
+
return value.trim();
|
|
131
|
+
}
|
|
132
|
+
function optionalText(value, field, label) {
|
|
133
|
+
if (value === null || value === undefined)
|
|
134
|
+
return null;
|
|
135
|
+
if (typeof value !== 'string')
|
|
136
|
+
throw thsError(`${label} has a non-text ${field}: ${JSON.stringify(value)}`, 'ths_invalid_response');
|
|
137
|
+
const text = value.trim();
|
|
138
|
+
return text === '' ? null : text;
|
|
139
|
+
}
|
|
140
|
+
function optionalNumber(value, field, label) {
|
|
141
|
+
if (value === null || value === undefined || value === '')
|
|
142
|
+
return null;
|
|
143
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
144
|
+
throw thsError(`${label} has a non-numeric ${field}: ${JSON.stringify(value)}`, 'ths_invalid_response');
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function requiredNumber(value, field, label) {
|
|
148
|
+
const parsed = optionalNumber(value, field, label);
|
|
149
|
+
if (parsed === null)
|
|
150
|
+
throw thsError(`${label} is missing ${field}`, 'ths_invalid_response');
|
|
151
|
+
return parsed;
|
|
152
|
+
}
|
|
153
|
+
function beijingDateTime(epochSeconds) {
|
|
154
|
+
const shifted = new Date((epochSeconds + BEIJING_OFFSET_SECONDS) * 1000).toISOString();
|
|
155
|
+
return { date: shifted.slice(0, 10), clock: shifted.slice(11, 19) };
|
|
156
|
+
}
|
|
157
|
+
/** Seal times are Unix seconds (strings), not HHMMSS integers; output is Beijing HH:MM:SS. */
|
|
158
|
+
function sealClock(value, upstreamDate, field, label) {
|
|
159
|
+
if (value === null || value === undefined || value === '')
|
|
160
|
+
return null;
|
|
161
|
+
const seconds = typeof value === 'number' ? value : typeof value === 'string' && /^\d+$/.test(value.trim()) ? Number(value) : Number.NaN;
|
|
162
|
+
if (!Number.isSafeInteger(seconds) || seconds <= 0)
|
|
163
|
+
throw thsError(`${label} has an unreadable ${field}: ${JSON.stringify(value)}`, 'ths_invalid_response');
|
|
164
|
+
const { date, clock } = beijingDateTime(seconds);
|
|
165
|
+
const expected = isoDateFromCompact(upstreamDate);
|
|
166
|
+
if (date !== expected)
|
|
167
|
+
throw thsError(`${label} ${field} ${seconds} falls on ${date}, not the trading day ${expected}`, 'ths_invalid_response');
|
|
168
|
+
return clock;
|
|
169
|
+
}
|
|
170
|
+
const HOT_KEYS = ['rank', 'code', 'name', 'rank_change', 'heat', 'change_pct', 'concepts', 'popularity_tag'];
|
|
171
|
+
const LIMIT_UP_KEYS = [
|
|
172
|
+
'code', 'name', 'price', 'change_pct', 'reason', 'board_type', 'seal_rate', 'break_times',
|
|
173
|
+
'seal_amount', 'seal_volume', 'high_days', 'first_seal', 'last_seal', 'is_again', 'turnover_rate_pct',
|
|
174
|
+
];
|
|
175
|
+
// Nullable shapes carry a description: hub.ts turns output_schema properties into the catalog
|
|
176
|
+
// field dictionary, and an undocumented column reads as "not declared".
|
|
177
|
+
function nullableText(description) {
|
|
178
|
+
return { oneOf: [{ type: 'string' }, { type: 'null' }], description };
|
|
179
|
+
}
|
|
180
|
+
function nullableNumber(description) {
|
|
181
|
+
return { oneOf: [{ type: 'number' }, { type: 'null' }], description };
|
|
182
|
+
}
|
|
183
|
+
function nullableInteger(description) {
|
|
184
|
+
return { oneOf: [{ type: 'integer' }, { type: 'null' }], description };
|
|
185
|
+
}
|
|
186
|
+
function rowSchema(properties, required) {
|
|
187
|
+
return { type: 'object', properties, required, additionalProperties: false };
|
|
188
|
+
}
|
|
189
|
+
const hotListOutput = {
|
|
190
|
+
type: 'array',
|
|
191
|
+
items: rowSchema({
|
|
192
|
+
rank: { type: 'integer', minimum: 1, description: '榜内排名(上游 order,实测 1..100 连续)' },
|
|
193
|
+
code: { type: 'string', description: '6 位 A 股代码,不带市场后缀' },
|
|
194
|
+
name: { type: 'string', description: '证券简称' },
|
|
195
|
+
rank_change: nullableInteger('排名变化:正数上升、负数下降、0 不变;上游缺失为 null'),
|
|
196
|
+
heat: { type: 'string', description: '人气值,上游原始字符串(不转数值,"215825.0" 的尾数照抄)' },
|
|
197
|
+
change_pct: nullableNumber('涨跌幅百分数原值:1.9608 = +1.9608%'),
|
|
198
|
+
concepts: { type: 'array', items: { type: 'string' }, description: '概念标签(tag.concept_tag);无标签为空数组' },
|
|
199
|
+
popularity_tag: nullableText('人气标签(tag.popularity_tag,如 2天1板);无则 null'),
|
|
200
|
+
}, HOT_KEYS),
|
|
201
|
+
};
|
|
202
|
+
const limitUpOutput = {
|
|
203
|
+
type: 'array',
|
|
204
|
+
items: rowSchema({
|
|
205
|
+
code: { type: 'string', description: '6 位 A 股代码,不带市场后缀(不含北交所)' },
|
|
206
|
+
name: { type: 'string', description: '证券简称' },
|
|
207
|
+
price: { type: 'number', description: '最新价,元' },
|
|
208
|
+
change_pct: { type: 'number', description: '涨跌幅百分数原值:10.0228 = +10.0228%' },
|
|
209
|
+
reason: nullableText('涨停原因题材(上游 reason_type);上游缺失为 null'),
|
|
210
|
+
board_type: { type: 'string', description: '板型:换手板 / 一字板 / T字板(实测三值)' },
|
|
211
|
+
seal_rate: nullableNumber('封板成功率,0~1 小数(0.8 = 80%);null = 上游未给,不是 0'),
|
|
212
|
+
break_times: nullableInteger('开板(炸板)次数;null = 上游未给,不是 0'),
|
|
213
|
+
seal_amount: { type: 'number', description: '封单额,元' },
|
|
214
|
+
seal_volume: nullableInteger('封单量,股;上游缺失为 null'),
|
|
215
|
+
high_days: { type: 'string', description: '几天几板字符串:首板 / 3天2板 / 7天4板;不是连板数' },
|
|
216
|
+
first_seal: nullableText('首次封板时间,北京时间 HH:MM:SS(上游 Unix 秒换算)'),
|
|
217
|
+
last_seal: nullableText('最后封板时间,北京时间 HH:MM:SS(上游 Unix 秒换算)'),
|
|
218
|
+
is_again: { type: 'integer', enum: [0, 1], description: '上游 is_again_limit 原值:1=回封,0=非回封' },
|
|
219
|
+
turnover_rate_pct: { type: 'number', description: '换手率百分数原值:27.7729 = 27.7729%' },
|
|
220
|
+
}, LIMIT_UP_KEYS),
|
|
221
|
+
};
|
|
222
|
+
const hotListInput = {
|
|
223
|
+
type: 'object',
|
|
224
|
+
properties: {
|
|
225
|
+
type: { type: 'string', enum: [...HOT_TYPES], description: '榜单周期:day 日榜(默认)/ hour 小时榜' },
|
|
226
|
+
},
|
|
227
|
+
required: [],
|
|
228
|
+
additionalProperties: false,
|
|
229
|
+
};
|
|
230
|
+
const limitUpInput = {
|
|
231
|
+
type: 'object',
|
|
232
|
+
properties: {
|
|
233
|
+
date: { type: 'string', description: '交易日 YYYY-MM-DD(也收 YYYYMMDD,归一成 YYYY-MM-DD);省略 = 上游最近交易日' },
|
|
234
|
+
page: { type: 'integer', minimum: 1, description: '页码,从 1 开始,默认 1' },
|
|
235
|
+
size: { type: 'integer', minimum: 1, maximum: MAX_PAGE_SIZE, description: `单页条数 1~${MAX_PAGE_SIZE},默认 ${DEFAULT_PAGE_SIZE}` },
|
|
236
|
+
},
|
|
237
|
+
required: [],
|
|
238
|
+
additionalProperties: false,
|
|
239
|
+
};
|
|
240
|
+
function normalizeHotList(params) {
|
|
241
|
+
const type = params.type === undefined ? 'day' : String(params.type).trim().toLowerCase();
|
|
242
|
+
if (!HOT_TYPES.includes(type))
|
|
243
|
+
throw new Error(`parameter type must be one of ${HOT_TYPES.join(', ')}`);
|
|
244
|
+
return { type };
|
|
245
|
+
}
|
|
246
|
+
function normalizeLimitUp(params) {
|
|
247
|
+
// Defaults are materialized so `{}` and `{page:1,size:200}` share one Dataset.
|
|
248
|
+
const normalized = { page: params.page === undefined ? 1 : pageParam(params.page), size: params.size === undefined ? DEFAULT_PAGE_SIZE : sizeParam(params.size) };
|
|
249
|
+
if (params.date !== undefined)
|
|
250
|
+
normalized.date = tradeDateParam(params.date);
|
|
251
|
+
return normalized;
|
|
252
|
+
}
|
|
253
|
+
function mapHotRow(item, index, label) {
|
|
254
|
+
const rowLabel = `${label} row ${index + 1}`;
|
|
255
|
+
if (!isRecord(item))
|
|
256
|
+
throw thsError(`${rowLabel} is not an object`, 'ths_invalid_response');
|
|
257
|
+
const rank = item.order;
|
|
258
|
+
if (typeof rank !== 'number' || !Number.isSafeInteger(rank) || rank < 1)
|
|
259
|
+
throw thsError(`${rowLabel} has an unreadable order: ${JSON.stringify(item.order)}`, 'ths_invalid_response');
|
|
260
|
+
const code = typeof item.code === 'string' ? item.code.trim() : '';
|
|
261
|
+
if (!/^\d{6}$/.test(code))
|
|
262
|
+
throw thsError(`${rowLabel} has an unreadable code: ${JSON.stringify(item.code)}`, 'ths_invalid_response');
|
|
263
|
+
const name = requiredText(item.name, 'name', rowLabel);
|
|
264
|
+
// Keep the upstream string (no numeric conversion): "215825.0" and "5007268" are both spellings
|
|
265
|
+
// of the same field, and Number() would drop the trailing ".0".
|
|
266
|
+
const heat = item.rate;
|
|
267
|
+
if (typeof heat !== 'string' || !NUMERIC_TEXT_PATTERN.test(heat.trim()))
|
|
268
|
+
throw thsError(`${rowLabel} has an unreadable rate: ${JSON.stringify(item.rate)}`, 'ths_invalid_response');
|
|
269
|
+
const rankChange = optionalNumber(item.hot_rank_chg, 'hot_rank_chg', rowLabel);
|
|
270
|
+
if (rankChange !== null && !Number.isSafeInteger(rankChange))
|
|
271
|
+
throw thsError(`${rowLabel} has a non-integer hot_rank_chg: ${JSON.stringify(item.hot_rank_chg)}`, 'ths_invalid_response');
|
|
272
|
+
const changePct = optionalNumber(item.rise_and_fall, 'rise_and_fall', rowLabel);
|
|
273
|
+
const tag = item.tag;
|
|
274
|
+
const concepts = [];
|
|
275
|
+
let popularityTag = null;
|
|
276
|
+
if (tag !== null && tag !== undefined) {
|
|
277
|
+
if (!isRecord(tag))
|
|
278
|
+
throw thsError(`${rowLabel} tag is not an object`, 'ths_invalid_response');
|
|
279
|
+
const conceptTag = tag.concept_tag;
|
|
280
|
+
if (conceptTag !== null && conceptTag !== undefined) {
|
|
281
|
+
if (!Array.isArray(conceptTag))
|
|
282
|
+
throw thsError(`${rowLabel} tag.concept_tag is not an array`, 'ths_invalid_response');
|
|
283
|
+
for (const entry of conceptTag) {
|
|
284
|
+
if (typeof entry !== 'string')
|
|
285
|
+
throw thsError(`${rowLabel} tag.concept_tag has a non-text entry: ${JSON.stringify(entry)}`, 'ths_invalid_response');
|
|
286
|
+
const text = entry.trim();
|
|
287
|
+
if (text !== '')
|
|
288
|
+
concepts.push(text);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
popularityTag = optionalText(tag.popularity_tag, 'tag.popularity_tag', rowLabel);
|
|
292
|
+
}
|
|
293
|
+
return { rank, code, name, rank_change: rankChange, heat: heat.trim(), change_pct: changePct, concepts, popularity_tag: popularityTag };
|
|
294
|
+
}
|
|
295
|
+
function mapLimitUpRow(item, upstreamDate, label) {
|
|
296
|
+
if (!isRecord(item))
|
|
297
|
+
throw thsError(`${label} is not an object`, 'ths_invalid_response');
|
|
298
|
+
const code = typeof item.code === 'string' ? item.code.trim() : '';
|
|
299
|
+
if (!/^\d{6}$/.test(code))
|
|
300
|
+
throw thsError(`${label} has an unreadable code: ${JSON.stringify(item.code)}`, 'ths_invalid_response');
|
|
301
|
+
const name = requiredText(item.name, 'name', label);
|
|
302
|
+
const price = requiredNumber(item.latest, 'latest', label);
|
|
303
|
+
if (price <= 0)
|
|
304
|
+
throw thsError(`${label} has a non-positive latest price: ${price}`, 'ths_invalid_response');
|
|
305
|
+
const changePct = requiredNumber(item.change_rate, 'change_rate', label);
|
|
306
|
+
const reason = optionalText(item.reason_type, 'reason_type', label);
|
|
307
|
+
const boardType = requiredText(item.limit_up_type, 'limit_up_type', label);
|
|
308
|
+
// Seal success rate is a 0..1 ratio; null means "upstream has no value" and must not become 0.
|
|
309
|
+
const sealRate = optionalNumber(item.limit_up_suc_rate, 'limit_up_suc_rate', label);
|
|
310
|
+
if (sealRate !== null && (sealRate < 0 || sealRate > 1))
|
|
311
|
+
throw thsError(`${label} has limit_up_suc_rate ${sealRate} outside 0..1`, 'ths_invalid_response');
|
|
312
|
+
const breakTimes = optionalNumber(item.open_num, 'open_num', label);
|
|
313
|
+
if (breakTimes !== null && (!Number.isSafeInteger(breakTimes) || breakTimes < 0))
|
|
314
|
+
throw thsError(`${label} has an unreadable open_num: ${JSON.stringify(item.open_num)}`, 'ths_invalid_response');
|
|
315
|
+
const sealAmount = requiredNumber(item.order_amount, 'order_amount', label);
|
|
316
|
+
if (sealAmount < 0)
|
|
317
|
+
throw thsError(`${label} has a negative order_amount: ${sealAmount}`, 'ths_invalid_response');
|
|
318
|
+
const sealVolume = optionalNumber(item.order_volume, 'order_volume', label);
|
|
319
|
+
if (sealVolume !== null && (!Number.isSafeInteger(sealVolume) || sealVolume < 0))
|
|
320
|
+
throw thsError(`${label} has an unreadable order_volume: ${JSON.stringify(item.order_volume)}`, 'ths_invalid_response');
|
|
321
|
+
const highDays = requiredText(item.high_days, 'high_days', label);
|
|
322
|
+
const firstSeal = sealClock(item.first_limit_up_time, upstreamDate, 'first_limit_up_time', label);
|
|
323
|
+
const lastSeal = sealClock(item.last_limit_up_time, upstreamDate, 'last_limit_up_time', label);
|
|
324
|
+
const isAgain = item.is_again_limit;
|
|
325
|
+
if (isAgain !== 0 && isAgain !== 1)
|
|
326
|
+
throw thsError(`${label} has an unreadable is_again_limit: ${JSON.stringify(item.is_again_limit)}`, 'ths_invalid_response');
|
|
327
|
+
const turnoverPct = requiredNumber(item.turnover_rate, 'turnover_rate', label);
|
|
328
|
+
return {
|
|
329
|
+
code,
|
|
330
|
+
name,
|
|
331
|
+
price,
|
|
332
|
+
change_pct: changePct,
|
|
333
|
+
reason,
|
|
334
|
+
board_type: boardType,
|
|
335
|
+
seal_rate: sealRate,
|
|
336
|
+
break_times: breakTimes,
|
|
337
|
+
seal_amount: sealAmount,
|
|
338
|
+
seal_volume: sealVolume,
|
|
339
|
+
high_days: highDays,
|
|
340
|
+
first_seal: firstSeal,
|
|
341
|
+
last_seal: lastSeal,
|
|
342
|
+
is_again: isAgain,
|
|
343
|
+
turnover_rate_pct: turnoverPct,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
async function executeHotList(params, signal) {
|
|
347
|
+
const type = String(params.type);
|
|
348
|
+
const label = `THS hot list (${type})`;
|
|
349
|
+
const search = new URLSearchParams({ stock_type: 'a', type, list_type: 'normal' });
|
|
350
|
+
const payload = await fetchJson(`${HOT_LIST_URL}?${search.toString()}`, hotListThrottle, label, signal);
|
|
351
|
+
const envelope = assertEnvelope(payload, label);
|
|
352
|
+
const data = envelope.data;
|
|
353
|
+
if (!isRecord(data) || !Array.isArray(data.stock_list))
|
|
354
|
+
throw thsError(`${label} response has no data.stock_list array`, 'ths_invalid_response');
|
|
355
|
+
return { data: data.stock_list.map((item, index) => mapHotRow(item, index, label)), schema: hotListOutput };
|
|
356
|
+
}
|
|
357
|
+
async function executeLimitUp(params, signal) {
|
|
358
|
+
const date = typeof params.date === 'string' ? params.date : undefined;
|
|
359
|
+
const page = Number(params.page);
|
|
360
|
+
const size = Number(params.size);
|
|
361
|
+
const label = `THS limit-up pool (${date ?? 'latest'})`;
|
|
362
|
+
const search = new URLSearchParams({
|
|
363
|
+
page: String(page),
|
|
364
|
+
limit: String(size),
|
|
365
|
+
field: LIMIT_UP_FIELDS,
|
|
366
|
+
filter: LIMIT_UP_FILTER,
|
|
367
|
+
order_field: LIMIT_UP_ORDER_FIELD,
|
|
368
|
+
order_type: LIMIT_UP_ORDER_TYPE,
|
|
369
|
+
});
|
|
370
|
+
if (date !== undefined)
|
|
371
|
+
search.set('date', compactDate(date));
|
|
372
|
+
const payload = await fetchJson(`${LIMIT_UP_URL}?${search.toString()}`, limitUpThrottle, label, signal);
|
|
373
|
+
const envelope = assertEnvelope(payload, label);
|
|
374
|
+
const data = envelope.data;
|
|
375
|
+
if (!isRecord(data))
|
|
376
|
+
throw thsError(`${label} response has no data object`, 'ths_invalid_response');
|
|
377
|
+
const upstreamDate = typeof data.date === 'string' ? data.date : '';
|
|
378
|
+
if (!COMPACT_DATE_PATTERN.test(upstreamDate) || !isCalendarDate(isoDateFromCompact(upstreamDate))) {
|
|
379
|
+
throw thsError(`${label} has an unreadable data.date: ${JSON.stringify(data.date)}`, 'ths_invalid_response');
|
|
380
|
+
}
|
|
381
|
+
if (date !== undefined && compactDate(date) !== upstreamDate)
|
|
382
|
+
throw thsError(`${label} ignored date ${date}: upstream returned ${upstreamDate}`, 'ths_invalid_response');
|
|
383
|
+
const pageMeta = data.page;
|
|
384
|
+
if (!isRecord(pageMeta))
|
|
385
|
+
throw thsError(`${label} response has no data.page object`, 'ths_invalid_response');
|
|
386
|
+
const total = pageMeta.total;
|
|
387
|
+
if (typeof total !== 'number' || !Number.isSafeInteger(total) || total < 0)
|
|
388
|
+
throw thsError(`${label} has an unreadable data.page.total: ${JSON.stringify(pageMeta.total)}`, 'ths_invalid_response');
|
|
389
|
+
const info = data.info;
|
|
390
|
+
if (!Array.isArray(info))
|
|
391
|
+
throw thsError(`${label} response has no data.info array`, 'ths_invalid_response');
|
|
392
|
+
// Non-trading day / future date / no limit-ups: HTTP 200 + status_code 0 + info [] is a legal empty.
|
|
393
|
+
// On that path upstream echoes page 0, so the page guard below only applies to non-empty results.
|
|
394
|
+
if (total === 0) {
|
|
395
|
+
if (info.length !== 0)
|
|
396
|
+
throw thsError(`${label} says total=0 but returned ${info.length} rows`, 'ths_invalid_response');
|
|
397
|
+
return { data: [], schema: limitUpOutput };
|
|
398
|
+
}
|
|
399
|
+
if (pageMeta.page !== page)
|
|
400
|
+
throw thsError(`${label} asked for page ${page} but upstream served page ${JSON.stringify(pageMeta.page)}: out-of-range pages fall back to the last page (with 0 rows), keep page <= ceil(total/size)`, 'ths_page_out_of_range');
|
|
401
|
+
if (pageMeta.limit !== size)
|
|
402
|
+
throw thsError(`${label} asked for size ${size} but upstream served ${JSON.stringify(pageMeta.limit)} rows per page`, 'ths_invalid_response');
|
|
403
|
+
if (info.length === 0)
|
|
404
|
+
throw thsError(`${label} says total=${total} but returned 0 rows`, 'ths_invalid_response');
|
|
405
|
+
if (info.length > size)
|
|
406
|
+
throw thsError(`${label} returned ${info.length} rows for size ${size}`, 'ths_invalid_response');
|
|
407
|
+
return { data: info.map((item, index) => mapLimitUpRow(item, upstreamDate, `${label} row ${index + 1}`)), schema: limitUpOutput };
|
|
408
|
+
}
|
|
409
|
+
function isFiniteNumberOrNull(value) {
|
|
410
|
+
return value === null || (typeof value === 'number' && Number.isFinite(value));
|
|
411
|
+
}
|
|
412
|
+
function isIntegerInRangeOrNull(value, minimum) {
|
|
413
|
+
return value === null || (Number.isSafeInteger(value) && Number(value) >= minimum);
|
|
414
|
+
}
|
|
415
|
+
/** HH:MM:SS with real hour/minute/second ranges; shape alone would accept 24:00:00. */
|
|
416
|
+
function isClockText(value) {
|
|
417
|
+
if (typeof value !== 'string' || !CLOCK_PATTERN.test(value))
|
|
418
|
+
return false;
|
|
419
|
+
const [hour, minute, second] = value.split(':').map(Number);
|
|
420
|
+
return hour <= 23 && minute <= 59 && second <= 59;
|
|
421
|
+
}
|
|
422
|
+
function isHotRow(row) {
|
|
423
|
+
return isRecord(row)
|
|
424
|
+
&& Object.keys(row).length === HOT_KEYS.length
|
|
425
|
+
&& Number.isSafeInteger(row.rank) && Number(row.rank) >= 1
|
|
426
|
+
&& typeof row.code === 'string' && /^\d{6}$/.test(row.code)
|
|
427
|
+
&& typeof row.name === 'string' && row.name.length > 0
|
|
428
|
+
&& (row.rank_change === null || Number.isSafeInteger(row.rank_change))
|
|
429
|
+
&& typeof row.heat === 'string' && NUMERIC_TEXT_PATTERN.test(row.heat)
|
|
430
|
+
&& isFiniteNumberOrNull(row.change_pct)
|
|
431
|
+
&& Array.isArray(row.concepts) && row.concepts.every((entry) => typeof entry === 'string')
|
|
432
|
+
&& (row.popularity_tag === null || (typeof row.popularity_tag === 'string' && row.popularity_tag.length > 0));
|
|
433
|
+
}
|
|
434
|
+
function isLimitUpRow(row) {
|
|
435
|
+
return isRecord(row)
|
|
436
|
+
&& Object.keys(row).length === LIMIT_UP_KEYS.length
|
|
437
|
+
&& typeof row.code === 'string' && /^\d{6}$/.test(row.code)
|
|
438
|
+
&& typeof row.name === 'string' && row.name.length > 0
|
|
439
|
+
&& typeof row.price === 'number' && Number.isFinite(row.price) && row.price > 0
|
|
440
|
+
&& typeof row.change_pct === 'number' && Number.isFinite(row.change_pct)
|
|
441
|
+
&& (row.reason === null || (typeof row.reason === 'string' && row.reason.length > 0))
|
|
442
|
+
&& typeof row.board_type === 'string' && row.board_type.length > 0
|
|
443
|
+
&& isFiniteNumberOrNull(row.seal_rate) && (row.seal_rate === null || (Number(row.seal_rate) >= 0 && Number(row.seal_rate) <= 1))
|
|
444
|
+
&& isIntegerInRangeOrNull(row.break_times, 0)
|
|
445
|
+
&& typeof row.seal_amount === 'number' && Number.isFinite(row.seal_amount) && row.seal_amount >= 0
|
|
446
|
+
&& isIntegerInRangeOrNull(row.seal_volume, 0)
|
|
447
|
+
&& typeof row.high_days === 'string' && row.high_days.length > 0
|
|
448
|
+
&& (row.first_seal === null || isClockText(row.first_seal))
|
|
449
|
+
&& (row.last_seal === null || isClockText(row.last_seal))
|
|
450
|
+
&& (row.is_again === 0 || row.is_again === 1)
|
|
451
|
+
&& typeof row.turnover_rate_pct === 'number' && Number.isFinite(row.turnover_rate_pct);
|
|
452
|
+
}
|
|
453
|
+
function createSource(options) {
|
|
454
|
+
const schema = {
|
|
455
|
+
capability: options.capability,
|
|
456
|
+
time_contract: getDataTimeContract(options.capability),
|
|
457
|
+
name: options.name,
|
|
458
|
+
source: `http:ths.${options.capability}`,
|
|
459
|
+
data_key: buildDataKey('ths', 'http', options.capability),
|
|
460
|
+
source_label: 'ths',
|
|
461
|
+
paginated: options.paginated,
|
|
462
|
+
cacheMaxAgeMs: options.cacheMaxAgeMs,
|
|
463
|
+
rowShape: { rootArray: true },
|
|
464
|
+
summary: options.summary,
|
|
465
|
+
description: options.description,
|
|
466
|
+
input_schema: options.inputSchema,
|
|
467
|
+
output_schema: options.outputSchema,
|
|
468
|
+
};
|
|
469
|
+
const normalize = (params) => {
|
|
470
|
+
if (!isRecord(params))
|
|
471
|
+
throw new Error('params must be an object');
|
|
472
|
+
assertKnown(params, options.allowed);
|
|
473
|
+
return options.normalize(params);
|
|
474
|
+
};
|
|
475
|
+
return {
|
|
476
|
+
schema,
|
|
477
|
+
normalizeParams: normalize,
|
|
478
|
+
// Empty arrays are legal for both capabilities (non-trading day); row shape is still enforced.
|
|
479
|
+
validateOutput: (data) => Array.isArray(data) && data.every(options.isRow),
|
|
480
|
+
execute: async (request, signal) => options.execute(normalize(request.params), signal),
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
export function createThsSources() {
|
|
484
|
+
return [
|
|
485
|
+
createSource({
|
|
486
|
+
capability: 'ths_hot_list',
|
|
487
|
+
name: 'get_ths_hot_list',
|
|
488
|
+
summary: '同花顺热榜 100 行(含概念/人气标签,网页直连)',
|
|
489
|
+
description: '同花顺网页直连热榜(dq.10jqka.com.cn,零 key;实测 2026-11-22 17:15 的 day / hour 两榜各 100 行)。一行一只票,按 rank 升序(= 上游 order,实测 1..100 连续无重复)。⛔ 与 Fuyao `hot_stock_list` 同为同花顺热榜但来源不同:Fuyao 是转售 API(只有 thscode/ticker/name/rank/heat/rank_change/rank_trend,**没有概念标签 / 人气标签**),本能力是网页直连(concepts 来自 tag.concept_tag、popularity_tag 来自 tag.popularity_tag);实测 2026-11-22 17:15 同一时刻 day / hour 两榜前 30 名的 name / rank / heat / rank_change 与 Fuyao **逐行一致(30/30,heat 原串也一致,如 day 榜 "5007268"、hour 榜 "215825.0")**,但 Fuyao 只截 Top30、本能力 100 行;⛔ 热榜是实时快照,两次请求之间数值会变(实测 hour 榜金科股份 rate 17:15 为 215825.0、17:19 为 212497.0),跨来源 / 跨时刻对账必须先确认是同一份快照,不一致时禁止混用。rank_change 与 Fuyao rank_change 同字段同值(实测 30/30),语义沿用:正数=排名上升、负数=下降、0=不变。单位与口径:heat 是上游**字符串**人气值,原串保留、不转数字(day 榜 "5007268"、hour 榜 "215825.0",转数值会丢尾零 / 改写精度);change_pct 是**百分数原值**(实测 rise_and_fall 1.9608 = +1.9608%;同日用 tencent_quote 对 000656 得 pct 1.96、用 ftshare_ashare_quote 得 change_rate 0.0196078431372549(比例)×100 = 1.9607843%,三方一致);0 是真实值(平盘),不是缺失。concepts 来自 tag.concept_tag(text[],无标签时为空数组 []);popularity_tag 来自 tag.popularity_tag(如「2天1板」「持续上榜」,实测 100 行里 62~66 行没有该字段 → null,不是空串)。⛔ type 只有 day / hour 两档(省略默认 day;其它值上游回 {code:-1,msg:"Param Error."} 且本层在参数层先拒);**榜单是快照:无分页(实测 page=2 仍回同一份 100 行)、无历史**——历史排行用 Fuyao `hot_stock_history`、单票排名走势用 Fuyao `hot_stock_rank_trend`。失败语义:HTTP 非 2xx / 非 JSON / 上游 code 或 status_code 非 0 一律响亮失败(同花顺有反爬史,401/403 不要循环重试);stock_list 为空按合法空返回、不伪造行(实测恒 100 行,回 0 行应视为上游异常)。行内不含榜单时间,新鲜度看 Dataset 的 captured_at。未收录上游字段:market / topic / analyse / analyse_title。',
|
|
490
|
+
inputSchema: hotListInput,
|
|
491
|
+
outputSchema: hotListOutput,
|
|
492
|
+
paginated: false,
|
|
493
|
+
cacheMaxAgeMs: 30_000,
|
|
494
|
+
allowed: ['type'],
|
|
495
|
+
normalize: normalizeHotList,
|
|
496
|
+
isRow: isHotRow,
|
|
497
|
+
execute: executeHotList,
|
|
498
|
+
}),
|
|
499
|
+
createSource({
|
|
500
|
+
capability: 'ths_limit_up_detail',
|
|
501
|
+
name: 'get_ths_limit_up_detail',
|
|
502
|
+
summary: '同花顺涨停揭秘(板型/封板成功率/是否回封)',
|
|
503
|
+
description: '同花顺涨停揭秘(data.10jqka.com.cn 网页 JSON,零 key):按交易日取涨停个股,补上 Fuyao `limit_up_pool` 没有的三列——**board_type(板型:实测 换手板 / 一字板 / T字板)、seal_rate(封板成功率 0~1 小数)、is_again(是否回封 0/1)**;另有 reason(涨停原因题材)/ price / change_pct / turnover_rate_pct / seal_amount / seal_volume / break_times / high_days / first_seal / last_seal。⛔ 与 Fuyao `limit_up_pool` 是两家口径、必须并存:Fuyao 有连板数(continue_day_cnt)/ 封板资金(seal_money)/ 涨停原因,但**没有板型 / 封板成功率 / 是否回封**;本能力**不含北交所**(上游 filter=HS,GEM2STAR 只覆盖沪深主板 + 创业板 + 科创板;实测 2026-11-20 的 28 行 market_type 只有 HS/GEM、无 8/4/92 开头代码,2026-01-05 的 107 行出现 HS/GEM/STAR),也**不含 ST 涨停**(实测与 Fuyao 三个交易日对账:2026-11-20 28 vs 30 差 2 行、2025-11-20 41 vs 49 差 8 行、2026-01-05 107 vs 126 差 19 行,差额**全部**是 ST 股)——北交所与 ST 涨停请用 Fuyao `limit_up_pool`。⛔ 单位 / 口径(全部实测):price 是最新价(元);change_pct 是**百分数原值**(10.0228 = +10.0228%,与 Fuyao price_change_ratio_pct、tencent_quote pct、ftshare_ashare_quote change_rate×100 三方一致);turnover_rate_pct 是**百分数原值**(27.7729 = 27.7729%,同 tencent_quote turnover 27.77);seal_rate 是**0~1 小数比例**(0.8 = 80%,1 = 100%;**null = 上游未给**(实测 2026-01-05 的 107 行里 14 行 null),不是 0;2026-11-20 国光股份 0 是真实值);seal_amount 单位**元**(实测 2026-11-20 全 28 行 = seal_volume × price,偏差 ≤5 元为上游取整、最大实测 4.25 元);seal_volume 单位**股**;break_times 是开板(炸板)次数,**null 不是 0**(实测连 LIMIT_BACK 的行也有 null,不能用它反推开板次数);high_days 是**字符串**(首板 / 3天2板 / 7天4板 / 15天13板),⛔ **不是连板数**(实测 2026-11-20 好当家 THS「7天4板」而 Fuyao continue_day_cnt=1「首板」);is_again 是上游 is_again_limit 的 0/1 原值;first_seal / last_seal 由上游 **Unix 秒**(字符串,如 "1795144339")转北京时间 HH:MM:SS(1795144339 → 11:12:19;实测与 Fuyao limit_up_time 的 HH:MM 逐行一致:2026-11-20 28/28、2026-01-05 107/107),⛔ **不是东财四池的 HHMMSS 整数**;时间戳换算出的北京日期必须等于响应 data.date,否则按结构异常失败。参数:date 省略 = 上游最近交易日(实测 2026-11-22 周日省略 → data.date=20261120;行内不带日期列,要确定业务日期请显式传),YYYY-MM-DD(也收 YYYYMMDD,归一成 YYYY-MM-DD);实测支持窗口起点 2025-11-07(2025-11-06 及更早回 status_code=-1「date参数不合法」,是**响亮失败不是空**;起点是固定日还是滚动窗未核出);非交易日 / 未来日期回 status_code=0 + info=[](合法空)。page / size:page 从 1 开始、size 1~200(实测 size=201 → status_code=-1「limitmust be less than or equal to 200」,上游原文如此),默认 1 / 200,单次只取一页(上游 page 元数据 {limit,total,count=总页数,page};输出只有本页行,行数 = size 时可能还有下一页);⛔ 超界 page 上游**回落到最后一页且该页返回 0 行**(实测 page=99&size=10 → 回显 page 3、info=[];size=200 时只有 1 页 → 回显 page 1),本层核对回显 page,不一致即失败,不静默把别的页当请求页返回。合法空 vs 失败:status_code=0 且 info=[] 才是合法空(非交易日 / 未来日期 / 当日无涨停);status_code 或 HTTP 非 0、非 JSON、data 结构不对一律响亮失败(同花顺有反爬史,401/403 不要循环重试)。⛔ 响应里的 trade_status 是**查询时刻**的会话状态、不是请求日期的状态(实测周日查 2026-11-20 时 trade_status=non_trading_day 却有 28 行),不要用它判空或判失败。未收录上游字段:market_type / market_id / currency_value(流通市值)/ is_new / change_tag / high_days_value / time_preview,以及 data.limit_up_count / limit_down_count / trade_status。',
|
|
504
|
+
inputSchema: limitUpInput,
|
|
505
|
+
outputSchema: limitUpOutput,
|
|
506
|
+
paginated: true,
|
|
507
|
+
cacheMaxAgeMs: 60_000,
|
|
508
|
+
allowed: ['date', 'page', 'size'],
|
|
509
|
+
normalize: normalizeLimitUp,
|
|
510
|
+
isRow: isLimitUpRow,
|
|
511
|
+
execute: executeLimitUp,
|
|
512
|
+
}),
|
|
513
|
+
];
|
|
514
|
+
}
|
package/lib/time/tools.js
CHANGED
|
@@ -47,10 +47,29 @@ 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
|
+
// Event-family filters (2026-11-22): the column each range filters is named in the warning, because
|
|
51
|
+
// "start_date" means 公告日 / 更新日 / 申购日 depending on the table.
|
|
52
|
+
eastmoney_institution_research: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**公告日**(NOTICE_DATE),不是实际接待日' },
|
|
53
|
+
eastmoney_holder_change: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**公告日**;输出里另有变动期间 start_date / end_date' },
|
|
54
|
+
eastmoney_buyback: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**数据更新日**(UPD),不是方案公告日' },
|
|
55
|
+
eastmoney_pledge: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**统计日**(中国结算按周发布,通常周五);落在非统计日的区间返回空' },
|
|
56
|
+
eastmoney_new_stock: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**申购日**(APPLY_DATE)' },
|
|
57
|
+
baostock_valuation_history: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '服务端无区间上限(全历史可一次返回);区间内没有交易日返回空数组,是合法空结果' },
|
|
50
58
|
eastmoney_margin_total: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '市场级两融同样按交易所分别披露:深市/北交所 T+1,同一日期可能只有沪市有行,不能把不完整日期加总' },
|
|
51
59
|
eastmoney_global_kline: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '全球指数/商品/汇率的历史长度不一,早于各符号起点的日期返回空数组,不是取数失败' },
|
|
52
60
|
eastmoney_convertible_bond_list: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '区间过滤的是**起息日**(实测与网上申购日恒等),不是上市日也不是摘牌日' },
|
|
53
61
|
auction_benchmark: { kind: 'date', fields: ['date'], warning: '显式日期必须是交易日;工具不会自动回退到最近交易日' },
|
|
62
|
+
// Official ETF shares has history on the SSE side, but the SZSE side is a latest-day snapshot only —
|
|
63
|
+
// that one deliberately has no contract, or a period mapping would silently mean "latest".
|
|
64
|
+
sse_etf_shares: { kind: 'date', fields: ['trade_date'], warning: '省略 trade_date 取最近已发布交易日(默认不是今天);非交易日/尚未发布返回空结果,不是取数失败' },
|
|
65
|
+
chinamoney_repo_fixing: { kind: 'date_range', fields: ['start_date', 'end_date'], warning: '上游只给整份 CSV,区间是本地裁剪;落在中国周末/节假的区间返回空,不是取数失败' },
|
|
66
|
+
csindex_index_valuation: { kind: 'date_range', fields: ['start_date', 'end_date'], maxDays: TEN_YEAR_DAYS, warning: '日期轴是上游工作日序列(节假日也有行);各指数更新不同步,最新值可能差一个工作日' },
|
|
67
|
+
ths_limit_up_detail: { kind: 'date', fields: ['date'], warning: '省略 date 取上游最近交易日;不含北交所(上游 filter=HS,GEM2STAR)' },
|
|
68
|
+
// 东财 push2ex four pools: the upstream keeps only ~15 trading days and silently clamps future/today dates.
|
|
69
|
+
eastmoney_limit_up_pool: { kind: 'date', fields: ['trade_date'], warning: '上游只保留最近约 15 个交易日;非交易日/超窗口返回空池,今天及更晚会被夹到最近交易日(行内 requested_date_clamped 标出)' },
|
|
70
|
+
eastmoney_limit_break_pool: { kind: 'date', fields: ['trade_date'], warning: '同 eastmoney_limit_up_pool:约 15 个交易日窗口,今天及更晚会夹到最近交易日' },
|
|
71
|
+
eastmoney_limit_down_pool: { kind: 'date', fields: ['trade_date'], warning: '同 eastmoney_limit_up_pool:约 15 个交易日窗口,今天及更晚会夹到最近交易日' },
|
|
72
|
+
eastmoney_yesterday_limit_up_pool: { kind: 'date', fields: ['trade_date'], warning: '同 eastmoney_limit_up_pool:约 15 个交易日窗口;行内 yesterday_* 是前一交易日的封板信息' },
|
|
54
73
|
limit_up_pool: { kind: 'date_ms', fields: ['date_ms'], warning: 'date_ms 必须对应交易日;工具不会自动回退到最近交易日' },
|
|
55
74
|
limit_down_pool: { kind: 'date_ms', fields: ['date_ms'], warning: 'date_ms 必须对应交易日;工具不会自动回退到最近交易日' },
|
|
56
75
|
limit_break_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.30.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.30.0';
|
|
8
8
|
export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
9
9
|
export class LocalFetchError extends Error {
|
|
10
10
|
code;
|
|
@@ -205,11 +205,18 @@ export declare function eastmoneyAnnouncementBody(client: EastmoneyClient, input
|
|
|
205
205
|
/**
|
|
206
206
|
* Always add the exchange prefix: bare codes get a fake empty page for STAR/ChiNext.
|
|
207
207
|
* That page is HTTP 200 and looks like "no reports", so also verify the numbered row count.
|
|
208
|
+
*
|
|
209
|
+
* ⛔ A *real* empty page is byte-identical to that fake one, so a single empty answer proves nothing:
|
|
210
|
+
* querying once per second gets the fake page, waiting ≥5s gets the reports. Every request therefore
|
|
211
|
+
* goes through the shared 6s chain, and an empty page is retried once — only then is it reported as
|
|
212
|
+
* "no reports". A page past the last one pays the same 6s and still comes back empty; correct, just slow.
|
|
208
213
|
*/
|
|
209
214
|
export declare function sinaReports(transport: Requester, input: {
|
|
210
215
|
code?: string;
|
|
211
216
|
page: number;
|
|
212
217
|
signal?: AbortSignal;
|
|
218
|
+
/** Tests inject a pass-through; production defaults to the shared 6s chain. */
|
|
219
|
+
throttle?: <T>(task: () => Promise<T>) => Promise<T>;
|
|
213
220
|
}): Promise<SourceOutcome>;
|
|
214
221
|
/**
|
|
215
222
|
* Always prefix the exchange; order matters: BJ segments (43/83/87/920) start with 9/4
|