From 6d836481e9da243191def85f909c74986f74c586 Mon Sep 17 00:00:00 2001 From: zhuhao Date: Mon, 10 Aug 2026 15:25:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=90=8C=E6=AD=A5=20ftshare-doc=20?= =?UTF-8?q?12=20=E7=AF=87=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 11 个公开方法 (217 total): daec_ohlcs, eastmoney_all_board_daily_kline, trading_calendar, report_announcement_list/summary, hsi_daily_weight, futures_eod_price, futures_kline_intraday/latest, member_build_process, member_position_ranking。 - eastmoney_futures_strange 重新指向 eastmoney-futures-strange 龙虎榜端点 (原 alias 至 eastmoney-futures-position 已移除)。 --- docs/API_REFERENCE.md | 437 +++++++++++++++++++++++++++++-- src/ftshare/apis/futures.py | 300 +++++++++++++++++++-- src/ftshare/apis/hk.py | 68 +++++ src/ftshare/apis/stock.py | 253 ++++++++++++++++++ src/ftshare/endpoints/futures.py | 62 ++++- src/ftshare/endpoints/hk.py | 8 + src/ftshare/endpoints/stock.py | 37 +++ tests/endpoint_cases.py | 8 + tests/test_endpoint_contracts.py | 2 +- 9 files changed, 1110 insertions(+), 65 deletions(-) diff --git a/docs/API_REFERENCE.md b/docs/API_REFERENCE.md index 9e85320..8f4d3e9 100644 --- a/docs/API_REFERENCE.md +++ b/docs/API_REFERENCE.md @@ -6,7 +6,7 @@ | 指标 | 数量 | |---|---:| -| SDK 方法总数 | 206 | +| SDK 方法总数 | 217 | ## 专题分布 @@ -14,13 +14,13 @@ | ftshare-doc 专题 | SDK 方法数 | API mixin 模块 | Endpoint 模块 | |---|---:|---|---| -| 股票数据 | 101 | `ftshare.apis.stock` | `ftshare.endpoints.stock` | -| 港股数据 | 14 | `ftshare.apis.hk` | `ftshare.endpoints.hk` | +| 股票数据 | 106 | `ftshare.apis.stock` | `ftshare.endpoints.stock` | +| 港股数据 | 15 | `ftshare.apis.hk` | `ftshare.endpoints.hk` | | 美股数据 | 9 | `ftshare.apis.us` | `ftshare.endpoints.us` | | 指数专题 | 10 | `ftshare.apis.index` | `ftshare.endpoints.index` | | ETF专题 | 10 | `ftshare.apis.etf` | `ftshare.endpoints.etf` | | 公募基金 | 20 | `ftshare.apis.fund` | `ftshare.endpoints.fund` | -| 期货数据 | 9 | `ftshare.apis.futures` | `ftshare.endpoints.futures` | +| 期货数据 | 14 | `ftshare.apis.futures` | `ftshare.endpoints.futures` | | 债券专题 | 4 | `ftshare.apis.bond` | `ftshare.endpoints.bond` | | 宏观经济 | 17 | `ftshare.apis.economic` | `ftshare.endpoints.economic` | | 大模型语料 | 5 | `ftshare.apis.llm_corpus` | `ftshare.endpoints.llm_corpus` | @@ -57,8 +57,10 @@ df = market.baidu_financial_calendar( | [`cashflow`](#api-cashflow) | A股现金流量表 | `GET` | `api/v1/market/data/finance/cashflow` | `stock_code`, `year`, `report_type`, `page`, `page_size` | `A股现金流量表.md` | | [`cashflow_stock_code`](#api-cashflow-stock-code) | 现金流支持股票代码 | `GET` | `api/v1/market/data/finance/cashflow-stock-code` | - | `现金流支持股票代码.md` | | [`company_list`](#api-company-list) | 公司列表 | `GET` | `api/v1/market/data/company-list` | `stock_name`, `stock_code`, `page`, `page_size` | `公司列表.md` | +| [`daec_ohlcs`](#api-daec-ohlcs) | DAEC历史OHLC | `GET` | `api/v1/market/data/daec/history/ohlcs` | `symbol`, `since`, `until`, `interval`, `adjust`, `compat`, `span`, `limit`, `until_ts_ms` | `DAEC历史OHLC.md` | | [`earnings_reports_paginated`](#api-earnings-reports-paginated) | 业绩快报 | `GET` | `api/v1/market/data/finance/stock-performance-express` | `stock_code`, `year`, `report_type`, `page`, `page_size` | `业绩快报.md` | | [`eastmoney_board_constituents`](#api-eastmoney-board-constituents) | 东方财富板块成份股 | `GET` | `api/v1/market/data/eastmoney-board-constituents` | `board_code` | `东方财富板块成份股.md` | +| [`eastmoney_all_board_daily_kline`](#api-eastmoney-all-board-daily-kline) | 东方财富全板块日线OHLC | `GET` | `api/v1/market/data/eastmoney-all-board-daily-ohlc` | `start_date`, `end_date`, `page`, `page_size` | `东方财富全板块日线OHLC.md` | | [`eastmoney_board_daily_kline`](#api-eastmoney-board-daily-kline) | 东方财富板块日线OHLC | `GET` | `api/v1/market/data/eastmoney-board-daily-ohlc` | `board_code`, `start_date`, `end_date`, `page`, `page_size` | `东方财富板块日线OHLC.md` | | [`eastmoney_board_latest_kline`](#api-eastmoney-board-latest-kline) | 东方财富板块最新OHLC | `GET` | `api/v1/market/data/eastmoney-board-latest-ohlc` | `board_code`, `page`, `page_size` | `东方财富板块最新OHLC.md` | | [`eastmoney_concept_boards`](#api-eastmoney-concept-boards) | 东方财富概念板块 | `GET` | `api/v1/market/data/eastmoney-concept-boards` | - | `东方财富概念板块.md` | @@ -90,6 +92,8 @@ df = market.baidu_financial_calendar( | [`price_change`](#api-price-change) | 价格变动 | `GET` | `api/v1/market/data/price/get-price-change` | `stock_code`, `base_date`, `n`, `direction` | `价格变动.md` | | [`risk_warning_stock_quotes`](#api-risk-warning-stock-quotes) | 风险警示股行情 | `GET` | `api/v1/market/data/risk-warning-stocks/quotes` | `date` | `风险警示股行情.md` | | [`risk_warning_stocks`](#api-risk-warning-stocks) | 风险警示股 | `GET` | `api/v1/market/data/risk-warning-stocks` | `date` | `风险警示股.md` | +| [`report_announcement_list`](#api-report-announcement-list) | 报告公告列表 | `GET` | `api/v1/market/data/report-announcements/list` | `date`, `sec_code`, `page`, `page_size` | `报告公告列表.md` | +| [`report_announcement_summary`](#api-report-announcement-summary) | 报告公告摘要 | `GET` | `api/v1/market/data/report-announcements/summary` | `announcement_id` | `报告公告摘要.md` | | [`search`](#api-search) | 标的搜索 | `GET` | `api/v1/market/security/search` | `query`, `limit` | `标的搜索.md` | | [`sh_hk_stock_connect_members`](#api-sh-hk-stock-connect-members) | 沪股通成份 | `GET` | `api/v1/market/data/sh-hk-stock-connect-members` | - | `沪股通成份.md` | | [`southbound`](#api-southbound) | 南向资金交易 | `GET` | `api/v1/market/data/southbound` | `date` | `南向资金交易.md` | @@ -145,6 +149,7 @@ df = market.baidu_financial_calendar( | [`ths_all_board_kline`](#api-ths-all-board-kline) | 同花顺全板块K线 | `GET` | `api/v1/market/data/ths-all-board-kline` | `start_date`, `end_date`, `page`, `page_size` | `同花顺全板块K线.md` | | [`ths_board_kline`](#api-ths-board-kline) | 同花顺板块K线 | `GET` | `api/v1/market/data/ths-board-kline` | `board_code`, `page`, `page_size` | `同花顺板块K线.md` | | [`ths_board_list`](#api-ths-board-list) | 同花顺板块列表 | `GET` | `api/v1/market/data/ths-board-list` | - | `同花顺板块列表.md` | +| [`trading_calendar`](#api-trading-calendar) | 交易日历 | `GET` | `api/v1/market/data/time/trading-calendar` | `market`, `start_date`, `end_date` | `交易日历.md` | | [`xueqiu_rank`](#api-xueqiu-rank) | 雪球股票排名 | `GET` | `api/v1/market/data/xueqiu-rank` | `rank_group`, `period`, `trade_date`, `page`, `page_size` | `雪球股票排名.md` | | [`yzxdr_detail`](#api-yzxdr-detail) | 除权除息明细 | `GET` | `api/v1/market/data/yzxdr-detail` | `year`, `quarter`, `stock_code`, `page`, `page_size` | `除权除息明细.md` | | [`pledge_summary`](#api-pledge-summary) | 股权质押汇总 | `GET` | `api/v1/market/data/pledge/pledge-summary` | `page`, `page_size` | `股权质押汇总.md` | @@ -167,6 +172,7 @@ df = market.baidu_financial_calendar( | [`hk_income_gene`](#api-hk-income-gene) | 港股利润表 | `GET` | `api/v1/market/data/hk/hk-income-gene` | `trade_code`, `year`, `report_type`, `start_date`, `end_date`, `page`, `page_size` | `港股利润表.md` | | [`hk_income_insur`](#api-hk-income-insur) | 港股利润表 | `GET` | `api/v1/market/data/hk/hk-income-insur` | `trade_code`, `year`, `report_type`, `start_date`, `end_date`, `page`, `page_size` | `港股利润表.md` | | [`hk_valuatnanalyd`](#api-hk-valuatnanalyd) | 港股估值分析 | `GET` | `api/v1/market/data/hk/hk-valuatnanalyd` | `trade_code`, `page`, `page_size` | `港股估值分析.md` | +| [`hsi_daily_weight`](#api-hsi-daily-weight) | 恒生指数每日权重 | `GET` | `api/v1/market/data/hk/hsi-daily-weight` | `trade_date`, `start_date`, `end_date`, `index_slug`, `stock_code`, `page`, `page_size` | `恒生指数每日权重.md` | | [`market_cap_hk`](#api-market-cap-hk) | 港股市值 | `GET` | `api/v1/market/data/hk/market-cap-hk` | `trade_code` | `港股市值.md` | ### 美股数据 @@ -245,12 +251,17 @@ df = market.baidu_financial_calendar( | [`china_futures_base_data`](#api-china-futures-base-data) | 中国期货基础数据 | `GET` | `api/v1/market/data/futures/futures-base-data` | `trade_date`, `symbol` | `中国期货基础数据.md` | | [`china_futures_lists`](#api-china-futures-lists) | 中国期货列表 | `GET` | `api/v1/market/data/futures/futures-lists` | `trade_date` | `中国期货列表.md` | | [`eastmoney_futures_position`](#api-eastmoney-futures-position) | 东方财富期货持仓 | `GET` | `api/v1/market/data/eastmoney-futures-position` | `exchange`, `variety_code`, `contract_code`, `trade_date`, `start_date`, `end_date`, `member_name_abbr`, `page`, `page_size` | `东方财富期货持仓.md` | +| [`eastmoney_futures_strange`](#api-eastmoney-futures-strange) | 东方财富期货龙虎榜 | `GET` | `api/v1/market/data/eastmoney-futures-strange` | `exchange`, `variety`, `contract`, `trade_date` | `东方财富期货龙虎榜.md` | | [`futures_contract_kline`](#api-futures-contract-kline) | 期货合约K线 | `GET` | `api/v1/market/data/futures/kline` | `symbol`, `interval`, `start`, `end`, `limit` | `期货合约K线.md` | +| [`futures_eod_price`](#api-futures-eod-price) | 期货日终行情 | `GET` | `api/v1/market/data/futures/eod-price` | `exchange`, `symbol`, `trade_date`, `start_date`, `end_date`, `page`, `page_size` | `期货日终行情.md` | +| [`futures_kline`](#api-futures-kline) | 期货合约K线 | `GET` | `api/v1/market/data/futures/kline` | `symbol`, `interval`, `start`, `end`, `limit` | `期货合约K线.md` | +| [`futures_kline_intraday`](#api-futures-kline-intraday) | 期货日内K线 | `GET` | `api/v1/market/data/futures/kline/intraday` | `symbol`, `interval`, `start`, `end`, `limit` | `期货日内K线.md` | +| [`futures_kline_latest`](#api-futures-kline-latest) | 期货最新K线 | `GET` | `api/v1/market/data/futures/kline/latest` | `symbol`, `interval` | `期货最新K线.md` | | [`major_contract`](#api-major-contract) | 重大合同 | `GET` | `api/v1/market/data/corporate/contract` | `start_date`, `end_date` | `重大合同.md` | | [`major_contract_by_symbol`](#api-major-contract-by-symbol) | 重大合同按标的 | `GET` | `api/v1/market/data/corporate/contract/by-symbol` | `symbol`, `page`, `page_size` | `重大合同按标的.md` | | [`major_contract_summary`](#api-major-contract-summary) | 重大合同汇总 | `GET` | `api/v1/market/data/corporate/contract/summary` | `page`, `page_size` | `重大合同汇总.md` | -| [`eastmoney_futures_strange`](#api-eastmoney-futures-strange) | 东方财富期货持仓 | `GET` | `api/v1/market/data/eastmoney-futures-position` | `exchange`, `variety_code`, `contract_code`, `trade_date`, `start_date`, `end_date`, `member_name_abbr`, `page`, `page_size` | `东方财富期货持仓.md` | -| [`futures_kline`](#api-futures-kline) | 期货合约K线 | `GET` | `api/v1/market/data/futures/kline` | `symbol`, `interval`, `start`, `end`, `limit` | `期货合约K线.md` | +| [`member_build_process`](#api-member-build-process) | 会员建仓过程 | `GET` | `api/v1/market/data/member-build-process` | `exchange`, `member_name`, `instrument_id`, `start_date`, `end_date`, `contract_multiplier`, `page`, `page_size` | `会员建仓过程.md` | +| [`member_position_ranking`](#api-member-position-ranking) | 会员持仓排名 | `GET` | `api/v1/market/data/member-position-ranking` | `exchange`, `instrument_id`, `trade_date`, `direction`, `page`, `page_size` | `会员持仓排名.md` | ### 债券专题 @@ -545,6 +556,43 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

