{"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":"en","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,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}