Skip to main content

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.2.tar.gz (331.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maoxianyong-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file maoxianyong-0.1.2.tar.gz.

File metadata

  • Download URL: maoxianyong-0.1.2.tar.gz
  • Upload date:
  • Size: 331.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for maoxianyong-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a86311633f08372a4c911dff3bb26210445d704a87aa5833421b58aaf378975b
MD5 8740f73461b12bd87e042493fcfa86c9
BLAKE2b-256 6c173d6b3e08a4a46d723d7ec7911a4b43015ff2fe621b018a36b4402b448b27

See more details on using hashes here.

File details

Details for the file maoxianyong-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for maoxianyong-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b1bbd81f2be8aada2ee8a4a993a76d2c1f337e8c92da79d42382eabcfd33363
MD5 6f6bb8764e0b6f0a154bfd27f4f69007
BLAKE2b-256 e0375f464fa6a7b077d6f1881e80dd80f713feac26b73cca10dd58513ed77515

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page