Skip to main content

Market data in your terminal, shaped for humans, scripts, and agents.

Project description

OpenTrade

Market data in your terminal, shaped for humans, scripts, and agents.

Search instruments, resolve quote IDs, inspect live quotes, review history, export datasets, and read indicator-rich observation output from one consistent command tree.

Python 3.10+ PyPI package Backend akshare Backend efinance Backend yfinance Default view observation Indicator enrichment

Installation · 30-second start · Command map · Output model · Indicator coverage · Observation examples

English | 简体中文 | 繁體中文

Discoverable
A task-shaped command tree makes it easier to find the right entrypoint than browsing raw upstream functions.
Readable
The CLI keeps terminal output consistent across table, json, csv, and tsv, with observation as the default view.
Indicator-rich
Compatible commands can be enriched with a broad built-in technical-indicator set for screening, review, and downstream analysis.

Installation

Install the published PyPI package opentrade. The package exposes both opentrade and optr.

uv
uv add -U opentrade
opentrade --help
pip
pip install -U opentrade
opentrade --help

Python 3.10+ is required.

What This Tool Is

opentrade is a product layer on top of upstream market-data providers, not a loose script collection.

It reorganizes upstream capability into a public command tree that is easier to browse from a terminal, easier to automate from scripts, and easier to consume in structured output. The goal is not to replace the upstream market-data library. The goal is to make that capability more stable and more usable from a CLI.

30-Second Start

1. Search first
opentrade search --query AAPL --market US_stock --result-count 5 --format json
Start here when you only know a ticker, keyword, or company name.
2. Query shared quotes directly
opentrade quote price latest --symbols AAPL --format json
Shared quote commands take cross-backend symbols or tickers such as AAPL directly.
3. Query market data
opentrade stock price history --symbols AAPL --market us_stock --start-date 20250102 --end-date 20250501 --format json
Continue from there into history, latest quotes, watch loops, and export workflows.

Main Functions

Instrument discovery
  • Search instruments by keyword.
  • Resolve symbols into 东方财富 quote_id when a provider-specific workflow needs it.
  • Move from discovery into quote and history queries without switching tools.
Cross-asset data access
  • Query stocks, funds, bonds, futures, and market-level live data.
  • Read both latest quotes and historical series.
  • Run refresh loops with one shared watch model.
Structured output
  • Export as table, json, csv, or tsv.
  • Use observation as the default public-facing view.
  • Fallback to raw when downstream consumers need the unwrapped shape.
Indicator enrichment
  • Choose basic, advanced, or full.
  • Expose trend, momentum, volatility, volume, and structure indicators.
  • Produce richer market context for review, screening, and automation.

Command Map

Top-level command Role Typical use
search Keyword-based discovery. Find candidates before you know the exact identifier.
resolve Identifier resolution. Turn a symbol into an 东方财富 quote_id for provider-specific workflows.
quote Cross-asset quote access. Use shared symbols or tickers directly for cross-backend quote, history, and profile queries.
market Market-level queries. Run live scans and market-mapping style lookups.
stock Stock-oriented queries. History, snapshots, live lists, flows, holders, and profiles.
fund Fund-oriented queries. NAV history, live estimates, allocation, managers, and reports.
bond Bond-oriented queries. Profiles, price history, live lists, trades, and flows.
futures Futures-oriented queries. Catalog, history, live quotes, and trade detail.
watch Refresh wrapper. Repeat a supported subcommand on a shared polling loop.

Output Model

Current real defaults
  • --format table
  • --indicator-level advanced
  • --view observation
  • --trace-window 32
Practical notes
  • observation is the default public-facing view.
  • Pass --view raw when you want the unwrapped payload shape.
  • json is usually the best target for downstream programs.
  • full gives richer indicator context than advanced, but costs more work.
Output or runtime flag Purpose
--format table|json|csv|tsv Choose terminal view or export-friendly structured output.
--full Print more complete result content.
--transpose Transpose tabular output for easier terminal reading in some cases.
--no-index Hide row indices in table output.
--limit N Keep only the first N rows in the rendered result.
--output PATH Write the rendered result to a file.
--encoding utf-8 Set file-output encoding.
--watch --interval --count --clear/--no-clear Run supported commands on a refresh loop.

Indicator Coverage

opentrade ships with a broad built-in indicator set. Compatible commands can expose far more than raw quotes, which makes the CLI useful for screening, review, and downstream analytics.

Moving averages and base transforms

sma · ema · rma · wma · dema · tema · trima · hma · zlema · highest · lowest · median_price · typical_price · true_range

Trend and channel indicators

macd · bollinger_bands · donchian_channel · keltner_channel · moving_average_envelope · aroon_indicator · dmi · adx · supertrend · parabolic_sar · ichimoku_cloud

Momentum indicators

momentum · roc · rsi · stochastic_oscillator · kdj · cci · williams_r · trix · tsi · ultimate_oscillator · dpo · ppo

Volume and money-flow indicators

