fix(api): NaN/±inf dans les Greeks sérialisés en null (500 sur /v1/options/history)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Showing 1 changed file with +4 and −0
modified
hfmarketdata/api/main.py
+4 −0
@@ -184,6 +184,10 @@ def _rows_to_response(rel, limit: int, fmt: str, order_col: str): | ||
| 184 | 184 | for col in df.columns: |
| 185 | 185 | if str(df[col].dtype).startswith("datetime"): |
| 186 | 186 | df[col] = df[col].astype(str) |
| 187 | + # NaN / ±inf (Greeks manquants dans les vieux trimestres) ne sont pas | |
| 188 | + # sérialisables en JSON strict → null | |
| 189 | + df = df.replace([float("inf"), float("-inf")], None) | |
| 190 | + df = df.astype(object).where(df.notna(), None) | |
| 187 | 191 | return {"count": len(df), "data": df.to_dict(orient="records")} |
| 188 | 192 | |
| 189 | 193 | |
| 190 | 194 | |