daec_ohlcs

+ +- 接口名称:DAEC历史OHLC +- HTTP:`GET` +- Path:`api/v1/market/data/daec/history/ohlcs` +- 参数:`symbol`, `since`, `until`, `interval`, `adjust`, `compat`, `span`, `limit`, `until_ts_ms` +- 来源文档:`DAEC历史OHLC.md` +- 原始接口:`daec_ohlcs` + +```text +DAEC历史OHLC. + +Endpoint: ``api/v1/market/data/daec/history/ohlcs``. +Method: ``GET``. +Documented endpoint: ``daec_ohlcs``. + +Args: + symbol: 标的代码 (type: string; required: Y). + since: 起始时间 (type: string; required: N). + until: 截止时间 (type: string; required: N). + interval: K 线周期 (type: string; required: N). + adjust: 复权类型 (type: string; required: N). + compat: 兼容模式 (type: string; required: N). + span: 时间跨度 (type: string; required: N). + limit: 返回条数 (type: int; required: N). + until_ts_ms: 截止时间戳(毫秒) (type: int; 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``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. +``` +

cashflow_stock_code

- 接口名称:现金流支持股票代码 @@ -709,6 +757,41 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

eastmoney_all_board_daily_kline

+ +- 接口名称:东方财富全板块日线OHLC +- HTTP:`GET` +- Path:`api/v1/market/data/eastmoney-all-board-daily-ohlc` +- 参数:`start_date`, `end_date`, `page`, `page_size` +- 来源文档:`东方财富全板块日线OHLC.md` +- 原始接口:`eastmoney_all_board_daily_kline` + +```text +东方财富全板块日线OHLC. + +Endpoint: ``api/v1/market/data/eastmoney-all-board-daily-ohlc``. +Method: ``GET``. +Documented endpoint: ``eastmoney_all_board_daily_kline``. + +Args: + start_date: 起始日期(含),YYYY-MM-DD 或 YYYYMMDD (type: string; required: N). + end_date: 截止日期(含),YYYY-MM-DD 或 YYYYMMDD (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. The SDK validates this against the endpoint-specific maximum. + 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``. +``` +

