VNStock Free Expert
Use this skill when the user needs advanced Vietnam stock analysis with vnstock, while staying safe on free-tier limits.
Important packaging note
This skill is self-contained and does not require shipping a separate vnstock/ docs folder.
All operational knowledge needed by the agent is stored under:
Read order
- Read
references/capabilities.md.
- Read
references/method_matrix.md for exact class/method mapping.
- Read
references/free_tier_playbook.md before large runs.
Scope and constraints
- Library:
vnstock only.
- Preferred sources:
kbs first, vci fallback.
- Never use
tcbs.
- Treat
Screener API as unavailable unless user confirms it is restored in their installed version.
Free-tier operating rules
- No API key: target <= 20 requests/minute.
- Free API key: target <= 60 requests/minute.
- Safe default pacing in scripts: 3.2s/request.
- Reuse cached artifacts between steps.
Shared confidence rubric (required)
Report confidence as High / Medium / Low using this standard:
High: universe coverage >= 95%, critical metrics coverage >= 80%, and hard errors <= 5% of symbols.
Medium: universe coverage >= 80%, critical metrics coverage >= 60%, and hard errors <= 15%.
Low: below Medium thresholds or material missing fields that can flip ranking results.
Always output:
- Confidence level.
- Coverage stats (
symbols_requested, symbols_scored, % missing by key metric).
- Top missing fields that may change conclusions.
API key configuration (implemented)
- Skill-local key file:
.env
- Variable:
VNSTOCK_API_KEY
- All API-calling scripts auto-load this key and call vnstock auth setup before requests.
- You can override per run with
--api-key "...".
Execution workflow (ordered)
- Validate environment (
python, vnstock, pandas) and load optional API key from .env.
- Build a universe using
scripts/build_universe.py (group, exchange, or symbols mode).
- Collect market data with
scripts/collect_market_data.py using safe pacing.
- Collect fundamentals with
scripts/collect_fundamentals.py.
- Score and rank using
scripts/score_stocks.py.
- Generate analyst-style memo with
scripts/generate_report.py.
- Apply confidence rubric, disclose missing fields, and summarize risks.
Downstream handoff bundle (required when doing single-ticker deep dive)
When the user request is about valuing or building a memo for a specific ticker (or a small list), output a compact JSON bundle that downstream skills can reuse:
ticker, as_of_date, currency
financials (income/balance/cashflow + key ratios if available)
price_history (returns 1m/3m/6m/12m)
peer_set (if you built one)
metadata.source and data_quality_notes
This bundle is designed to feed equity-valuation-framework and portfolio-risk-manager.
Script map
A) Discovery and universal invocation (for broad feature coverage)
catalog_vnstock.py
Path: scripts/catalog_vnstock.py
Use when:
- You need to inspect available classes/methods in the installed
vnstock version.
- You want to confirm compatibility before running a method.
invoke_vnstock.py
Path: scripts/invoke_vnstock.py
Use when:
- You need to call any supported class/method beyond the prebuilt valuation pipeline.
- You want one generic entry point for
Listing, Quote, Company, Finance, Trading, Fund, or other exported classes.
This script supports dynamic invocation by class name and method name with JSON kwargs.
B) Valuation pipeline scripts
build_universe.py
Use when building symbol universe from index/exchange/custom symbol list.
Input: source + mode + group/exchange/symbols.
Output: outputs/universe_*.csv and latest pointers.
collect_market_data.py
Use when collecting OHLCV/momentum fields (3M, 6M, 12M returns).
Input: universe CSV path.
Output: outputs/market_data_*.csv + per-symbol errors in JSON.
collect_fundamentals.py
Use when collecting valuation and quality metrics from finance/company APIs.
Input: universe CSV path.
Output: outputs/fundamentals_*.csv + per-symbol errors in JSON.
score_stocks.py
Use when ranking symbols with composite scoring.
Input: market + fundamentals CSV files.
Output: outputs/ranking_*.csv.
generate_report.py
Use when converting ranking output to analyst-style markdown memo.
Input: ranking CSV file.
Output: outputs/investment_memo_*.md.
run_pipeline.py
Use when running the end-to-end pipeline in one command.
Input: source + universe mode.
Output: all artifacts above in one run.
Error handling rules
- Log symbol-level failures and continue processing remaining symbols.
- Do not claim missing metrics as zeros; mark them as missing.
- If a critical step fails, stop and report failed step + command + suggested retry scope.
Recommended decision logic
- If request is “standard valuation/ranking”: run pipeline scripts.
- If request needs a specific vnstock capability not in pipeline: use
catalog_vnstock.py then invoke_vnstock.py.
- If request volume is large: apply
free_tier_playbook.md throttling and chunking strategy.
Confidence aggregation (required)
When output includes ranking and valuation interpretation:
- Compute data confidence from coverage metrics (
symbols_scored, missing key fields, error ratio).
- Compute model confidence from method robustness (single metric vs multi-factor consistency).
- Final confidence = lower of data confidence and model confidence.
- In
Low confidence cases, provide directional output only and list required missing inputs.
Required output template
What Was Run: scripts, source, universe scope, and pacing profile.
Coverage: requested symbols, scored symbols, and missingness by key field.
Top Results: ranked list with score columns.
Key Risks: concentration, stale data, missing metrics, or provider limitations.
Confidence and Gaps: final confidence + exact blockers.
Quick command examples
python scripts/catalog_vnstock.py --outdir ./outputs
python scripts/invoke_vnstock.py --class-name Quote --init-kwargs '{"source":"kbs","symbol":"VCB"}' --method history --method-kwargs '{"start":"2024-01-01","end":"2024-12-31","interval":"1D"}' --outdir ./outputs
python scripts/run_pipeline.py --source kbs --mode group --group VN30 --outdir ./outputs
Trigger examples
- "Analyze VN30 using vnstock but keep it free-tier safe."
- "Rank Vietnamese stocks by value/quality/momentum with KBS data."
- "Run a full vnstock pipeline and return top candidates with risk notes."
1---2name: vnstock-free-expert3description: Runs an end-to-end vnstock workflow for free-tier-safe Vietnam stock valuation, ranking, and API operations with strict rate-limit control; used when users request Vietnamese stock analysis under free-tier constraints.4---5
6# VNStock Free Expert
7
8Use this skill when the user needs advanced Vietnam stock analysis with `vnstock`, while staying safe on free-tier limits.
9
10## Important packaging note
11This skill is self-contained and does not require shipping a separate `vnstock/` docs folder.
12All operational knowledge needed by the agent is stored under:
13- `references/`
14
15## Read order
161. Read `references/capabilities.md`.
172. Read `references/method_matrix.md` for exact class/method mapping.
183. Read `references/free_tier_playbook.md` before large runs.
19
20## Scope and constraints
21- Library: `vnstock` only.
22- Preferred sources: `kbs` first, `vci` fallback.
23- Never use `tcbs`.
24- Treat `Screener API` as unavailable unless user confirms it is restored in their installed version.
25
26## Free-tier operating rules
27- No API key: target <= 20 requests/minute.
28- Free API key: target <= 60 requests/minute.
29- Safe default pacing in scripts: 3.2s/request.
30- Reuse cached artifacts between steps.
31
32## Shared confidence rubric (required)
33Report confidence as `High` / `Medium` / `Low` using this standard:
34- `High`: universe coverage >= 95%, critical metrics coverage >= 80%, and hard errors <= 5% of symbols.
35- `Medium`: universe coverage >= 80%, critical metrics coverage >= 60%, and hard errors <= 15%.
36- `Low`: below `Medium` thresholds or material missing fields that can flip ranking results.
37
38Always output:
391. Confidence level.
402. Coverage stats (`symbols_requested`, `symbols_scored`, `% missing by key metric`).
413. Top missing fields that may change conclusions.
42
43## API key configuration (implemented)
44- Skill-local key file: `.env`
45- Variable: `VNSTOCK_API_KEY`
46- All API-calling scripts auto-load this key and call vnstock auth setup before requests.
47- You can override per run with `--api-key "..."`.
48
49## Execution workflow (ordered)
501. Validate environment (`python`, `vnstock`, `pandas`) and load optional API key from `.env`.
512. Build a universe using `scripts/build_universe.py` (`group`, `exchange`, or `symbols` mode).
523. Collect market data with `scripts/collect_market_data.py` using safe pacing.
534. Collect fundamentals with `scripts/collect_fundamentals.py`.
545. Score and rank using `scripts/score_stocks.py`.
556. Generate analyst-style memo with `scripts/generate_report.py`.
567. Apply confidence rubric, disclose missing fields, and summarize risks.
57
58## Downstream handoff bundle (required when doing single-ticker deep dive)
59When the user request is about valuing or building a memo for a **specific ticker** (or a small list), output a compact JSON bundle that downstream skills can reuse:
60- `ticker`, `as_of_date`, `currency`
61- `financials` (income/balance/cashflow + key ratios if available)
62- `price_history` (returns 1m/3m/6m/12m)
63- `peer_set` (if you built one)
64- `metadata.source` and `data_quality_notes`
65
66This bundle is designed to feed `equity-valuation-framework` and `portfolio-risk-manager`.
67
68## Script map
69
70### A) Discovery and universal invocation (for broad feature coverage)
71
721. `catalog_vnstock.py`
73Path: `scripts/catalog_vnstock.py`
74
75Use when:
76- You need to inspect available classes/methods in the installed `vnstock` version.
77- You want to confirm compatibility before running a method.
78
792. `invoke_vnstock.py`
80Path: `scripts/invoke_vnstock.py`
81
82Use when:
83- You need to call any supported class/method beyond the prebuilt valuation pipeline.
84- You want one generic entry point for `Listing`, `Quote`, `Company`, `Finance`, `Trading`, `Fund`, or other exported classes.
85
86This script supports dynamic invocation by class name and method name with JSON kwargs.
87
88### B) Valuation pipeline scripts
89
901. `build_universe.py`
91Use when building symbol universe from index/exchange/custom symbol list.
92Input: source + mode + group/exchange/symbols.
93Output: `outputs/universe_*.csv` and latest pointers.
94
952. `collect_market_data.py`
96Use when collecting OHLCV/momentum fields (3M, 6M, 12M returns).
97Input: universe CSV path.
98Output: `outputs/market_data_*.csv` + per-symbol errors in JSON.
99
1003. `collect_fundamentals.py`
101Use when collecting valuation and quality metrics from finance/company APIs.
102Input: universe CSV path.
103Output: `outputs/fundamentals_*.csv` + per-symbol errors in JSON.
104
1054. `score_stocks.py`
106Use when ranking symbols with composite scoring.
107Input: market + fundamentals CSV files.
108Output: `outputs/ranking_*.csv`.
109
1105. `generate_report.py`
111Use when converting ranking output to analyst-style markdown memo.
112Input: ranking CSV file.
113Output: `outputs/investment_memo_*.md`.
114
1156. `run_pipeline.py`
116Use when running the end-to-end pipeline in one command.
117Input: source + universe mode.
118Output: all artifacts above in one run.
119
120## Error handling rules
1211. Log symbol-level failures and continue processing remaining symbols.
1222. Do not claim missing metrics as zeros; mark them as missing.
1233. If a critical step fails, stop and report failed step + command + suggested retry scope.
124
125## Recommended decision logic
1261. If request is “standard valuation/ranking”: run pipeline scripts.
1272. If request needs a specific vnstock capability not in pipeline: use `catalog_vnstock.py` then `invoke_vnstock.py`.
1283. If request volume is large: apply `free_tier_playbook.md` throttling and chunking strategy.
129
130## Confidence aggregation (required)
131When output includes ranking and valuation interpretation:
1321. Compute data confidence from coverage metrics (`symbols_scored`, missing key fields, error ratio).
1332. Compute model confidence from method robustness (single metric vs multi-factor consistency).
1343. Final confidence = lower of data confidence and model confidence.
1354. In `Low` confidence cases, provide directional output only and list required missing inputs.
136
137## Required output template
1381. `What Was Run`: scripts, source, universe scope, and pacing profile.
1392. `Coverage`: requested symbols, scored symbols, and missingness by key field.
1403. `Top Results`: ranked list with score columns.
1414. `Key Risks`: concentration, stale data, missing metrics, or provider limitations.
1425. `Confidence and Gaps`: final confidence + exact blockers.
143
144## Quick command examples
145```bash
146python scripts/catalog_vnstock.py --outdir ./outputs
147python scripts/invoke_vnstock.py --class-name Quote --init-kwargs '{"source":"kbs","symbol":"VCB"}' --method history --method-kwargs '{"start":"2024-01-01","end":"2024-12-31","interval":"1D"}' --outdir ./outputs
148python scripts/run_pipeline.py --source kbs --mode group --group VN30 --outdir ./outputs
149```
150
151## Trigger examples
152- "Analyze VN30 using vnstock but keep it free-tier safe."
153- "Rank Vietnamese stocks by value/quality/momentum with KBS data."
154- "Run a full vnstock pipeline and return top candidates with risk notes."