### Install efinance Library Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/README.md Install the efinance library using pip. This command is used for initial setup. ```bash pip install efinance ``` -------------------------------- ### Basic efinance Usage Examples Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/README.md Demonstrates basic usage of the efinance library for fetching stock, fund, bond, and futures data. Ensure the library is installed and imported before use. ```python import efinance as ef # Stock market data df = ef.stock.get_quote_history('600519') # K-line data quotes = ef.stock.get_realtime_quotes() # Real-time quotes # Fund data df = ef.fund.get_quote_history('161725') # NAV history df = ef.fund.get_base_info('161725') # Fund info # Bond data df = ef.bond.get_quote_history('123111') # K-line data # Futures data df = ef.futures.get_quote_history('m113:1604') # K-line data ``` -------------------------------- ### Get All Real-time Stock Quotes Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetches real-time quotes for all available stocks. This can return a large dataset. ```python >>> import efinance as ef >>> ef.stock.get_realtime_quotes() ``` -------------------------------- ### Get Realtime Quotes for All Stocks Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetches real-time quotes for all available stocks. This is the default behavior when no arguments are provided. ```APIDOC ## Get Realtime Quotes for All Stocks ### Description Fetches real-time quotes for all available stocks. This is the default behavior when no arguments are provided. ### Method ```python ef.stock.get_realtime_quotes() ``` ### Parameters This method does not accept any parameters when fetching all stocks. ### Response Example ```json { "股票代码": "688787", "股票名称": "N海天", "涨跌幅": "277.59%", "最新价": "139.48", "最高": "172.39", "最低": "139.25", "今开": "171.66", "涨跌额": "102.54", "换手率": "85.62%", "量比": "-", "动态市盈率": "78.93", "成交量": "74519", "成交额": "1110318832.0", "昨日收盘": "36.94", "总市值": "5969744000", "流通市值": "1213908667", "行情ID": "1.688787", "市场类型": "沪A" } ``` ``` -------------------------------- ### Get Latest IPO Information Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Retrieves the latest IPO data. Returns a pandas DataFrame. ```python import efinance as ef df = ef.stock.get_latest_ipo_info() print(df) ``` -------------------------------- ### Get Bond Deal Details Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/bond.md Retrieves trade detail records for a given bond. Requires the efinance library to be imported. ```python import efinance as ef df = ef.bond.get_deal_detail('123111', max_count=1000) print(df) ``` -------------------------------- ### Search Quote Information Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/utils.md Retrieve quote information for a given security code. This example demonstrates how to fetch and print details like the security name, code, and quote ID. ```python from efinance.utils import search_quote quote = search_quote('600519') print(f"Name: {quote.name}") print(f"Code: {quote.code}") print(f"Quote ID: {quote.quote_id}") ``` -------------------------------- ### Get Fund Investment Positions (Latest) Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Retrieve the latest publicly available investment positions for a given fund code. ```python >>> import efinance as ef >>> # 获取最新公开的持仓数据 >>> ef.fund.get_invest_position('161725') ``` -------------------------------- ### Get Fund Investment Positions (Historical) Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetch historical investment positions for a fund by providing a list of specific public dates. ```python >>> import efinance as ef >>> # 获取近 2 个公开持仓数据 >>> public_dates = ef.fund.get_public_dates('161725') >>> ef.fund.get_invest_position('161725',public_dates[:2]) ``` -------------------------------- ### Get Real-time Quotes for ETF Categories Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetches real-time quotes for stocks within specific ETF categories, such as 'ETF'. ```python >>> ef.stock.get_realtime_quotes(['ETF']) ``` -------------------------------- ### Get Fund Period Change Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Retrieves the period change data for a specific fund code. Use this to get historical performance metrics. ```python import efinance as ef returns = ef.fund.get_period_change('161725') print(returns) ``` -------------------------------- ### Get Stock Quote Snapshot Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Fetches a real-time market snapshot for a specific stock code. Includes bid/ask levels and sizes. Returns a pandas Series. ```python import efinance as ef snapshot = ef.stock.get_quote_snapshot('600519') print(f"Buy 1: {snapshot['买1价']} x {snapshot['买1数量']}") print(f"Sell 1: {snapshot['卖1价']} x {snapshot['卖1数量']}") ``` -------------------------------- ### Get Real-time Quotes for Specific Markets Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetches real-time quotes for stocks in specified markets like '创业板' (ChiNext) or '港股' (Hong Kong Stocks). ```python >>> ef.stock.get_realtime_quotes(['创业板','港股']) ``` -------------------------------- ### Get Real-time Quotes with Pre-configured Filters Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Retrieve real-time stock quotes using a pre-configured market filter like '沪A'. This is the simplest way to filter market data. ```python import efinance as ef # Using pre-configured filter df = ef.stock.get_realtime_quotes(fs='沪A') ``` -------------------------------- ### Get All and Filtered Fund Codes Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Retrieve all available fund codes or filter by fund type (e.g., 'gp' for stock funds). ```python >>> import efinance as ef >>> # 全部类型的基金 >>> ef.fund.get_fund_codes() >>> # 股票型基金 >>> ef.fund.get_fund_codes(ft = 'gp') ``` -------------------------------- ### Get Fund Basic Information Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Fetches basic information for one or more funds. Handles both single fund codes and lists of codes, returning Series or DataFrame respectively. ```python import efinance as ef # Single fund info = ef.fund.get_base_info('161725') print(f"Fund type: {info['基金类型']}") # Multiple funds df = ef.fund.get_base_info(['161725', '519674']) ``` -------------------------------- ### Get Real-time Futures Quotes Source: https://github.com/micro-sheep/efinance/blob/main/examples/futures.ipynb Fetch live trading data for futures contracts, including price, volume, and change information. This is essential for monitoring current market conditions. ```python ef.futures.get_realtime_quotes() ``` -------------------------------- ### get_latest_quote Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Get the latest quote data for specific stocks. ```APIDOC ## get_latest_quote ### Description Get latest quotes for specific stocks. ### Method GET (assumed, as no request body is specified and data is being retrieved) ### Endpoint `/stock/latest_quote` (inferred) ### Parameters #### Query Parameters - **stock_codes** (str or List[str]) - Required - Stock code(s) to retrieve ### Response #### Success Response (200) - **DataFrame** - Latest quote data for specified stocks ``` -------------------------------- ### Get Realtime Quotes for Specific Market Types Source: https://github.com/micro-sheep/efinance/blob/main/docs/api.md Fetches real-time quotes for specified market types, such as '创业板', '港股', or 'ETF'. ```APIDOC ## Get Realtime Quotes for Specific Market Types ### Description Fetches real-time quotes for specified market types, such as '创业板', '港股', or 'ETF'. ### Method ```python ef.stock.get_realtime_quotes(market_types: list[str]) ``` ### Parameters #### Path Parameters - **market_types** (list[str]) - Required - A list of strings specifying the market types to fetch data for (e.g., ['创业板','港股'], ['ETF']). ### Request Example ```python import efinance as ef # Fetching data for '创业板' and '港股' ef.stock.get_realtime_quotes(['创业板','港股']) # Fetching data for 'ETF' ef.stock.get_realtime_quotes(['ETF']) ``` ### Response Example ```json { "股票代码": "00859", "股票名称": "中昌国际控股", "涨跌幅": "49.02%", "最新价": "0.38", "最高": "0.38", "最低": "0.26", "今开": "0.26", "涨跌额": "0.125", "换手率": "0.08%", "量比": "86.85", "动态市盈率": "-2.83", "成交量": "938000", "成交额": "262860.0", "昨日收盘": "0.255", "总市值": "427510287", "流通市值": "427510287", "行情ID": "128.00859", "市场类型": "None" } ``` ``` -------------------------------- ### Get Fund Asset Type Allocation Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Retrieves the asset type allocation percentages for a fund. Use this to understand the fund's investment breakdown. ```python import efinance as ef allocation = ef.fund.get_types_percentage('161725') print(allocation) ``` -------------------------------- ### Get Real-time Quotes with Multiple Filters Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Fetch real-time stock quotes by specifying multiple market filters in a list, such as '沪A' and '深A'. This allows for broader data retrieval. ```python # Using multiple filters (list) df = ef.stock.get_realtime_quotes(fs=['沪A', '深A']) ``` -------------------------------- ### Get Fund Public Disclosure Dates Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Fetches the public disclosure dates for a given fund code. Useful for understanding when fund data becomes available. ```python import efinance as ef dates = ef.fund.get_public_dates('161725') print(f"Available dates: {dates}") ``` -------------------------------- ### Get Stock Board Information Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Retrieves board membership and classification data for a specific stock code. Returns a pandas DataFrame. ```python import efinance as ef df = ef.stock.get_belong_board('600519') ``` -------------------------------- ### Get Fund Industry Distribution Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Retrieves the industry distribution of a fund's holdings. Use this to analyze sector-specific investments. ```python import efinance as ef industries = ef.fund.get_industry_distribution('161725') print(industries) ``` -------------------------------- ### Get Basic Stock Information Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Retrieve fundamental stock information such as PE ratio, market cap, and ROE. Returns a Series for a single stock or a DataFrame for multiple stocks. ```python import efinance as ef # Single stock info = ef.stock.get_base_info('600519') print(info['市盈率(动)']) # Multiple stocks df = ef.stock.get_base_info(['600519', '300715', '000651']) ``` -------------------------------- ### Get Futures Base Information Source: https://github.com/micro-sheep/efinance/blob/main/examples/futures.ipynb Retrieve fundamental information about futures contracts, such as their codes, names, and market types. This is useful for understanding the available futures and their identifiers. ```python ef.futures.get_futures_base_info() ``` -------------------------------- ### Get Futures Quote History (Daily Frequency) Source: https://github.com/micro-sheep/efinance/blob/main/examples/futures.ipynb Retrieve historical daily price data for a specific futures contract. You need to provide the quote ID of the futures contract you are interested in. ```python quote_id = '115.ZCM' ef.futures.get_quote_history(quote_id) ``` -------------------------------- ### Get Daily Stock Billboard within Date Range Source: https://github.com/micro-sheep/efinance/blob/main/docs/example.md Retrieves the daily stock billboard data for a specified period. This is useful for analyzing stock performance trends over a defined date range. ```python >>> # 获取指定日期区间的龙虎榜数据 >>> start_date = '2021-08-20' # 开始日期 >>> end_date = '2021-08-27' # 结束日期 >>> ef.stock.get_daily_billboard(start_date = start_date,end_date = end_date) 股票代码 股票名称 上榜日期 解读 收盘价 涨跌幅 换手率 龙虎榜净买额 龙虎榜买入额 龙虎榜卖出额 龙虎榜成交额 市场总成交额 净买额占总成交比 成交额占总成交比 流通市值 上榜原因 0 000608 阳光股份 2021-08-27 卖一主卖,成功率48.36% 3.73 -9.9034 3.8430 -8.709942e+06 1.422786e+07 2.293780e+07 3.716565e+07 110838793 -7.858208 33.531268 2.796761e+09 日跌幅偏离值达到7%的前5只证券 1 000751 锌业股份 2021-08-27 主力做T,成功率18.84% 5.32 -2.9197 19.6505 -1.079219e+08 5.638899e+07 1.643109e+08 2.206999e+08 1462953973 -7.376984 15.085906 7.500502e+09 日振幅值达到15%的前5只证券 2 000762 西藏矿业 2021-08-27 北京资金买入,成功率39.42% 63.99 1.0741 15.6463 2.938758e+07 4.675541e+08 4.381665e+08 9.057206e+08 4959962598 0.592496 18.260633 3.332571e+10 日振幅值达到15%的前5只证券 3 000833 粤桂股份 2021-08-27 实力游资买入,成功率44.55% 8.87 10.0496 8.8263 4.993555e+07 1.292967e+08 7.936120e+07 2.086580e+08 895910429 5.573721 23.290046 3.353614e+09 连续三个交易日内,涨幅偏离值累计达到20%的证券 4 001208 华菱线缆 2021-08-27 1家机构买入,成功率40.43% 19.72 4.3386 46.1985 4.055258e+07 1.537821e+08 1.132295e+08 2.670117e+08 1203913048 3.368398 22.178651 2.634710e+09 日换手率达到20%的前5只证券 .. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... 414 605580 恒盛能源 2021-08-20 买一主买,成功率33.33% 13.28 10.0249 0.4086 2.413149e+06 2.713051e+06 2.999022e+05 3.012953e+06 2713051 88.945937 111.054054 6.640000e+08 有价格涨跌幅限制的日收盘价格涨幅偏离值达到7%的前三只证券 415 688029 南微医学 2021-08-20 4家机构卖出,成功率55.82% 204.61 -18.5340 8.1809 -1.412053e+08 1.883342e+08 3.295394e+08 5.178736e+08 762045800 -18.529760 67.958326 9.001510e+09 有价格涨跌幅限制的日收盘价格跌幅达到15%的前五只证券 416 688408 中信博 2021-08-20 4家机构卖出,成功率47.86% 179.98 -0.0666 15.3723 -4.336304e+07 3.750919e+08 4.184550e+08 7.935469e+08 846547400 -5.122340 93.739221 5.695886e+09 有价格涨跌幅限制的日价格振幅达到30%的前五只证券 ``` -------------------------------- ### Get Futures Quote History (Custom Frequency) Source: https://github.com/micro-sheep/efinance/blob/main/examples/futures.ipynb Retrieve historical price data for a specific futures contract with a custom frequency (e.g., 5-minute intervals). Specify the quote ID and the desired frequency (klt) in minutes. ```python quote_id = '115.ZCM' freq = 5 ef.futures.get_quote_history(quote_id,klt=freq) ``` -------------------------------- ### Import efinance Library Source: https://github.com/micro-sheep/efinance/blob/main/examples/futures.ipynb Import the efinance library to begin using its functionalities. ```python import efinance as ef ``` -------------------------------- ### Configuring efinance via Function Parameters Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Demonstrates configuring the `get_quote_history` function using various parameters, including date ranges, klt, fqt, market type, error suppression, and cache usage. ```python import efinance as ef from efinance.utils import MarketType # All configuration via parameters df = ef.stock.get_quote_history( '600519', beg='20210101', end='20210630', klt=101, fqt=1, market_type=MarketType.A_stock, suppress_error=False, use_id_cache=True ) ``` -------------------------------- ### get_belong_board Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Get board information for a specific stock, including its membership and classification data. ```APIDOC ## get_belong_board ### Description Get board information for a stock. ### Parameters #### Path Parameters - **stock_code** (str) - Required - Stock code ### Returns - pd.DataFrame: Board membership and classification data ### Example ```python import efinance as ef df = ef.stock.get_belong_board('600519') ``` ``` -------------------------------- ### Using MagicConfig for Extra Fields Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Demonstrates how to use MagicConfig constants to enable specific behaviors like including extra fields in function responses. Import MagicConfig from efinance.utils. ```python from efinance.utils import MagicConfig # Usage pattern ef.stock.get_quote_history('600519', **{MagicConfig.EXTRA_FIELDS: True}) ``` -------------------------------- ### Rate Limiting Solutions in Efinance Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/errors.md Demonstrates strategies to avoid rate limiting and connection issues, including enabling local caching and adding delays between requests. ```python import efinance as ef import time # 1. Enable local caching quote = ef.utils.search_quote('600519', use_local=True) # 2. Add delays between requests for code in codes: df = ef.stock.get_quote_history(code) time.sleep(1) # 3. Use alternative service # Consider using TickFlow: https://tickflow.org # (mentioned in README.md) ``` -------------------------------- ### get_realtime_quotes Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Get real-time stock quotes for a group or filter. Defaults to Shanghai-Shenzhen A-shares if no filter is specified. ```APIDOC ## get_realtime_quotes ### Description Get real-time stock quotes for a group/filter. ### Method GET (assumed, as no request body is specified and data is being retrieved) ### Endpoint `/stock/realtime_quotes` (inferred) ### Parameters #### Query Parameters - **fs** (str or List[str]) - Optional - Market filter identifier(s); if None, returns Shanghai-Shenzhen A-shares ### Response #### Success Response (200) - **DataFrame** - Real-time quotes with columns: 代码, 名称, 涨跌幅, 最新价, 最高, 最低, 今开, 涨跌额, 换手率, 量比, 动态市盈率, 成交量, 成交额, 昨日收盘, 总市值, 流通市值, 市场类型, 行情ID ``` -------------------------------- ### Optimize Memory Usage with Pagination Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md For large datasets, use pagination by specifying the 'pz' parameter to retrieve data in smaller chunks, optimizing memory usage and preventing potential crashes. ```python import efinance as ef # Use pagination for large result sets df = ef.fund.get_quote_history('161725', pz=100) # Return 100 records, not all ``` -------------------------------- ### Concurrent Data Retrieval with Multitasking Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md The efinance library leverages the 'multitasking' library to perform batch operations concurrently, significantly speeding up data retrieval for multiple items. ```python import efinance as ef # Automatically uses multitasking for batch operations df = ef.stock.get_base_info(['600519', '000651', '300750']) # Concurrent ``` -------------------------------- ### Display Progress Bars for Batch Operations Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md The library automatically displays progress bars (using tqdm) for batch operations, providing visual feedback on the progress of multiple data retrievals. ```python import efinance as ef # Progress bars automatically displayed for batch operations df = ef.stock.get_base_info(['600519', '000651', '300750']) # Shows progress bar ``` -------------------------------- ### Efinance Utilizes Rich for Formatted Output Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md The efinance library automatically integrates with the 'rich' library to provide nicely formatted output, especially for error messages, improving readability. ```python import efinance as ef import rich # Library automatically uses rich for formatted output result = ef.stock.get_base_info('invalid_code') # Pretty error message via rich ``` -------------------------------- ### Search Security Information Locally Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/utils.md Searches for security information directly within the local cache. This is faster than a full search but only returns results if they are present and not expired (cache TTL is 3 days). ```python import efinance as ef quote = ef.utils.search_quote_locally('600519') if quote: print(f"Cached: {quote.name}") else: print("Not in cache or expired") ``` -------------------------------- ### Get Real-time Stock Quotes Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Fetch real-time stock quotes. By default, it retrieves data for Shanghai-Shenzhen A-shares. Can also filter by specific market identifiers. ```python import efinance as ef # Shanghai-Shenzhen A-stocks (default) df = ef.stock.get_realtime_quotes() # Using filter df = ef.stock.get_realtime_quotes(fs='沪A') ``` -------------------------------- ### Set Efinance Verbosity via Environment Variable Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Control the library's verbosity level by setting the EFINANCE_VERBOSE environment variable. This is useful for debugging or reducing log output. ```bash # Example: Set verbosity (if supported by library) export EFINANCE_VERBOSE=1 ``` -------------------------------- ### Get Daily Stock Billboard Source: https://github.com/micro-sheep/efinance/blob/main/docs/example.md Retrieves the daily stock billboard data. This function provides a comprehensive list of stocks with detailed metrics and reasons for their appearance on the billboard. ```python >>> ef.stock.get_daily_billboard() 股票代码 股票名称 上榜日期 解读 收盘价 涨跌幅 换手率 龙虎榜净买额 龙虎榜买入额 龙虎榜卖出额 龙虎榜成交额 市场总成交额 净买额占总成交比 成交额占总成交比 流通市值 上榜原因 0 000608 阳光股份 2021-08-27 卖一主卖,成功率48.36% 3.73 -9.9034 3.8430 -8.709942e+06 1.422786e+07 2.293780e+07 3.716565e+07 110838793 -7.858208 33.531268 2.796761e+09 日跌幅偏离值达到7%的前5只证券 1 000751 锌业股份 2021-08-27 主力做T,成功率18.84% 5.32 -2.9197 19.6505 -1.079219e+08 5.638899e+07 1.643109e+08 2.206999e+08 1462953973 -7.376984 15.085906 7.500502e+09 日振幅值达到15%的前5只证券 2 000762 西藏矿业 2021-08-27 北京资金买入,成功率39.42% 63.99 1.0741 15.6463 2.938758e+07 4.675541e+08 4.381665e+08 9.057206e+08 4959962598 0.592496 18.260633 3.332571e+10 日振幅值达到15%的前5只证券 3 000833 粤桂股份 2021-08-27 实力游资买入,成功率44.55% 8.87 10.0496 8.8263 4.993555e+07 1.292967e+08 7.936120e+07 2.086580e+08 895910429 5.573721 23.290046 3.353614e+09 连续三个交易日内,涨幅偏离值累计达到20%的证券 4 001208 华菱线缆 2021-08-27 1家机构买入,成功率40.43% 19.72 4.3386 46.1985 4.055258e+07 1.537821e+08 1.132295e+08 2.670117e+08 1203913048 3.368398 22.178651 2.634710e+09 日换手率达到20%的前5只证券 .. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... 70 688558 国盛智科 2021-08-27 买一主买,成功率38.71% 60.72 1.6064 34.0104 1.835494e+07 1.057779e+08 8.742293e+07 1.932008e+08 802569300 2.287023 24.072789 2.321743e+09 有价格涨跌幅限制的日换手率达到30%的前五只证券 71 688596 正帆科技 2021-08-27 1家机构买入,成功率57.67% 26.72 3.1660 3.9065 -1.371039e+07 8.409046e+07 9.780085e+07 1.818913e+08 745137400 -1.839982 24.410438 4.630550e+09 有价格涨跌幅限制的连续3个交易日内收盘价格涨幅偏离值累计达到30%的证券 72 688663 新风光 2021-08-27 卖一主卖,成功率37.18% 28.17 -17.6316 32.2409 1.036460e+07 5.416901e+07 4.380440e+07 9.797341e+07 274732700 3.772613 35.661358 8.492507e+08 有价格涨跌幅限制的日收盘价格跌幅达到15%的前五只证券 73 688663 新风光 2021-08-27 卖一主卖,成功率37.18% 28.17 -17.6316 32.2409 1.036460e+07 5.416901e+07 4.380440e+07 9.797341e+07 274732700 3.772613 35.661358 8.492507e+08 有价格涨跌幅限制的日换手率达到30%的前五只证券 74 688667 菱电电控 2021-08-27 1家机构卖出,成功率49.69% 123.37 -18.8996 17.7701 -2.079877e+06 4.611216e+07 4.819204e+07 9.430420e+07 268503400 -0.774618 35.122163 1.461225e+09 有价格涨跌幅限制的日收盘价格跌幅达到15%的前五只证券 [75 rows x 16 columns] ``` -------------------------------- ### Add Custom Market Configuration Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/utils.md Add or update market configuration settings. This function allows for the registration of custom market categories, numbers, and names, with an option to handle duplicate entries. ```python from efinance.utils import add_market # Add custom market add_market('my_market', '999', 'Custom Exchange') ``` -------------------------------- ### get_quote_snapshot Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Get a real-time market snapshot for a single stock, including bid/ask levels and depth. This function requires a stock code and returns a pandas Series with snapshot data. ```APIDOC ## get_quote_snapshot ### Description Get real-time market snapshot for a single stock (bid/ask levels, depth). ### Parameters #### Path Parameters - **stock_code** (str) - Required - Stock code ### Returns - pd.Series: Snapshot data including price, bid/ask levels (1-5), bid/ask sizes, time, etc. ### Example ```python import efinance as ef snapshot = ef.stock.get_quote_snapshot('600519') print(f"Buy 1: {snapshot['买1价']} x {snapshot['买1数量']}") print(f"Sell 1: {snapshot['卖1价']} x {snapshot['卖1数量']}") ``` ``` -------------------------------- ### get_base_info Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/stock.md Retrieve basic information about stocks, including PE ratio, market cap, and ROE. Supports single or multiple stock codes. ```APIDOC ## get_base_info ### Description Retrieve basic information about stocks (PE ratio, market cap, ROE, etc.). ### Method GET (assumed, as no request body is specified and data is being retrieved) ### Endpoint `/stock/base_info` (inferred) ### Parameters #### Query Parameters - **stock_codes** (str or List[str]) - Required - Stock code(s) to query ### Response #### Success Response (200) - **Series** - When stock_codes is a string; includes 股票代码, 股票名称, 市盈率(动), 市净率, 所处行业, 总市值, 流通市值, 板块编号, ROE, 净利率, 净利润, 毛利率 - **DataFrame** - When stock_codes is a list of strings ``` -------------------------------- ### get_base_info Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/api-reference/fund.md Retrieves basic information for one or more funds, including fees, inception date, and assets. Supports both single fund codes and lists of codes. ```APIDOC ## get_base_info ### Description Get fund basic information (fees, inception date, assets, etc.). ### Method ```python def get_base_info(fund_codes: Union[str, List[str]]) -> Union[pd.Series, pd.DataFrame] ``` ### Parameters #### Path Parameters - **fund_codes** (str or List[str]) - Required - Fund code(s) ### Returns - **pd.Series** - When fund_codes is a string; basic fund information - **pd.DataFrame** - When fund_codes is a list ### Example ```python import efinance as ef # Single fund info = ef.fund.get_base_info('161725') print(f"Fund type: {info['基金类型']}") # Multiple funds df = ef.fund.get_base_info(['161725', '519674']) ``` ``` -------------------------------- ### Get Real-time Quotes with Custom Filter String Source: https://github.com/micro-sheep/efinance/blob/main/_autodocs/configuration.md Utilize a custom filter string for advanced control over real-time quote retrieval. This method is for users needing specific query parameters. ```python # Using custom filter string (advanced) df = ef.stock.get_realtime_quotes(fs='m:1 t:2') ```