Tushare API: A Guide to Accessing Chinese Stock Market Data
Accessing accurate stock market data is essential for developers, financial analysts, quantitative researchers, and investors. China’s stock market offers many opportunities, but working with its financial data requires reliable tools that provide historical prices, real-time information, company fundamentals, and trading statistics.
The Tushare API is a popular Python-based financial data interface designed to help users collect and analyze Chinese stock market information. It provides access to datasets covering A-shares, stock indexes, financial statements, and other market-related information.
Whether you are developing an automated trading strategy, building a financial dashboard, or conducting quantitative research, understanding how Tushare works can help you choose the right data solution.
This guide explains its features, installation process, Python integration, limitations, and alternatives.
What Is Tushare API?
Tushare is an open-source Python library and financial data platform that allows developers to retrieve Chinese financial market information through programmatic interfaces.
It is particularly useful for accessing data from China’s major stock exchanges, including the Shanghai Stock Exchange (SSE) and Shenzhen Stock Exchange (SZSE).
Users can integrate the collected information into Python applications, spreadsheets, analytical models, and quantitative trading systems.
The platform offers several types of financial information, including:
- Chinese stock market prices.
- Historical stock trading data.
- Daily trading statistics.
- Company financial statements.
- Stock indexes and market indicators.
- Company profiles and basic information.
- Economic and financial datasets.
Tushare Pro uses a points-based permission system, meaning access to certain datasets depends on account permissions and available points.
Key Features of Tushare
Understanding its main features can help developers decide whether Tushare is suitable for their projects.
1. Historical Stock Market Data
Historical information is important for understanding previous market movements. Tushare provides historical daily stock prices and other trading information that researchers can use for market analysis.
This data can help users:
- Study historical price movements.
- Identify market trends.
- Compare different stocks.
- Develop backtesting strategies.
- Analyze trading volume.
2. Company Financial Information
Financial information helps investors understand the performance of publicly listed companies.
Tushare provides access to financial datasets, including balance sheets, income statements, and cash flow statements, subject to dataset permissions.
3. Python Integration
One of Tushare’s biggest advantages is its Python integration. Developers can retrieve financial information directly into Python applications without manually downloading large datasets.
This makes it useful for data scientists, quantitative analysts, and financial software developers.
4. Stock Market Analysis
The collected data can be used with Python libraries such as Pandas, NumPy, and Matplotlib.
These tools allow users to organize financial information, calculate indicators, and create visual reports.
5. Quantitative Research
Quantitative researchers can use historical market information to test investment strategies and examine how different trading signals perform over time.
How to Install and Set Up Tushare API
Getting started with Tushare is relatively simple if you already have Python installed.
Step 1: Install Python
First, install Python on your computer. You can download it from the official Python website.
Python 3 is recommended for modern financial data projects.
Step 2: Install the Tushare Library
Open your terminal or command prompt and run:
pip install tushare
This command installs the Tushare package and makes its functions available in your Python environment.
Step 3: Create a Tushare Account
Visit the official Tushare website and register an account. After registration, you can obtain an API token.
The token is required to authenticate requests to Tushare Pro services.
Step 4: Configure Your API Token
Import the library and configure your token:
import tushare as tsts.set_token(‘YOUR_TUSHARE_TOKEN’)pro = ts.pro_api()
Replace YOUR_TUSHARE_TOKEN with your actual API token.
Keep your token private and avoid publishing it in public code repositories.
How to Retrieve Chinese Stock Market Data Using Tushare
After completing the installation, you can start retrieving financial information.
For example, the following code retrieves daily stock trading data:
import tushare as tsts.set_token(‘YOUR_TUSHARE_TOKEN’)pro = ts.pro_api()data = pro.daily( ts_code=’600519.SH’, start_date=’20260101′, end_date=’20260130′)print(data.head())
This example requests daily trading information for stock code 600519 on the Shanghai Stock Exchange.
The returned dataset can include:
- Trading date.
- Opening price.
- Highest price.
- Lowest price.
- Closing price.
- Previous closing price.
- Price changes.
- Trading volume.
- Trading amount.
You can use Pandas to organize and analyze the retrieved information.
Common Tushare API Data Types
Different financial projects require different datasets. The following table explains some commonly used data categories.
| Data Type | Purpose | Common Use |
| Daily stock data | Historical trading prices | Market analysis |
| Stock basics | Company and stock information | Stock screening |
| Financial statements | Company financial performance | Fundamental analysis |
| Index data | Stock market index information | Market comparison |
| Trading calendar | Exchange trading dates | Data scheduling |
| Money flow | Capital movement information | Trading research |
| Dividend data | Company dividend information | Investment research |
Availability may depend on the Tushare Pro account’s permissions and points.
Advantages of Using Tushare
Tushare offers several benefits for people working with Chinese financial markets.
Easy Python Development
Python integration makes it convenient to collect, process, and analyze financial information. Developers can combine Tushare with existing data science libraries.
Useful for Historical Research
Historical stock information is valuable for studying market behavior and testing trading strategies. Researchers can use datasets to examine different market conditions.
Financial Data Variety
The platform provides multiple financial datasets, making it useful for projects that require both stock market information and company financial details.
Automation Opportunities
Developers can create automated scripts to collect financial information, update databases, and generate analytical reports.
Limitations of Tushare API
Although Tushare is useful, it may not be the perfect choice for every financial application.
Some limitations should be considered before integrating it into a production system.
1. Points-Based Access
Tushare Pro uses a points-based system. Some datasets require higher permissions, and users may need additional points to access particular information.
2. Real-Time Data Requirements
Tushare is widely used for historical and research-oriented datasets. Developers building applications that require continuous live market updates should carefully evaluate its available data services.
3. Market Coverage
Tushare primarily focuses on China’s financial markets. Developers working with multiple international markets may need additional data providers.
4. API Rate Limits
Depending on the dataset and account permissions, API requests may have limits. Applications collecting large amounts of information should consider request frequency and data management.
5. Technical Knowledge
Although the Python library is relatively easy to use, beginners may still need basic programming knowledge to process datasets and troubleshoot API errors.
Tushare Alternatives for Chinese Stock Market Data
Choosing a financial data provider depends on your project’s requirements. Some applications need historical research datasets, while others require live prices, streaming updates, and broader market coverage.
One option worth exploring is iTick, which provides financial market data through REST API and WebSocket interfaces.
Developers looking for additional information about Tushare alternatives can compare different data access models and features.
iTick for Real-Time Market Information
iTick provides financial market data covering Chinese A-shares, Hong Kong stocks, US stocks, and other markets.
Its features include:
- Real-time stock quotes.
- Historical K-line information.
- WebSocket data streaming.
- Stock information and symbol lists.
- Multiple financial market coverage.
For developers interested in retrieving market prices, the stock quote API documentation explains how to request stock quotes using REST API endpoints.
Tushare vs. iTick
| Feature | Tushare | iTick |
| Python integration | Yes | Yes |
| Historical data | Yes | Yes |
| Real-time quotes | Dataset-dependent | Yes |
| WebSocket streaming | Not its main focus | Yes |
| Chinese stock coverage | Strong | Yes |
| International markets | More limited | Broader coverage |
| Access model | Points-based | Free and paid plans |
The right choice depends on your data requirements. Tushare is useful for historical research and financial datasets, while iTick can complement it with real-time market information.
Tips for Working with Financial Market APIs
Before using any financial data provider in a live application, consider these practices.
- Protect API credentials: Store tokens in environment variables rather than directly in public source code.
- Handle errors: Include exception handling to manage failed requests and unexpected responses.
- Respect request limits: Avoid sending unnecessary requests that may exceed provider restrictions.
- Validate information: Check missing values, timestamps, and unusual prices before performing calculations.
- Store historical information: Use databases or structured files to manage frequently accessed datasets.
- Check data permissions: Understand the provider’s licensing and redistribution rules.
- Test before deployment: Verify that your application works correctly under different market conditions.
These practices can improve reliability and help prevent common data collection problems.
Frequently Asked Questions (FAQs)
1. What is Tushare API used for?
Tushare is used to collect Chinese financial market information, including historical stock prices, company financial statements, trading statistics, and stock indexes.
2. Is Tushare API free?
Tushare offers access to certain datasets through its free services. However, Tushare Pro uses a points-based permission system, and some advanced datasets require additional points.
3. Does Tushare support Python?
Yes. Tushare provides a Python library that allows developers to retrieve financial information and integrate it into analytical applications.
4. Can I use Tushare for real-time stock prices?
Tushare is commonly used for historical and research-oriented financial data. If your application requires continuous real-time updates, evaluate dedicated real-time data providers as well.
5. Is Tushare suitable for quantitative trading?
Yes. Researchers and developers can use its historical datasets for backtesting, financial modeling, and quantitative strategy development.
6. What are the best alternatives to Tushare?
The best alternative depends on your requirements. iTick is worth considering for real-time quotes, historical market data, and WebSocket streaming. Other providers may also be suitable depending on market coverage and pricing.
Conclusion
Tushare is a useful financial data platform for developers, researchers, and analysts interested in China’s stock markets. Its Python integration, historical datasets, and company financial information make it valuable for quantitative research and financial analysis.
However, users should consider its points-based access system, dataset permissions, and real-time data requirements before selecting it for a project.
For applications that need both historical research and live market information, combining Tushare with another financial data provider can be a practical approach. The best solution ultimately depends on your project’s technical requirements, budget, and market coverage needs.




