
Security News
Google’s OSV Fix Just Added 500+ New Advisories — All Thanks to One Small Policy Change
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
A Python library for accessing Tushare financial data through optimized API.
pip install tudata
import tudata as ts
# Set your Tushare token (only need to do this once)
ts.set_token('your_tushare_token_here')
# Initialize the API client
api = ts.pro_api()
# Or initialize with token directly
api = ts.pro_api(token='your_token_here')
# Get stock basic information
stocks = api.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
print(stocks.head())
# Get daily trading data
daily_data = api.daily(ts_code='000001.SZ', start_date='20240101', end_date='20241201')
print(daily_data.head())
# Get trading calendar
cal = api.trade_cal(exchange='', start_date='20240101', end_date='20241201')
print(cal.head())
# Get historical price data with pro_bar
df = ts.pro_bar(ts_code='000001.SZ', start_date='20240101', end_date='20241201', freq='D')
print(df.head())
pro_api
The main API client class for accessing Tushare data.
api = ts.pro_api(token=None)
Parameters:
token
(str, optional): Your Tushare API token. If not provided, will use stored token.stock_basic(**kwargs)
- Get basic stock informationdaily(**kwargs)
- Get daily trading dataweekly(**kwargs)
- Get weekly trading datamonthly(**kwargs)
- Get monthly trading dataadj_factor(**kwargs)
- Get adjustment factorsdaily_basic(**kwargs)
- Get daily basic trading metricsincome(**kwargs)
- Get income statement databalancesheet(**kwargs)
- Get balance sheet datacashflow(**kwargs)
- Get cash flow statement datafina_indicator(**kwargs)
- Get financial indicatorsmoneyflow(**kwargs)
- Get money flow datatop_list(**kwargs)
- Get top gainers/loserslimit_list_d(**kwargs)
- Get daily limit up/down stocksindex_basic(**kwargs)
- Get index basic informationindex_daily(**kwargs)
- Get index daily dataindex_weight(**kwargs)
- Get index constituent weightsfund_basic(**kwargs)
- Get fund basic informationfund_nav(**kwargs)
- Get fund net asset valuefund_daily(**kwargs)
- Get fund daily trading dataset_token(token)
Store your Tushare API token locally.
Parameters:
token
(str): Your Tushare API tokenget_token()
Retrieve the stored Tushare API token.
Returns:
str
: The stored token, or None if not setpro_bar(ts_code, start_date, end_date, freq='D', **kwargs)
Get time series data with enhanced functionality.
Parameters:
ts_code
(str): Stock code (e.g., '000001.SZ')start_date
(str): Start date in 'YYYYMMDD' formatend_date
(str): End date in 'YYYYMMDD' formatfreq
(str): Data frequency ('D', 'W', 'M', etc.)The library includes optimized connection settings:
The library automatically handles:
import tudata as ts
api = ts.pro_api()
# Get all listed stocks
stocks = api.stock_basic(list_status='L')
print(f"Total stocks: {len(stocks)}")
print(stocks[['ts_code', 'name', 'industry']].head())
# Get 1 year of daily data for a specific stock
data = api.daily(
ts_code='000001.SZ',
start_date='20230101',
end_date='20231231'
)
print(data[['trade_date', 'open', 'high', 'low', 'close', 'vol']].head())
# Get financial indicators for a stock
indicators = api.fina_indicator(
ts_code='000001.SZ',
start_date='20230101',
end_date='20231231'
)
print(indicators[['end_date', 'roe', 'roa', 'eps']].head())
# Get real-time quotes (requires special permission)
quotes = api.realtime_quote(ts_code='000001.SZ,000002.SZ')
print(quotes)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please file an issue on the GitHub repository.
This library is for educational and research purposes. Please ensure you comply with Tushare's terms of service and any applicable financial data regulations.
FAQs
A Python library for accessing Tushare financial data through optimized API
We found that tudata demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
Research
/Security News
175 malicious npm packages (26k+ downloads) used unpkg CDN to host redirect scripts for a credential-phishing campaign targeting 135+ organizations worldwide.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.