@barchart/portfolio-api-common 1.0.78 → 1.0.82

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.
@@ -49,8 +49,12 @@ module.exports = (() => {
49
49
  this._dataFormat.income = null;
50
50
  this._dataFormat.market = null;
51
51
  this._dataFormat.marketPercent = null;
52
+ this._dataFormat.marketDirection = null;
52
53
  this._dataFormat.unrealizedToday = null;
54
+ this._dataFormat.unrealizedTodayNegative = false;
55
+ this._dataFormat.unrealizedTodayDirection = null;
53
56
  this._dataFormat.total = null;
57
+ this._dataFormat.totalNegative = false;
54
58
  this._dataFormat.summaryOneTotal = null;
55
59
  this._dataFormat.summaryTwoTotal = null;
56
60
 
@@ -220,13 +224,17 @@ module.exports = (() => {
220
224
  return updates;
221
225
  }, {
222
226
  market: Decimal.ZERO,
227
+ marketDirection: unchanged,
228
+ unrealizedToday: Decimal.ZERO,
229
+ unrealizedTodayDirection: unchanged
223
230
 
224
- unrealizedToday: Decimal.ZERO
225
231
  });
226
232
  } else {
227
233
  updates = {
228
234
  market: actual.market.add(item.data.marketChange),
229
- unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
235
+ 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() }
230
238
  };
231
239
  }
232
240
 
@@ -246,13 +254,25 @@ module.exports = (() => {
246
254
  actual.marketPercent = updates.marketPercent;
247
255
  actual.unrealizedToday = updates.unrealizedToday;
248
256
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
249
-
250
257
  format.market = formatCurrency(actual.market, currency);
251
258
  format.marketPercent = formatPercent(actual.marketPercent, 2);
252
259
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
253
260
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
254
261
  format.total = formatCurrency(actual.total, currency);
262
+ format.totalNegative = actual.total.getIsNegative();
263
+
264
+ if (updates.marketDirection.up || updates.marketDirection.down) {
265
+ format.marketDirection = unchanged;
266
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
267
+ }
268
+
269
+ if (updates.unrealizedTodayDirection.up || updates.unrealizedTodayDirection.down) {
270
+ format.unrealizedTodayDirection = unchanged;
271
+ setTimeout(() => format.unrealizedTodayDirection = updates.unrealizedTodayDirection, 0);
272
+ }
255
273
  }
256
274
 
275
+ const unchanged = { up: false, down: false };
276
+
257
277
  return PositionGroup;
258
278
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.78",
3
+ "version": "1.0.82",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -988,8 +988,12 @@ module.exports = (() => {
988
988
  this._dataFormat.income = null;
989
989
  this._dataFormat.market = null;
990
990
  this._dataFormat.marketPercent = null;
991
+ this._dataFormat.marketDirection = null;
991
992
  this._dataFormat.unrealizedToday = null;
993
+ this._dataFormat.unrealizedTodayNegative = false;
994
+ this._dataFormat.unrealizedTodayDirection = null;
992
995
  this._dataFormat.total = null;
996
+ this._dataFormat.totalNegative = false;
993
997
  this._dataFormat.summaryOneTotal = null;
994
998
  this._dataFormat.summaryTwoTotal = null;
995
999
 
@@ -1159,13 +1163,17 @@ module.exports = (() => {
1159
1163
  return updates;
1160
1164
  }, {
1161
1165
  market: Decimal.ZERO,
1166
+ marketDirection: unchanged,
1167
+ unrealizedToday: Decimal.ZERO,
1168
+ unrealizedTodayDirection: unchanged
1162
1169
 
1163
- unrealizedToday: Decimal.ZERO
1164
1170
  });
1165
1171
  } else {
1166
1172
  updates = {
1167
1173
  market: actual.market.add(item.data.marketChange),
1168
- unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
1174
+ 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() }
1169
1177
  };
1170
1178
  }
1171
1179
 
@@ -1185,14 +1193,26 @@ module.exports = (() => {
1185
1193
  actual.marketPercent = updates.marketPercent;
1186
1194
  actual.unrealizedToday = updates.unrealizedToday;
1187
1195
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
1188
-
1189
1196
  format.market = formatCurrency(actual.market, currency);
1190
1197
  format.marketPercent = formatPercent(actual.marketPercent, 2);
1191
1198
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
1192
1199
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
1193
1200
  format.total = formatCurrency(actual.total, currency);
1201
+ format.totalNegative = actual.total.getIsNegative();
1202
+
1203
+ if (updates.marketDirection.up || updates.marketDirection.down) {
1204
+ format.marketDirection = unchanged;
1205
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
1206
+ }
1207
+
1208
+ if (updates.unrealizedTodayDirection.up || updates.unrealizedTodayDirection.down) {
1209
+ format.unrealizedTodayDirection = unchanged;
1210
+ setTimeout(() => format.unrealizedTodayDirection = updates.unrealizedTodayDirection, 0);
1211
+ }
1194
1212
  }
1195
1213
 
1214
+ const unchanged = { up: false, down: false };
1215
+
1196
1216
  return PositionGroup;
1197
1217
  })();
1198
1218