Skill: Structured Financial Portfolio JSON Generation
Purpose
Generate strictly-schema-compliant JSON answers for portfolio analysis, risk review, and allocation committee tasks. Input always contains a prompt, data payloads, and an answer_template.json that serves as the schema contract.
Prerequisites
- Read
/workspace/environment_access.md for any environment URL overrides.
- Read
input/prompt.txt to understand the high-level request.
- Read all files under
input/payloads/ — there may be multiple JSON data sources.
- Read
input/payloads/answer_template.json — this is the schema contract, not a fill-in-the-blanks form.
Step-by-Step Procedure
1. Discovery — Load All Inputs
Read every file in input/payloads/ before performing any calculation. Data sources may include:
- Raw index level histories (
index_levels)
- Correlation matrices (
correlation_matrix)
- Risk metric tables (
risk_metrics)
- Carry/momentum/volatility signals (
carry, momentum, vol_z)
- Prior views and constraints (
prior_views, constraints)
- Meeting memos or review requests
2. Schema Extraction — Parse answer_template.json
The answer_template.json defines the exact output contract. Extract the following for every required top-level key:
type: string, number, list, boolean, enum
required_value: if present, the exact literal value required (e.g., "PF-MA-HELIO", "Q2_2026")
format: e.g., "YYYY-MM-DD"
length: for lists, exact expected count
item_order: for lists, the exact ordering of items by a discriminant field (e.g., opportunity_set or pair_role)
allowed_values: for enums, the closed set of permitted strings
precision: for numbers, decimal places (typically 3)
calculation: human-readable formula or method (e.g., "Pearson correlation of monthly simple returns", "signal_score = (carry + mom + vol_z) / 3")
ordering_rule: special sorting rules (e.g., "Index ids within each pair must be sorted alphabetically")
3. Calculation — Derive Each Field from Payload Data
Perform calculations exactly as specified in the template. Common patterns:
Correlation from Index Levels
- Compute monthly simple returns:
(level_t / level_{t-1}) - 1 for consecutive months.
- Compute Pearson correlation between two return series.
- Round to the
precision specified (usually 3 decimal places).
- For pair fields, sort index IDs alphabetically before placing them in the list.
Signal Scores
- Formulas like
signal_score = (carry + mom + vol_z) / 3 are common.
- Round to specified precision.
Z-Scores
z_score = (value - mean) / std_dev across the cross-section of assets.
- Round to specified precision.
Rankings
- Rank assets by a computed metric (e.g., signal_score, z_score).
rank is typically 1-based.
View Determination (UW / N / OW)
- Compare signal_score against thresholds or cross-sectional rankings.
change is derived by comparing the new view against prior_view:
- Same →
"UNCHANGED"
- Higher (e.g., UW → N, N → OW) →
"UP"
- Lower (e.g., OW → N, N → UW) →
"DOWN"
Rebalance Trigger & Next Step
- These are enums. Select the value that matches the narrative in the prompt and data.
rebalance_trigger examples: correlation_cap_breach, hy_cap_pressure, duration_drift, watchlist_concentration, committee_review.
next_step examples: approve_rotation, defer_pending_risk_review, approve_with_monitoring, reject_constraint_breach.
Boolean Flags
portfolio_risk_concentration_flag: set based on whether any correlation or concentration metric exceeds a threshold described in the prompt or evident from the data.
4. Assembly — Build the Output JSON
- Include all
required_top_level_keys in the exact order specified (or at minimum, ensure none are missing).
- For list fields, order items exactly according to
item_order in the template.
- Use only values from
allowed_values for enum fields.
- Format dates as
YYYY-MM-DD.
- Ensure numbers match the specified
precision.
- Ensure string fields with
required_value match exactly.
5. Validation — Self-Check Before Writing
Run a mental checklist against the template:
Common Pitfalls
- Ignoring
answer_template.json: The prompt alone is insufficient; the template is the authoritative schema.
- Wrong list ordering:
item_order is strict. Re-ordering items will fail validation.
- Missing precision: Financial metrics typically require 3 decimal places. Do not truncate or over-round.
- Alphabetical pair sorting: Index IDs inside correlation pairs must often be sorted alphabetically, even if the prompt mentions them in a different order.
- Enum values: Inventing rationale codes or trigger names that are not in
allowed_values will fail.
- Skipping payloads: Some tasks have multiple payload files; missing one leads to incomplete calculations.
Example Workflow Summary
Read input/prompt.txt → understand narrative.
Read input/payloads/answer_template.json → extract schema contract.
Read input/payloads/*.json → load all data.
- Compute correlations, signal scores, z-scores, rankings, views per template rules.
- Assemble JSON with exact keys, ordering, enums, and precision.
- Write to
output/answer.json.
1---2name: fewshot-attempt-03-223description: Skill: Structured Financial Portfolio JSON Generation4---5# Skill: Structured Financial Portfolio JSON Generation67## Purpose8Generate strictly-schema-compliant JSON answers for portfolio analysis, risk review, and allocation committee tasks. Input always contains a prompt, data payloads, and an `answer_template.json` that serves as the schema contract.910## Prerequisites11- Read `/workspace/environment_access.md` for any environment URL overrides.12- Read `input/prompt.txt` to understand the high-level request.13- Read **all** files under `input/payloads/` — there may be multiple JSON data sources.14- Read `input/payloads/answer_template.json` — this is the **schema contract**, not a fill-in-the-blanks form.1516## Step-by-Step Procedure1718### 1. Discovery — Load All Inputs19Read every file in `input/payloads/` before performing any calculation. Data sources may include:20- Raw index level histories (`index_levels`)21- Correlation matrices (`correlation_matrix`)22- Risk metric tables (`risk_metrics`)23- Carry/momentum/volatility signals (`carry`, `momentum`, `vol_z`)24- Prior views and constraints (`prior_views`, `constraints`)25- Meeting memos or review requests2627### 2. Schema Extraction — Parse `answer_template.json`28The `answer_template.json` defines the exact output contract. Extract the following for **every** required top-level key:29- `type`: string, number, list, boolean, enum30- `required_value`: if present, the exact literal value required (e.g., `"PF-MA-HELIO"`, `"Q2_2026"`)31- `format`: e.g., `"YYYY-MM-DD"`32- `length`: for lists, exact expected count33- `item_order`: for lists, the exact ordering of items by a discriminant field (e.g., `opportunity_set` or `pair_role`)34- `allowed_values`: for enums, the closed set of permitted strings35- `precision`: for numbers, decimal places (typically 3)36- `calculation`: human-readable formula or method (e.g., "Pearson correlation of monthly simple returns", "signal_score = (carry + mom + vol_z) / 3")37- `ordering_rule`: special sorting rules (e.g., "Index ids within each pair must be sorted alphabetically")3839### 3. Calculation — Derive Each Field from Payload Data40Perform calculations **exactly** as specified in the template. Common patterns:4142#### Correlation from Index Levels43- Compute **monthly simple returns**: `(level_t / level_{t-1}) - 1` for consecutive months.44- Compute **Pearson correlation** between two return series.45- Round to the `precision` specified (usually 3 decimal places).46- For pair fields, **sort index IDs alphabetically** before placing them in the list.4748#### Signal Scores49- Formulas like `signal_score = (carry + mom + vol_z) / 3` are common.50- Round to specified precision.5152#### Z-Scores53- `z_score = (value - mean) / std_dev` across the cross-section of assets.54- Round to specified precision.5556#### Rankings57- Rank assets by a computed metric (e.g., signal_score, z_score).58- `rank` is typically 1-based.5960#### View Determination (UW / N / OW)61- Compare signal_score against thresholds or cross-sectional rankings.62- `change` is derived by comparing the new `view` against `prior_view`:63 - Same → `"UNCHANGED"`64 - Higher (e.g., UW → N, N → OW) → `"UP"`65 - Lower (e.g., OW → N, N → UW) → `"DOWN"`6667#### Rebalance Trigger & Next Step68- These are enums. Select the value that matches the narrative in the prompt and data.69- `rebalance_trigger` examples: `correlation_cap_breach`, `hy_cap_pressure`, `duration_drift`, `watchlist_concentration`, `committee_review`.70- `next_step` examples: `approve_rotation`, `defer_pending_risk_review`, `approve_with_monitoring`, `reject_constraint_breach`.7172#### Boolean Flags73- `portfolio_risk_concentration_flag`: set based on whether any correlation or concentration metric exceeds a threshold described in the prompt or evident from the data.7475### 4. Assembly — Build the Output JSON76- Include **all** `required_top_level_keys` in the exact order specified (or at minimum, ensure none are missing).77- For list fields, order items exactly according to `item_order` in the template.78- Use **only** values from `allowed_values` for enum fields.79- Format dates as `YYYY-MM-DD`.80- Ensure numbers match the specified `precision`.81- Ensure string fields with `required_value` match exactly.8283### 5. Validation — Self-Check Before Writing84Run a mental checklist against the template:85- [ ] All `required_top_level_keys` present?86- [ ] All enum values in `allowed_values`?87- [ ] All list lengths match `length`?88- [ ] All list items in `item_order` sequence?89- [ ] All numbers rounded to `precision`?90- [ ] All `required_value` fields exact?91- [ ] Date format correct?92- [ ] Pairs alphabetically sorted where required?9394## Common Pitfalls95- **Ignoring `answer_template.json`**: The prompt alone is insufficient; the template is the authoritative schema.96- **Wrong list ordering**: `item_order` is strict. Re-ordering items will fail validation.97- **Missing precision**: Financial metrics typically require 3 decimal places. Do not truncate or over-round.98- **Alphabetical pair sorting**: Index IDs inside correlation pairs must often be sorted alphabetically, even if the prompt mentions them in a different order.99- **Enum values**: Inventing rationale codes or trigger names that are not in `allowed_values` will fail.100- **Skipping payloads**: Some tasks have multiple payload files; missing one leads to incomplete calculations.101102## Example Workflow Summary1031. `Read input/prompt.txt` → understand narrative.1042. `Read input/payloads/answer_template.json` → extract schema contract.1053. `Read input/payloads/*.json` → load all data.1064. Compute correlations, signal scores, z-scores, rankings, views per template rules.1075. Assemble JSON with exact keys, ordering, enums, and precision.1086. Write to `output/answer.json`.