Metadata-Version: 2.4
Name: open-stock-data
Version: 0.1.3
Summary: Core library for stock/crypto data with multi-source failover
License: MIT
Project-URL: Homepage, https://github.com/openstockdata/open-stock-data
Keywords: stock,trading,multi-source,akshare,efinance,tushare
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: akshare>=1.17.0
Requires-Dist: efinance>=0.5.0
Requires-Dist: baostock>=0.8.8
Requires-Dist: yfinance>=0.2.0
Requires-Dist: tushare>=1.4.0
Requires-Dist: tenacity>=8.0.0
Requires-Dist: cachetools>=6.2.0
Requires-Dist: diskcache>=5.6.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.28.0
Provides-Extra: test
Requires-Dist: pytest>=8.0.0; extra == "test"
Requires-Dist: pytest-timeout>=2.3.0; extra == "test"

# open-stock-data

Core library for stock/crypto data with multi-source failover.

Provides 42 tool functions for A-stock, HK, US stock, and crypto data with automatic failover across 6 data sources.

## Install

```bash
pip install open-stock-data
```

## Usage

```python
from open_stock_data.tools import stock_prices, get_current_time

# Get stock prices
print(stock_prices(symbol="600519", market="sh", limit=5))

# Get current time
print(get_current_time())
```

## Environment Variables

| Variable | Purpose |
|----------|---------|
| `TUSHARE_TOKEN` | Tushare API token (enables Priority 0 A-share source) |
| `ALPHA_VANTAGE_API_KEY` | Alpha Vantage API key (enables Priority 4 US stock data) |
| `OKX_BASE_URL` | Custom OKX API proxy endpoint |
| `BINANCE_BASE_URL` | Custom Binance API proxy endpoint |
| `NEWSNOW_CHANNELS` | Comma-separated news source channels |
| `LOG_LEVEL` | Logging level (default: INFO) |

## Available Tools

### A-Stock (价格行情)
- `stock_prices` — 个股K线数据
- `stock_realtime` — 个股实时行情
- `stock_batch_realtime` — 批量实时行情

### A-Stock (信息查询)
- `search` — 股票搜索
- `stock_info` — 个股基本信息
- `stock_indicators` — 财务指标摘要
- `get_current_time` — 当前时间与交易日历

### A-Stock (市场资金)
- `stock_lhb_ggtj_sina` — 龙虎榜
- `stock_sector_fund_flow_rank` — 板块资金流排名
- `stock_margin_trading` — 融资融券
- `stock_zt_pool` — 涨停池
- `stock_north_flow` — 北向资金
- `stock_block_trade` — 大宗交易
- `stock_holder_num` — 股东人数

### A-Stock (个股分析)
- `stock_chip` — 筹码分布
- `stock_fund_flow` — 个股资金流向
- `stock_sector_spot` — 板块行情
- `stock_board_cons` — 板块成分股

### A-Stock (估值财务)
- `stock_market_pe_percentile` — 市场PE分位
- `stock_industry_pe` — 行业PE
- `stock_dividend_history` — 分红历史
- `stock_institutional_holdings` — 基金持仓
- `stock_earnings_calendar` — 业绩披露日历
- `stock_financial_compare` — 财务对比

### A-Stock (股东)
- `stock_locked_shares` — 限售解禁
- `stock_pledge_ratio` — 质押比例
- `stock_top10_holders` — 十大股东

### A-Stock (量化)
- `backtest_strategy` — 回测策略

### US Stock
- `stock_prices_global` — 全球股票K线
- `stock_overview_us` — 美股概览
- `stock_financials_us` — 美股财报
- `stock_earnings_us` — 美股业绩
- `stock_insider_us` — 内部交易
- `stock_news_us` — 美股新闻
- `stock_tech_indicators_us` — 美股技术指标

### Crypto
- `okx_prices` — OKX行情
- `okx_loan_ratios` — OKX借贷比
- `okx_taker_volume` — OKX主动买卖量
- `binance_ai_report` — Binance AI报告

### Market & News
- `stock_news` — 个股新闻
- `stock_news_global` — 全球财经新闻
- `data_source_status` — 数据源状态
