{"id":6614,"library":"efinance","title":"efinance","description":"efinance is a free and open-source Python library designed for quickly obtaining stock, fund, and futures data based on Eastmoney. It is actively maintained with frequent minor releases, providing convenience for personal trading system needs. The library simplifies the process of fetching historical and real-time financial market data.","status":"active","version":"0.5.8","language":"python","source_language":"en","source_url":"https://github.com/Micro-sheep/efinance","tags":["finance","stock","fund","futures","data-scraping","eastmoney"],"install":[{"cmd":"pip install efinance","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Used extensively for data structuring and manipulation, especially for returning historical and real-time quotes as DataFrames.","package":"pandas","optional":false},{"reason":"Likely used internally for numerical operations within data processing functions.","package":"numpy","optional":false},{"reason":"Fundamental for making HTTP requests to scrape data from web sources like Eastmoney.","package":"requests","optional":false}],"imports":[{"symbol":"efinance","correct":"import efinance as ef"},{"symbol":"ef.stock","correct":"import efinance as ef\ndata = ef.stock.get_quote_history('600519')"},{"symbol":"ef.fund","correct":"import efinance as ef\ninfo = ef.fund.get_base_info(['161725', '005827'])"}],"quickstart":{"code":"import efinance as ef\n\n# Get historical daily K-line data for a stock (e.g., '600519' for Kweichow Moutai)\nstock_code = '600519'\nhistory_data = ef.stock.get_quote_history(stock_code)\nprint(f\"Historical data for {stock_code}:\\n{history_data.head()}\")\n\n# Get basic information for multiple funds (e.g., '161725', '005827')\nfund_codes = ['161725', '005827']\nfund_info = ef.fund.get_base_info(fund_codes)\nprint(f\"Basic info for funds {fund_codes}:\\n{fund_info.head()}\")","lang":"python","description":"Fetches historical daily K-line data for a specified stock and retrieves basic information for a list of funds, demonstrating common usage patterns."},"warnings":[{"fix":"Regularly update the library to the latest version. Monitor GitHub issues and releases for updates regarding data source changes. Consider implementing fallback mechanisms or data validation in your application.","message":"The library relies on web scraping data from Eastmoney. Changes to Eastmoney's website structure or APIs may cause `efinance` functions to break or return incorrect data without warning.","severity":"breaking","affected_versions":"All versions"},{"fix":"Adhere strictly to the stated non-commercial use policy. For commercial projects, seek alternative, commercially licensed data providers.","message":"The library explicitly states it is 'only for learning and exchange, and must not be used for commercial purposes' (本项目仅供学习交流使用，不得用于商业用途。). Using it for commercial applications may violate their terms or expose you to legal risks.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement delays between requests, use caching, or consider alternative data sources suggested by the library (e.g., TickFlow as mentioned in documentation) if persistent issues occur. Check your network connection.","message":"Users may encounter rate limiting or network errors (限流或网络报错) when fetching large amounts of data or making frequent requests, as data is scraped from public sources.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use the library for educational, research, or personal analysis where minor data delays or discrepancies are acceptable. For critical financial applications, use dedicated, reliable, and often paid, financial APIs with strong service level agreements.","message":"Scraped data may not be perfectly real-time or entirely accurate. It's unsuitable for high-frequency trading or applications requiring guaranteed data integrity.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'activ':26 'base':21 'conveni':33 'data':20,53,59 'data-scrap':58 'design':12 'eastmoney':23,61 'efin':1,2 'fetch':45 'financ':54 'financi':51 'free':5 'frequent':29 'fund':17,56 'futur':19,57 'histor':46 'librari':11,40 'maintain':27 'market':52 'minor':30 'need':38 'obtain':15 'open':8 'open-sourc':7 'person':35 'process':43 'provid':32 'python':10 'quick':14 'real':49 'real-tim':48 'releas':31 'scrape':60 'simplifi':41 'sourc':9 'stock':16,55 'system':37 'time':50 'trade':36","created_at":"2026-04-15T18:35:28.636413+00:00","updated_at":"2026-04-16T14:47:20.577630+00:00","problems":[{"fix":"Install the library using pip: `pip install efinance` or `pip3 install efinance`. If using a virtual environment, ensure it's activated before installation.","cause":"The `efinance` library is not installed in your current Python environment or the Python interpreter cannot locate it.","error":"ModuleNotFoundError: No module named 'efinance'"},{"fix":"Check your internet connection, try again later, or ensure your `efinance` library is updated to the latest version: `pip install --upgrade efinance`. If the issue persists, the upstream Eastmoney API might have changed its response format, requiring a library update or code adjustment.","cause":"The data returned from the Eastmoney API is not a valid JSON format, often due to an API change, rate limiting, or a temporary service outage resulting in an HTML error page or an empty response instead of expected data.","error":"json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"},{"fix":"Inspect the actual column names returned by `efinance` (e.g., by printing `df.columns` or `df.head()`) and update your code to match the new column names. For example, '开盘' (open) might have changed to '今开' (current open).","cause":"The column names returned by `efinance` functions (e.g., `get_realtime_quotes`) have changed or differ from what your code expects, often due to updates in the underlying Eastmoney data source or the `efinance` library itself.","error":"Column name doesn't match the data that is fetched by efinance"},{"fix":"Review the documentation or recent changes for the `efinance` function you are using to understand the updated DataFrame structure. Adjust your code to use the correct, current column names. Consider printing `df.columns` to see available columns.","cause":"This typically occurs when a function within `efinance` (or the underlying data source) changes the structure of the returned Pandas DataFrame, such as renaming or removing a column, and your code attempts to access the old, non-existent column.","error":"AttributeError: 'DataFrame' object has no attribute 'some_old_column_name'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.5.8","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Micro-sheep/efinance","docs":"https://efinance.readthedocs.io","changelog":null,"pypi":"https://pypi.org/project/efinance/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}