aiden-shared-calculations-unified 1.0.154 → 1.0.155
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Calculates the $ AUM allocated to each asset for a single PI.
|
|
3
|
-
* Includes a lookback mechanism: If AUM is missing today, it checks the last
|
|
3
|
+
* Includes a lookback mechanism: If AUM is missing today, it checks the last 30 days of rankings.
|
|
4
4
|
*/
|
|
5
5
|
class PIDailyAssetAUM {
|
|
6
6
|
static getMetadata() {
|
|
@@ -14,9 +14,9 @@ class PIDailyAssetAUM {
|
|
|
14
14
|
mandatoryRoots: ['portfolio'], // Rankings are mandatory but handled via lookback if missing today
|
|
15
15
|
|
|
16
16
|
// 2. Rankings Lookback Series
|
|
17
|
-
// This requests the last
|
|
17
|
+
// This requests the last 30 days of rankings to be available in context.seriesData.root.rankings
|
|
18
18
|
rootDataSeries: {
|
|
19
|
-
rankings:
|
|
19
|
+
rankings: 30
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -45,8 +45,6 @@ class PIDailyAssetAUM {
|
|
|
45
45
|
|
|
46
46
|
if (historicalAum > 0) {
|
|
47
47
|
piAum = historicalAum;
|
|
48
|
-
// Optional: Log that we used historical data
|
|
49
|
-
// context.logger.log('INFO', `Using historical AUM for ${userId} from ${dateKey}: $${piAum}`);
|
|
50
48
|
break;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -66,10 +64,9 @@ class PIDailyAssetAUM {
|
|
|
66
64
|
const ticker = context.mappings.instrumentToTicker[instId] || `ID:${instId}`;
|
|
67
65
|
|
|
68
66
|
// Get Weight (%)
|
|
69
|
-
const pct = extract.getPositionWeight(pos);
|
|
67
|
+
const pct = extract.getPositionWeight(pos);
|
|
70
68
|
|
|
71
69
|
// Calculate $ Value: AUM * (Weight / 100)
|
|
72
|
-
// Note: Ensure pct is treated as percentage (e.g. 5.5 = 5.5%)
|
|
73
70
|
if (pct > 0) {
|
|
74
71
|
const usdValue = piAum * (pct / 100);
|
|
75
72
|
|
|
@@ -79,10 +76,10 @@ class PIDailyAssetAUM {
|
|
|
79
76
|
});
|
|
80
77
|
|
|
81
78
|
// --- STEP C: Output Results ---
|
|
82
|
-
//
|
|
83
|
-
this.results = {
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
// CRITICAL FIX: Accumulate results, do not overwrite 'this.results'
|
|
80
|
+
if (!this.results) this.results = {};
|
|
81
|
+
|
|
82
|
+
this.results[userId] = allocationMap;
|
|
86
83
|
|
|
87
84
|
return this.results;
|
|
88
85
|
}
|