@barchart/portfolio-api-common 1.0.79 → 1.0.83
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/lib/processing/PositionGroup.js +11 -9
- package/package.json +1 -1
- package/test/SpecRunner.js +11 -9
|
@@ -52,7 +52,6 @@ module.exports = (() => {
|
|
|
52
52
|
this._dataFormat.marketDirection = null;
|
|
53
53
|
this._dataFormat.unrealizedToday = null;
|
|
54
54
|
this._dataFormat.unrealizedTodayNegative = false;
|
|
55
|
-
this._dataFormat.unrealizedTodayDirection = null;
|
|
56
55
|
this._dataFormat.total = null;
|
|
57
56
|
this._dataFormat.totalNegative = false;
|
|
58
57
|
this._dataFormat.summaryOneTotal = null;
|
|
@@ -224,17 +223,15 @@ module.exports = (() => {
|
|
|
224
223
|
return updates;
|
|
225
224
|
}, {
|
|
226
225
|
market: Decimal.ZERO,
|
|
227
|
-
marketDirection:
|
|
228
|
-
unrealizedToday: Decimal.ZERO
|
|
229
|
-
unrealizedTodayDirection: { up: false, down: false }
|
|
226
|
+
marketDirection: unchanged,
|
|
227
|
+
unrealizedToday: Decimal.ZERO
|
|
230
228
|
|
|
231
229
|
});
|
|
232
230
|
} else {
|
|
233
231
|
updates = {
|
|
234
232
|
market: actual.market.add(item.data.marketChange),
|
|
235
233
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
236
|
-
unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
|
|
237
|
-
unrealizedTodayDirection: { up: item.data.unrealizedTodayChange.getIsPositive(), down: item.data.unrealizedTodayChange.getIsNegative() }
|
|
234
|
+
unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
|
|
238
235
|
};
|
|
239
236
|
}
|
|
240
237
|
|
|
@@ -254,16 +251,21 @@ module.exports = (() => {
|
|
|
254
251
|
actual.marketPercent = updates.marketPercent;
|
|
255
252
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
256
253
|
actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
|
|
257
|
-
|
|
258
254
|
format.market = formatCurrency(actual.market, currency);
|
|
259
255
|
format.marketPercent = formatPercent(actual.marketPercent, 2);
|
|
260
|
-
|
|
256
|
+
|
|
257
|
+
if (updates.marketDirection.up || updates.marketDirection.down) {
|
|
258
|
+
format.marketDirection = unchanged;
|
|
259
|
+
setTimeout(() => format.marketDirection = updates.marketDirection, 0);
|
|
260
|
+
}
|
|
261
|
+
|
|
261
262
|
format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
|
|
262
263
|
format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
|
|
263
|
-
format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
|
|
264
264
|
format.total = formatCurrency(actual.total, currency);
|
|
265
265
|
format.totalNegative = actual.total.getIsNegative();
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
const unchanged = { up: false, down: false };
|
|
269
|
+
|
|
268
270
|
return PositionGroup;
|
|
269
271
|
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -991,7 +991,6 @@ module.exports = (() => {
|
|
|
991
991
|
this._dataFormat.marketDirection = null;
|
|
992
992
|
this._dataFormat.unrealizedToday = null;
|
|
993
993
|
this._dataFormat.unrealizedTodayNegative = false;
|
|
994
|
-
this._dataFormat.unrealizedTodayDirection = null;
|
|
995
994
|
this._dataFormat.total = null;
|
|
996
995
|
this._dataFormat.totalNegative = false;
|
|
997
996
|
this._dataFormat.summaryOneTotal = null;
|
|
@@ -1163,17 +1162,15 @@ module.exports = (() => {
|
|
|
1163
1162
|
return updates;
|
|
1164
1163
|
}, {
|
|
1165
1164
|
market: Decimal.ZERO,
|
|
1166
|
-
marketDirection:
|
|
1167
|
-
unrealizedToday: Decimal.ZERO
|
|
1168
|
-
unrealizedTodayDirection: { up: false, down: false }
|
|
1165
|
+
marketDirection: unchanged,
|
|
1166
|
+
unrealizedToday: Decimal.ZERO
|
|
1169
1167
|
|
|
1170
1168
|
});
|
|
1171
1169
|
} else {
|
|
1172
1170
|
updates = {
|
|
1173
1171
|
market: actual.market.add(item.data.marketChange),
|
|
1174
1172
|
marketDirection: { up: item.data.marketChange.getIsPositive(), down: item.data.marketChange.getIsNegative() },
|
|
1175
|
-
unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
|
|
1176
|
-
unrealizedTodayDirection: { up: item.data.unrealizedTodayChange.getIsPositive(), down: item.data.unrealizedTodayChange.getIsNegative() }
|
|
1173
|
+
unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
|
|
1177
1174
|
};
|
|
1178
1175
|
}
|
|
1179
1176
|
|
|
@@ -1193,17 +1190,22 @@ module.exports = (() => {
|
|
|
1193
1190
|
actual.marketPercent = updates.marketPercent;
|
|
1194
1191
|
actual.unrealizedToday = updates.unrealizedToday;
|
|
1195
1192
|
actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
|
|
1196
|
-
|
|
1197
1193
|
format.market = formatCurrency(actual.market, currency);
|
|
1198
1194
|
format.marketPercent = formatPercent(actual.marketPercent, 2);
|
|
1199
|
-
|
|
1195
|
+
|
|
1196
|
+
if (updates.marketDirection.up || updates.marketDirection.down) {
|
|
1197
|
+
format.marketDirection = unchanged;
|
|
1198
|
+
setTimeout(() => format.marketDirection = updates.marketDirection, 0);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1200
1201
|
format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
|
|
1201
1202
|
format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
|
|
1202
|
-
format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
|
|
1203
1203
|
format.total = formatCurrency(actual.total, currency);
|
|
1204
1204
|
format.totalNegative = actual.total.getIsNegative();
|
|
1205
1205
|
}
|
|
1206
1206
|
|
|
1207
|
+
const unchanged = { up: false, down: false };
|
|
1208
|
+
|
|
1207
1209
|
return PositionGroup;
|
|
1208
1210
|
})();
|
|
1209
1211
|
|