Turn efinance into a terminal interface that is easier for humans and agents to reuse
Explicit command tree, unified output layer, reusable watch workflow, and optional technical-indicator enrichment.
Installation · 30-second start · US stock examples · Command map · Indicator enrichment · Project architecture
|
Predictable Command names map directly to upstream functions, which makes discovery, scripting, and agent orchestration easier. |
Consumable Every result lands in table / json / csv / tsv, so you do not need a different post-processing path for every shape.
|
Extensible Discovery, parameter reflection, execution, rendering, and enrichment stay separated so the CLI can evolve locally instead of turning monolithic. |
Install from PyPI package the-efinance-cli. The published commands are efinance and efi.
uv add -U the-efinance-cli
efinance --helppip install -U the-efinance-cli
efinance --helpPython 3.10+ is required.
efinance-cliis not a loose script bundle. It is a command-line product layer built on top ofefinance.
It compresses the upstream market-data API surface into an explicit command tree, while separating command discovery, parameter introspection, execution, rendering, and technical-indicator enrichment into distinct modules. The goal is not to replace the market library. The goal is to make the existing capability more stable and reusable from a terminal.
1. Search first
efinance search AAPL --market US_stock --result-count 5 --format json |
2. Resolve quote_id
efinance utils get-quote-id AAPL105.AAPL.
|
3. Query data
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --limit 20 |
The issue is not missing capability
|
The CLI solves for stable operational use
|
Discovery and identifier resolution
efinance search AAPL --market US_stock --result-count 5
efinance search NVDA --market US_stock --format json
efinance utils get-quote-id AAPLHistory and export
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --limit 20
efinance stock get-quote-history MSFT --market-type us_stock --beg 20250102 --end 20250501 --format csv --output msft-history.csv
efinance stock get-quote-history TSLA --market-type us_stock --beg 20250102 --end 20250501 --indicator-level advanced --fullLatest quote and watch loop
efinance common get-latest-quote 105.AAPL --format json
efinance watch --interval 5 common get-latest-quote 105.NVDA --format json
efinance common get-latest-quote 105.MSFT --format json --output msft-latest.jsonOutput controls
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --transpose
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --no-index
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --format tsv --output aapl.tsvNote: realtime quote stability depends on the upstream market-data source. The CLI keeps failure states visible instead of hiding network volatility.
| Top-level command | Role | Typical use |
|---|---|---|
search |
Search securities by keyword and optional market enum. | The first stop when you do not know the exact identifier yet. |
watch |
Wrap any supported subcommand with a refresh loop. | One polling policy across many commands. |
stock |
Stock-oriented queries. | History, snapshots, latest quote, flows, holder data. |
fund |
Fund-oriented queries. | Net value, estimated move, positions, report download. |
bond |
Bond-oriented queries. | Base info, quotes, historical trade and capital flow. |
futures |
Futures-oriented queries. | Base info, realtime quotes, K-line, trade detail. |
common |
Shared cross-asset query entrypoints. | Useful when you already know the quote_id. |
utils |
Search and identifier tooling. | search-quote, get-quote-id, add-market. |
Module command groups
stockget-base-infoget-latest-quoteget-quote-historyget-quote-snapshotget-realtime-quotesget-deal-detailget-history-billget-today-billget-top10-stock-holder-infoget-all-company-performance
|
fundget-base-infoget-fund-codesget-fund-managerget-industry-distributionget-invest-positionget-pdf-reportsget-period-changeget-public-datesget-quote-historyget-realtime-increase-rate
|
bond / futures / common / utilsbond.get-base-infobond.get-quote-historyfutures.get-futures-base-infofutures.get-quote-historycommon.get-latest-quotecommon.get-quote-historyutils.search-quoteutils.search-quote-locallyutils.get-quote-idutils.add-market
|
| Format | Best for | Behavior |
|---|---|---|
table |
Direct terminal reading | Default mode for DataFrame-like results. |
json |
Agent or script pipelines | Best when the next step expects structured data. |
csv |
Persistence and exchange | Useful for spreadsheets, scripts, and analysis workflows. |
tsv |
Spreadsheet-friendly export | Same model as CSV, but tab-delimited. |
Shared runtime flags:
--full--transpose--no-index--limit N--output PATH--encoding utf-8
These flags stay consistent across the entire command tree.
Inline watch
efinance common get-latest-quote 105.AAPL --watch --interval 5 |
Top-level wrapper
efinance watch --interval 5 common get-latest-quote 105.AAPL --format json |
Shared watch flags:
--watch--interval FLOAT--count INT--clear / --no-clear
enrichment/ adds indicator columns when the output shape is compatible enough for history, latest quotes, snapshots, and some realtime lists.
| Level | Alias | History window | Realtime limit | Typical use |
|---|---|---|---|---|
basic |
1 |
60 | 50 | Moving averages, RSI, KDJ, MACD, and other core observations. |
advanced |
2 |
120 | 80 | Trend-strength, channel-style, and broader momentum indicators. |
full |
3 |
200 | 120 | Broader coverage including Ichimoku, SAR, pivots, Fibonacci, and support/resistance. |
The built-in set is broadly grouped as:
- Trend: MACD, Bollinger Bands, DMI / ADX, SuperTrend, Ichimoku, Donchian, Keltner, Aroon, Parabolic SAR
- Momentum: RSI, KDJ, ROC, CCI, PPO, TRIX, TSI, Williams %R
- Volume: OBV, MFI, CMF, PVT, VWAP, Force Index, Volume Ratio
- Volatility: ATR, NATR, Historical Volatility, Chaikin Volatility, Mass Index
- Price structure: Pivot Points, Fibonacci Retracement, Rolling Support / Resistance
flowchart LR
A["Natural-language intent"] --> B["search"]
B --> C["utils get-quote-id"]
C --> D["stock / common / futures"]
D --> E["rendering.py"]
E --> F["table / json / csv / tsv"]
D --> G["enrichment/"]
The stable path is:
search -> get-quote-id -> module query -> structured output / file export
Execution pipeline
flowchart LR
API["Upstream efinance API"] --> REG["registry.py"]
REG --> INT["introspection.py"]
INT --> CMD["Click command tree"]
CMD --> EXEC["executor.py"]
EXEC --> ENR["enrichment/"]
EXEC --> REN["rendering.py"]
REN --> OUT["stdout / file output"]
| File / package | Role |
|---|---|
efinance_cli/main.py |
Process entrypoint. |
efinance_cli/app.py |
Application assembly. |
efinance_cli/commands.py |
Root command, module groups, and top-level commands. |
efinance_cli/registry.py |
Whitelist and command metadata for exposed upstream capability. |
efinance_cli/introspection.py |
Signature-driven Click parameter synthesis. |
efinance_cli/executor.py |
Request execution, watch looping, and result emission. |
efinance_cli/rendering.py |
Output formatting and serialization. |
efinance_cli/enrichment/ |
Technical-indicator enrichment on compatible results. |
efinance_cli/indicators/ |
Reusable indicator math primitives. |
Outside direct CLI control
|
CLI behavior
|
The safest extension path is:
- Update the upstream function whitelist or help overrides in
registry.py. - Extend
introspection.pyonly when a new parameter type needs a coercion rule. - Extend
rendering.pyonly when a new result shape appears. - Extend
enrichment/only when a command family should gain indicator augmentation. - Add or update smoke tests for the changed surface.
The repository currently protects two minimal contracts:
- indicator exports and result shapes
basic / advanced / fullenrichment behavior
The goal is not to prove the trading semantics of every indicator. The goal is to reduce silent regressions in the command and enrichment layers.
|
Design notes CLI design and usage notes Architecture notes |
Entrypointsefinanceefi
|
See LICENSE.