Add IDX above1 ownership discovery and import

This commit is contained in:
Rasyidan Akbar F. 2026-03-30 11:58:53 +07:00
commit 9d406ba3ee

View file

@ -22,7 +22,8 @@ src/
├── cli/ # Command handlers (clap derive structs)
│ ├── stocks.rs # stocks quote/history/technical/fundamental/...
│ ├── config.rs # config get/set/init/path
│ └── cache.rs # cache info/clear
│ ├── cache.rs # cache info/clear
│ └── ownership.rs # ownership import/query commands
├── api/ # Data providers (trait-based abstraction)
│ ├── mod.rs # MarketDataProvider trait + factory functions
│ ├── types.rs # All domain types (Quote, Ohlc, Fundamentals, ...)
@ -43,6 +44,22 @@ src/
- **Yahoo** = automatic fallback for history/OHLCV (MSN doesn't support IDX history)
- Configurable: `IDX_PROVIDER=msn|yahoo`, `IDX_HISTORY_PROVIDER=auto|yahoo|msn`
## Current Status
- Automated coverage is healthy: `cargo test` currently passes with 122 tests (86 unit, 36 integration).
- Live `stocks` commands are implemented and smoke-tested for: `quote`, `history`, `technical`, `growth`, `valuation`, `risk`, `fundamental`, `compare`, `profile`, `financials`, `earnings`, `sentiment`, `insights`, `news`, `screen`.
- `stocks history --history-provider msn` is intentionally unsupported for IDX; `auto` falls back to Yahoo.
- `ownership import --fetch-bing` is still intentionally unsupported; Bing client groundwork exists but the CLI path is deferred.
## Known Hardening Gaps
- MSN-only commands still bypass the shared cache/offline path in `src/cli/stocks.rs`; `--offline` is not reliable for `profile`/`financials`/`earnings`/`sentiment`/`insights`/`news`/`screen`.
- Core quote flow has a verified `--offline --no-cache` bug: stale cache can still be served.
- Startup/config failures do not yet honor the JSON error contract; runtime failures do.
- `stocks screen --filter` and `--region` still silently coerce invalid values instead of rejecting them.
- Some live MSN output is incomplete or misleading:
- `profile` can return sparse fields.
- `insights.last_updated` is still empty.
- `financials` table output has malformed negative-number formatting in some rows.
## Development
```bash
nix develop # enter dev shell
@ -64,15 +81,15 @@ cargo test # all tests pass
1. **Schema-driven** — define types first, build logic around them. Types are the spec.
2. **Functional approach** — pure parse/transform functions (`parse_*`, `normalize_*`), no hidden state.
3. **Data types heavy** — rich enums, newtypes, composite structs. Precision via integer representations (basis points for %, i64 for shares).
4. **Provider abstraction** — all data access through traits, never call Yahoo/MSN directly from commands.
4. **Provider abstraction first** — all data access should flow through traits/factories. Note: current MSN-only stock commands still instantiate `MsnProvider` directly in `src/cli/stocks.rs`; removing that split path is an active hardening target.
5. **Sync only** — no tokio/async. CLI tool, ureq is sufficient.
6. **Test with fixtures** — never hit live APIs in tests. Mock provider + fixture JSON.
7. **Output contract** — table to stdout (humans), `--output json` (machines), errors to stderr.
8. **Feature-gated modules**`ownership` feature for SQLite dep, keeps base binary lean.
## Docs
Detailed specs live in `docs-internal/` (gitignored — internal strategy):
- `docs-internal/SPEC.md` — system design, command tree, milestones
- `docs-internal/TODO.md` — sprint breakdown
- `docs-internal/ownership/SPEC.md` — ownership module architecture
- `docs-internal/ownership/TODO.md` — ownership sprint plan
Start with the repo-visible docs:
- `FEATURE_SPEC.md` — current hardening backlog and CLI truth-pass expectations
- `TODO.md` — working task list, including latest smoke findings
- `docs/ARCHITECTURE.md` — provider/capability design and error strategy
- `docs/CONVENTIONS.md` — repo conventions