eastmoney_board_latest_kline

- 接口名称:东方财富板块最新OHLC @@ -1581,6 +1664,37 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

trading_calendar

+ +- 接口名称:交易日历 +- HTTP:`GET` +- Path:`api/v1/market/data/time/trading-calendar` +- 参数:`market`, `start_date`, `end_date` +- 来源文档:`交易日历.md` +- 原始接口:`trading_calendar` + +```text +交易日历. + +Endpoint: ``api/v1/market/data/time/trading-calendar``. +Method: ``GET``. +Documented endpoint: ``trading_calendar``. + +Args: + market: 市场标识 (type: string; required: N). + start_date: 起始日期 (type: string; required: N). + end_date: 截止日期 (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. + **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``. +``` +

price_change

- 接口名称:价格变动 @@ -1671,6 +1785,70 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

report_announcement_list

+ +- 接口名称:报告公告列表 +- HTTP:`GET` +- Path:`api/v1/market/data/report-announcements/list` +- 参数:`date`, `sec_code`, `page`, `page_size` +- 来源文档:`报告公告列表.md` +- 原始接口:`report_announcement_list` + +```text +报告公告列表. + +Endpoint: ``api/v1/market/data/report-announcements/list``. +Method: ``GET``. +Documented endpoint: ``report_announcement_list``. + +Args: + date: 公告日期 (type: string; required: N). + sec_code: 证券代码 (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. The SDK validates this against the endpoint-specific maximum. + 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``. +``` + +

report_announcement_summary

+ +- 接口名称:报告公告摘要 +- HTTP:`GET` +- Path:`api/v1/market/data/report-announcements/summary` +- 参数:`announcement_id` +- 来源文档:`报告公告摘要.md` +- 原始接口:`report_announcement_summary` + +```text +报告公告摘要. + +Endpoint: ``api/v1/market/data/report-announcements/summary``. +Method: ``GET``. +Documented endpoint: ``report_announcement_summary``. + +Args: + announcement_id: 公告 ID (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. + **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``. +``` + - 接口名称:标的搜索 @@ -4092,6 +4270,44 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

hsi_daily_weight

+ +- 接口名称:恒生指数每日权重 +- HTTP:`GET` +- Path:`api/v1/market/data/hk/hsi-daily-weight` +- 参数:`trade_date`, `start_date`, `end_date`, `index_slug`, `stock_code`, `page`, `page_size` +- 来源文档:`恒生指数每日权重.md` +- 原始接口:`hsi_daily_weight` + +```text +恒生指数每日权重. + +Endpoint: ``api/v1/market/data/hk/hsi-daily-weight``. +Method: ``GET``. +Documented endpoint: ``hsi_daily_weight``. + +Args: + trade_date: 交易日期 (type: string; required: N). + start_date: 起始日期 (type: string; required: N). + end_date: 结束日期 (type: string; required: N). + index_slug: 指数代码 (type: string; required: N). + stock_code: 成份股代码 (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. The SDK validates this against the endpoint-specific maximum. + 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``. +``` +

market_cap_hk

- 接口名称:港股市值 @@ -5720,33 +5936,25 @@ Returns:

eastmoney_futures_strange

-- 接口名称:东方财富期货持仓 +- 接口名称:东方财富期货龙虎榜 - HTTP:`GET` -- Path:`api/v1/market/data/eastmoney-futures-position` -- 参数:`exchange`, `variety_code`, `contract_code`, `trade_date`, `start_date`, `end_date`, `member_name_abbr`, `page`, `page_size` -- 来源文档:`东方财富期货持仓.md` -- 原始接口:`get_eastmoney_futures_position` +- Path:`api/v1/market/data/eastmoney-futures-strange` +- 参数:`exchange`, `variety`, `contract`, `trade_date` +- 来源文档:`东方财富期货龙虎榜.md` +- 原始接口:`eastmoney_futures_strange` ```text -东方财富期货持仓. +东方财富期货龙虎榜. -Endpoint: ``api/v1/market/data/eastmoney-futures-position``. +Endpoint: ``api/v1/market/data/eastmoney-futures-strange``. Method: ``GET``. -Documented endpoint: ``get_eastmoney_futures_position``. +Documented endpoint: ``eastmoney_futures_strange``. 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). - 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). - member_name_abbr: 会员简称 (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. The SDK validates this against the endpoint-specific maximum. - 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``. + exchange: 交易所代码:``shfe``/``dce``/``czce``/``cffex``/``ine``/``gfe`` (type: string; required: Y). + variety: 品种名称,如 ``多晶硅`` (type: string; required: Y). + contract: 合约代码,如 ``ps2609`` (type: string; required: Y). + trade_date: 交易日,``YYYYMMDD`` (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. @@ -5791,6 +5999,183 @@ Returns: payloads when multi-page fetching is used with ``raw=True``. ``` +

