efinance: a Python client for Eastmoney stock, fund, bond and futures data
efinance is a Python library for quickly fetching fund, stock, bond and futures data, a great helper for backtesting and quantitative trading.
At a glance
- What is it?
- efinance wraps Eastmoney's public quote endpoints behind pandas DataFrames. It is convenient for personal research and backtesting prototypes, and it inherits every weakness of a scraped data source.
- Who is it for?
- efinance fits individual researchers and quant hobbyists who want Chinese A-share, fund, bond or futures history in a DataFrame within minutes, and who can tolerate an unofficial data path. It does not fit production trading systems, commercial redistribution, or anyone who needs a contractual data guarantee.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 128 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- Micro-sheep/efinance4,186 ★ · +115
| Repository | 2026-09-23 | 2026-11-22 |
|---|---|---|
| Micro-sheep/efinance | 4.1k | 4.2k |
115 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The gap efinance fills for Chinese market data
Public market data for Chinese securities is scattered across exchange pages, fund company sites and portal APIs. efinance collects several of those feeds behind one Python import. The README describes it as a free open source library for obtaining stock, fund and futures data, built by an individual, and the pyproject metadata states the purpose more precisely: a finance tool to get stock, fund and futures data based on eastmoney. The topic list on the repository adds bonds to that set, and the examples directory contains four notebooks, one each for stock, fund, bond and futures.
The intended user is someone building a personal trading or research system, not an institution. The README carries an explicit statement that the project is for learning and exchange and must not be used commercially. That sentence matters more than the licence line, because it describes the author's intent about the data path rather than the code. If your plan involves redistribution or a paid product, this is the wrong starting point regardless of how the MIT licence reads.
The API shape is the real selling point. You pass a ticker or a Chinese stock name and get a pandas DataFrame back, with columns such as 股票名称, 股票代码, 日期, 开盘, 收盘, 最高, 最低, 成交量, 成交额, 振幅, 涨跌幅, 涨跌额 and 换手率. No authentication, no key, no registration step appears in the README.
How efinance gets its data and what comes back
efinance is a client, not a data provider. It calls Eastmoney endpoints over HTTP and parses the responses into DataFrames. The dependency list in requirements.txt tells you what the parsing layer leans on: requests for transport, pandas for the tabular output, jsonpath for pulling fields out of nested responses, beautifulsoup4 for HTML, retry for re-attempting failed calls, multitasking for concurrency, tqdm for progress bars and rich for terminal output. Nothing in that list is a database driver or a storage engine, which confirms the design: fetch, parse, hand back, and let the caller decide what to persist.
The single entry point shown throughout the README is ef.stock.get_quote_history. It accepts A-share codes like 600519, non-A-share tickers like AAPL, Chinese names like 微软, and ETF codes like 513050. The README's sample output for 600519 runs from 2001-08-27 to 2021-07-29 and reports 4761 rows across 13 columns, so the function returns full available history rather than a default window. The same call on AAPL returns 8744 rows and on 微软 8362 rows, which means the identifier resolution step happens inside the library, not in your code.
Those prints also expose a quirk worth knowing before you trust the numbers. The earliest rows for 600519 show negative prices around -89, and the earliest AAPL and MSFT rows show negative opens and closes with zero turnover. These look like adjusted or placeholder values from the upstream source rather than real traded prices. The README presents them without comment. Any backtest that starts at the beginning of a series will consume them.
Installing efinance and pulling your first quote history
The README gives pip as the primary install path and states Python 3.6 or later in the badge. The package metadata lists classifiers from Python 3.6 through 3.12.
pip install efinanceTo upgrade an existing install, the README uses the upgrade flag rather than a version pin.
pip install efinance --upgradeFor a development checkout, the README clones the repository and installs it in editable mode from the project root.
# 克隆代码
git clone https://github.com/Micro-sheep/efinance
cd efinance
pip install -e .There is also a Docker path. The Dockerfile is based on continuumio/miniconda3, sets a default working directory through an ARG named HOME, and runs pip install efinance during the build. The README builds the image from the repository root and then runs it interactively.
docker build -t efinance . --no-cache
docker run --rm -it efinanceOnce installed, the smallest real use is a history pull. Import the package under its documented alias, pick a code, and call get_quote_history. The README uses 600519, the Kweichow Moutai ticker.
import efinance as ef
stock_code = '600519'
ef.stock.get_quote_history(stock_code)What you should see is a DataFrame with the Chinese column headers listed earlier and one row per trading day. The README's own run of this call reports 4761 rows and 13 columns for 600519. If your network is blocked from the upstream endpoint, expect a connection error rather than an empty frame, because the library has no offline cache.
Rate limiting, unofficial endpoints and the limits of a scraper
The README itself flags the main operational risk. It asks, in a callout, whether you are hitting rate limits or network errors, and suggests a different data source when throttling or connection timeouts occur. That is the author telling you the upstream endpoint can refuse or drop your requests, and that the library does not solve it for you beyond the retry dependency in requirements.txt.
There is no documented caching layer, no local store, and no backoff policy described in the README. Every call is a network call. A backtest that loops over a few thousand tickers will issue a few thousand requests against a third-party service, and the failure mode is a raised exception partway through the loop, leaving you with partial results unless you write your own checkpointing. The retry package is a dependency, but the README does not document its configuration or how many attempts are made.
The data provenance is the second limit. Because the values come from Eastmoney's public pages, column semantics are whatever that source provides. The negative early prices in the README output are the clearest example. There is also no documented schema versioning, so a change on the upstream side can alter column names or availability without a release here.
Finally, the README's non-commercial statement and the MIT licence point in different directions. The code is MIT, but the author's stated intent restricts use, and the underlying data is not the author's to license at all. If your use case is commercial, treat the data rights as unresolved and check the upstream source's terms yourself.
efinance against akshare and baostock
The two names that come up alongside efinance are akshare and baostock, and the three differ in scope and in how they treat the data source.
akshare is the closer comparison. It is a much larger collection of interfaces covering Chinese and global markets, and it aggregates many upstream sources rather than one. The practical difference is breadth against coherence: akshare gives you more endpoints and more asset classes, while efinance gives you a small, uniform surface where every call returns the same 13-column shape. If you want one narrow job done with a predictable DataFrame, efinance's smaller API is easier to reason about. If you need coverage that efinance does not have, akshare is the one to check first.
baostock takes a different route entirely. It is built around its own data service rather than scraping public pages, which changes the failure profile: you depend on that service's availability and terms instead of a portal's. For historical A-share daily bars specifically, baostock is a reasonable alternative when the Eastmoney endpoint is giving you trouble, which is roughly the situation the efinance README itself points at.
Neither comparison makes efinance redundant. Its value is the combination of a single import, pandas output, and no credential step, and that combination is what the README demonstrates end to end.
Maintenance, licensing and the upgrade question
The repository is not archived. The last push was on 2026-07-17, which is recent enough that the project has not gone quiet. The release history is less even: v0.5.5 landed on 2025-03-15, v0.5.4 five days earlier on 2025-03-10, and v0.5.1 a year before that on 2024-03-24. The pyproject file declares version 0.5.9, which is ahead of the most recent tagged release in the list, so the packaging metadata and the release tags are not in lockstep. If you pin by tag, check which version you are actually getting.
The dependency set is modest and all common packages, which keeps upgrade cost low in normal conditions. The risk is not your dependency tree; it is the upstream endpoint. A release of efinance cannot fix a change on Eastmoney's side except by adapting the parser, and there is no documented deprecation policy for the Python API. Treat the function signatures as stable until a changelog entry says otherwise, and read changelog.md before upgrading rather than assuming backward compatibility.
The licence is MIT, declared both in the LICENSE file and in the pyproject license field. MIT covers the code. It does not cover the market data that flows through it, and the README's non-commercial statement is a separate signal from the author. Nothing here is legal advice; if you plan to redistribute the data, that question sits with the upstream source, not with this repository.
Editorial conclusion
efinance fits individual researchers and quant hobbyists who want Chinese A-share, fund, bond or futures history in a DataFrame within minutes, and who can tolerate an unofficial data path. It does not fit production trading systems, commercial redistribution, or anyone who needs a contractual data guarantee. Before adopting it, run ef.stock.get_quote_history('600519') against your network, confirm the returned column names and date range match what your strategy expects, and check the changelog for the version you pin, because the project's own README notes that rate limiting and connection timeouts happen and points users to a different data source when they do.
Frequently asked questions
What exactly is efinance?
It is a Python library for obtaining stock, fund, bond and futures data, built by an individual developer and based on Eastmoney. The README describes it as a free open source tool for getting data into a personal trading system, and the project metadata lists it under the MIT licence.
What are the risks of using efinance?
The README warns that you may hit rate limiting or connection timeouts, and suggests an alternative data source when that happens. The library has no documented cache or offline mode, so every call depends on a third-party endpoint, and the README states the project is for learning and exchange and not for commercial use.
How do I install efinance?
The README's primary path is pip install efinance, with pip install efinance --upgrade to update. It also documents a source install using git clone and pip install -e ., and a Docker build from the repository root.
Which markets and asset classes does efinance cover?
The README shows A-share history for codes like 600519, non-A-share tickers such as AAPL, Chinese name lookups like 微软, and ETF history for 513050. The repository topics add fund, bond and futures, and the examples directory has a notebook for each of those four categories.
Why do early rows in the efinance output show negative prices?
The README's sample output for 600519 begins at 2001-08-27 with negative open and close values, and the AAPL and MSFT samples show the same pattern with zero turnover. The README does not explain or filter these rows, so they appear to come from the upstream source as-is.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/micro-sheep-efinance)Star history chart for your README
[](https://hysenlabs.com/projects/micro-sheep-efinance)Was this useful?