diff --git a/docs/API_REFERENCE.md b/docs/API_REFERENCE.md index a64117d..25c0747 100644 --- a/docs/API_REFERENCE.md +++ b/docs/API_REFERENCE.md @@ -6,7 +6,7 @@ | 指标 | 数量 | |---|---:| -| SDK 方法总数 | 248 | +| SDK 方法总数 | 250 | ## 专题分布 @@ -15,10 +15,10 @@ | 股票数据 | 131 | `ftshare.apis.stock` | `ftshare.endpoints.stock` | | 港股数据 | 3 | `ftshare.apis.hk` | `ftshare.endpoints.hk` | | 美股数据 | 2 | `ftshare.apis.us` | `ftshare.endpoints.us` | -| 指数专题 | 15 | `ftshare.apis.index` | `ftshare.endpoints.index` | +| 指数专题 | 16 | `ftshare.apis.index` | `ftshare.endpoints.index` | | ETF专题 | 17 | `ftshare.apis.etf` | `ftshare.endpoints.etf` | | 公募基金 | 18 | `ftshare.apis.fund` | `ftshare.endpoints.fund` | -| 期货数据 | 21 | `ftshare.apis.futures` | `ftshare.endpoints.futures` | +| 期货数据 | 22 | `ftshare.apis.futures` | `ftshare.endpoints.futures` | | 债券专题 | 9 | `ftshare.apis.bond` | `ftshare.endpoints.bond` | | 宏观经济 | 23 | `ftshare.apis.economic` | `ftshare.endpoints.economic` | | 大模型语料 | 7 | `ftshare.apis.llm_corpus` | `ftshare.endpoints.llm_corpus` | @@ -197,6 +197,7 @@ | [`index_realtime_minute_kline`](#api-index-realtime-minute-kline) | 指数实时分钟K线 | `GET` | `api/v4/market/data/index-realtime-minute-kline` | `symbols` | `指数实时分钟K线.md` | | [`index_weight_list`](#api-index-weight-list) | 指数权重列表 | `GET` | `api/v1/market/data/index/index_weight` | `index_code`, `date`, `page`, `page_size` | `指数权重列表.md` | | [`index_weight_summary`](#api-index-weight-summary) | 指数权重汇总 | `GET` | `api/v1/market/data/index/index_weight_summary` | `index_code`, `page`, `page_size` | `指数权重汇总.md` | +| [`sw_index_daily_quotes`](#api-sw-index-daily-quotes) | 申万指数日行情 | `GET` | `api/v1/market/data/sw-index/daily-quotes` | `index_code`, `trade_date`, `start_date`, `end_date`, `index_type`, `page`, `page_size` | `申万指数日行情.md` | | [`sw_industry_constituent_history`](#api-sw-industry-constituent-history) | 申万行业成份股历史 | `GET` | `api/v1/market/data/sw-industry/constituent-history` | `industry_code` | `申万行业成份股历史.md` | | [`sw_industry_daily_metrics`](#api-sw-industry-daily-metrics) | 申万行业日度指标 | `GET` | `api/v1/market/data/sw-industry/daily-metrics` | `level`, `start_date`, `end_date`, `industry_code`, `page`, `page_size` | `申万行业日度指标.md` | | [`sw_industry_overview`](#api-sw-industry-overview) | 申万行业总览 | `GET` | `api/v1/market/data/sw-industry/overview` | `date`, `level`, `page`, `page_size` | `申万行业总览.md` | @@ -263,9 +264,11 @@ | [`fut_settle`](#api-fut-settle) | 期货每日结算参数 | `GET` | `api/v1/market/data/futures/fut-settle` | `ts_code`, `trade_date`, `start_date`, `end_date`, `exchange`, `page`, `page_size` | `期货每日结算参数.md` | | [`fut_weekly_detail`](#api-fut-weekly-detail) | 期货主要品种交易周报 | `GET` | `api/v1/market/data/futures/fut-weekly-detail` | `week`, `prd`, `start_week`, `end_week`, `exchange`, `page`, `page_size` | `期货主要品种交易周报.md` | | [`fut_wsr`](#api-fut-wsr) | 期货仓单日报 | `GET` | `api/v1/market/data/futures/fut-wsr` | `trade_date`, `start_date`, `end_date`, `symbol`, `exchange`, `page`, `page_size` | `期货仓单日报.md` | +| [`futures_daily_kline`](#api-futures-daily-kline) | 期货官方日K与9999主连 | `GET` | `api/v1/market/data/futures/daily-kline` | `symbol`, `trade_date`, `start_date`, `end_date`, `rule_version`, `page`, `page_size` | `期货官方日K与9999主连.md` | | [`futures_kline`](#api-futures-kline) | 期货合约历史K线 | `GET` | `api/v1/market/data/futures/kline` | `symbol`, `interval`, `start`, `end`, `limit` | `期货合约历史K线.md` | | [`futures_kline_batch`](#api-futures-kline-batch) | 批量期货合约历史K线 | `GET` | `api/v2/market/data/futures/kline/batch` | `symbols`, `interval`, `start`, `end`, `limit` | `批量期货合约历史K线.md` | | [`futures_minutes`](#api-futures-minutes) | 期货历史分钟K线 | `GET` | `api/v2/market/data/futures_minutes` | `symbol`, `symbols`, `interval`, `start`, `end`, `limit` | `期货历史分钟K线.md` | +| [`futures_minutes_single`](#api-futures-minutes-single) | 期货历史分钟K线单合约 | `GET` | `api/v2/market/data/futures_minutes/single` | `symbol`, `interval`, `start`, `end`, `limit` | `期货历史分钟K线单合约.md` | | [`futures_minutes_realtime`](#api-futures-minutes-realtime) | 期货实时分钟K线 | `GET` | `api/v4/market/data/futures_minutes/realtime` | `symbols` | `期货实时分钟K线.md` | | [`futures_realtime_day_kline`](#api-futures-realtime-day-kline) | 期货实时日K线 | `GET` | `api/v4/market/data/futures-realtime-day-kline` | `symbols` | `期货实时日K线.md` | | [`futures_nanhua_index_kline`](#api-futures-nanhua-index-kline) | 南华期货指数日K线 | `GET` | `api/v1/market/data/futures/nanhua-index-kline` | `code`, `trade_date`, `start_date`, `end_date`, `page`, `page_size` | `南华期货指数日K线.md` | @@ -1786,7 +1789,7 @@ Returns: ```text 盘前数据. -Endpoint: ``api/v1/market/data/stk-premarket``. +Endpoint: ``api/v2/market/data/stk-premarket``. Method: ``GET``. Documented endpoint: ``stk_premarket``. @@ -3893,6 +3896,45 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