futures_eod_price

+ +- 接口名称:期货日终行情 +- HTTP:`GET` +- Path:`api/v1/market/data/futures/eod-price` +- 参数:`exchange`, `symbol`, `trade_date`, `start_date`, `end_date`, `page`, `page_size` +- 来源文档:`期货日终行情.md` +- 原始接口:`futures_eod_price` + +```text +期货日终行情. + +Endpoint: ``api/v1/market/data/futures/eod-price``. +Method: ``GET``. +Documented endpoint: ``futures_eod_price``. + +Args: + exchange: 交易所代码,精确匹配 (type: string; required: N). + symbol: 合约代码,精确匹配 (type: string; required: N). + trade_date: 精确交易日,8 位 ``YYYYMMDD``;不可与 ``start_date``/``end_date`` 同时使用 (type: int; required: N). + start_date: 起始交易日,8 位 ``YYYYMMDD`` (type: int; required: N). + end_date: 结束交易日,8 位 ``YYYYMMDD``;与 ``start_date`` 同时提供时须 ``start_date`` ≤ ``end_date`` (type: int; 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. The SDK validates this against the endpoint-specific maximum. + 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_intraday

+ +- 接口名称:期货日内K线 +- HTTP:`GET` +- Path:`api/v1/market/data/futures/kline/intraday` +- 参数:`symbol`, `interval`, `start`, `end`, `limit` +- 来源文档:`期货日内K线.md` +- 原始接口:`futures_kline_intraday` + +```text +期货日内K线. + +Endpoint: ``api/v1/market/data/futures/kline/intraday``. +Method: ``GET``. +Documented endpoint: ``futures_kline_intraday``. + +Args: + symbol: WIND 合约全码或表内合约代码 (type: string; required: Y). + interval: 当前仅支持 ``1min``,兼容 ``1m``,默认 ``1min`` (type: string; required: N). + start: 开始时间,毫秒时间戳,闭区间 (type: int64; required: N). + end: 结束时间,毫秒时间戳,闭区间;与 ``start`` 同时提供时跨度不得超过 3 天 (type: int64; required: N). + limit: 最大返回条数,默认 600,范围 1~1000 (type: int; 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``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. +``` + +

futures_kline_latest

+ +- 接口名称:期货最新K线 +- HTTP:`GET` +- Path:`api/v1/market/data/futures/kline/latest` +- 参数:`symbol`, `interval` +- 来源文档:`期货最新K线.md` +- 原始接口:`futures_kline_latest` + +```text +期货最新K线. + +Endpoint: ``api/v1/market/data/futures/kline/latest``. +Method: ``GET``. +Documented endpoint: ``futures_kline_latest``. + +Args: + symbol: WIND 合约全码(如 ``A2605.DCE``)或表内合约代码(如 ``a2605``) (type: string; required: Y). + interval: 当前仅支持 ``1min``,兼容 ``1m``,默认 ``1min`` (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. + **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``. +``` + +

member_build_process

+ +- 接口名称:会员建仓过程 +- HTTP:`GET` +- Path:`api/v1/market/data/member-build-process` +- 参数:`exchange`, `member_name`, `instrument_id`, `start_date`, `end_date`, `contract_multiplier`, `page`, `page_size` +- 来源文档:`会员建仓过程.md` +- 原始接口:`member_build_process` + +```text +会员建仓过程. + +Endpoint: ``api/v1/market/data/member-build-process``. +Method: ``GET``. +Documented endpoint: ``member_build_process``. + +Args: + exchange: 交易所代码,如 ``SHFE``、``DCE``、``CZCE`` (type: string; required: Y). + member_name: 会员名称 (type: string; required: Y). + instrument_id: 合约代码,如 ``rb2601`` (type: string; required: Y). + start_date: 起始日期,``YYYYMMDD`` 或 ``YYYY-MM-DD``,默认 ``20260101`` (type: string; required: N). + end_date: 结束日期,``YYYYMMDD`` 或 ``YYYY-MM-DD``,默认当天 (type: string; required: N). + contract_multiplier: 合约乘数;不传时按品种默认表推导 (type: float; 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. The SDK validates this against the endpoint-specific maximum. + 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``. +``` + +

member_position_ranking

+ +- 接口名称:会员持仓排名 +- HTTP:`GET` +- Path:`api/v1/market/data/member-position-ranking` +- 参数:`exchange`, `instrument_id`, `trade_date`, `direction`, `page`, `page_size` +- 来源文档:`会员持仓排名.md` +- 原始接口:`member_position_ranking` + +```text +会员持仓排名. + +Endpoint: ``api/v1/market/data/member-position-ranking``. +Method: ``GET``. +Documented endpoint: ``member_position_ranking``. + +Args: + exchange: 交易所代码,如 ``SHFE``、``DCE``、``CZCE`` (type: string; required: Y). + instrument_id: 合约代码,如 ``a2605`` (type: string; required: Y). + trade_date: 交易日,``YYYYMMDD`` 或 ``YYYY-MM-DD`` (type: string; required: Y). + direction: 查询方向:``long`` 或 ``short``,也接受常见中文和缩写别名 (type: string; required: Y). + 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. The SDK validates this against the endpoint-specific maximum. + 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``. +``` + ### 债券专题

cb_base_data

diff --git a/src/ftshare/apis/futures.py b/src/ftshare/apis/futures.py index 4c86a02..b1e39ff 100644 --- a/src/ftshare/apis/futures.py +++ b/src/ftshare/apis/futures.py @@ -298,12 +298,98 @@ def eastmoney_futures_position( def eastmoney_futures_strange( self, exchange: Any | None = None, - variety_code: Any | None = None, - contract_code: Any | None = None, + variety: Any | None = None, + contract: Any | None = None, + trade_date: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """东方财富期货龙虎榜. + + Endpoint: ``api/v1/market/data/eastmoney-futures-strange``. + Method: ``GET``. + Documented endpoint: ``eastmoney_futures_strange``. + + Args: + exchange: 交易所代码:``shfe``/``dce``/``czce``/``cffex``/``ine``/``gfe`` (type: string; required: Y). + variety: 品种名称,如 ``多晶硅`` (type: string; required: Y). + contract: 合约代码,如 ``ps2609`` (type: string; required: Y). + trade_date: 交易日,``YYYYMMDD`` (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. + **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 = {'exchange': exchange, 'variety': variety, 'contract': contract, 'trade_date': trade_date} + request_params.update(kwargs) + return self._call_endpoint( + 'eastmoney_futures_strange', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def futures_contract_kline( + 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/v1/market/data/futures/kline``. + Method: ``GET``. + Documented endpoint: ``futures_contract_kline``. + + Args: + symbol: WIND 合约全码,如 A2605.DCE (type: string; required: Y). + interval: 周期,默认 1min;可选 1min/5min/15min/30min/60min/daily/weekly/monthly/quarterly/yearly (type: string; required: N). + start: 开始时间戳(毫秒);与 end 跨度 ≤3 天;仅 start 表示 [start,+∞) (type: int64; required: N). + end: 结束时间戳(毫秒,闭区间);须与 start 同时传入,禁止只传 end (type: int64; required: N). + limit: 最大返回条数,默认 500 (type: int; 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``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. + """ + request_params = {'symbol': symbol, 'interval': interval, 'start': start, 'end': end, 'limit': limit} + request_params.update(kwargs) + return self._call_endpoint( + 'futures_contract_kline', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def futures_eod_price( + self, + exchange: Any | None = None, + symbol: Any | None = None, trade_date: Any | None = None, start_date: Any | None = None, end_date: Any | None = None, - member_name_abbr: Any | None = None, page: int | None = None, page_size: int | None = None, limit: int | None = None, @@ -315,20 +401,18 @@ def eastmoney_futures_strange( as_dataframe: bool = True, **kwargs: Any, ) -> Any: - """东方财富期货持仓. + """期货日终行情. - Endpoint: ``api/v1/market/data/eastmoney-futures-position``. + Endpoint: ``api/v1/market/data/futures/eod-price``. Method: ``GET``. - Documented endpoint: ``get_eastmoney_futures_position``. + Documented endpoint: ``futures_eod_price``. 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). - 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). - member_name_abbr: 会员简称 (type: string; required: N). + exchange: 交易所代码,精确匹配 (type: string; required: N). + symbol: 合约代码,精确匹配 (type: string; required: N). + trade_date: 精确交易日,8 位 ``YYYYMMDD``;不可与 ``start_date``/``end_date`` 同时使用 (type: int; required: N). + start_date: 起始交易日,8 位 ``YYYYMMDD`` (type: int; required: N). + end_date: 结束交易日,8 位 ``YYYYMMDD``;与 ``start_date`` 同时提供时须 ``start_date`` ≤ ``end_date`` (type: int; 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. The SDK validates this against the endpoint-specific maximum. limit: Maximum number of rows to return. The SDK may fetch multiple pages to satisfy this limit. @@ -344,9 +428,9 @@ def eastmoney_futures_strange( ``as_dataframe=False``, raw JSON when ``raw=True``, or raw page payloads when multi-page fetching is used with ``raw=True``. """ - request_params = {'exchange': exchange, 'variety_code': variety_code, 'contract_code': contract_code, 'trade_date': trade_date, 'start_date': start_date, 'end_date': end_date, 'member_name_abbr': member_name_abbr} + request_params = {'exchange': exchange, 'symbol': symbol, 'trade_date': trade_date, 'start_date': start_date, 'end_date': end_date} request_params.update(kwargs) - path = ENDPOINTS['eastmoney_futures_strange'].path + path = ENDPOINTS['futures_eod_price'].path return self.get_paginated( path, page=page, @@ -354,37 +438,38 @@ def eastmoney_futures_strange( limit=limit, all_pages=all_pages, max_pages=max_pages, + max_page_size=200, raw=raw, fields=fields, as_dataframe=as_dataframe, **request_params, ) - def futures_contract_kline( + def futures_kline_intraday( self, symbol: Any | None = None, interval: Any | None = None, start: Any | None = None, end: Any | None = None, - limit: Any | None = None, + limit: int | None = None, *, raw: bool = False, fields: Sequence[str] | str | None = None, as_dataframe: bool = True, **kwargs: Any, ) -> Any: - """期货合约K线. + """期货日内K线. - Endpoint: ``api/v1/market/data/futures/kline``. + Endpoint: ``api/v1/market/data/futures/kline/intraday``. Method: ``GET``. - Documented endpoint: ``futures_contract_kline``. + Documented endpoint: ``futures_kline_intraday``. Args: - symbol: WIND 合约全码,如 A2605.DCE (type: string; required: Y). - interval: 周期,默认 1min;可选 1min/5min/15min/30min/60min/daily/weekly/monthly/quarterly/yearly (type: string; required: N). - start: 开始时间戳(毫秒);与 end 跨度 ≤3 天;仅 start 表示 [start,+∞) (type: int64; required: N). - end: 结束时间戳(毫秒,闭区间);须与 start 同时传入,禁止只传 end (type: int64; required: N). - limit: 最大返回条数,默认 500 (type: int; required: N). + symbol: WIND 合约全码或表内合约代码 (type: string; required: Y). + interval: 当前仅支持 ``1min``,兼容 ``1m``,默认 ``1min`` (type: string; required: N). + start: 开始时间,毫秒时间戳,闭区间 (type: int64; required: N). + end: 结束时间,毫秒时间戳,闭区间;与 ``start`` 同时提供时跨度不得超过 3 天 (type: int64; required: N). + limit: 最大返回条数,默认 600,范围 1~1000 (type: int; 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. @@ -398,7 +483,170 @@ def futures_contract_kline( request_params = {'symbol': symbol, 'interval': interval, 'start': start, 'end': end, 'limit': limit} request_params.update(kwargs) return self._call_endpoint( - 'futures_contract_kline', + 'futures_kline_intraday', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def futures_kline_latest( + self, + symbol: Any | None = None, + interval: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """期货最新K线. + + Endpoint: ``api/v1/market/data/futures/kline/latest``. + Method: ``GET``. + Documented endpoint: ``futures_kline_latest``. + + Args: + symbol: WIND 合约全码(如 ``A2605.DCE``)或表内合约代码(如 ``a2605``) (type: string; required: Y). + interval: 当前仅支持 ``1min``,兼容 ``1m``,默认 ``1min`` (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. + **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, 'interval': interval} + request_params.update(kwargs) + return self._call_endpoint( + 'futures_kline_latest', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def member_build_process( + self, + exchange: Any | None = None, + member_name: Any | None = None, + instrument_id: Any | None = None, + start_date: Any | None = None, + end_date: Any | None = None, + contract_multiplier: 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/member-build-process``. + Method: ``GET``. + Documented endpoint: ``member_build_process``. + + Args: + exchange: 交易所代码,如 ``SHFE``、``DCE``、``CZCE`` (type: string; required: Y). + member_name: 会员名称 (type: string; required: Y). + instrument_id: 合约代码,如 ``rb2601`` (type: string; required: Y). + start_date: 起始日期,``YYYYMMDD`` 或 ``YYYY-MM-DD``,默认 ``20260101`` (type: string; required: N). + end_date: 结束日期,``YYYYMMDD`` 或 ``YYYY-MM-DD``,默认当天 (type: string; required: N). + contract_multiplier: 合约乘数;不传时按品种默认表推导 (type: float; 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. The SDK validates this against the endpoint-specific maximum. + 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 = {'exchange': exchange, 'member_name': member_name, 'instrument_id': instrument_id, 'start_date': start_date, 'end_date': end_date, 'contract_multiplier': contract_multiplier} + request_params.update(kwargs) + path = ENDPOINTS['member_build_process'].path + return self.get_paginated( + path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + max_page_size=200, + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def member_position_ranking( + self, + exchange: Any | None = None, + instrument_id: Any | None = None, + trade_date: Any | None = None, + direction: 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/member-position-ranking``. + Method: ``GET``. + Documented endpoint: ``member_position_ranking``. + + Args: + exchange: 交易所代码,如 ``SHFE``、``DCE``、``CZCE`` (type: string; required: Y). + instrument_id: 合约代码,如 ``a2605`` (type: string; required: Y). + trade_date: 交易日,``YYYYMMDD`` 或 ``YYYY-MM-DD`` (type: string; required: Y). + direction: 查询方向:``long`` 或 ``short``,也接受常见中文和缩写别名 (type: string; required: Y). + 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. The SDK validates this against the endpoint-specific maximum. + 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 = {'exchange': exchange, 'instrument_id': instrument_id, 'trade_date': trade_date, 'direction': direction} + request_params.update(kwargs) + path = ENDPOINTS['member_position_ranking'].path + return self.get_paginated( + path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + max_page_size=200, raw=raw, fields=fields, as_dataframe=as_dataframe, diff --git a/src/ftshare/apis/hk.py b/src/ftshare/apis/hk.py index 9fbf758..5f273cb 100644 --- a/src/ftshare/apis/hk.py +++ b/src/ftshare/apis/hk.py @@ -651,6 +651,74 @@ def hk_valuatnanalyd( **request_params, ) + def hsi_daily_weight( + self, + trade_date: Any | None = None, + start_date: Any | None = None, + end_date: Any | None = None, + index_slug: Any | None = None, + stock_code: 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/hk/hsi-daily-weight``. + Method: ``GET``. + Documented endpoint: ``hsi_daily_weight``. + + Args: + trade_date: 交易日期 (type: string; required: N). + start_date: 起始日期 (type: string; required: N). + end_date: 结束日期 (type: string; required: N). + index_slug: 指数代码 (type: string; required: N). + stock_code: 成份股代码 (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. The SDK validates this against the endpoint-specific maximum. + 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 = { + 'trade_date': trade_date, + 'start_date': start_date, + 'end_date': end_date, + 'index_slug': index_slug, + 'stock_code': stock_code, + } + request_params.update(kwargs) + path = ENDPOINTS['hsi_daily_weight'].path + return self.get_paginated( + 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, + max_page_size=ENDPOINTS['hsi_daily_weight'].max_page_size, + **request_params, + ) + def market_cap_hk( self, trade_code: Any | None = None, diff --git a/src/ftshare/apis/stock.py b/src/ftshare/apis/stock.py index 536ecba..ffeda6c 100644 --- a/src/ftshare/apis/stock.py +++ b/src/ftshare/apis/stock.py @@ -131,6 +131,69 @@ def cashflow( **request_params, ) + def daec_ohlcs( + self, + symbol: Any | None = None, + since: Any | None = None, + until: Any | None = None, + interval: Any | None = None, + adjust: Any | None = None, + compat: Any | None = None, + span: Any | None = None, + limit: Any | None = None, + until_ts_ms: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """DAEC历史OHLC. + + Endpoint: ``api/v1/market/data/daec/history/ohlcs``. + Method: ``GET``. + Documented endpoint: ``daec_ohlcs``. + + Args: + symbol: 标的代码 (type: string; required: Y). + since: 起始时间 (type: string; required: N). + until: 截止时间 (type: string; required: N). + interval: K 线周期 (type: string; required: N). + adjust: 复权类型 (type: string; required: N). + compat: 兼容模式 (type: string; required: N). + span: 时间跨度 (type: string; required: N). + limit: 返回条数 (type: int; required: N). + until_ts_ms: 截止时间戳(毫秒) (type: int; 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``, raw JSON when ``raw=True``, or raw page + payloads when multi-page fetching is used with ``raw=True``. + """ + request_params = { + 'symbol': symbol, + 'since': since, + 'until': until, + 'interval': interval, + 'adjust': adjust, + 'compat': compat, + 'span': span, + 'limit': limit, + 'until_ts_ms': until_ts_ms, + } + request_params.update(kwargs) + return self._call_endpoint( + 'daec_ohlcs', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def cashflow_stock_code( self, *, @@ -1334,6 +1397,62 @@ def eastmoney_board_daily_kline( **request_params, ) + def eastmoney_all_board_daily_kline( + self, + start_date: Any | None = None, + end_date: 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: + """东方财富全板块日线OHLC. + + Endpoint: ``api/v1/market/data/eastmoney-all-board-daily-ohlc``. + Method: ``GET``. + Documented endpoint: ``eastmoney_all_board_daily_kline``. + + Args: + start_date: 起始日期(含),YYYY-MM-DD 或 YYYYMMDD (type: string; required: N). + end_date: 截止日期(含),YYYY-MM-DD 或 YYYYMMDD (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. The SDK validates this against the endpoint-specific maximum. + 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 = {'start_date': start_date, 'end_date': end_date} + request_params.update(kwargs) + path = ENDPOINTS['eastmoney_all_board_daily_kline'].path + return self.get_paginated( + path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + max_page_size=ENDPOINTS['eastmoney_all_board_daily_kline'].max_page_size, + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def eastmoney_board_latest_kline( self, board_code: Any | None = None, @@ -1943,6 +2062,47 @@ def nth_trade_date( **request_params, ) + def trading_calendar( + self, + market: Any | None = None, + start_date: Any | None = None, + end_date: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """交易日历. + + Endpoint: ``api/v1/market/data/time/trading-calendar``. + Method: ``GET``. + Documented endpoint: ``trading_calendar``. + + Args: + market: 市场标识 (type: string; required: N). + start_date: 起始日期 (type: string; required: N). + end_date: 截止日期 (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. + **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 = {'market': market, 'start_date': start_date, 'end_date': end_date} + request_params.update(kwargs) + return self._call_endpoint( + 'trading_calendar', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def price_change( self, stock_code: Any | None = None, @@ -3076,6 +3236,99 @@ def risk_warning_stocks( **request_params, ) + def report_announcement_list( + self, + date: Any | None = None, + sec_code: 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/report-announcements/list``. + Method: ``GET``. + Documented endpoint: ``report_announcement_list``. + + Args: + date: 公告日期 (type: string; required: N). + sec_code: 证券代码 (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. The SDK validates this against the endpoint-specific maximum. + 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 = {'date': date, 'sec_code': sec_code} + request_params.update(kwargs) + path = ENDPOINTS['report_announcement_list'].path + return self.get_paginated( + path, + page=page, + page_size=page_size, + limit=limit, + all_pages=all_pages, + max_pages=max_pages, + max_page_size=ENDPOINTS['report_announcement_list'].max_page_size, + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + + def report_announcement_summary( + self, + announcement_id: Any | None = None, + *, + raw: bool = False, + fields: Sequence[str] | str | None = None, + as_dataframe: bool = True, + **kwargs: Any, + ) -> Any: + """报告公告摘要. + + Endpoint: ``api/v1/market/data/report-announcements/summary``. + Method: ``GET``. + Documented endpoint: ``report_announcement_summary``. + + Args: + announcement_id: 公告 ID (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. + **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 = {'announcement_id': announcement_id} + request_params.update(kwargs) + return self._call_endpoint( + 'report_announcement_summary', + raw=raw, + fields=fields, + as_dataframe=as_dataframe, + **request_params, + ) + def stk_code_change( self, trade_code: Any | None = None, diff --git a/src/ftshare/endpoints/futures.py b/src/ftshare/endpoints/futures.py index 19ebc8c..06a072c 100644 --- a/src/ftshare/endpoints/futures.py +++ b/src/ftshare/endpoints/futures.py @@ -27,6 +27,13 @@ 'original_api': 'get_eastmoney_futures_position', 'params': ('exchange', 'variety_code', 'contract_code', 'trade_date', 'start_date', 'end_date', 'member_name_abbr', 'page', 'page_size'), }, + 'eastmoney_futures_strange': { + 'path': 'api/v1/market/data/eastmoney-futures-strange', + 'title': '东方财富期货龙虎榜', + 'doc_file': '东方财富期货龙虎榜.md', + 'original_api': 'eastmoney_futures_strange', + 'params': ('exchange', 'variety', 'contract', 'trade_date'), + }, 'futures_contract_kline': { 'path': 'api/v1/market/data/futures/kline', 'title': '期货合约K线', @@ -34,6 +41,35 @@ 'original_api': 'futures_contract_kline', 'params': ('symbol', 'interval', 'start', 'end', 'limit'), }, + 'futures_kline': { + 'path': 'api/v1/market/data/futures/kline', + 'title': '期货合约K线', + 'doc_file': '期货合约K线.md', + 'original_api': 'futures_contract_kline', + 'params': ('symbol', 'interval', 'start', 'end', 'limit'), + }, + 'futures_kline_intraday': { + 'path': 'api/v1/market/data/futures/kline/intraday', + 'title': '期货日内K线', + 'doc_file': '期货日内K线.md', + 'original_api': 'futures_kline_intraday', + 'params': ('symbol', 'interval', 'start', 'end', 'limit'), + }, + 'futures_kline_latest': { + 'path': 'api/v1/market/data/futures/kline/latest', + 'title': '期货最新K线', + 'doc_file': '期货最新K线.md', + 'original_api': 'futures_kline_latest', + 'params': ('symbol', 'interval'), + }, + 'futures_eod_price': { + 'path': 'api/v1/market/data/futures/eod-price', + 'title': '期货日终行情', + 'doc_file': '期货日终行情.md', + 'original_api': 'futures_eod_price', + 'params': ('exchange', 'symbol', 'trade_date', 'start_date', 'end_date', 'page', 'page_size'), + 'max_page_size': 200, + }, 'major_contract': { 'path': 'api/v1/market/data/corporate/contract', 'title': '重大合同', @@ -56,18 +92,20 @@ 'original_api': 'major_contract_summary', 'params': ('page', 'page_size'), }, - 'eastmoney_futures_strange': { - 'path': 'api/v1/market/data/eastmoney-futures-position', - 'title': '东方财富期货持仓', - 'doc_file': '东方财富期货持仓.md', - 'original_api': 'get_eastmoney_futures_position', - 'params': ('exchange', 'variety_code', 'contract_code', 'trade_date', 'start_date', 'end_date', 'member_name_abbr', 'page', 'page_size'), + 'member_build_process': { + 'path': 'api/v1/market/data/member-build-process', + 'title': '会员建仓过程', + 'doc_file': '会员建仓过程.md', + 'original_api': 'member_build_process', + 'params': ('exchange', 'member_name', 'instrument_id', 'start_date', 'end_date', 'contract_multiplier', 'page', 'page_size'), + 'max_page_size': 200, }, - 'futures_kline': { - 'path': 'api/v1/market/data/futures/kline', - 'title': '期货合约K线', - 'doc_file': '期货合约K线.md', - 'original_api': 'futures_contract_kline', - 'params': ('symbol', 'interval', 'start', 'end', 'limit'), + 'member_position_ranking': { + 'path': 'api/v1/market/data/member-position-ranking', + 'title': '会员持仓排名', + 'doc_file': '会员持仓排名.md', + 'original_api': 'member_position_ranking', + 'params': ('exchange', 'instrument_id', 'trade_date', 'direction', 'page', 'page_size'), + 'max_page_size': 200, }, }) diff --git a/src/ftshare/endpoints/hk.py b/src/ftshare/endpoints/hk.py index 2c2b981..70ae452 100644 --- a/src/ftshare/endpoints/hk.py +++ b/src/ftshare/endpoints/hk.py @@ -97,6 +97,14 @@ 'original_api': 'get_hk_valuatnanalyd', 'params': ('trade_code', 'page', 'page_size'), }, + 'hsi_daily_weight': { + 'path': 'api/v1/market/data/hk/hsi-daily-weight', + 'title': '恒生指数每日权重', + 'doc_file': '恒生指数每日权重.md', + 'original_api': 'hsi_daily_weight', + 'params': ('trade_date', 'start_date', 'end_date', 'index_slug', 'stock_code', 'page', 'page_size'), + 'max_page_size': 200, + }, 'market_cap_hk': { 'path': 'api/v1/market/data/hk/market-cap-hk', 'title': '港股市值', diff --git a/src/ftshare/endpoints/stock.py b/src/ftshare/endpoints/stock.py index 3b47e02..5eadbe7 100644 --- a/src/ftshare/endpoints/stock.py +++ b/src/ftshare/endpoints/stock.py @@ -57,6 +57,13 @@ 'params': ('stock_code', 'year', 'report_type', 'page', 'page_size'), 'max_page_size': 500, }, + 'daec_ohlcs': { + 'path': 'api/v1/market/data/daec/history/ohlcs', + 'title': 'DAEC历史OHLC', + 'doc_file': 'DAEC历史OHLC.md', + 'original_api': 'daec_ohlcs', + 'params': ('symbol', 'since', 'until', 'interval', 'adjust', 'compat', 'span', 'limit', 'until_ts_ms'), + }, 'cashflow_stock_code': { 'path': 'api/v1/market/data/finance/cashflow-stock-code', 'title': '现金流支持股票代码', @@ -85,6 +92,14 @@ 'original_api': 'eastmoney_board_constituents', 'params': ('board_code',), }, + 'eastmoney_all_board_daily_kline': { + 'path': 'api/v1/market/data/eastmoney-all-board-daily-ohlc', + 'title': '东方财富全板块日线OHLC', + 'doc_file': '东方财富全板块日线OHLC.md', + 'original_api': 'eastmoney_all_board_daily_kline', + 'params': ('start_date', 'end_date', 'page', 'page_size'), + 'max_page_size': 200, + }, 'eastmoney_board_daily_kline': { 'path': 'api/v1/market/data/eastmoney-board-daily-ohlc', 'title': '东方财富板块日线OHLC', @@ -270,6 +285,13 @@ 'original_api': 'get_nth_trade_date', 'params': ('n',), }, + 'trading_calendar': { + 'path': 'api/v1/market/data/time/trading-calendar', + 'title': '交易日历', + 'doc_file': '交易日历.md', + 'original_api': 'trading_calendar', + 'params': ('market', 'start_date', 'end_date'), + }, 'performance_forecasts_paginated': { 'path': 'api/v1/market/data/finance/stock-performance-forecast', 'title': '业绩预告', @@ -299,6 +321,21 @@ 'original_api': 'risk_warning_stocks', 'params': ('date',), }, + 'report_announcement_list': { + 'path': 'api/v1/market/data/report-announcements/list', + 'title': '报告公告列表', + 'doc_file': '报告公告列表.md', + 'original_api': 'report_announcement_list', + 'params': ('date', 'sec_code', 'page', 'page_size'), + 'max_page_size': 200, + }, + 'report_announcement_summary': { + 'path': 'api/v1/market/data/report-announcements/summary', + 'title': '报告公告摘要', + 'doc_file': '报告公告摘要.md', + 'original_api': 'report_announcement_summary', + 'params': ('announcement_id',), + }, 'search': { 'path': 'api/v1/market/security/search', 'title': '标的搜索', diff --git a/tests/endpoint_cases.py b/tests/endpoint_cases.py index 241f032..a2d51f6 100644 --- a/tests/endpoint_cases.py +++ b/tests/endpoint_cases.py @@ -6,6 +6,7 @@ SAMPLE_VALUES: dict[str, Any] = { "adjust": "Forward", "adjust_kind": "Forward", + "announcement_id": "announcement-1", "base_date": "2026-07-17", "begin_date": "20260101", "board": "all", @@ -20,7 +21,9 @@ "classify_std": "证监会行业分类", "client_type": "一般", "compat": "v2", + "contract": "A2609.DCE", "contract_code": "A2609.DCE", + "contract_multiplier": 10, "date": "20260717", "days": 5, "direction": "northbound", @@ -36,10 +39,12 @@ "history": True, "hk_code": "00700.HK", "index_code": "000300", + "index_slug": "HSI", "industry_code": "801010", "inst_type": "基金", "institution_code": "000001", "institution_id": "1001", + "instrument_id": "A2609", "instrument_type": "stock", "interval": "Day", "interval_unit": "Day", @@ -53,6 +58,7 @@ "market": "CN", "market_code": "000300", "market_id": "XSHG", + "member_name": "永安期货", "member_name_abbr": "永安期货", "n": 5, "n_code": "000001.SZ", @@ -74,6 +80,7 @@ "rept_type": "annual", "request_id": "request-1", "scope": "ChinaStock", + "sec_code": "000001", "secid": "1.600000", "sector_code": "BK001", "sector_type": "concept", @@ -105,6 +112,7 @@ "until_ts_millis": 1784307600000, "until_ts_ms": 1784307600000, "variant": "300001", + "variety": "A", "variety_code": "A", "year": 2024, } diff --git a/tests/test_endpoint_contracts.py b/tests/test_endpoint_contracts.py index 5c87b66..a7878c6 100644 --- a/tests/test_endpoint_contracts.py +++ b/tests/test_endpoint_contracts.py @@ -52,7 +52,7 @@ def _response_payload(name: str) -> Any: def test_contract_cases_cover_all_public_sdk_methods(): - assert len(PUBLIC_CONTRACTS) == 202 + assert len(PUBLIC_CONTRACTS) == 213 assert PUBLIC_CONTRACTS | NON_PUBLISHED_ENDPOINTS == set(ENDPOINTS) assert not (PUBLIC_CONTRACTS & NON_PUBLISHED_ENDPOINTS) From d7be107c0b5cf09fedc97deba015df8fe8f3c87b Mon Sep 17 00:00:00 2001 From: zhuhao Date: Mon, 10 Aug 2026 16:21:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20SDK=20=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=20FTSHARE=5FBASE=5FURL=20=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.py 模块加载时若存在 FTSHARE_BASE_URL 则覆盖默认 base_url,便于测试/内网部署切换。set_base_url() API 不变。 --- src/ftshare/config.py | 7 +++++++ tests/test_integration_market.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/ftshare/config.py b/src/ftshare/config.py index b68c371..8f42557 100644 --- a/src/ftshare/config.py +++ b/src/ftshare/config.py @@ -2,6 +2,8 @@ from __future__ import annotations +import os + DEFAULT_BASE_URL = "https://market.ft.tech/gateway/" """Default FTShare API base URL.""" @@ -47,3 +49,8 @@ def set_base_url(url: str) -> str: global _BASE_URL _BASE_URL = normalize_base_url(url) return _BASE_URL + + +_env_base_url = os.environ.get("FTSHARE_BASE_URL") +if _env_base_url: + set_base_url(_env_base_url) diff --git a/tests/test_integration_market.py b/tests/test_integration_market.py index ee66969..3d007b0 100644 --- a/tests/test_integration_market.py +++ b/tests/test_integration_market.py @@ -7,6 +7,8 @@ import ftshare as ft +from test_endpoint_contracts import PUBLIC_CONTRACTS, _call_kwargs + pytestmark = pytest.mark.integration @@ -57,3 +59,15 @@ def test_real_eastmoney_us_stock_list_tabular_extract(): df = market.eastmoney_us_stock_list(page=1, page_size=5) assert isinstance(df, pd.DataFrame) + + +@pytest.mark.parametrize("method_name", sorted(PUBLIC_CONTRACTS)) +def test_real_public_endpoint_returns_rows(method_name): + _skip_unless_enabled() + market = ft.market_api(timeout=20) + + kwargs = _call_kwargs(method_name) + + rows = getattr(market, method_name)(as_dataframe=False, **kwargs) + + assert rows is not None