efinance

0.5.8 · active · verified Wed Apr 15

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.

Warnings

Install

Imports

Quickstart

Fetches historical daily K-line data for a specified stock and retrieves basic information for a list of funds, demonstrating common usage patterns.

import efinance as ef

# Get historical daily K-line data for a stock (e.g., '600519' for Kweichow Moutai)
stock_code = '600519'
history_data = ef.stock.get_quote_history(stock_code)
print(f"Historical data for {stock_code}:\n{history_data.head()}")

# Get basic information for multiple funds (e.g., '161725', '005827')
fund_codes = ['161725', '005827']
fund_info = ef.fund.get_base_info(fund_codes)
print(f"Basic info for funds {fund_codes}:\n{fund_info.head()}")

view raw JSON →