Guide · Open source
How to use akshare: install, fetch stock data and plot it
Updated · written with AI from the project's own documentation and checked against our catalogue data
AKShare is an open-source Python library of functions that download financial data such as stock price history, bonds, funds and futures, returning results as tables you can analyze or chart. This guide is for Python users, students and analysts who want to fetch that data without writing their own scrapers. By the end you will have installed it, pulled a stock price table and plotted a chart.
Quick start
- 1Check your Python version. Confirm you have Python 3.11 or higher, 64-bit. AKShare requires it.
- 2Install akshare. Run uv pip install akshare --upgrade, or use pip install akshare --upgrade.
- 3Import the library. Start your script with import akshare as ak.
- 4Fetch a price table. Call ak.stock_zh_a_hist with a symbol, period, start date, end date and adjust value.
- 5Search for other interfaces. Use ak.search with a keyword to find interface names offline.
- 6Plot the result. Install mplfinance separately and pass the table to mpf.plot for a candlestick chart.
Install akshare with uv or pip
AKShare requires Python 3.11 or higher (64-bit). The README recommends installing with uv, and also shows a standard pip route.
If you are in mainland China, the README also lists a Tsinghua mirror index you can add to either command.
- Recommended: uv pip install akshare --upgrade
- Alternative: pip install akshare --upgrade
- The uv environment guide on the official site covers installing uv and creating a virtual environment.
uv pip install akshare --upgradeFetch stock price history in a few lines
Import the library as ak and call a function such as stock_zh_a_hist. The example in the README requests daily data for stock symbol 000001 between two dates. The result is a table you can print or analyze.
The adjust parameter is left empty in the example. The README's output shows columns such as the date, opening, closing, high and low prices, and turnover rate.
- symbol: the stock code, for example 000001
- period: for example daily
- start_date and end_date: in the form 20170301
- adjust: left as an empty string in the example
import akshare as ak
stock_zh_a_hist_df = ak.stock_zh_a_hist(symbol="000001", period="daily", start_date="20170301", end_date="20231022", adjust="")
print(stock_zh_a_hist_df)Find the right interface with search
AKShare includes an offline interface registry. ak.search() looks up interfaces by keyword and does not make a network request. ak.interface_info() returns full metadata for a single interface, including its parameters and output columns.
The search is keyword matching, not semantic search. If you already know the exact interface name, passing it in will rank that interface first.
- Use search when you know the topic but not the function name
- Use interface_info to check parameters before calling a function
- The README points to the interface search docs for limits
import akshare as ak
search_df = ak.search("可转债 实时行情", limit=5)
print(search_df)
interface_info_dict = ak.interface_info("bond_cb_jsl")
print(interface_info_dict)Plot the data with mplfinance
AKShare returns tables, so you can chart them with other libraries. The README example uses mplfinance, which you install separately with pip. It loads US daily data for AAPL, sets the date as the index, slices a date range and draws a candlestick chart with moving averages and volume.
Note that mplfinance is not part of AKShare and must be installed on its own.
- Install the plotting library: pip install mplfinance
- ak.stock_us_daily returns the price table
- Slice by date range, then pass the table to mpf.plot
import akshare as ak
import mplfinance as mpf
stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="qfq")
stock_us_daily_df = stock_us_daily_df.set_index(["date"])
stock_us_daily_df = stock_us_daily_df["2020-04-01": "2020-04-29"]
mpf.plot(stock_us_daily_df, type="candle", mav=(3, 6, 9), volume=True, show_nontrading=False)Use the data responsibly
The project's statement says the data is for academic research and reference only, and does not constitute any investment proposal. It also says some interfaces may be removed for uncontrollable reasons, so do not build critical systems on a single interface without checking.
For other languages or AI assistants, the separate AKTools project provides an HTTP API and MCP server.
- Treat output as reference data, not trading advice
- Check the data dictionary and documentation for each interface you use
- Use AKTools if your tools are not written in Python
What people use it for
- Academic research on Chinese stock price history
- Personal analysis of historical stock prices without writing scrapers
- Student projects that practice data analysis on real financial tables
- Feeding financial data to other tools or AI assistants through the AKTools project
Frequently asked questions
Is akshare free to use?
AKShare is released under the MIT licence, as shown in the project's README. The README states its data is for academic research and reference only.
What Python version does akshare need?
The README says AKShare requires Python 3.11 or higher, 64-bit.
How do I install akshare?
The README recommends uv pip install akshare --upgrade. You can also use pip install akshare --upgrade.
Can I use akshare for trading decisions?
The project explicitly disclaims investment recommendations. Its statement says data is for reference only and any investor using it should pay more attention to data risk.
Is akshare reliable for production data?
The README says some data interfaces may be removed for uncontrollable reasons and the data is for reference only. If you need guaranteed, licensed market data, the README does not offer that assurance, so look at other providers.
How does akshare compare to Tushare or yfinance?
This page does not include a verified comparison. Tushare, FinanceToolkit, yfinance and OpenBB are listed as comparable projects in the source, so check each project's documentation to compare coverage and terms.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
AKShare suits Python users doing academic or personal research on Chinese financial markets, and anyone who wants historical price tables without writing scrapers. It is a poor fit for production systems that need guaranteed, licensed data, or for users who do not work in Python unless they run the separate AKTools service.
Install options & downloads