@nadohq/nuanze-client 0.54.0 → 0.55.0

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.
Files changed (78) hide show
  1. package/README.md +8 -6
  2. package/dist/{NuanzeClient-CJI8D65z.cjs → NuanzeClient-C9yQILjc.cjs} +33 -1
  3. package/dist/NuanzeClient-C9yQILjc.cjs.map +1 -0
  4. package/dist/NuanzeClient.cjs +1 -1
  5. package/dist/NuanzeClient.d.cts +28 -1
  6. package/dist/NuanzeClient.d.cts.map +1 -1
  7. package/dist/NuanzeClient.d.ts +28 -1
  8. package/dist/NuanzeClient.d.ts.map +1 -1
  9. package/dist/NuanzeClient.js +33 -1
  10. package/dist/NuanzeClient.js.map +1 -1
  11. package/dist/{NuanzeServerFailureError-Cx8QbH0G.d.cts → NuanzeServerFailureError-DSY-xKVx.d.cts} +2 -2
  12. package/dist/{NuanzeServerFailureError-Cx8QbH0G.d.cts.map → NuanzeServerFailureError-DSY-xKVx.d.cts.map} +1 -1
  13. package/dist/{NuanzeServerFailureError-XY6Sa63q.d.ts → NuanzeServerFailureError-DckOXwP0.d.ts} +2 -2
  14. package/dist/{NuanzeServerFailureError-XY6Sa63q.d.ts.map → NuanzeServerFailureError-DckOXwP0.d.ts.map} +1 -1
  15. package/dist/{clientModelTypes-Cq932LpY.d.ts → clientModelTypes-B22P2pH3.d.cts} +123 -3
  16. package/dist/clientModelTypes-B22P2pH3.d.cts.map +1 -0
  17. package/dist/{clientModelTypes-Cq932LpY.d.cts → clientModelTypes-B22P2pH3.d.ts} +123 -3
  18. package/dist/clientModelTypes-B22P2pH3.d.ts.map +1 -0
  19. package/dist/{clientTypes-C4KxDEuR.d.cts → clientTypes-CJWiS0sM.d.ts} +77 -3
  20. package/dist/clientTypes-CJWiS0sM.d.ts.map +1 -0
  21. package/dist/{clientTypes-DK_rXTKz.d.ts → clientTypes-C_PGq9TZ.d.cts} +77 -3
  22. package/dist/clientTypes-C_PGq9TZ.d.cts.map +1 -0
  23. package/dist/dataMappers.cjs +121 -2
  24. package/dist/dataMappers.cjs.map +1 -1
  25. package/dist/dataMappers.d.cts +35 -5
  26. package/dist/dataMappers.d.cts.map +1 -1
  27. package/dist/dataMappers.d.ts +35 -5
  28. package/dist/dataMappers.d.ts.map +1 -1
  29. package/dist/dataMappers.js +115 -3
  30. package/dist/dataMappers.js.map +1 -1
  31. package/dist/index.cjs +9 -1
  32. package/dist/index.d.cts +7 -7
  33. package/dist/index.d.ts +7 -7
  34. package/dist/index.js +3 -3
  35. package/dist/{serverModelTypes-DREyTkS2.d.ts → serverModelTypes-D0JfVkqd.d.ts} +63 -3
  36. package/dist/serverModelTypes-D0JfVkqd.d.ts.map +1 -0
  37. package/dist/{serverModelTypes-SJs6R1Jb.d.cts → serverModelTypes-D8vC-W1m.d.cts} +63 -3
  38. package/dist/serverModelTypes-D8vC-W1m.d.cts.map +1 -0
  39. package/dist/{serverQueryTypes-CSwEuNlG.d.ts → serverQueryTypes-CflQbxsI.d.ts} +40 -4
  40. package/dist/serverQueryTypes-CflQbxsI.d.ts.map +1 -0
  41. package/dist/{serverQueryTypes-D_8Gn1t0.d.cts → serverQueryTypes-DS0PzfC8.d.cts} +40 -4
  42. package/dist/serverQueryTypes-DS0PzfC8.d.cts.map +1 -0
  43. package/dist/types/NuanzeServerFailureError.d.cts +1 -1
  44. package/dist/types/NuanzeServerFailureError.d.ts +1 -1
  45. package/dist/types/clientModelTypes.cjs +12 -0
  46. package/dist/types/clientModelTypes.cjs.map +1 -1
  47. package/dist/types/clientModelTypes.d.cts +2 -2
  48. package/dist/types/clientModelTypes.d.ts +2 -2
  49. package/dist/types/clientModelTypes.js +12 -1
  50. package/dist/types/clientModelTypes.js.map +1 -1
  51. package/dist/types/clientTypes.d.cts +2 -2
  52. package/dist/types/clientTypes.d.ts +2 -2
  53. package/dist/types/index.cjs +1 -0
  54. package/dist/types/index.d.cts +6 -6
  55. package/dist/types/index.d.ts +6 -6
  56. package/dist/types/index.js +2 -2
  57. package/dist/types/serverModelTypes.d.cts +2 -2
  58. package/dist/types/serverModelTypes.d.ts +2 -2
  59. package/dist/types/serverQueryTypes.cjs.map +1 -1
  60. package/dist/types/serverQueryTypes.d.cts +2 -2
  61. package/dist/types/serverQueryTypes.d.ts +2 -2
  62. package/dist/types/serverQueryTypes.js.map +1 -1
  63. package/package.json +3 -3
  64. package/src/NuanzeClient.ts +50 -0
  65. package/src/dataMappers.ts +154 -0
  66. package/src/types/clientModelTypes.ts +128 -1
  67. package/src/types/clientTypes.ts +81 -0
  68. package/src/types/serverModelTypes.ts +66 -0
  69. package/src/types/serverQueryTypes.ts +42 -0
  70. package/dist/NuanzeClient-CJI8D65z.cjs.map +0 -1
  71. package/dist/clientModelTypes-Cq932LpY.d.cts.map +0 -1
  72. package/dist/clientModelTypes-Cq932LpY.d.ts.map +0 -1
  73. package/dist/clientTypes-C4KxDEuR.d.cts.map +0 -1
  74. package/dist/clientTypes-DK_rXTKz.d.ts.map +0 -1
  75. package/dist/serverModelTypes-DREyTkS2.d.ts.map +0 -1
  76. package/dist/serverModelTypes-SJs6R1Jb.d.cts.map +0 -1
  77. package/dist/serverQueryTypes-CSwEuNlG.d.ts.map +0 -1
  78. package/dist/serverQueryTypes-D_8Gn1t0.d.cts.map +0 -1
