Skip to main content

Standardized Chinese financial market data interface built on AKShare

Project description

AKShare One Derivative

Standardized Chinese financial market data interface + derivatives analytics engine

中文 | English

Built on AKShare, AKShare One Derivative provides:

  • Unified input/output formats across 6 data sources (EastMoney, Sina, XueQiu, SSE, Exchange, AKShare)
  • Two-track architecture: Track A (data fetching) + Track B (derivatives analytics)
  • Built-in MCP server with 43 tools for LLM Agent integration
  • Covers A-shares, futures, ETF options, and commodity options

Installation

pip install akshare-one-derivative

# With MCP server support
pip install akshare-one-derivative[mcp]

# With TA-Lib technical indicators
pip install akshare-one-derivative[talib]

Requires Python >= 3.10.

Quick Start

from akshare_one import get_hist_data, get_realtime_data

# Stock historical data (EastMoney, forward-adjusted)
df = get_hist_data("600000", interval="day", adjust="qfq")

# Futures main contract daily data (Sina)
from akshare_one import get_futures_hist_data
df = get_futures_hist_data(symbol="AG", contract="main", interval="day")

# ETF options chain (Sina)
from akshare_one import get_options_chain
df = get_options_chain(underlying_symbol="510300")

# Commodity options chain (Sina, auto-detect main contract by OI)
from akshare_one import get_commodity_options_chain
df = get_commodity_options_chain(commodity_symbol="黄金期权", contract="main")

# Calculate Greeks (Black-76)
from akshare_one.options_indicators import calculate_greeks
greeks = calculate_greeks(S=3.2, K=3.0, T=0.25, r=0.02, sigma=0.2)

# Historical volatility with Yang-Zhang estimator
from akshare_one.futures_indicators import get_historical_volatility
hv = get_historical_volatility(ohlcv_df, method="yang_zhang", window=20)

API Overview

Track A — Data Fetching

All functions return standardized pd.DataFrame with unified column names.

Category Functions Sources
Stock get_basic_info get_hist_data get_realtime_data get_news_data EastMoney, Sina, XueQiu
Financial get_balance_sheet get_income_statement get_cash_flow get_financial_metrics Sina, EastMoney
Futures get_futures_hist_data get_futures_realtime_data get_futures_main_contracts Sina
Futures Derived get_futures_basis get_futures_roll_yield get_futures_position_ranking get_futures_warehouse_receipt get_futures_inventory AKShare
ETF Options get_options_chain get_options_realtime get_options_expirations get_options_hist Sina
Options Indicators get_options_greeks get_options_risk_indicators get_options_value_analysis get_commodity_options_iv SSE, Exchange
Commodity Options get_commodity_options_contracts get_commodity_options_chain get_commodity_options_hist Sina
Insider get_inner_trade_data XueQiu

Track B — Derivatives Analytics

Local computation engines operating on Track A data.

Options Indicators (akshare_one.options_indicators):

Function Description
calculate_greeks Greeks & theoretical value (Black-76 / BS)
calculate_iv Implied volatility solver
get_options_pcr Put-Call Ratio (by volume or OI)
get_options_max_pain Max Pain strike
get_iv_rank / get_iv_percentile IV Rank & Percentile (rolling window)
get_iv_smile IV smile curve (OTM filtering, real moneyness)
get_iv_term_structure ATM IV term structure across expirations

Futures Indicators (akshare_one.futures_indicators):

Function Description
get_historical_volatility HV (close-to-close / Parkinson / Garman-Klass / Yang-Zhang)
get_volatility_cone Volatility cone (multi-window percentiles)
get_futures_oi_change Open interest change
get_futures_price_oi_divergence Price-OI divergence signal
get_futures_vwap VWAP
get_futures_term_structure Futures term structure (curve slope & level)
get_futures_spread Inter-contract spread
get_futures_long_short_ratio Long/short ratio from position ranking

Technical Indicators (akshare_one.indicators):

34 indicators including SMA, EMA, RSI, MACD, Bollinger Bands, Stochastic, ATR, CCI, ADX, OBV, MFI, SAR, and more. Supports TA-Lib and pure-pandas backends.

MCP Server

The built-in MCP server exposes 43 tools for LLM agents (Claude, GPT, etc.), organized in three categories:

Category Prefix Count Description
Data Fetching get_* 28 Track A pass-through, returns list[dict]
Self-contained Analysis compute_* 13 Internally fetches data + computes indicator
Pure Math calculate_* 2 Greeks calculation & IV solver

compute_* tools are designed for LLM agents — they accept simple params (symbol, date) and handle data fetching internally, so agents never need to pass DataFrames.

Run the server

# stdio mode (for Claude Desktop, Cursor, etc.)
uvx --from "akshare-one-derivative[mcp]" akshare-one-derivative

# HTTP mode
uvx --from "akshare-one-derivative[mcp]" akshare-one-derivative --transport http --port 8000

Claude Desktop config

{
  "mcpServers": {
    "akshare-one": {
      "command": "uvx",
      "args": ["--from", "akshare-one-derivative[mcp]", "akshare-one-derivative"]
    }
  }
}

Architecture

akshare_one/
├── __init__.py              # Track A public API (28 functions)
├── options_indicators.py    # Track B options (8 functions)
├── futures_indicators.py    # Track B futures (9 functions)
├── indicators.py            # Technical indicators (34 functions)
├── mcp/
│   └── server.py            # FastMCP server (43 tools)
└── modules/
    ├── derivatives/          # Track B engines (Greeks, options, futures)
    ├── historical/           # Stock historical data providers
    ├── realtime/             # Stock realtime data providers
    ├── financial/            # Financial statement providers
    ├── futures/              # Futures data providers (Sina, AKShare)
    ├── options/              # Options data providers (ETF + commodity)
    ├── indicators/           # Technical indicator calculators
    ├── info/                 # Stock info providers
    ├── insider/              # Insider trade providers
    ├── news/                 # News providers
    └── cache.py              # TTL cache (cachetools)

All modules follow the Factory + ABC pattern: base.py (abstract interface) → factory.py (registry) → {source}.py (implementation).

Documentation

Full API documentation: https://zwldarren.github.io/akshare-one/

License

MIT

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

akshare_one_derivative-0.4.0rc2.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

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

akshare_one_derivative-0.4.0rc2-py3-none-any.whl (112.8 kB view details)

Uploaded Python 3

File details

Details for the file akshare_one_derivative-0.4.0rc2.tar.gz.

File metadata

  • Download URL: akshare_one_derivative-0.4.0rc2.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for akshare_one_derivative-0.4.0rc2.tar.gz
Algorithm Hash digest
SHA256 f3409ae0f1a4d310643e8782f8facf2de3c0e8609f9032931d23dc17217de9f7
MD5 6969824325e93a4d2f69b62fb6e3c8bf
BLAKE2b-256 65d50c4704e08cdcc208a08b131982be1e2adc3c98eb963472d9af867dc7740f

See more details on using hashes here.

File details

Details for the file akshare_one_derivative-0.4.0rc2-py3-none-any.whl.

File metadata

  • Download URL: akshare_one_derivative-0.4.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 112.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for akshare_one_derivative-0.4.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 da1171283574f54f5655735bf320b230adef01d949edde289d962d270363b50f
MD5 577bd8c63d963f0c72e59f8ebfb3c0d8
BLAKE2b-256 1b32e1f247b1aa78a838c910862d45778d373f6579eccabc121c6ec700b0bd19

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