aiden-shared-calculations-unified 1.0.38 → 1.0.39
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.
|
@@ -30,8 +30,12 @@ class UserProfitabilityTracker {
|
|
|
30
30
|
for (const pos of portfolio.AggregatedPositions) {
|
|
31
31
|
// Use NetProfit (the % return)
|
|
32
32
|
const netProfit = ('NetProfit' in pos) ? pos.NetProfit : (pos.ProfitAndLoss || 0);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
|
|
34
|
+
// --- START FIX ---
|
|
35
|
+
// "Normal" user portfolios use the 'Invested' field for portfolio percentage.
|
|
36
|
+
// 'InvestedAmount' and 'Amount' are different fields.
|
|
37
|
+
const invested = pos.Invested || 0;
|
|
38
|
+
// --- END FIX ---
|
|
35
39
|
|
|
36
40
|
if (invested > 0) {
|
|
37
41
|
weightedPnlSum += netProfit * invested;
|
|
@@ -115,4 +119,4 @@ class UserProfitabilityTracker {
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
module.exports = UserProfitabilityTracker;
|
|
122
|
+
module.exports = UserProfitabilityTracker;
|