How to Use Python to Retrieve A‑Share Market Data and Control Positions for Quantitative Trading
This article explains four practical Python methods—Pandas_datareader, yfinance, Tushare, and JoinQuant—to fetch A‑share market data and manage trading positions, while also providing QR‑code links to free Python learning resources.
Python is widely used for quantitative trading, and this article introduces four ways to obtain A‑share market data using Python.
Pandas_datareader
The simplest method uses Pandas_datareader to fetch data such as Yahoo finance (note that Yahoo services are unavailable in mainland China after 2021‑11‑01).
yfinance
Another option is the yfinance library, which provides similar functionality with an easy‑to‑use interface.
Tushare
For more comprehensive Chinese market data, the Tushare API can be used, though full features may require a paid token.
JoinQuant
The final approach leverages the JoinQuant platform, allowing data retrieval via the get_price function without installing additional packages.
The article also includes QR codes and links to a free Python public course and additional learning resources.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.