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.
Installation · 30-second start · Command map · Output model · Indicator coverage · Observation examples
|
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
opentradeis 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
|
Cross-asset data access
|
Structured output
|
Indicator enrichment
|
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
|
Practical notes
|
| 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, or9988.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
efinanceorakshare. fund nav historyandfund profileare 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
quotecommands use symbol/ticker inputs; the--quote-idsalias remains for compatibility but should not be read as an 东方财富quote_idrequirement. - 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
|
Usage boundaries
|
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9fd27a687bcf78860664686bfbe3a8cd130fd6a3fcc70632c86fd3e08f6fe94
|
|
| MD5 |
e25b205385107a84c0ccbe099f1ad9c4
|
|
| BLAKE2b-256 |
f89af393f9a7d499a1b0006efbab0ea35f3f2cb57e65f5288a5e9dd0e45aa0ea
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
852ea252071cc3ef3862cd549d9e54872de152fef205ae539a7f40a39163f634
|
|
| MD5 |
fe5b82b4b8c60be8ed07202552d96b4b
|
|
| BLAKE2b-256 |
eb5445a1f411bd592bfc0344103db373c001616c9e27ae8cff536b6f7a833177
|