|
38 | 38 | ) |
39 | 39 | from .models import ( |
40 | 40 | BulkVolResponse, |
| 41 | + RawVolSurface, |
41 | 42 | RealizedVolResponse, |
42 | 43 | SpotHistoryResponse, |
43 | 44 | VolHistoryResponse, |
|
48 | 49 | DEFAULT_BASE_URL = "https://cryptovol-api-nbakzshi6q-uc.a.run.app" |
49 | 50 | DEFAULT_TIMEOUT = 30.0 |
50 | 51 | DEFAULT_MAX_RETRIES = 3 |
51 | | -DEFAULT_USER_AGENT = "cryptovol-python/0.3.0" |
| 52 | +DEFAULT_USER_AGENT = "cryptovol-python/0.4.0" |
52 | 53 |
|
53 | 54 | StrikeType = Literal["strike", "moneyness", "delta"] |
54 | 55 | OptionType = Literal["C", "P"] |
@@ -272,6 +273,50 @@ def vol_surface_bulk( |
272 | 273 | data = self._request("POST", "/v1/vol-surface/bulk", json=body) |
273 | 274 | return data if raw else BulkVolResponse.model_validate(data) |
274 | 275 |
|
| 276 | + def vol_surface_raw( |
| 277 | + self, |
| 278 | + ccy: str, |
| 279 | + *, |
| 280 | + session: Session = "us", |
| 281 | + date: Optional[str] = None, |
| 282 | + raw: bool = False, |
| 283 | + ) -> Union[RawVolSurface, Dict[str, Any]]: |
| 284 | + """Raw market-quoted vol surface for one snapshot (PRO and ULTRA). |
| 285 | +
|
| 286 | + Returns every listed expiry with its quoted strike ladder |
| 287 | + (``strikes``) and the market implied vol at each strike |
| 288 | + (``mkt_vol``, index-aligned), plus ``forward``, ``atm_strike``, and |
| 289 | + ``spot``. This is the discrete market data *before* model fitting — |
| 290 | + for a smooth interpolated vol at an arbitrary strike/moneyness/delta |
| 291 | + use :meth:`vol_surface` or :meth:`vol_surface_bulk`. |
| 292 | +
|
| 293 | + Parameters |
| 294 | + ---------- |
| 295 | + ccy: |
| 296 | + Asset symbol. |
| 297 | + session: |
| 298 | + ``"asia"``, ``"london"``, or ``"us"``. Subject to your plan tier. |
| 299 | + date: |
| 300 | + Optional snapshot date (``YYYY-MM-DD``). Defaults to the latest |
| 301 | + available snapshot. |
| 302 | + raw: |
| 303 | + If True, return the parsed JSON dict instead of a typed model. |
| 304 | +
|
| 305 | + Example |
| 306 | + ------- |
| 307 | +
|
| 308 | + surf = cv.vol_surface_raw(ccy="BTC", session="us") |
| 309 | + for exp in surf.expiries: |
| 310 | + print(exp.expiry, exp.forward, len(exp.strikes), "strikes") |
| 311 | + """ |
| 312 | + params = _drop_none({ |
| 313 | + "ccy": ccy, |
| 314 | + "session": session, |
| 315 | + "date": date, |
| 316 | + }) |
| 317 | + data = self._request("GET", "/v1/vol-surface/raw", params=params) |
| 318 | + return data if raw else RawVolSurface.model_validate(data) |
| 319 | + |
275 | 320 | def vol_history( |
276 | 321 | self, |
277 | 322 | ccy: str = "BTC", |
|
0 commit comments