aiden-shared-calculations-unified 1.0.88 → 1.0.90

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.
@@ -56,7 +56,7 @@ class AssetPnlStatus {
56
56
  if (pnl === 0) continue;
57
57
 
58
58
  const ticker = mappings.instrumentToTicker[instId];
59
- const sector = mappings.sectorMapping[instId];
59
+ const sector = mappings.instrumentToSector[instId];
60
60
  const isWinner = pnl > 0;
61
61
 
62
62
  if (ticker) {
@@ -57,7 +57,7 @@ class AssetPositionSize {
57
57
  if (!instId) continue;
58
58
 
59
59
  const ticker = mappings.instrumentToTicker[instId];
60
- const sector = mappings.sectorMapping[instId];
60
+ const sector = mappings.instrumentToSector[instId];
61
61
 
62
62
  if (ticker) {
63
63
  this._init(this.tickerBuckets, ticker);
@@ -42,7 +42,7 @@ class AverageDailyPnlPerSector {
42
42
  process(context) {
43
43
  const { extract } = context.math;
44
44
  const { mappings, user } = context;
45
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
45
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
46
46
 
47
47
  const positions = extract.getPositions(user.portfolio.today, user.type);
48
48
  const userSectorPnL = new Map();
@@ -41,7 +41,7 @@ class PlatformOwnershipPerSector {
41
41
  process(context) {
42
42
  const { extract } = context.math;
43
43
  const { mappings, user } = context;
44
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
44
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
45
45
 
46
46
  const positions = extract.getPositions(user.portfolio.today, user.type);
47
47
 
@@ -87,9 +87,9 @@ class CorePriceMetrics {
87
87
 
88
88
  process(context) {
89
89
  const { mappings, prices, date } = context;
90
- const { instrumentToTicker, sectorMapping } = mappings;
90
+ // FIX 1: Use the correct property name 'instrumentToSector'
91
+ const { instrumentToTicker, instrumentToSector } = mappings;
91
92
 
92
- // Uses history from context
93
93
  const priceData = prices?.history;
94
94
  const todayDateStr = date.today;
95
95
 
@@ -101,7 +101,8 @@ class CorePriceMetrics {
101
101
  const by_instrument = {};
102
102
  const tickerToInstrument = {};
103
103
 
104
- for (const p of priceData) {
104
+ // FIX 2: Iterate over Object.values() since priceData is a map, not an array
105
+ for (const p of Object.values(priceData)) {
105
106
  const ticker = instrumentToTicker[p.instrumentId];
106
107
  if (!ticker) continue;
107
108
  tickerToInstrument[ticker] = p.instrumentId;
@@ -125,7 +126,9 @@ class CorePriceMetrics {
125
126
  const sectorAggs = {};
126
127
  for (const ticker in by_instrument) {
127
128
  const instId = tickerToInstrument[ticker];
128
- const sector = sectorMapping[instId] || "Unknown";
129
+ // FIX 1 (Usage): Use the corrected variable name
130
+ const sector = instrumentToSector[instId] || "Unknown";
131
+
129
132
  if (!sectorAggs[sector]) sectorAggs[sector] = { metrics: {}, counts: {} };
130
133
 
131
134
  const data = by_instrument[ticker];
@@ -42,7 +42,7 @@ class ProfitabilityRatioPerSector {
42
42
  process(context) {
43
43
  const { extract } = context.math;
44
44
  const { mappings, user } = context;
45
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
45
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
46
46
 
47
47
  const positions = extract.getPositions(user.portfolio.today, user.type);
48
48
 
@@ -41,7 +41,7 @@ class SpeculatorLeveragePerSector {
41
41
  process(context) {
42
42
  const { extract } = context.math;
43
43
  const { mappings, user } = context;
44
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
44
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
45
45
 
46
46
  const positions = extract.getPositions(user.portfolio.today, user.type);
47
47
 
@@ -46,7 +46,7 @@ class SpeculatorSLDistanceSectorBreakdown {
46
46
  process(context) {
47
47
  const { extract } = context.math;
48
48
  const { mappings, user } = context;
49
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
49
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
50
50
 
51
51
  const positions = extract.getPositions(user.portfolio.today, user.type);
52
52
 
@@ -41,7 +41,7 @@ class TotalLongPerSector {
41
41
  process(context) {
42
42
  const { extract } = context.math;
43
43
  const { mappings, user } = context;
44
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
44
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
45
45
 
46
46
  const positions = extract.getPositions(user.portfolio.today, user.type);
47
47
 
@@ -41,7 +41,7 @@ class TotalShortPerSector {
41
41
  process(context) {
42
42
  const { extract } = context.math;
43
43
  const { mappings, user } = context;
44
- if (!this.sectorMap) this.sectorMap = mappings.sectorMapping;
44
+ if (!this.sectorMap) this.sectorMap = mappings.instrumentToSector;
45
45
 
46
46
  const positions = extract.getPositions(user.portfolio.today, user.type);
47
47
 
@@ -50,7 +50,7 @@ class RiskAppetiteIndex {
50
50
 
51
51
  if (!this.tickerMap) {
52
52
  this.tickerMap = mappings.instrumentToTicker;
53
- this.sectorMap = mappings.sectorMapping;
53
+ this.sectorMap = mappings.instrumentToSector;
54
54
  }
55
55
 
56
56
  const positions = extract.getPositions(user.portfolio.today, user.type);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiden-shared-calculations-unified",
3
- "version": "1.0.88",
3
+ "version": "1.0.90",
4
4
  "description": "Shared calculation modules for the BullTrackers Computation System.",
5
5
  "main": "index.js",
6
6
  "files": [