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.
pip install efinanceVerified import paths — ran on the pinned version, not inferred.
Fetches historical daily K-line data for a specified stock and retrieves basic information for a list of funds, demonstrating common usage patterns.
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.
Adhere strictly to the stated non-commercial use policy. For commercial projects, seek alternative, commercially licensed data providers.
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.
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.
Install the library using pip: `pip install efinance` or `pip3 install efinance`. If using a virtual environment, ensure it's activated before installation.
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.
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).
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.