obv · accumulation_distribution · chaikin_money_flow · chaikin_oscillator · mfi · vwap · force_index · ease_of_movement · price_volume_trend · volume_ratio

Volatility indicators

atr · natr · historical_volatility · chaikin_volatility · mass_index

Price-structure indicators

pivot_points · fibonacci_retracement · rolling_support_resistance

Common Chinese-market technical indicators

bias · bbi · psy · vr · mtm · dma · brar · cr · emv · asi

Level What it gives you in practice
basic The core trend and momentum set such as MA, EMA, MACD, RSI, KDJ, BOLL, ATR, and OBV.
advanced Broader trend-strength, channel, and money-flow coverage such as ADX, Donchian, Keltner, SuperTrend, MFI, PVT, CMF, VWAP, VR, and PSY.
full Richer structure and market-context layers such as Ichimoku, SAR, Mass Index, Pivot Points, Fibonacci Retracement, support/resistance, ADL, Chaikin Oscillator, Chaikin Volatility, and EMV.

Observation Examples

The examples below only show the public-facing observation format.

Latest quote observation

Command

opentrade quote price latest --symbols AAPL --format table --indicator-level full --trace-window 4

Typical output

+-----------------------------+
| meta                        |
+-----------------------------+
| module: common              |
| function: get_quote_history |
| view: observation           |
| indicator_level: full       |
| trace_window: 4             |
| row_count: 4                |
| code: AAPL                  |
| name: Apple Inc.            |
| as_of: 2026-05-28           |
+-----------------------------+

+------------------+
| latest_quote     |
+------------------+
| code: AAPL       |
| name: Apple Inc. |
| date: 2026-05-28 |
| close: 106       |
| open: 105        |
| high: 107        |
| low: 104         |
| volume: 1700     |
+------------------+

+---------------------+
| current_metrics     |
+---------------------+
| close: 106          |
| open: 105           |
| high: 107           |
| low: 104            |
| volume: 1700        |
| ma5: 103            |
| ma10: 102.5         |
| macd_dif: 0.36      |
| macd_dea: 0.26      |
| rsi14: 59           |
+---------------------+

+-----------------------------------+
| trace_points.price_ma             |
+-----------------------------------+
| [block 1] bar_offset: -3 -> 0     |
| bar_offset: -3 | -2 | -1 | 0      |
| close: 100 | 102 | 104 | 106      |
| ma5: 99.8 | 100.5 | 102 | 103     |
| ma10: 100.1 | 100.4 | 101 | 102.5 |
+-----------------------------------+

+-------------------------------------------------------------+
| recent_events                                               |
+-------------------------------------------------------------+
| [1] bars_ago: -2                                            |
|     event_key: ma5_crossed_above_ma10                       |
|     subject_a: ma5                                          |
|     relation: crossed_above                                 |
|     subject_b: ma10                                         |
|     description: ma5 moved from below to above ma10         |
| prev_a: 99.8   prev_b: 100.1   curr_a: 100.5   curr_b:      |
| 100.4                                                     |
+-------------------------------------------------------------+
History observation

Command

opentrade stock price history --symbols AAPL --market us_stock --start-date 20250102 --end-date 20250501 --format table --indicator-level advanced --trace-window 4

Typical output

+-----------------------------+
| meta                        |
+-----------------------------+
| module: common              |
| function: get_quote_history |
| view: observation           |
| indicator_level: full       |
| trace_window: 4             |
| row_count: 4                |
| code: AAPL                  |
| name: Apple Inc.            |
| as_of: 2026-05-28           |
+-----------------------------+

+---------------------+
| current_metrics     |
+---------------------+
| close: 106          |
| ma5: 103            |
| ma10: 102.5         |
| ma20: 101.4         |
| ema12: 102.9        |
| ema26: 101.7        |
| macd_dif: 0.36      |
| macd_dea: 0.26      |
| rsi14: 59           |
| kdj_k: 62           |
| kdj_d: 60           |
| plus_di: 28         |
| minus_di: 16        |
| adx: 28             |
+---------------------+

+---------------------------------------+
| trace_points.macd_osc                 |
+---------------------------------------+
| [block 1] bar_offset: -3 -> 0         |
| bar_offset: -3 | -2 | -1 | 0          |
| macd_dif: 0.05 | 0.2 | 0.28 | 0.36    |
| macd_dea: -0.02 | 0.08 | 0.18 | 0.26  |
| rsi14: 51 | 54 | 56 | 59              |
| kdj_k: 50 | 55 | 60 | 62              |
| kdj_d: 47 | 52 | 57 | 60              |
+---------------------------------------+

+-------------------------------------------------------------+
| recent_events                                               |
+-------------------------------------------------------------+
| [1] bars_ago: 0                                             |
|     event_key: volume_ratio_5_crossed_above_1               |
|     subject_a: volume_ratio_5                               |
|     relation: crossed_above                                 |
|     subject_b: 1.0                                          |
|     description: volume_ratio_5 moved from at-or-below to   |
|     above 1                                                 |
| prev_a: 1   prev_b: 1   curr_a: 1.3   curr_b: 1             |
+-------------------------------------------------------------+
Multi-source fund observation

