@startsimpli/api 0.5.18 → 0.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/api",
3
- "version": "0.5.18",
3
+ "version": "0.5.19",
4
4
  "description": "Type-safe Django REST API client for StartSimpli apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -78,10 +78,9 @@ export const ENDPOINTS = {
78
78
  EARNINGS_CALENDAR: 'api/v1/markets/calendar',
79
79
  TRADING_SNAPSHOTS: 'api/v1/markets/trading/snapshots',
80
80
 
81
- // Options (TENTATIVE — schemas to be confirmed by claude-mac via agent_bridge req 42c763b2)
81
+ // Options — schemas aligned with brain-trading prefs (agent_bridge req b09a6bb6)
82
82
  OPTIONS_CHAIN: 'api/v1/markets/options/chain',
83
- OPTIONS_IV: 'api/v1/markets/options/iv',
84
- OPTIONS_SKEW: 'api/v1/markets/options/skew',
83
+ OPTIONS_IV_HISTORY: (symbol: string) => `api/v1/markets/instruments/${symbol}/options/iv/history`,
85
84
  OPTIONS_GREEKS: 'api/v1/markets/options/greeks',
86
85
  VIX_TERM: 'api/v1/markets/vix_term',
87
86
 
package/src/index.ts CHANGED
@@ -237,9 +237,11 @@ export type {
237
237
  OptionsChainResponse,
238
238
  OptionsIvPoint,
239
239
  OptionsIvResponse,
240
+ OptionsIvHistoryParams,
240
241
  OptionsSkewPoint,
241
- OptionsSkewResponse,
242
242
  OptionsGreeks,
243
+ VixTenor,
244
+ VixTermState,
243
245
  VixTermPoint,
244
246
  VixTermResponse,
245
247
  } from './lib/markets-api';
@@ -271,34 +271,40 @@ export interface OptionsChainParams {
271
271
  expiry?: string;
272
272
  }
273
273
 
274
+ // Per brain-trading req b09a6bb6 — atm/skew/put-call ratios as a single snapshot row
274
275
  export interface OptionsIvPoint {
275
- date: string;
276
- iv30: number;
277
- iv60: number | null;
278
- iv90: number | null;
279
- iv30Rank: number | null;
280
- iv30Percentile: number | null;
276
+ snapshotDate: string;
277
+ atmIv: number;
278
+ atmCallIv: number | null;
279
+ atmPutIv: number | null;
280
+ ivSkew25d: number | null;
281
+ ivSkewOtmPuts: number | null;
282
+ putCallVolumeRatio: number | null;
283
+ putCallOiRatio: number | null;
284
+ // Populated once 20+ days of history accumulate
285
+ ivRank30d: number | null;
286
+ ivRank252d: number | null;
281
287
  }
282
288
 
283
289
  export interface OptionsIvResponse {
284
290
  symbol: string;
285
- count: number;
286
291
  results: OptionsIvPoint[];
287
292
  }
288
293
 
294
+ export interface OptionsIvHistoryParams {
295
+ symbol: string;
296
+ since?: string;
297
+ until?: string;
298
+ }
299
+
300
+ // Skew is derived client-side from chain (per brain-trading guidance);
301
+ // kept as a local UI type, not an endpoint.
289
302
  export interface OptionsSkewPoint {
290
303
  strike: number;
291
304
  iv: number;
292
305
  side: OptionSide;
293
306
  }
294
307
 
