Unified stock data infrastructure for A-share, HK and US markets
Project description
maoxianyong
Unified stock data infrastructure for A-share, HK and US markets.
Install
pip install maoxianyong
Quick Start
from stock import StockReader, get_universe
reader = StockReader()
# Single stock
df = reader.get('NVDA.US', start='2024-01-01')
# Multi-stock wide table (for backtesting / correlation)
close = reader.get_wide(['NVDA.US', 'AMD.US', 'TSLA.US'], 'close', start='2024-01-01')
close.pct_change().corr()
# All US stocks
us = reader.get_market('US', start='2024-01-01')
# Custom SQL
reader.query("""
SELECT symbol, date, close,
close / LAG(close) OVER (PARTITION BY symbol ORDER BY date) - 1 AS ret
FROM {daily}
WHERE market = 'US'
ORDER BY symbol, date
""")
# Index constituents
symbols = get_universe('hs300') # CSI 300
symbols = get_universe('hsi') # Hang Seng Index
symbols = get_universe('us_core') # US tech + sector leaders
Data Sources
| Market | Source | Symbols |
|---|---|---|
| A-share | AKShare (Sina) | 600519.SH, 000001.SZ |
| HK | AKShare (Sina) | 00700.HK, 09988.HK |
| US | yfinance | AAPL.US, NVDA.US |
Cloud Sync (Aliyun OSS)
export DATA_SOURCE=oss
export OSS_KEY_ID=your-key
export OSS_KEY_SECRET=your-secret
export OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com
export OSS_BUCKET=your-bucket
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
maoxianyong-0.1.0.tar.gz
(331.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maoxianyong-0.1.0.tar.gz.
File metadata
- Download URL: maoxianyong-0.1.0.tar.gz
- Upload date:
- Size: 331.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d1021535a971b6aeff3e8c83f3b7cd46927a00f460aff463d4f05b90529a30c
|
|
| MD5 |
927dca575513e1b96d7d89c6f3fb6299
|
|
| BLAKE2b-256 |
1f294e783e6f0c275897a32c63cf006d673ddd8c935ec476960ab57f527ca66e
|
File details
Details for the file maoxianyong-0.1.0-py3-none-any.whl.
File metadata
- Download URL: maoxianyong-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a23d88a80b2da17e6206499d1b0a1ede740c20b170ea342dbef1239107b2882e
|
|
| MD5 |
68d2c112306fc595edae1e9a450080e1
|
|
| BLAKE2b-256 |
2d16e6c8fe5d6a17d403cda5de11f9517178c055bb373185b0bafa51beb363e2
|