fix(msn): correct API response parsing for profile, financials, insights, screener, history

- financials: fix incomeStatement serde rename (was incomeStatements, API sends singular)
- financials: flatten nested sub-objects (income/revenue/expense/cash) in parse_statement_section
- insights: rewrite RawInsight to match actual API shape ({insights:[{insightName,insightStatement,category}]})
- insights: group insight items into highlights (non-risk) and risks by category
- screener: build Quote directly in parse_screener_results, skip stocks with no price
- profile: use short_name fallback when long_name is null, hide empty fields
- history: map Finance/Charts 404 to Unsupported with clear IDX-specific message
- tests: update MSN history/technical tests to use mock provider
This commit is contained in:
Ciphercat 2026-03-06 20:08:03 +00:00
commit 2207c928b2
5 changed files with 251 additions and 38 deletions

View file

@ -68,7 +68,19 @@ impl HistoryProvider for MsnProvider {
_interval: &Interval,
) -> Result<Vec<Bar>, IdxError> {
let chart_type = period_to_chart_type(period);
let raw = self.client.fetch_charts(symbol, chart_type)?;
let raw = self.client.fetch_charts(symbol, chart_type).map_err(|e| {
// Finance/Charts returns 404 for IDX stocks — MSN doesn't provide
// OHLCV chart history for the Indonesian exchange (XIDX).
if matches!(e, IdxError::SymbolNotFound(_)) {
IdxError::Unsupported(
"MSN Finance/Charts does not provide OHLCV history for IDX (XIDX) stocks. \
Use --provider yahoo for historical data."
.to_string(),
)
} else {
e
}
})?;
parse_chart_history(symbol, period, &raw)
}
}