295
- export interface OptionsSkewResponse {
296
- symbol: string;
297
- expiry: string;
298
- spot: number;
299
- results: OptionsSkewPoint[];
300
- }
301
-
302
308
  export interface OptionsGreeks {
303
309
  symbol: string;
304
310
  expiry: string;
@@ -312,15 +318,20 @@ export interface OptionsGreeks {
312
318
  computedAt: string | null;
313
319
  }
314
320
 
321
+ export type VixTenor = '9D' | '30D' | '3M' | string;
322
+ export type VixTermState = 'contango' | 'backwardation';
323
+
315
324
  export interface VixTermPoint {
316
- symbol: 'VIX' | 'VIX3M' | 'VIX6M' | 'VIX1Y' | string;
325
+ tenor: VixTenor;
326
+ symbol: string;
317
327
  value: number;
318
328
  percentile252d: number | null;
319
- dailyDelta: number | null;
329
+ delta1d: number | null;
320
330
  }
321
331
 
322
332
  export interface VixTermResponse {
323
333
  generatedAt: string;
334
+ state: VixTermState;
324
335
  points: VixTermPoint[];
325
336
  }
326
337
 
@@ -440,24 +451,24 @@ function coerceContract(c: OptionContract): OptionContract {
440
451
  function coerceIvPoint(p: OptionsIvPoint): OptionsIvPoint {
441
452
  return {
442
453
  ...p,
443
- iv30: n(p.iv30),
444
- iv60: maybeN(p.iv60),
445
- iv90: maybeN(p.iv90),
446
- iv30Rank: maybeN(p.iv30Rank),
447
- iv30Percentile: maybeN(p.iv30Percentile),
454
+ atmIv: n(p.atmIv),
455
+ atmCallIv: maybeN(p.atmCallIv),
456
+ atmPutIv: maybeN(p.atmPutIv),
457
+ ivSkew25d: maybeN(p.ivSkew25d),
458
+ ivSkewOtmPuts: maybeN(p.ivSkewOtmPuts),
459
+ putCallVolumeRatio: maybeN(p.putCallVolumeRatio),
460
+ putCallOiRatio: maybeN(p.putCallOiRatio),
461
+ ivRank30d: maybeN(p.ivRank30d),
462
+ ivRank252d: maybeN(p.ivRank252d),
448
463
  };
449
464
  }
450
465
 
451
- function coerceSkewPoint(p: OptionsSkewPoint): OptionsSkewPoint {
452
- return { ...p, strike: n(p.strike), iv: n(p.iv) };
453
- }
454
-
455
466
  function coerceVixPoint(p: VixTermPoint): VixTermPoint {
456
467
  return {
457
468
  ...p,
458
469
  value: n(p.value),
459
470
  percentile252d: maybeN(p.percentile252d),
460
- dailyDelta: maybeN(p.dailyDelta),
471
+ delta1d: maybeN(p.delta1d),
461
472
  };
462
473
  }
463
474
 
@@ -539,20 +550,14 @@ export class MarketsApi {
539
550
  };
540
551
  }
541
552
 
542
- async getOptionsIv(symbol: string): Promise<OptionsIvResponse> {
543
- const res = await this.client.fetch.get<OptionsIvResponse>(ENDPOINTS.OPTIONS_IV, {
544
- params: { symbol },
553
+ async getOptionsIvHistory(params: OptionsIvHistoryParams): Promise<OptionsIvResponse> {
554
+ const { symbol, ...rest } = params;
555
+ const res = await this.client.fetch.get<OptionsIvResponse>(ENDPOINTS.OPTIONS_IV_HISTORY(symbol), {
556
+ params: rest as Record<string, unknown>,
545
557
  });
546
558
  return { ...res, results: (res.results ?? []).map(coerceIvPoint) };
547
559
  }
548
560
 
549
- async getOptionsSkew(symbol: string, expiry: string): Promise<OptionsSkewResponse> {
550
- const res = await this.client.fetch.get<OptionsSkewResponse>(ENDPOINTS.OPTIONS_SKEW, {
551
- params: { symbol, expiry },
552
- });
553
- return { ...res, spot: n(res.spot), results: (res.results ?? []).map(coerceSkewPoint) };
554
- }
555
-
556
561
  async getOptionsGreeks(symbol: string, expiry: string, strike: number, side: OptionSide): Promise<OptionsGreeks> {
557
562
  const res = await this.client.fetch.get<OptionsGreeks>(ENDPOINTS.OPTIONS_GREEKS, {
558
563
  params: { symbol, expiry, strike, side },