sw_index_daily_quotes

+ +- 接口名称:申万指数日行情 +- HTTP:`GET` +- Path:`api/v1/market/data/sw-index/daily-quotes` +- 参数:`index_code`, `trade_date`, `start_date`, `end_date`, `index_type`, `page`, `page_size` +- 来源文档:`申万指数日行情.md` +- 原始接口:`sw_index_daily_quotes` + +```text +申万指数日行情. + +Endpoint: ``api/v1/market/data/sw-index/daily-quotes``. +Method: ``GET``. +Documented endpoint: ``sw_index_daily_quotes``. + +Args: + index_code: 申万指数代码,如 ``801001``;也可带 ``.SI`` 后缀,如 ``801001.SI``,后缀不区分大小写 (type: string; required: N). + trade_date: 单个交易日 ``YYYYMMDD``,用于查询当日全市场截面;与 ``start_date``/``end_date`` 互斥 (type: string; required: N). + start_date: 起始日期 ``YYYYMMDD``,包含当天;不传 ``trade_date`` 时必填,且需与 ``end_date`` 同时提供 (type: string; required: N). + end_date: 截止日期 ``YYYYMMDD``,包含当天;不传 ``trade_date`` 时必填,且需与 ``start_date`` 同时提供 (type: string; required: N). + index_type: 指数分类,可取 ``一级行业`` / ``二级行业`` / ``三级行业`` / ``市场表征`` / ``风格指数`` / ``量化策略`` / ``新三板`` / ``大类风格``;空串视同未传 (type: string; required: N). + page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set. + page_size: Rows per page, default 50. The SDK validates this against the endpoint-specific maximum of 200. + limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit. + all_pages: Fetch and combine pages until the server reports the last page. + max_pages: Optional safety cap for ``all_pages``. + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + +Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``。服务端 + 数值字段以字符串返回,``trade_date`` 为 ``YYYY-MM-DD``。 +``` +

sw_industry_constituent_history

- 接口名称:申万行业成份股历史 @@ -4892,7 +4934,7 @@ Documented endpoint: ``get_china_futures_base_data_handler``. Args: trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N). - symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N). + symbol: 不带交易所后缀的合约代码,如 ``CU2609``;请求不区分大小写;CZCE 真实合约必须使用四位年份代码(如 ``AP2612``);不传或空表示该日全部 (type: string; required: N). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -4990,7 +5032,7 @@ Method: ``GET``. Documented endpoint: ``ft_limit``. Args: - ts_code: 合约代码,例如 `A2609.DCE`、`CU2608.SHF`。 (type: string; required: N). + ts_code: 不带交易所后缀的合约代码,如 ``A2609``、``CU2608``;请求不区分大小写并兼容 Tushare 短后缀,响应统一返回完整交易所后缀 (type: string; required: N). trade_date: 单个交易日,格式 `YYYYMMDD`;不能与日期区间同时使用。`trade_date` 与 `start_date`+`end_date` 至少提供一组。 (type: integer; required: N). start_date: 开始交易日,格式 `YYYYMMDD`;须与 `end_date` 同时提供。 (type: integer; required: N). end_date: 结束交易日,格式 `YYYYMMDD`;须与 `start_date` 同时提供。 (type: integer; required: N). @@ -5029,7 +5071,7 @@ Method: ``GET``. Documented endpoint: ``fut_settle``. Args: - ts_code: 合约代码。 (type: string; required: N). + ts_code: 不带交易所后缀的合约代码,如 ``A2609``;请求不区分大小写,CZCE 真实合约必须使用四位年份代码(如 ``AP2612``) (type: string; required: N). trade_date: 单个交易日,格式 `YYYYMMDD`;不能与日期区间同时使用。 (type: integer; required: N). start_date: 开始交易日,格式 `YYYYMMDD`;必须与 `end_date` 同时传入,且日期区间跨度不超过 31 天。 (type: integer; required: N). end_date: 结束交易日,格式 `YYYYMMDD`;必须与 `start_date` 同时传入。 (type: integer; required: N). @@ -5126,6 +5168,44 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

futures_daily_kline

