Asteria Portfolio Risk
Core workflow
- Read the task prompt and local payloads — identify the portfolio, template, and decision context.
- Fetch current state from the Asteria API — always use the live environment over stale local data.
- Reconcile conflicting records — when a local payload disagrees with the API, the API wins unless the task explicitly says otherwise.
- Compute required metrics using the bundled scripts where applicable.
- Apply policy thresholds from
/api/policiesto evaluate constraint passes. - Fill the JSON template exactly — keep numeric precision, field ordering, and enum values as declared.
API base
http://task-env:9010
See references/api_endpoints.md for the full endpoint catalog and data shapes. See references/policies.md for threshold definitions and allocation mapping rules.
Data precedence
When a local payload contains stale marks (older date, worksheet snapshot, desk note about unreconciled data), always prefer the current API responses. The data_precedence field in some templates captures this choice as current_environment_over_stale_payload. Only use local_payload_over_current_environment when the task explicitly instructs it.
Scripts
Correlation computation
Use scripts/compute_correlation.py to compute Pearson correlations from monthly index-level time series. The script accepts two columns of levels and returns a single correlation rounded to 3 decimals.
python3 scripts/compute_correlation.py --levels-a "100,101,102,..." --levels-b "200,201,203,..."
Portfolio fixed-income metrics
Use scripts/compute_portfolio_metrics.py to compute weighted YTM, weighted duration, HY allocation percentage, and total market value from holdings and bond universe data.
python3 scripts/compute_portfolio_metrics.py \
--holdings-json '<holdings array>' \
--bonds-json '<bonds array>' \
--issuers-json '<issuers array>'
The script reads JSON arrays from arguments, combines them, and outputs post-trade metrics.
Allocation view resolution
Use scripts/resolve_allocation_view.py to determine the active view (OW/N/UW), view change versus prior quarter, conviction level, and rationale code from signal scores and policy thresholds.
python3 scripts/resolve_allocation_view.py \
--signal-score 0.48 \
--prior-view N \
--policy-json '<allocation mapping policy>'
Constraint checking
After computing post-trade metrics, compare against the relevant policy from /api/policies. Each portfolio's constraint_policy_id determines which policy section applies:
POL_CREDIT_DEFAULT— standard credit constraints (HY cap 20%, duration band 3.0–5.0, issuer concentration 12%)POL_CREDIT_RISK_REDUCTION— same constraints plus a target HY reduction (≥4.0 pp reduction)POL_CORRELATION_DEFAULT— correlation high threshold 0.8, low threshold 0.2POL_MULTI_ASSET_DEFAULT— composites credit, correlation, and allocation mappingPOL_MULTI_ASSET_RISK— composites credit risk reduction and correlation; escalation at two or more material exceptions
Allocation mapping
Signal scores from /api/macro-signals map to views through the thresholds in /api/policies → allocation_mapping:
- Score ≥ 0.35 →
OW - Score ≤ -0.35 →
UW - Between →
N
Conviction is determined from signal score absolute value:
|score|≥ 0.70 →HIGH- 0.35 ≤
|score|< 0.70 →MEDIUM |score|< 0.35 →LOW
Change versus prior quarter: compare the current quarter's view to the prior quarter's view from /api/allocation/prior-views. If view rank (OW=1, N=0, UW=-1) increases → UP, decreases → DOWN, unchanged → UNCHANGED.
Index correlation reviews
When computing pairwise correlations from monthly index levels:
- Fetch levels for each index in the universe from
/api/index-levels/{index_id}. - For each pair, extract the overlapping date range, compute monthly simple returns:
(level_t / level_{t-1}) - 1. - Compute Pearson correlation from the two return series.
- Identify highest-positive and lowest correlations among all pairs.
- The number of return observations is one fewer than the number of level observations (because the first level produces no return).
Common enum values
See references/enum_values.md for the full set of allowed values used across Asteria JSON templates.