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.4.tar.gz (334.7 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.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for maoxianyong-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e0eb0487a9ca7117902298d15e3173f87b8bb4387b154988829d382513c69021
MD5 a6ed3ca3551f2ec4e289d4963ba9c289
BLAKE2b-256 96480fe8ecdf013288742f734d5690eec0cddd03f78b4059fc3591d8cdc5c116

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for maoxianyong-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d04e87dfc99d086cc68339e7de65ab141bf105a5fefb01de5700f502f62abf
MD5 d494b587bb8012e55f87ba5bf5373326
BLAKE2b-256 e8e44d067070d5fdaba8fcfddf0a7ce946a122397e07ade1a6893133c4710f73

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