Command

opentrade fund nav history-batch --symbols 161725 --symbols 005827 --format table --view observation --trace-window 4

Typical output

+---------------+
| source.161725 |
+---------------+

+-----------------------------+
| meta                        |
+-----------------------------+
| module: common              |
| function: get_quote_history |
| view: observation           |
| indicator_level: full       |
| trace_window: 4             |
| row_count: 4                |
| code: AAPL                  |
| name: Apple Inc.            |
| as_of: 2026-05-28           |
+-----------------------------+

+------------------+
| latest_quote     |
+------------------+
| code: AAPL       |
| name: Apple Inc. |
| date: 2026-05-28 |
| close: 106       |
+------------------+

+---------------+
| source.005827 |
+---------------+

+-----------------------------+
| meta                        |
+-----------------------------+
| module: common              |
| function: get_quote_history |
| view: observation           |
| indicator_level: full       |
| trace_window: 4             |
| row_count: 4                |
| code: AAPL                  |
| name: Apple Inc.            |
| as_of: 2026-05-28           |
+-----------------------------+

+------------------+
| latest_quote     |
+------------------+
| code: AAPL       |
| name: Apple Inc. |
| date: 2026-05-28 |
| close: 106       |
+------------------+

Common Workflows

Search and inspect
opentrade search --query NVDA --market US_stock
opentrade quote price latest --symbols NVDA
Watch a quote
opentrade watch --interval 5 --count 3 quote price latest --symbols AAPL --format json
Batch fund history
opentrade fund nav history-batch --symbols 161725 --symbols 005827 --format json
Market-level live scan
opentrade market price live --market US_stock --format json

Yahoo Finance Backend

yfinance is now a first-class backend for a focused subset of shared commands. Use --backend yfinance when you want Yahoo Finance data explicitly, and keep the following boundaries in mind:

  • Supported shared coverage includes search, stock and quote history, quote latest, conditional stock latest/snapshot, and stock and quote profile.
  • Yahoo-only capability currently starts with quote news, exposed as a provider-extension command instead of pretending to be backend-agnostic.
  • Symbol semantics follow Yahoo tickers first. Typical inputs are AAPL, MSFT, 0700.HK, or 9988.HK; A-share symbols are only translated on the stock paths, and not every domestic-market symbol style can be inferred safely.
  • Current yfinance shared execution is effectively single-target on the stock/quote paths. For batch history or batch latest requests, prefer efinance or akshare.
  • fund nav history and fund profile are not shared yfinance commands. If you need fund data through Yahoo, pass a Yahoo fund ticker through provider-specific workflows instead of mainland fund codes.
  • Shared quote commands use symbol/ticker inputs; the --quote-ids alias remains for compatibility but should not be read as an 东方财富 quote_id requirement.
  • Live smoke verification is intentionally optional because Yahoo may return explicit rate-limit failures even for valid requests.
opentrade search --query AAPL --backend yfinance --format json
opentrade quote price latest --symbols AAPL --backend yfinance --format json
opentrade quote news --quote-id AAPL --result-count 5 --format json

Notes

Data-source boundaries
  • The CLI depends on upstream market-data availability.
  • Realtime stability depends on network conditions and source-side behavior.
  • Some commands support richer indicator enrichment than others.
  • yfinance-backed commands use Yahoo ticker / symbol semantics and may fail with explicit rate-limit errors.
  • Optional live smoke checks should be run manually against a small symbol set because Yahoo throttling makes them non-deterministic.
Usage boundaries
  • Use side-effect commands such as report download intentionally.
  • Prefer json when another program will consume the result.
  • Prefer observation when a human or agent needs concise market context instead of raw tables.

License

See LICENSE.

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

opentrade-1.0.0.tar.gz (135.3 kB view details)

Uploaded Source

Built Distribution

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

opentrade-1.0.0-py3-none-any.whl (104.2 kB view details)

Uploaded Python 3

File details

Details for the file opentrade-1.0.0.tar.gz.

File metadata

  • Download URL: opentrade-1.0.0.tar.gz
  • Upload date:
  • Size: 135.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opentrade-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c9fd27a687bcf78860664686bfbe3a8cd130fd6a3fcc70632c86fd3e08f6fe94
MD5 e25b205385107a84c0ccbe099f1ad9c4
BLAKE2b-256 f89af393f9a7d499a1b0006efbab0ea35f3f2cb57e65f5288a5e9dd0e45aa0ea

See more details on using hashes here.

File details

Details for the file opentrade-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: opentrade-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 104.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for opentrade-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 852ea252071cc3ef3862cd549d9e54872de152fef205ae539a7f40a39163f634
MD5 fe5b82b4b8c60be8ed07202552d96b4b
BLAKE2b-256 eb5445a1f411bd592bfc0344103db373c001616c9e27ae8cff536b6f7a833177

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