efinance 命令行终端
Project description
efinance-cli
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.
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. |
What This Is
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.
30-Second Start
1. Search first
efinance search AAPL --market US_stock --result-count 5 --format json
If you only know the ticker or company name, the search entrypoint is the safest place to start.
|
2. Resolve quote_id
efinance utils get-quote-id AAPL
Common US stocks resolve into a unified identifier such as 105.AAPL.
|
3. Query data
efinance stock get-quote-history AAPL --market-type us_stock --beg 20250102 --end 20250501 --limit 20
You can keep going from there for history, latest quotes, exports, and downstream processing.
|
Why Not Call the Upstream API Directly
The issue is not missing capability
|
The CLI solves for stable operational use
|
US Stock Examples
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 AAPL
History 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 --full
Latest 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.json
Output 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.tsv
Note: realtime quote stability depends on the upstream market-data source. The CLI keeps failure states visible instead of hiding network volatility.
Command Map
| 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
|
Output Model
| 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.
Watch Model
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
Indicator Enrichment
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
Agent-Friendly Query Path
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
Project Architecture
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. |
Data-Source Boundaries
Outside direct CLI control
|
CLI behavior
|
How To Extend It
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.
Quality Bar
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.
Related Docs
|
Design notes CLI design and usage notes Architecture notes |
Entrypointsefinanceefi
|
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
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 the_efinance_cli-0.1.1.tar.gz.
File metadata
- Download URL: the_efinance_cli-0.1.1.tar.gz
- Upload date:
- Size: 48.7 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 |
e63849d5eb78f61ed68bdb574d77c13f8806dd0322b612f87091bd6da212b2f0
|
|
| MD5 |
cfafcbe5dac3d87f3cd8842af5ec8949
|
|
| BLAKE2b-256 |
8a49e0d1ec9d170d7f40f23cd48484d4d0010bf7b70b8815fa394336e745c23e
|
File details
Details for the file the_efinance_cli-0.1.1-py3-none-any.whl.
File metadata
- Download URL: the_efinance_cli-0.1.1-py3-none-any.whl
- Upload date:
- Size: 43.9 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 |
6ccf656e6b780791adcd0cf6e516c9b2e1f2c79109fe889e79e89b11c64821f6
|
|
| MD5 |
80b20171d6bcf719a4a91938d4550c91
|
|
| BLAKE2b-256 |
1d5fd41c3b5560d298e392877bc5f9a0ed2fc3f542dd3576754d608a16335fcf
|