+ +- 接口名称:期货官方日K与9999主连 +- HTTP:`GET` +- Path:`api/v1/market/data/futures/daily-kline` +- 参数:`symbol`, `trade_date`, `start_date`, `end_date`, `rule_version`, `page`, `page_size` +- 来源文档:`期货官方日K与9999主连.md` +- 原始接口:`futures_daily_kline` + +```text +期货官方日K与9999主连. + +Endpoint: ``api/v1/market/data/futures/daily-kline``. +Method: ``GET``. +Documented endpoint: ``futures_daily_kline``. + +Args: + symbol: 期货合约或 9999 主连代码,交易所后缀可带可不带,如 ``A2405``、``A2405.DCE``、``A9999``、``A9999.DCE``;不带后缀时由服务端推断交易所。CZCE 真实合约必须使用四位年份代码(如 ``AP2612.CZCE``),三位代码返回成功空结果 (type: string; required: Y). + trade_date: 单个交易日 ``YYYYMMDD``;与 ``start_date``、``end_date`` 二选一 (type: string; required: N). + start_date: 范围查询起始交易日 ``YYYYMMDD``;必须与 ``end_date`` 成对传入,不能与 ``trade_date`` 同时传入 (type: string; required: N). + end_date: 范围查询结束交易日 ``YYYYMMDD``;必须与 ``start_date`` 成对传入,且不能早于 ``start_date`` (type: string; required: N). + rule_version: 9999 主连映射规则版本,默认 ``v1``;查询真实合约时无需传入 (type: string; required: N). + page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set. + page_size: Rows per page, default 50. The SDK validates this against the endpoint-specific maximum of 500. + limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit. + all_pages: Fetch and combine pages until the server reports the last page. + max_pages: Optional safety cap for ``all_pages``. + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + +Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. +``` +

futures_kline