@@ -2,6 +2,8 @@ import { toBigNumber } from '@nadohq/shared';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import {
4
4
  NuanzeCandle,
5
+ NuanzeCohort,
6
+ NuanzeCohortSeriesPoint,
5
7
  NuanzeCollateralFlow,
6
8
  NuanzeCollateralFlowPoint,
7
9
  NuanzeFollowedLeaderboardItem,
@@ -23,11 +25,15 @@ import {
23
25
  NuanzePositioningTotals,
24
26
  NuanzeSeriesPoint,
25
27
  NuanzeStockFundamentals,
28
+ NuanzeSubaccountCloseTrade,
26
29
  NuanzeSubaccountLeaderboardItem,
30
+ NuanzeSubaccountLongShortBias,
31
+ NuanzeSubaccountMostTradedMarket,
27
32
  NuanzeWalletPosition,
28
33
  NuanzeWalletTrade,
29
34
  } from './types/clientModelTypes';
30
35
  import {
36
+ GetNuanzeCohortsResponse,
31
37
  GetNuanzeCollateralFlowSeriesResponse,
32
38
  GetNuanzeCollateralFlowSummaryResponse,
33
39
  GetNuanzeCollateralFlowsResponse,
@@ -46,6 +52,7 @@ import {
46
52
  GetNuanzePlatformSummaryResponse,
47
53
  GetNuanzeSubaccountLeaderboardPositionResponse,
48
54
  GetNuanzeSubaccountLeaderboardResponse,
55
+ GetNuanzeSubaccountStatsResponse,
49
56
  GetNuanzeWalletLeaderboardPositionResponse,
50
57
  GetNuanzeWalletPnlResponse,
51
58
  GetNuanzeWalletPnlSeriesResponse,
@@ -55,7 +62,9 @@ import {
55
62
  } from './types/clientTypes';
56
63
  import {
57
64
  NuanzeServerCandle,
65
+ NuanzeServerCohort,
58
66
  NuanzeServerCohortPositioningCell,
67
+ NuanzeServerCohortSeriesPoint,
59
68
  NuanzeServerCollateralFlow,
60
69
  NuanzeServerCollateralFlowPoint,
61
70
  NuanzeServerFollowedLeaderboardItem,
@@ -80,11 +89,15 @@ import {
80
89
  NuanzeServerSeriesPoint,
81
90
  NuanzeServerSidePositioningCell,
82
91
  NuanzeServerStockFundamentals,
92
+ NuanzeServerSubaccountCloseTrade,
83
93
  NuanzeServerSubaccountLeaderboardItem,
94
+ NuanzeServerSubaccountLongShortBias,
95
+ NuanzeServerSubaccountMostTradedMarket,
84
96
  NuanzeServerWalletPosition,
85
97
  NuanzeServerWalletTrade,
86
98
  } from './types/serverModelTypes';
87
99
  import {
100
+ NuanzeServerCohortsResponse,
88
101
  NuanzeServerCollateralFlowSeriesResponse,
89
102
  NuanzeServerCollateralFlowSummaryResponse,
90
103
  NuanzeServerCollateralFlowsResponse,
@@ -101,6 +114,7 @@ import {
101
114
  NuanzeServerPlatformSummaryResponse,
102
115
  NuanzeServerSubaccountLeaderboardPositionResponse,
103
116
  NuanzeServerSubaccountLeaderboardResponse,
117
+ NuanzeServerSubaccountStatsResponse,
104
118
  NuanzeServerWalletLeaderboardPositionResponse,
105
119
  NuanzeServerWalletPnlResponse,
106
120
  NuanzeServerWalletPnlSeriesResponse,
@@ -400,6 +414,8 @@ export function mapNuanzeFollowedLeaderboardItem(
400
414
  productIds: server.productIds,
401
415
  productCount: server.productCount,
402
416
  globalRank: server.globalRank,
417
+ volume: mapNuanzeDecimal(server.volume),
418
+ pointsTier: server.pointsTier,
403
419
  };
404
420
  }
405
421
 
@@ -421,6 +437,8 @@ export function mapNuanzeSubaccountLeaderboardItem(
421
437
  productIds: server.productIds,
422
438
  productCount: server.productCount,
423
439
  globalRank: server.globalRank,
440
+ volume: mapNuanzeDecimal(server.volume),
441
+ pointsTier: server.pointsTier,
424
442
  };
425
443
  }
426
444
 
@@ -470,6 +488,94 @@ export function mapNuanzeSubaccountLeaderboardPositionResponse(
470
488
  };
471
489
  }
472
490
 
491
+ /**
492
+ * Maps a server-side close-event trade extreme, converting realized PnL to `BigNumber`.
493
+ */
494
+ export function mapNuanzeSubaccountCloseTrade(
495
+ server: NuanzeServerSubaccountCloseTrade,
496
+ ): NuanzeSubaccountCloseTrade {
497
+ return {
498
+ tradeId: server.tradeId,
499
+ productId: server.productId,
500
+ ticker: server.ticker,
501
+ realizedPnl: toBigNumber(server.realizedPnl),
502
+ matchedAt: server.matchedAt,
503
+ };
504
+ }
505
+
506
+ /**
507
+ * Maps a server-side position-based long/short bias, converting notionals and percentages to
508
+ * `BigNumber`.
509
+ */
510
+ export function mapNuanzeSubaccountLongShortBias(
511
+ server: NuanzeServerSubaccountLongShortBias,
512
+ ): NuanzeSubaccountLongShortBias {
513
+ return {
514
+ longPct: mapNuanzeDecimal(server.longPct),
515
+ shortPct: mapNuanzeDecimal(server.shortPct),
516
+ longNotional: toBigNumber(server.longNotional),
517
+ shortNotional: toBigNumber(server.shortNotional),
518
+ };
519
+ }
520
+
521
+ /**
522
+ * Maps a server-side most-traded market, converting volume to `BigNumber`.
523
+ */
524
+ export function mapNuanzeSubaccountMostTradedMarket(
525
+ server: NuanzeServerSubaccountMostTradedMarket,
526
+ ): NuanzeSubaccountMostTradedMarket {
527
+ return {
528
+ productId: server.productId,
529
+ ticker: server.ticker,
530
+ trades: server.trades,
531
+ volume: toBigNumber(server.volume),
532
+ };
533
+ }
534
+
535
+ /**
536
+ * Maps a server-side `GET /subaccounts/{subaccountHex}` response, converting every decimal
537
+ * string to `BigNumber`.
538
+ */
539
+ export function mapNuanzeSubaccountStatsResponse(
540
+ server: NuanzeServerSubaccountStatsResponse,
541
+ ): GetNuanzeSubaccountStatsResponse {
542
+ return {
543
+ subaccountHex: server.subaccountHex,
544
+ timeframe: server.timeframe,
545
+ owner: server.owner,
546
+ subaccountName: server.subaccountName,
547
+ username: server.username,
548
+ displayName: server.displayName,
549
+ pnl: mapNuanzeDecimal(server.pnl),
550
+ wins: server.wins,
551
+ losses: server.losses,
552
+ winRate: mapNuanzeDecimal(server.winRate),
553
+ trades: server.trades,
554
+ productIds: server.productIds,
555
+ productCount: server.productCount,
556
+ globalRank: server.globalRank,
557
+ filteredRank: server.filteredRank,
558
+ cumulativeVolume: toBigNumber(server.cumulativeVolume),
559
+ windowVolume: toBigNumber(server.windowVolume),
560
+ windowPnl: toBigNumber(server.windowPnl),
561
+ averageLeverage: mapNuanzeDecimal(server.averageLeverage),
562
+ bestTrade:
563
+ server.bestTrade === null
564
+ ? null
565
+ : mapNuanzeSubaccountCloseTrade(server.bestTrade),
566
+ worstTrade:
567
+ server.worstTrade === null
568
+ ? null
569
+ : mapNuanzeSubaccountCloseTrade(server.worstTrade),
570
+ longShortBias: mapNuanzeSubaccountLongShortBias(server.longShortBias),
571
+ mostTradedMarket:
572
+ server.mostTradedMarket === null
573
+ ? null
574
+ : mapNuanzeSubaccountMostTradedMarket(server.mostTradedMarket),
575
+ asOf: server.asOf,
576
+ };
577
+ }
578
+
473
579
  /**
474
580
  * Maps a server-side `GET /wallets/leaderboard` response, including the nullable `viewAs`
475
581
  * viewer. A filter-excluded followed viewer keeps its full item with `filteredRank` null; a
@@ -545,6 +651,54 @@ export function mapNuanzePlatformSummaryResponse(
545
651
  };
546
652
  }
547
653
 
654
+ /**
655
+ * Maps a server-side cohort long-percentage sample.
656
+ */
657
+ export function mapNuanzeCohortSeriesPoint(
658
+ server: NuanzeServerCohortSeriesPoint,
659
+ ): NuanzeCohortSeriesPoint {
660
+ return {
661
+ timestamp: server.timestamp,
662
+ walletCount: server.walletCount,
663
+ longPct: mapNuanzeDecimal(server.longPct),
664
+ };
665
+ }
666
+
667
+ /**
668
+ * Maps a server-side lifetime-PnL wallet cohort.
669
+ */
670
+ export function mapNuanzeCohort(server: NuanzeServerCohort): NuanzeCohort {
671
+ return {
672
+ key: server.key,
673
+ label: server.label,
674
+ pnlMin: mapNuanzeDecimal(server.pnlMin),
675
+ pnlMax: mapNuanzeDecimal(server.pnlMax),
676
+ walletCount: server.walletCount,
677
+ pnl: toBigNumber(server.pnl),
678
+ averagePnl: mapNuanzeDecimal(server.averagePnl),
679
+ walletsInProfit: server.walletsInProfit,
680
+ walletsInLoss: server.walletsInLoss,
681
+ trades: server.trades,
682
+ longNotional: toBigNumber(server.longNotional),
683
+ shortNotional: toBigNumber(server.shortNotional),
684
+ longPct: mapNuanzeDecimal(server.longPct),
685
+ shortPct: mapNuanzeDecimal(server.shortPct),
686
+ series: server.series.map(mapNuanzeCohortSeriesPoint),
687
+ };
688
+ }
689
+
690
+ /**
691
+ * Maps a server-side `GET /cohorts` response.
692
+ */
693
+ export function mapNuanzeCohortsResponse(
694
+ server: NuanzeServerCohortsResponse,
695
+ ): GetNuanzeCohortsResponse {
696
+ return {
697
+ items: server.items.map(mapNuanzeCohort),
698
+ asOf: server.asOf,
699
+ };
700
+ }
701
+
548
702
  /**
549
703
  * Maps a server-side `GET /wallets/{address}` response.
550
704
  */
@@ -311,10 +311,21 @@ export const NUANZE_COHORT_KEYS = [
311
311
  ] as const;
312
312
 
313
313
  /**
314
- * Wallet cohort label used by positioning cells.
314
+ * Lifetime account PnL wallet cohort, used by positioning cells and `GET /cohorts`.
315
315
  */
316
316
  export type NuanzeCohortKey = (typeof NUANZE_COHORT_KEYS)[number];
317
317
 
318
+ /**
319
+ * Every {@link NuanzePointsTier} the API can report: 1 Breeze, 2 Gust, 3 Wind, 4 Storm, and
320
+ * 5 Tornado.
321
+ */
322
+ export const NUANZE_POINTS_TIERS = [1, 2, 3, 4, 5] as const;
323
+
324
+ /**
325
+ * Nado Points tier, from 1 Breeze to 5 Tornado.
326
+ */
327
+ export type NuanzePointsTier = (typeof NUANZE_POINTS_TIERS)[number];
328
+
318
329
  /**
319
330
  * Every {@link NuanzeNotionalBucket} the API can report. Frozen USD ranges are small [10, 1000),
320
331
  * medium [1000, 10000), large [10000, 100000), and whale [100000, +infinity).
@@ -694,6 +705,61 @@ export interface NuanzeFollowedLeaderboardItem {
694
705
  * the subaccount has no PnL in the window.
695
706
  */
696
707
  globalRank: number | null;
708
+ /**
709
+ * Perp plus spot volume in the timeframe, from the same account snapshots and window bounds as
710
+ * `pnl`, or null when the subaccount has no account snapshot at the window's grain.
711
+ */
712
+ volume: BigNumber | null;
713
+ /**
714
+ * Owner wallet's Nado Points tier in the latest completed weekly epoch (the tier Nado shows as
715
+ * current), shared by every subaccount of the owner and refreshed daily. Null when the owner
716
+ * has no points record for that epoch.
717
+ */
718
+ pointsTier: NuanzePointsTier | null;
719
+ }
720
+
721
+ /**
722
+ * Close-event trade extreme from `GET /subaccounts/{subaccountHex}`.
723
+ */
724
+ export interface NuanzeSubaccountCloseTrade {
725
+ /** Fill ID of the closing fill. */
726
+ tradeId: number;
727
+ /** Perp product ID. */
728
+ productId: number;
729
+ /** Asset ticker, e.g. `ETH`. */
730
+ ticker: string;
731
+ /** Close-event realized PnL of the fill. */
732
+ realizedPnl: BigNumber;
733
+ /** When the fill matched, as a UTC ISO 8601 string. */
734
+ matchedAt: string;
735
+ }
736
+
737
+ /**
738
+ * Position-based long/short bias from `GET /subaccounts/{subaccountHex}`.
739
+ */
740
+ export interface NuanzeSubaccountLongShortBias {
741
+ /** Share of qualifying current perp notional held long, 0-100. Null when flat. */
742
+ longPct: BigNumber | null;
743
+ /** Share of qualifying current perp notional held short, 0-100. Null when flat. */
744
+ shortPct: BigNumber | null;
745
+ /** Qualifying current long notional in USD. */
746
+ longNotional: BigNumber;
747
+ /** Qualifying current short notional in USD. */
748
+ shortNotional: BigNumber;
749
+ }
750
+
751
+ /**
752
+ * Most-traded perp market from `GET /subaccounts/{subaccountHex}`.
753
+ */
754
+ export interface NuanzeSubaccountMostTradedMarket {
755
+ /** Perp product ID. */
756
+ productId: number;
757
+ /** Asset ticker, e.g. `ETH`. */
758
+ ticker: string;
759
+ /** Perp fill count in the window. */
760
+ trades: number;
761
+ /** Windowed fill volume in USD. */
762
+ volume: BigNumber;
697
763
  }
698
764
 
699
765
  /**
@@ -730,6 +796,18 @@ export interface NuanzeSubaccountLeaderboardItem {
730
796
  * subaccount has no PnL in the window.
731
797
  */
732
798
  globalRank: number | null;
799
+ /**
800
+ * Perp plus spot volume in the timeframe, from the same account snapshots and window bounds as
801
+ * `pnl` (and as `windowVolume` on `GET /subaccounts/{subaccountHex}`), or null when the
802
+ * subaccount has no account snapshot at the window's grain.
803
+ */
804
+ volume: BigNumber | null;
805
+ /**
806
+ * Owner wallet's Nado Points tier in the latest completed weekly epoch (the tier Nado shows as
807
+ * current), shared by every subaccount of the owner and refreshed daily. Null when the owner
808
+ * has no points record for that epoch.
809
+ */
810
+ pointsTier: NuanzePointsTier | null;
733
811
  }
734
812
 
735
813
  /**
@@ -776,6 +854,55 @@ export interface NuanzePlatformDeltas {
776
854
  tradersPct: BigNumber | null;
777
855
  }
778
856
 
857
+ /**
858
+ * Four-hourly sample of a wallet cohort's long percentage.
859
+ */
860
+ export interface NuanzeCohortSeriesPoint {
861
+ /** Sample time as a UTC ISO 8601 string. */
862
+ timestamp: string;
863
+ /** Wallets in the cohort at the sample. */
864
+ walletCount: number;
865
+ /** Share of the cohort's open perp notional held long, 0-100, or null when it was flat. */
866
+ longPct: BigNumber | null;
867
+ }
868
+
869
+ /**
870
+ * Wallet cohort bucketed by lifetime equity-basis account PnL summed across the wallet's
871
+ * subaccounts. Every wallet that has traded belongs to exactly one cohort.
872
+ */
873
+ export interface NuanzeCohort {
874
+ /** Cohort key. */
875
+ key: NuanzeCohortKey;
876
+ /** Display label. */
877
+ label: string;
878
+ /** Inclusive lower lifetime PnL bound, or null when unbounded. */
879
+ pnlMin: BigNumber | null;
880
+ /** Exclusive upper lifetime PnL bound, or null when unbounded. */
881
+ pnlMax: BigNumber | null;
882
+ /** Wallets in the cohort. */
883
+ walletCount: number;
884
+ /** Sum of the members' lifetime account PnL. */
885
+ pnl: BigNumber;
886
+ /** Mean lifetime account PnL per wallet, or null when the cohort is empty. */
887
+ averagePnl: BigNumber | null;
888
+ /** Members with lifetime account PnL above zero. */
889
+ walletsInProfit: number;
890
+ /** Members with lifetime account PnL at or below zero. */
891
+ walletsInLoss: number;
892
+ /** Lifetime fill count across the members. */
893
+ trades: number;
894
+ /** Members' current open perp notional held long. */
895
+ longNotional: BigNumber;
896
+ /** Members' current open perp notional held short. */
897
+ shortNotional: BigNumber;
898
+ /** Share of open perp notional held long, 0-100, or null when the cohort is flat. */
899
+ longPct: BigNumber | null;
900
+ /** Share of open perp notional held short, 0-100, or null when the cohort is flat. */
901
+ shortPct: BigNumber | null;
902
+ /** Long percentage every four hours over the last 30 days, oldest first. */
903
+ series: NuanzeCohortSeriesPoint[];
904
+ }
905
+
779
906
  /**
780
907
  * Replica-backed wallet position snapshot. Not an execution-grade live feed.
781
908
  */
@@ -2,6 +2,7 @@ import BigNumber from 'bignumber.js';
2
2
  import {
3
3
  NuanzeCandle,
4
4
  NuanzeCandleInterval,
5
+ NuanzeCohort,
5
6
  NuanzeCollateralFlow,
6
7
  NuanzeCollateralFlowPoint,
7
8
  NuanzeCoverage,
@@ -36,7 +37,10 @@ import {
36
37
  NuanzeSeriesMetric,
37
38
  NuanzeSeriesPoint,
38
39
  NuanzeSourceInterval,
40
+ NuanzeSubaccountCloseTrade,
39
41
  NuanzeSubaccountLeaderboardItem,
42
+ NuanzeSubaccountLongShortBias,
43
+ NuanzeSubaccountMostTradedMarket,
40
44
  NuanzeWalletPosition,
41
45
  NuanzeWalletTrade,
42
46
  } from './clientModelTypes';
@@ -332,6 +336,73 @@ export interface GetNuanzeSubaccountLeaderboardPositionResponse {
332
336
  asOf: string;
333
337
  }
334
338
 
339
+ /**
340
+ * Params for `NuanzeClient.getSubaccountStats`.
341
+ */
342
+ export interface GetNuanzeSubaccountStatsParams {
343
+ /**
344
+ * Explicit public bytes32 subaccount hex (`0x` plus 64 hex characters, the SDK
345
+ * `subaccountToHex` form) to look up.
346
+ */
347
+ subaccountHex: string;
348
+ /** Stat window, default `30d`. */
349
+ timeframe?: NuanzeLeaderboardTimeframe;
350
+ }
351
+
352
+ /**
353
+ * Response of `NuanzeClient.getSubaccountStats`.
354
+ */
355
+ export interface GetNuanzeSubaccountStatsResponse {
356
+ /** Lowercase bytes32 subaccount hex (owner + name). */
357
+ subaccountHex: string;
358
+ /** Echoed stat window. */
359
+ timeframe: NuanzeLeaderboardTimeframe;
360
+ /** Lowercase subaccount owner address. */
361
+ owner: string;
362
+ /** Subaccount name. */
363
+ subaccountName: string;
364
+ /** Canonical username, or null when the subaccount has not claimed one. */
365
+ username: string | null;
366
+ /** User-facing display name, or null when unavailable. */
367
+ displayName: string | null;
368
+ /** Equity-basis account PnL for the window, or null for an untraded window. */
369
+ pnl: BigNumber | null;
370
+ /** Close-derived win count. */
371
+ wins: number;
372
+ /** Close-derived loss count. */
373
+ losses: number;
374
+ /** Win rate, or null when there are no closed trades. */
375
+ winRate: BigNumber | null;
376
+ /** Perp fill count in the window. */
377
+ trades: number;
378
+ /** Traded product IDs, sorted by fill count descending. */
379
+ productIds: number[];
380
+ /** Number of distinct traded products. Equals `productIds.length`. */
381
+ productCount: number;
382
+ /** Rank across all subaccounts for the window. Null when the subaccount has no PnL. */
383
+ globalRank: number | null;
384
+ /** Rank with private, untraded, and unclaimed subaccounts included. */
385
+ filteredRank: number | null;
386
+ /** Lifetime fill volume in USD. */
387
+ cumulativeVolume: BigNumber;
388
+ /** Window fill volume in USD. */
389
+ windowVolume: BigNumber;
390
+ /** Window PnL delta in USD. */
391
+ windowPnl: BigNumber;
392
+ /** Notional-weighted effective leverage over current isolated perp legs. Null when none. */
393
+ averageLeverage: BigNumber | null;
394
+ /** Fill with the largest close-event realized PnL in the window. Null when no closes. */
395
+ bestTrade: NuanzeSubaccountCloseTrade | null;
396
+ /** Fill with the smallest close-event realized PnL in the window. Null when no closes. */
397
+ worstTrade: NuanzeSubaccountCloseTrade | null;
398
+ /** Point-in-time bias from current open perp legs. */
399
+ longShortBias: NuanzeSubaccountLongShortBias;
400
+ /** Top perp market by fill count in the window. Null when no activity row. */
401
+ mostTradedMarket: NuanzeSubaccountMostTradedMarket | null;
402
+ /** When the response was generated, as a UTC ISO 8601 string. */
403
+ asOf: string;
404
+ }
405
+
335
406
  /**
336
407
  * Params for `NuanzeClient.getFollowedLeaderboard`. `timeframe` is required and applies to
337
408
  * every per-subaccount figure.
@@ -469,6 +540,16 @@ export interface GetNuanzePlatformSummaryResponse {
469
540
  asOf: string;
470
541
  }
471
542
 
543
+ /**
544
+ * Response of `NuanzeClient.getCohorts`.
545
+ */
546
+ export interface GetNuanzeCohortsResponse {
547
+ /** All six cohorts, always in `NUANZE_COHORT_KEYS` order (most to least profitable). */
548
+ items: NuanzeCohort[];
549
+ /** When the response was generated, as a UTC ISO 8601 string. */
550
+ asOf: string;
551
+ }
552
+
472
553
  /**
473
554
  * Params for `NuanzeClient.getWalletSummary`.
474
555
  */
@@ -10,6 +10,7 @@ import {
10
10
  NuanzeMinPositionUsd,
11
11
  NuanzeNewsStory,
12
12
  NuanzeNotionalBucket,
13
+ NuanzePointsTier,
13
14
  NuanzePositionSide,
14
15
  NuanzeTradeSide,
15
16
  } from './clientModelTypes';
@@ -182,6 +183,8 @@ export interface NuanzeServerFollowedLeaderboardItem {
182
183
  productIds: number[];
183
184
  productCount: number;
184
185
  globalRank: number | null;
186
+ volume: string | null;
187
+ pointsTier: NuanzePointsTier | null;
185
188
  }
186
189
 
187
190
  /**
@@ -199,6 +202,39 @@ export interface NuanzeServerSubaccountLeaderboardItem {
199
202
  productIds: number[];
200
203
  productCount: number;
201
204
  globalRank: number | null;
205
+ volume: string | null;
206
+ pointsTier: NuanzePointsTier | null;
207
+ }
208
+
209
+ /**
210
+ * Close-event trade extreme as returned on the wire.
211
+ */
212
+ export interface NuanzeServerSubaccountCloseTrade {
213
+ tradeId: number;
214
+ productId: number;
215
+ ticker: string;
216
+ realizedPnl: string;
217
+ matchedAt: string;
218
+ }
219
+
220
+ /**
221
+ * Position-based long/short bias as returned on the wire.
222
+ */
223
+ export interface NuanzeServerSubaccountLongShortBias {
224
+ longPct: string | null;
225
+ shortPct: string | null;
226
+ longNotional: string;
227
+ shortNotional: string;
228
+ }
229
+
230
+ /**
231
+ * Most-traded perp market as returned on the wire.
232
+ */
233
+ export interface NuanzeServerSubaccountMostTradedMarket {
234
+ productId: number;
235
+ ticker: string;
236
+ trades: number;
237
+ volume: string;
202
238
  }
203
239
 
204
240
  /**
@@ -210,6 +246,36 @@ export interface NuanzeServerPlatformDeltas {
210
246
  tradersPct: string | null;
211
247
  }
212
248
 
249
+ /**
250
+ * Cohort long-percentage sample as returned on the wire.
251
+ */
252
+ export interface NuanzeServerCohortSeriesPoint {
253
+ timestamp: string;
254
+ walletCount: number;
255
+ longPct: string | null;
256
+ }
257
+
258
+ /**
259
+ * Lifetime-PnL wallet cohort as returned on the wire.
260
+ */
261
+ export interface NuanzeServerCohort {
262
+ key: NuanzeCohortKey;
263
+ label: string;
264
+ pnlMin: string | null;
265
+ pnlMax: string | null;
266
+ walletCount: number;
267
+ pnl: string;
268
+ averagePnl: string | null;
269
+ walletsInProfit: number;
270
+ walletsInLoss: number;
271
+ trades: number;
272
+ longNotional: string;
273
+ shortNotional: string;
274
+ longPct: string | null;
275
+ shortPct: string | null;
276
+ series: NuanzeServerCohortSeriesPoint[];
277
+ }
278
+
213
279
  /**
214
280
  * Wallet position snapshot as returned on the wire.
215
281
  */
@@ -14,6 +14,7 @@ import { NuanzeNewsStory } from './clientModelTypes';
14
14
  import { NuanzeErrorCode } from './nuanzeErrorCodes';
15
15
  import {
16
16
  NuanzeServerCandle,
17
+ NuanzeServerCohort,
17
18
  NuanzeServerCollateralFlow,
18
19
  NuanzeServerCollateralFlowPoint,
19
20
  NuanzeServerFollowedLeaderboardItem,
@@ -26,7 +27,10 @@ import {
26
27
  NuanzeServerOpenPosition,
27
28
  NuanzeServerPlatformDeltas,
28
29
  NuanzeServerSeriesPoint,
30
+ NuanzeServerSubaccountCloseTrade,
29
31
  NuanzeServerSubaccountLeaderboardItem,
32
+ NuanzeServerSubaccountLongShortBias,
33
+ NuanzeServerSubaccountMostTradedMarket,
30
34
  NuanzeServerWalletPosition,
31
35
  NuanzeServerWalletTrade,
32
36
  } from './serverModelTypes';
@@ -124,6 +128,36 @@ export interface NuanzeServerSubaccountLeaderboardPositionResponse {
124
128
  asOf: string;
125
129
  }
126
130
 
131
+ /**
132
+ * `GET /subaccounts/{subaccountHex}` response as returned on the wire.
133
+ */
134
+ export interface NuanzeServerSubaccountStatsResponse {
135
+ subaccountHex: string;
136
+ timeframe: NuanzeLeaderboardTimeframe;
137
+ owner: string;
138
+ subaccountName: string;
139
+ username: string | null;
140
+ displayName: string | null;
141
+ pnl: string | null;
142
+ wins: number;
143
+ losses: number;
144
+ winRate: string | null;
145
+ trades: number;
146
+ productIds: number[];
147
+ productCount: number;
148
+ globalRank: number | null;
149
+ filteredRank: number | null;
150
+ cumulativeVolume: string;
151
+ windowVolume: string;
152
+ windowPnl: string;
153
+ averageLeverage: string | null;
154
+ bestTrade: NuanzeServerSubaccountCloseTrade | null;
155
+ worstTrade: NuanzeServerSubaccountCloseTrade | null;
156
+ longShortBias: NuanzeServerSubaccountLongShortBias;
157
+ mostTradedMarket: NuanzeServerSubaccountMostTradedMarket | null;
158
+ asOf: string;
159
+ }
160
+
127
161
  /**
128
162
  * `GET /wallets/leaderboard` response as returned on the wire.
129
163
  */
@@ -163,6 +197,14 @@ export interface NuanzeServerPlatformSummaryResponse {
163
197
  asOf: string;
164
198
  }
165
199
 
200
+ /**
201
+ * `GET /cohorts` response as returned on the wire.
202
+ */
203
+ export interface NuanzeServerCohortsResponse {
204
+ items: NuanzeServerCohort[];
205
+ asOf: string;
206
+ }
207
+
166
208
  /**
167
209
  * `GET /wallets/{address}` response as returned on the wire.
168
210
  */