feat: flatten opportunity commands, add config management, fix completions

- Flatten opportunity into top-level portfolio and opportunity commands
- Add interactive config get/set/key/secret with type coercion
- Rewrite --doc to show TUI vs JSON schema per command
- Unify agent mode output to JSON only
- Make init prompt for API key/secret interactively
- Fix coin tab completion alias binding
- Fix set_config_value reading from wrong path
- Fail loudly on invalid numeric config values

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-20 08:43:30 +08:00
parent 3855477155
commit e37993c8b5
6 changed files with 941 additions and 171 deletions

View File

@@ -61,6 +61,8 @@ This creates:
If you are using **zsh** or **bash**, `init` will also generate and install shell completion scripts automatically, and update your rc file (`~/.zshrc` or `~/.bashrc`) if needed.
`init` interactively prompts for your Binance API key and secret if they are missing. Use `--no-prompt` to skip this.
`config.toml` stores runtime and strategy settings. `.env` stores:
```bash
@@ -101,18 +103,32 @@ coinhunter sell BTCUSDT --qty 0.01 --type limit --price 90000
coin b BTCUSDT -Q 100 -d
coin s BTCUSDT -q 0.01 -t limit -p 90000
# Opportunities (aliases: opp, o)
coinhunter opportunity portfolio
coinhunter opportunity scan
coinhunter opportunity scan --symbols BTCUSDT ETHUSDT SOLUSDT
coin opp pf
coin o scan -s BTCUSDT ETHUSDT
# Portfolio (aliases: pf, p)
coinhunter portfolio
coinhunter portfolio --agent
coin pf
# Opportunity scanning (aliases: o)
coinhunter opportunity
coinhunter opportunity --symbols BTCUSDT ETHUSDT SOLUSDT
coin o -s BTCUSDT ETHUSDT
# Audit log
coinhunter catlog
coinhunter catlog -n 20
coinhunter catlog -n 10 -o 10
# Configuration management (aliases: cfg, c)
coinhunter config get # show all config
coinhunter config get binance.recv_window
coinhunter config set opportunity.top_n 20
coinhunter config set trading.dry_run_default true
coinhunter config set market.universe_allowlist BTCUSDT,ETHUSDT
coinhunter config key YOUR_API_KEY # or omit value to prompt interactively
coinhunter config secret YOUR_SECRET # or omit value to prompt interactively
coin c get opportunity.top_n
coin c set trading.dry_run_default false
# Self-upgrade
coinhunter upgrade
coin upgrade