- 接口名称:期货合约历史K线 @@ -5175,7 +5255,7 @@ Method: ``GET``. Documented endpoint: ``futures_kline_batch``. Args: - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数 (type: string; required: Y). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). interval: K 线周期,默认 ``daily`` (type: string; required: N). start: 起始时间戳,单位毫秒 (type: integer; required: N). end: 结束时间戳,单位毫秒,不能单独传 (type: integer; required: N). @@ -5207,12 +5287,12 @@ Method: ``GET``. Documented endpoint: ``futures_minutes``. Args: - symbol: 单个期货合约代码,带交易所短后缀;与 ``symbols`` 二选一 (type: string; required: N). - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数;与 ``symbol`` 二选一 (type: string; required: N). + symbol: 单个期货合约代码,不带交易所后缀,如 ``A2611``;请求不区分大小写,CZCE 真实合约必须使用四位年份代码;与 ``symbols`` 二选一 (type: string; required: N). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码;与 ``symbol`` 二选一 (type: string; required: N). interval: 分钟周期,默认 ``1min`` (type: string; required: N). start: 起始时间戳,单位毫秒;必填 (type: integer; required: Y). end: 结束时间戳,单位毫秒;必填,不能单独传 (type: integer; required: Y). - limit: 返回条数上限,范围 1~1000 (type: integer; required: N). + limit: 返回条数上限,范围 1~10000,批量时按每个合约分别限制 (type: integer; required: N). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -5223,6 +5303,39 @@ Returns: ``as_dataframe=False``, or raw JSON when ``raw=True``. ``` +

futures_minutes_single

+ +- 接口名称:期货历史分钟K线单合约 +- HTTP:`GET` +- Path:`api/v2/market/data/futures_minutes/single` +- 参数:`symbol`, `interval`, `start`, `end`, `limit` +- 来源文档:`期货历史分钟K线单合约.md` +- 原始接口:`futures_minutes_single` + +```text +期货历史分钟K线单合约. + +Endpoint: ``api/v2/market/data/futures_minutes/single``. +Method: ``GET``. +Documented endpoint: ``futures_minutes_single``. + +Args: + symbol: 单个期货合约代码,使用不带交易所后缀的裸代码,如 ``A2611``,不区分大小写;只接受 ``symbol``,传 ``symbols`` 会返回 HTTP 400 (type: string; required: Y). + interval: 分钟周期,默认 ``1min``;可选 ``1min`` / ``5min`` / ``15min`` / ``30min`` / ``60min`` (type: string; required: N). + start: 起始时间戳,单位毫秒,闭区间,按北京时间解释;必须与 ``end`` 同时传入 (type: integer; required: Y). + end: 结束时间戳,单位毫秒,闭区间;与 ``start`` 的时间跨度不得超过 3 个自然日(含首尾) (type: integer; required: Y). + limit: 返回的最新 K 线条数,默认 500,范围 1~10000 (type: integer; required: N). + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + +Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, or raw JSON when ``raw=True``。``data.total`` + 为查询范围内聚合后的总记录数,不受 ``limit`` 截断。 +``` +

futures_minutes_realtime

- 接口名称:期货实时分钟K线 @@ -5240,7 +5353,7 @@ Method: ``GET``. Documented endpoint: ``futures_minutes_realtime``. Args: - symbols: 逗号分隔的期货合约代码列表,1~20 个 (type: string; required: Y). + symbols: 逗号分隔的不带交易所后缀的期货合约代码列表,1~20 个;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -5305,7 +5418,7 @@ Method: ``GET``. Documented endpoint: ``futures_realtime_day_kline``. Args: - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数 (type: string; required: Y). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. diff --git a/pyproject.toml b/pyproject.toml index 6e331c0..2b2866d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "ftshare" -version = "1.0.12" +version = "1.0.13" description = "Python SDK for FTShare market data APIs." readme = "README.md" requires-python = ">=3.9" diff --git a/src/ftshare/apis/futures.py b/src/ftshare/apis/futures.py index 81f5fd9..a29a2d8 100644 --- a/src/ftshare/apis/futures.py +++ b/src/ftshare/apis/futures.py @@ -173,7 +173,7 @@ def china_futures_base_data( Args: trade_date: 交易日 YYYYMMDD;不传则使用前一交易日(CST) (type: int; required: N). - symbol: 合约全码如 A2605.DCE;大小写不敏感;不传或空表示该日全部 (type: string; required: N). + symbol: 不带交易所后缀的合约代码,如 ``CU2609``;请求不区分大小写;CZCE 真实合约必须使用四位年份代码(如 ``AP2612``);不传或空表示该日全部 (type: string; required: N). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -260,7 +260,7 @@ def eastmoney_futures_position( Args: exchange: 交易所代码:shfe / dce / czce / cffex / ine / gfe (type: string; required: N). variety_code: 品种代码,如 cu / au / al / IF (type: string; required: N). - contract_code: 合约代码,如 CU2607 / AU2608 (type: string; required: N). + contract_code: 合约代码,如 CU2607 / AU2608;请求不区分大小写,CZCE 真实合约使用四位年份代码 (type: string; required: N). trade_date: 交易日 YYYYMMDD;与 start_date/end_date 互斥 (type: string; required: N). start_date: 区间起始日 YYYYMMDD;需与 end_date 同时提供 (type: string; required: N). end_date: 区间结束日 YYYYMMDD;需与 start_date 同时提供 (type: string; required: N). @@ -317,12 +317,12 @@ def futures_minutes( Documented endpoint: ``futures_minutes``. Args: - symbol: 单个期货合约代码,带交易所短后缀;与 ``symbols`` 二选一 (type: string; required: N). - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数;与 ``symbol`` 二选一 (type: string; required: N). + symbol: 单个期货合约代码,不带交易所后缀,如 ``A2611``;请求不区分大小写,CZCE 真实合约必须使用四位年份代码;与 ``symbols`` 二选一 (type: string; required: N). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码;与 ``symbol`` 二选一 (type: string; required: N). interval: 分钟周期,默认 ``1min`` (type: string; required: N). start: 起始时间戳,单位毫秒;必填 (type: integer; required: Y). end: 结束时间戳,单位毫秒;必填,不能单独传 (type: integer; required: Y). - limit: 返回条数上限,范围 1~1000 (type: integer; required: N). + limit: 返回条数上限,范围 1~10000,批量时按每个合约分别限制 (type: integer; required: N). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -349,6 +349,125 @@ def futures_minutes( **request_params, ) + def futures_minutes_single( + self, + symbol: Any | None = None, + interval: Any | None = None, + start: Any | None = None, + end: Any | None = None, + limit: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """期货历史分钟K线单合约. + + Endpoint: ``api/v2/market/data/futures_minutes/single``. + Method: ``GET``. + Documented endpoint: ``futures_minutes_single``. + + Args: + symbol: 单个期货合约代码,使用不带交易所后缀的裸代码,如 ``A2611``,不区分大小写;只接受 ``symbol``,传 ``symbols`` 会返回 HTTP 400 (type: string; required: Y). + interval: 分钟周期,默认 ``1min``;可选 ``1min`` / ``5min`` / ``15min`` / ``30min`` / ``60min`` (type: string; required: N). + start: 起始时间戳,单位毫秒,闭区间,按北京时间解释;必须与 ``end`` 同时传入 (type: integer; required: Y). + end: 结束时间戳,单位毫秒,闭区间;与 ``start`` 的时间跨度不得超过 3 个自然日(含首尾) (type: integer; required: Y). + limit: 返回的最新 K 线条数,默认 500,范围 1~10000 (type: integer; required: N). + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + + Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, or raw JSON when ``raw=True``。``data.total`` + 为查询范围内聚合后的总记录数,不受 ``limit`` 截断。 + """ + request_params = { + 'symbol': symbol, + 'interval': interval, + 'start': start, + 'end': end, + 'limit': limit, + } + request_params.update(kwargs) + return self._call_endpoint( + 'futures_minutes_single', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def futures_daily_kline( + self, + symbol: Any | None = None, + trade_date: Any | None = None, + start_date: Any | None = None, + end_date: Any | None = None, + rule_version: Any | None = None, + page: int | None = None, + page_size: int | None = None, + limit: int | None = None, + all_pages: bool = False, + max_pages: int | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """期货官方日K与9999主连. + + Endpoint: ``api/v1/market/data/futures/daily-kline``. + Method: ``GET``. + Documented endpoint: ``futures_daily_kline``. + + Args: + symbol: 期货合约或 9999 主连代码,交易所后缀可带可不带,如 ``A2405``、``A2405.DCE``、``A9999``、``A9999.DCE``;不带后缀时由服务端推断交易所。CZCE 真实合约必须使用四位年份代码(如 ``AP2612.CZCE``),三位代码返回成功空结果 (type: string; required: Y). + trade_date: 单个交易日 ``YYYYMMDD``;与 ``start_date``、``end_date`` 二选一 (type: string; required: N). + start_date: 范围查询起始交易日 ``YYYYMMDD``;必须与 ``end_date`` 成对传入,不能与 ``trade_date`` 同时传入 (type: string; required: N). + end_date: 范围查询结束交易日 ``YYYYMMDD``;必须与 ``start_date`` 成对传入,且不能早于 ``start_date`` (type: string; required: N). + rule_version: 9999 主连映射规则版本,默认 ``v1``;查询真实合约时无需传入 (type: string; required: N). + page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set. + page_size: Rows per page, default 50. The SDK validates this against the endpoint-specific maximum of 500. + limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit. + all_pages: Fetch and combine pages until the server reports the last page. + max_pages: Optional safety cap for ``all_pages``. + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + + Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. + """ + request_params = { + 'symbol': symbol, + 'trade_date': trade_date, + 'start_date': start_date, + 'end_date': end_date, + 'rule_version': rule_version, + } + request_params.update(kwargs) + endpoint = ENDPOINTS['futures_daily_kline'] + return self.get_paginated( + endpoint.path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + max_page_size=endpoint.max_page_size, + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def futures_kline( self, symbol: Any | None = None, @@ -369,7 +488,7 @@ def futures_kline( Documented endpoint: ``futures_kline``. Args: - symbol: 期货合约代码 (type: string; required: Y). + symbol: 不带交易所后缀的期货合约代码,如 ``A2611``;请求不区分大小写,CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). interval: K线周期,默认 ``daily`` (type: string; required: N). start: 起始时间戳,单位毫秒 (type: integer; required: N). end: 结束时间戳,单位毫秒,不能单独传 (type: integer; required: N). @@ -419,7 +538,7 @@ def futures_kline_batch( Documented endpoint: ``futures_kline_batch``. Args: - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数 (type: string; required: Y). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). interval: K 线周期,默认 ``daily`` (type: string; required: N). start: 起始时间戳,单位毫秒 (type: integer; required: N). end: 结束时间戳,单位毫秒,不能单独传 (type: integer; required: N). @@ -465,7 +584,7 @@ def futures_minutes_realtime( Documented endpoint: ``futures_minutes_realtime``. Args: - symbols: 逗号分隔的期货合约代码列表,1~20 个 (type: string; required: Y). + symbols: 逗号分隔的不带交易所后缀的期货合约代码列表,1~20 个;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -501,7 +620,7 @@ def futures_realtime_day_kline( Documented endpoint: ``futures_realtime_day_kline``. Args: - symbols: 1~20 个期货合约代码;使用逗号分隔,兼容重复参数 (type: string; required: Y). + symbols: 1~20 个不带交易所后缀的期货合约代码;使用逗号分隔,兼容重复参数;CZCE 真实合约必须使用四位年份代码 (type: string; required: Y). raw: Return the decoded JSON payload without tabular extraction. fields: Optional field list or comma-separated field string applied after extraction. as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. @@ -670,7 +789,7 @@ def fut_settle( Documented endpoint: ``fut_settle``. Args: - ts_code: 合约代码。 (type: string; required: N). + ts_code: 不带交易所后缀的合约代码,如 ``A2609``;请求不区分大小写,CZCE 真实合约必须使用四位年份代码(如 ``AP2612``) (type: string; required: N). trade_date: 单个交易日,格式 `YYYYMMDD`;不能与日期区间同时使用。 (type: integer; required: N). start_date: 开始交易日,格式 `YYYYMMDD`;必须与 `end_date` 同时传入,且日期区间跨度不超过 31 天。 (type: integer; required: N). end_date: 结束交易日,格式 `YYYYMMDD`;必须与 `start_date` 同时传入。 (type: integer; required: N). @@ -734,7 +853,7 @@ def ft_limit( Documented endpoint: ``ft_limit``. Args: - ts_code: 合约代码,例如 `A2609.DCE`、`CU2608.SHF`。 (type: string; required: N). + ts_code: 不带交易所后缀的合约代码,如 ``A2609``、``CU2608``;请求不区分大小写并兼容 Tushare 短后缀,响应统一返回完整交易所后缀 (type: string; required: N). trade_date: 单个交易日,格式 `YYYYMMDD`;不能与日期区间同时使用。`trade_date` 与 `start_date`+`end_date` 至少提供一组。 (type: integer; required: N). start_date: 开始交易日,格式 `YYYYMMDD`;须与 `end_date` 同时提供。 (type: integer; required: N). end_date: 结束交易日,格式 `YYYYMMDD`;须与 `start_date` 同时提供。 (type: integer; required: N). diff --git a/src/ftshare/apis/index.py b/src/ftshare/apis/index.py index c8840f1..98d27a1 100644 --- a/src/ftshare/apis/index.py +++ b/src/ftshare/apis/index.py @@ -486,6 +486,73 @@ def sw_index_history_minutes(self, index_code: Any | None = None, start_date: An params.update(kwargs) return self.get_paginated(ENDPOINTS['sw_index_history_minutes'].path, page=page, page_size=page_size, limit=limit, all_pages=all_pages, max_pages=max_pages, raw=raw, fields=fields, as_dataframe=as_dataframe, **params) + def sw_index_daily_quotes( + self, + index_code: Any | None = None, + trade_date: Any | None = None, + start_date: Any | None = None, + end_date: Any | None = None, + index_type: Any | None = None, + page: int | None = None, + page_size: int | None = None, + limit: int | None = None, + all_pages: bool = False, + max_pages: int | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """申万指数日行情. + + Endpoint: ``api/v1/market/data/sw-index/daily-quotes``. + Method: ``GET``. + Documented endpoint: ``sw_index_daily_quotes``. + + Args: + index_code: 申万指数代码,如 ``801001``;也可带 ``.SI`` 后缀,如 ``801001.SI``,后缀不区分大小写 (type: string; required: N). + trade_date: 单个交易日 ``YYYYMMDD``,用于查询当日全市场截面;与 ``start_date``/``end_date`` 互斥 (type: string; required: N). + start_date: 起始日期 ``YYYYMMDD``,包含当天;不传 ``trade_date`` 时必填,且需与 ``end_date`` 同时提供 (type: string; required: N). + end_date: 截止日期 ``YYYYMMDD``,包含当天;不传 ``trade_date`` 时必填,且需与 ``start_date`` 同时提供 (type: string; required: N). + index_type: 指数分类,可取 ``一级行业`` / ``二级行业`` / ``三级行业`` / ``市场表征`` / ``风格指数`` / ``量化策略`` / ``新三板`` / ``大类风格``;空串视同未传 (type: string; required: N). + page: Page number, starting from 1. If omitted, the server default is used unless ``limit`` or ``all_pages`` is set. + page_size: Rows per page, default 50. The SDK validates this against the endpoint-specific maximum of 200. + limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit. + all_pages: Fetch and combine pages until the server reports the last page. + max_pages: Optional safety cap for ``all_pages``. + raw: Return the decoded JSON payload without tabular extraction. + fields: Optional field list or comma-separated field string applied after extraction. + as_dataframe: Return a pandas ``DataFrame`` by default; set to ``False`` for Python rows. + **kwargs: Extra request parameters forwarded unchanged. Useful when the service adds parameters before the SDK is regenerated. + + Returns: + A pandas ``DataFrame`` by default, Python rows when + ``as_dataframe=False``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``。服务端 + 数值字段以字符串返回,``trade_date`` 为 ``YYYY-MM-DD``。 + """ + request_params = { + 'index_code': index_code, + 'trade_date': trade_date, + 'start_date': start_date, + 'end_date': end_date, + 'index_type': index_type, + } + request_params.update(kwargs) + return self.get_paginated( + ENDPOINTS['sw_index_daily_quotes'].path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def index_minutes_batch(self, symbols: Any | None = None, interval_value: Any | None = None, since_ts_millis: Any | None = None, until_ts_millis: Any | None = None, limit: Any | None = None, *, raw: bool = False, fields: Sequence[str] | str | None = None, as_dataframe: bool = True, **kwargs: Any) -> Any: """批量指数历史分钟行情.""" params = {'symbols': symbols_to_csv_string(symbols), 'interval_value': interval_value, 'since_ts_millis': since_ts_millis, 'until_ts_millis': until_ts_millis, 'limit': limit} diff --git a/src/ftshare/apis/stock.py b/src/ftshare/apis/stock.py index bbfeba9..ee05203 100644 --- a/src/ftshare/apis/stock.py +++ b/src/ftshare/apis/stock.py @@ -2840,7 +2840,7 @@ def stk_premarket( ) -> Any: """盘前数据. - Endpoint: ``api/v1/market/data/stk-premarket``. + Endpoint: ``api/v2/market/data/stk-premarket``. Method: ``GET``. Documented endpoint: ``stk_premarket``. diff --git a/src/ftshare/endpoints/futures.py b/src/ftshare/endpoints/futures.py index ff71497..a8466d8 100644 --- a/src/ftshare/endpoints/futures.py +++ b/src/ftshare/endpoints/futures.py @@ -34,6 +34,21 @@ 'original_api': 'futures_minutes', 'params': ('symbol', 'symbols', 'interval', 'start', 'end', 'limit'), }, + 'futures_minutes_single': { + 'path': 'api/v2/market/data/futures_minutes/single', + 'title': '期货历史分钟K线单合约', + 'doc_file': '期货历史分钟K线单合约.md', + 'original_api': 'futures_minutes_single', + 'params': ('symbol', 'interval', 'start', 'end', 'limit'), + }, + 'futures_daily_kline': { + 'path': 'api/v1/market/data/futures/daily-kline', + 'title': '期货官方日K与9999主连', + 'doc_file': '期货官方日K与9999主连.md', + 'original_api': 'futures_daily_kline', + 'params': ('symbol', 'trade_date', 'start_date', 'end_date', 'rule_version', 'page', 'page_size'), + 'max_page_size': 500, + }, 'futures_kline': { 'path': 'api/v1/market/data/futures/kline', 'title': '期货合约历史K线', diff --git a/src/ftshare/endpoints/index.py b/src/ftshare/endpoints/index.py index 515ad23..04be09b 100644 --- a/src/ftshare/endpoints/index.py +++ b/src/ftshare/endpoints/index.py @@ -104,6 +104,13 @@ 'original_api': 'sw_index_history_minutes', 'params': ('index_code', 'start_date', 'end_date', 'page', 'page_size'), }, + 'sw_index_daily_quotes': { + 'path': 'api/v1/market/data/sw-index/daily-quotes', + 'title': '申万指数日行情', + 'doc_file': '申万指数日行情.md', + 'original_api': 'sw_index_daily_quotes', + 'params': ('index_code', 'trade_date', 'start_date', 'end_date', 'index_type', 'page', 'page_size'), + }, 'index_minutes_batch': { 'path': 'api/v2/market/data/index_minutes/batch', 'title': '批量指数历史分钟行情', diff --git a/tests/endpoint_cases.py b/tests/endpoint_cases.py index 4153107..fa44523 100644 --- a/tests/endpoint_cases.py +++ b/tests/endpoint_cases.py @@ -36,8 +36,8 @@ "con_name": "平安银行", "cont": "1", "company_name": "平安银行", - "contract": "A2609.DCE", - "contract_code": "A2609.DCE", + "contract": "A2609", + "contract_code": "A2609", "contract_multiplier": 10, "currency": "USD", "curve_name": "中债国债收益率曲线", @@ -185,7 +185,7 @@ "etf_net_value": {"etf_code": "510300", "nav_date": 20260909, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "etf_pcf_infos": {"symbol": "510300.SH", "trade_date": "20260909", "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "etf_share": {"etf_code": "510300", "stati_perd": "日", "start_date": None, "end_date": None, "page": 1, "page_size": 5}, - "ft_limit": {"ts_code": "A2609.DCE", "trade_date": "20260717", "start_date": None, "end_date": None, "cont": "A", "exchange": "DCE", "page": 1, "page_size": 5}, + "ft_limit": {"ts_code": "A2609", "trade_date": "20260717", "start_date": None, "end_date": None, "cont": "A", "exchange": "DCE", "page": 1, "page_size": 5}, "fund_index_fund": {"index_code": "000300", "scope": "all"}, "fund_asset_allocation": {"fund_code": "000001", "report_date": 20260331, "publish_date": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "fund_holder_structure": {"fund_code": "000001", "report_type": "年度报告", "start_date": None, "end_date": None}, @@ -193,14 +193,14 @@ "fund_net_value": {"fund_code": "000001", "nav_date": 20260717, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "fund_net_value_performance": {"fund_code": "000001", "stat_date": "20260717", "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "fund_portfolio": {"fund_code": "000001", "report_date": 20260331, "publish_date": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, - "fut_settle": {"ts_code": "A2609.DCE", "trade_date": "20260717", "start_date": None, "end_date": None, "exchange": "DCE", "page": 1, "page_size": 5}, + "fut_settle": {"ts_code": "A2609", "trade_date": "20260717", "start_date": None, "end_date": None, "exchange": "DCE", "page": 1, "page_size": 5}, "fut_weekly_detail": {"week": "202629", "prd": "CU,AL", "start_week": None, "end_week": None, "exchange": "DCE", "page": 1, "page_size": 5}, "fut_wsr": {"trade_date": "20260717", "start_date": None, "end_date": None, "symbol": "CU", "exchange": "DCE", "page": 1, "page_size": 5}, - "futures_kline": {"symbol": "A2609.DCE", "interval": "daily", "start": 1784048400000, "end": 1784050200000, "limit": 5}, - "futures_kline_batch": {"symbols": "A2609.DCE", "interval": "daily", "start": 1784048400000, "end": 1784050200000, "limit": 5}, - "futures_minutes": {"symbol": "A2609.DCE", "symbols": None, "interval": "1min", "start": 1784048400000, "end": 1784050200000, "limit": 5}, - "futures_minutes_realtime": {"symbols": "A2609.DCE"}, - "futures_realtime_day_kline": {"symbols": "A2609.DCE"}, + "futures_kline": {"symbol": "A2609", "interval": "daily", "start": 1784048400000, "end": 1784050200000, "limit": 5}, + "futures_kline_batch": {"symbols": "A2609", "interval": "daily", "start": 1784048400000, "end": 1784050200000, "limit": 5}, + "futures_minutes": {"symbol": "A2609", "symbols": None, "interval": "1min", "start": 1784048400000, "end": 1784050200000, "limit": 5}, + "futures_minutes_realtime": {"symbols": "A2609"}, + "futures_realtime_day_kline": {"symbols": "A2609"}, "hk_candlesticks": {"trade_code": "00700.HK", "interval_unit": "day", "until_date": "20260717", "since_date": "20260715", "interval_value": 1, "limit": 5, "adjust_kind": "forward"}, "index_candlesticks": {"symbol": "000300.SH", "interval_unit": "day", "adjust_kind": "forward", "since_ts_millis": 1784048400000, "until_ts_millis": 1784050200000, "limit": 5}, "index_candlesticks_batch": {"symbols": "000300.SH", "interval_unit": "day", "adjust_kind": "forward", "since_ts_millis": 1784048400000, "until_ts_millis": 1784050200000, "limit": 5}, @@ -309,11 +309,13 @@ def _millis(day: str, time: str = "00:00:00") -> int: "fund_share": {"fund_code": "000001", "stati_perd": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "fut_weekly_detail": {"week": "202629", "prd": None, "start_week": None, "end_week": None, "exchange": None, "page": 1, "page_size": 5}, "fut_wsr": {"trade_date": "20260717", "start_date": None, "end_date": None, "symbol": None, "exchange": None, "page": 1, "page_size": 5}, - "futures_kline": {"symbol": "A2609.DCE", "interval": "daily", "start": _millis("2026-05-01"), "end": _millis("2026-07-17", "15:00:00"), "limit": 5}, - "futures_kline_batch": {"symbols": "A2609.DCE", "interval": "daily", "start": _millis("2026-05-01"), "end": _millis("2026-07-17", "15:00:00"), "limit": 5}, - "futures_minutes": {"symbol": "A2609.DCE", "symbols": None, "interval": "1min", "start": _millis("2026-07-17", "09:30:00"), "end": _millis("2026-07-17", "10:00:00"), "limit": 5}, - "futures_minutes_realtime": {"symbols": "A2609.DCE"}, - "futures_realtime_day_kline": {"symbols": "A2609.DCE"}, + "futures_kline": {"symbol": "A2609", "interval": "daily", "start": _millis("2026-05-01"), "end": _millis("2026-07-17", "15:00:00"), "limit": 5}, + "futures_kline_batch": {"symbols": "A2609", "interval": "daily", "start": _millis("2026-05-01"), "end": _millis("2026-07-17", "15:00:00"), "limit": 5}, + "futures_daily_kline": {"symbol": "A9999.DCE", "trade_date": None, "start_date": "20261101", "end_date": "20261117", "rule_version": "v1", "page": 1, "page_size": 5}, + "futures_minutes": {"symbol": "A2609", "symbols": None, "interval": "1min", "start": _millis("2026-07-17", "09:30:00"), "end": _millis("2026-07-17", "10:00:00"), "limit": 5}, + "futures_minutes_single": {"symbol": "A2611.DCE", "interval": "5min", "start": _millis("2026-07-17", "09:30:00"), "end": _millis("2026-07-17", "10:00:00"), "limit": 5}, + "futures_minutes_realtime": {"symbols": "A2609"}, + "futures_realtime_day_kline": {"symbols": "A2609"}, "futures_nanhua_index_kline": {"code": "AG_NH", "trade_date": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "global_index_daily_kline": {"secid": "100.HSI", "start_date": "20260701", "end_date": "20260717", "limit": 5}, "kline_pattern_annotations": {"date": "20260918", "symbol": None, "pattern": None, "page": 1, "page_size": 5}, @@ -331,6 +333,7 @@ def _millis(day: str, time: str = "00:00:00") -> int: "stock_share": {"stock_code": "920476.BJ", "date": "20261012", "date_type": "end_date", "page": 1, "page_size": 5}, "stock_ggmx": {"stock_code": None, "change_direction": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, "stock_minute_seal": {"trade_date": "20260923", "symbol": "000560.SZ"}, + "sw_index_daily_quotes": {"index_code": "801001", "trade_date": None, "start_date": "20261101", "end_date": "20261111", "index_type": None, "page": 1, "page_size": 5}, "sw_industry_constituent_history": {"industry_code": "801010.SI"}, "sw_industry_daily_metrics": {"level": None, "start_date": "20260901", "end_date": "20260918", "industry_code": "801010.SI", "page": 1, "page_size": 5}, "szse_convertible_bond_directed_trades": {"security_code": None, "trade_date": None, "start_date": None, "end_date": None, "page": 1, "page_size": 5}, diff --git a/tests/test_client.py b/tests/test_client.py index 1454439..4e2926b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -353,6 +353,9 @@ def test_requested_endpoint_api_versions(): "hsi_daily_weight": "api/v1/market/data/hk/hsi-daily-weight", "stk_ah_comparison": "api/v1/market/data/hk/stk-ah-comparison", "sw_index_history_minutes": "api/v1/market/data/sw-index/history-minutes", + "sw_index_daily_quotes": "api/v1/market/data/sw-index/daily-quotes", + "futures_daily_kline": "api/v1/market/data/futures/daily-kline", + "futures_minutes_single": "api/v2/market/data/futures_minutes/single", "index_minutes_batch": "api/v2/market/data/index_minutes/batch", "etf_minutes_batch": "api/v2/market/data/etf_minutes/batch", "etf_announcements": "api/v2/market/data/announcements/etf-announcements", @@ -1970,3 +1973,105 @@ def test_index_fut_depth_unwraps_bare_object_data(): assert result == data assert session.calls[0]["url"] == "https://market.ft.tech/gateway/api/v1/market/data/index-fut/depth" assert session.calls[0]["params"] == {"trade_date": "20261030", "code_prefix": "IF"} + + +def test_futures_daily_kline_forwards_symbol_range_and_allows_page_size_500(): + payload = { + "code": 200, + "message": "success", + "data": { + "items": [ + { + "symbol": "A9999", + "trade_date": 20261117, + "open": 5011.0, + "high": 5040.0, + "low": 4998.0, + "close": 5023.0, + "volume": 233487, + "amount": 11730307300.0, + "open_interest": 342838, + } + ], + "total": 1, + "page": 1, + "page_size": 500, + }, + } + session = FakeSession([FakeResponse(payload=payload)]) + client = FtshareClient(session=session) + + df = client.futures_daily_kline( + symbol="A9999.DCE", + start_date="20261101", + end_date="20261117", + rule_version="v1", + page=1, + page_size=500, + ) + + assert session.calls[0]["url"] == "https://market.ft.tech/gateway/api/v1/market/data/futures/daily-kline" + assert session.calls[0]["params"] == { + "symbol": "A9999.DCE", + "start_date": "20261101", + "end_date": "20261117", + "rule_version": "v1", + "page": 1, + "page_size": 500, + } + assert df["symbol"].tolist() == ["A9999"] + + with pytest.raises(ValueError, match="page_size must be between 1 and 500"): + client.futures_daily_kline(symbol="A9999.DCE", page_size=501) + + +def test_futures_minutes_single_forwards_bare_symbol_and_interval(): + session = FakeSession([FakeResponse(payload={"code": 200, "message": "success", "data": {"items": [], "total": 0}})]) + client = FtshareClient(session=session) + + client.futures_minutes_single( + symbol="A2611", + interval="5min", + start=1791475200000, + end=1791647999000, + limit=500, + as_dataframe=False, + ) + + assert session.calls[0]["url"] == "https://market.ft.tech/gateway/api/v2/market/data/futures_minutes/single" + assert session.calls[0]["params"] == { + "symbol": "A2611", + "interval": "5min", + "start": 1791475200000, + "end": 1791647999000, + "limit": 500, + } + + +def test_sw_index_daily_quotes_forwards_filters_and_extracts_records(): + session = FakeSession([FakeResponse(payload=paginated_records([{"index_code": "801001", "trade_date": "2026-11-02"}]))]) + client = FtshareClient(session=session) + + rows = client.sw_index_daily_quotes( + index_code="801001.SI", + start_date="20261101", + end_date="20261111", + index_type="市场表征", + page=1, + page_size=200, + as_dataframe=False, + ) + + assert session.calls[0]["url"] == "https://market.ft.tech/gateway/api/v1/market/data/sw-index/daily-quotes" + assert session.calls[0]["params"] == { + "index_code": "801001.SI", + "start_date": "20261101", + "end_date": "20261111", + "index_type": "市场表征", + "page": 1, + "page_size": 200, + } + assert rows == [{"index_code": "801001", "trade_date": "2026-11-02"}] + + with pytest.raises(ValueError, match="page_size must be between 1 and 200"): + client.sw_index_daily_quotes(page_size=201)