feat: add quant layer, portfolio-review, and strategy-backtest skills
All checks were successful
continuous-integration/drone/push Build is passing

fundamental-analysis: added statistical risk layer
- normality test (Jarque-Bera) — validates Sharpe/VaR reliability
- unit root test (ADF) — validates technical analysis applicability
- rolling skew/kurtosis — tail risk monitoring
- interpretation rules for crash risk detection

portfolio-review (NEW): portfolio health check and similarity search
- HRP optimization, correlation matrix, risk parity weights
- t-SNE clustering for hidden correlations
- stock similarity search for diversification
- rule-engine BUY_MORE/HOLD/SELL per holding

strategy-backtest (NEW): historical strategy validation
- SMA crossover, RSI mean-reversion, buy-and-hold, momentum
- comparison framework with Sharpe, max DD, win rate
- validation workflow for trade-analyze recommendations

Coverage: 67% → 79% of API endpoints (104/131)
This commit is contained in:
Yaojia Wang
2026-03-21 19:19:40 +01:00
parent 880f830741
commit e798fce6a8
3 changed files with 294 additions and 2 deletions

View File

@@ -38,6 +38,18 @@ curl -sk "$BASE/api/v1/stock/{TICKER}/sortino?days=365"
# Omega ratio (full distribution gain/loss)
curl -sk "$BASE/api/v1/stock/{TICKER}/omega?days=365"
# Normality test (are returns normally distributed? If not, Sharpe/VaR underestimates risk)
curl -sk "$BASE/api/v1/stock/{TICKER}/normality?days=365"
# Unit root test (does the price have a trend, or is it random walk?)
curl -sk "$BASE/api/v1/stock/{TICKER}/unitroot?days=365"
# Rolling skewness (negative skew = increasing downside tail risk)
curl -sk "$BASE/api/v1/stock/{TICKER}/rolling/skew?days=365&window=30"
# Rolling kurtosis (high = fat tails, extreme moves more likely)
curl -sk "$BASE/api/v1/stock/{TICKER}/rolling/kurtosis?days=365&window=30"
# Share statistics (float, shares outstanding, short % of float)
curl -sk "$BASE/api/v1/stock/{TICKER}/share-statistics"
@@ -81,10 +93,17 @@ curl -sk "$BASE/api/v1/calendar/earnings?start_date=$(date +%Y-%m-%d)&end_date=$
- Beta: {value} — [defensive <0.8 / market ~1.0 / aggressive >1.2]
- CAPM alpha: {%} — [outperforming / underperforming vs market]
- Sharpe (1Y): {value} — [poor <0.5 / good >1.0 / excellent >2.0]
- Sortino (1Y): {value} — [context vs Sharpe]
- Sortino (1Y): {value} — Sortino > Sharpe suggests positive skew (good)
- Max drawdown (1Y): {%}
- Omega ratio: {value}
### Statistical Risk (Quant Layer)
- Normality: {Jarque-Bera p-value} — [normal (p>0.05): Sharpe/VaR reliable / non-normal (p<0.05): use Sortino/Omega instead]
- Unit root (ADF): {p-value} — [trend present (p<0.05): technicals valid / random walk (p>0.05): technicals unreliable]
- Rolling skew (30d): {latest value} — [negative = growing downside tail / positive = upside tail / near 0 = symmetric]
- Rolling kurtosis (30d): {latest value} — [>3 = fat tails, extreme moves likely / <3 = thin tails, well-behaved]
- ⚠️ If non-normal + negative skew + high kurtosis = **elevated crash risk**, reduce position size
### Institutional & Ownership
- Float: {shares} ({% of total})
- Short % of float: {%} — [low <5% / moderate / high >15%]
@@ -113,4 +132,7 @@ curl -sk "$BASE/api/v1/calendar/earnings?start_date=$(date +%Y-%m-%d)&end_date=$
- Flag **earnings within 7 days** as a major catalyst/risk
- Sortino > Sharpe for stocks with asymmetric return profiles
- High short interest + upcoming catalyst = potential squeeze
- Keep under 500 words
- If normality test fails: Sharpe/VaR are unreliable, emphasize Sortino and Omega instead
- If unit root test fails (random walk): de-emphasize technical signals in your assessment
- Negative rolling skew + high kurtosis = crash risk flag — recommend smaller position
- Keep under 600 words