@barchart/portfolio-api-common 1.0.80 → 1.0.84

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.
@@ -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;
@@ -93,6 +92,10 @@ module.exports = (() => {
93
92
  return this._dataFormat;
94
93
  }
95
94
 
95
+ get actual() {
96
+ return this._dataActual;
97
+ }
98
+
96
99
  get single() {
97
100
  return this._single;
98
101
  }
@@ -224,17 +227,15 @@ module.exports = (() => {
224
227
  return updates;
225
228
  }, {
226
229
  market: Decimal.ZERO,
227
- marketDirection: { up: false, down: false },
228
- unrealizedToday: Decimal.ZERO,
229
- unrealizedTodayDirection: { up: false, down: false }
230
+ marketDirection: unchanged,
231
+ unrealizedToday: Decimal.ZERO
230
232
 
231
233
  });
232
234
  } else {
233
235
  updates = {
234
236
  market: actual.market.add(item.data.marketChange),
235
237
  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() }
238
+ unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
238
239
  };
239
240
  }
240
241
 
@@ -254,19 +255,24 @@ module.exports = (() => {
254
255
  actual.marketPercent = updates.marketPercent;
255
256
  actual.unrealizedToday = updates.unrealizedToday;
256
257
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
257
-
258
258
  format.market = formatCurrency(actual.market, currency);
259
259
  format.marketPercent = formatPercent(actual.marketPercent, 2);
260
- format.marketDirection = unchanged;
261
- format.marketDirection = updates.marketDirection;
260
+
261
+ if (updates.marketDirection.up || updates.marketDirection.down) {
262
+ format.marketDirection = unchanged;
263
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
264
+ }
265
+
262
266
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
263
267
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
264
- format.unrealizedTodayDirection = unchanged;
265
- format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
266
268
  format.total = formatCurrency(actual.total, currency);
267
269
  format.totalNegative = actual.total.getIsNegative();
268
270
  }
269
271
 
272
+ function calculatePercent() {
273
+
274
+ }
275
+
270
276
  const unchanged = { up: false, down: false };
271
277
 
272
278
  return PositionGroup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.80",
3
+ "version": "1.0.84",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -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;
@@ -1032,6 +1031,10 @@ module.exports = (() => {
1032
1031
  return this._dataFormat;
1033
1032
  }
1034
1033
 
1034
+ get actual() {
1035
+ return this._dataActual;
1036
+ }
1037
+
1035
1038
  get single() {
1036
1039
  return this._single;
1037
1040
  }
@@ -1163,17 +1166,15 @@ module.exports = (() => {
1163
1166
  return updates;
1164
1167
  }, {
1165
1168
  market: Decimal.ZERO,
1166
- marketDirection: { up: false, down: false },
1167
- unrealizedToday: Decimal.ZERO,
1168
- unrealizedTodayDirection: { up: false, down: false }
1169
+ marketDirection: unchanged,
1170
+ unrealizedToday: Decimal.ZERO
1169
1171
 
1170
1172
  });
1171
1173
  } else {
1172
1174
  updates = {
1173
1175
  market: actual.market.add(item.data.marketChange),
1174
1176
  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() }
1177
+ unrealizedToday: actual.unrealizedToday.add(item.data.unrealizedTodayChange)
1177
1178
  };
1178
1179
  }
1179
1180
 
@@ -1193,19 +1194,24 @@ module.exports = (() => {
1193
1194
  actual.marketPercent = updates.marketPercent;
1194
1195
  actual.unrealizedToday = updates.unrealizedToday;
1195
1196
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
1196
-
1197
1197
  format.market = formatCurrency(actual.market, currency);
1198
1198
  format.marketPercent = formatPercent(actual.marketPercent, 2);
1199
- format.marketDirection = unchanged;
1200
- format.marketDirection = updates.marketDirection;
1199
+
1200
+ if (updates.marketDirection.up || updates.marketDirection.down) {
1201
+ format.marketDirection = unchanged;
1202
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
1203
+ }
1204
+
1201
1205
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
1202
1206
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
1203
- format.unrealizedTodayDirection = unchanged;
1204
- format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
1205
1207
  format.total = formatCurrency(actual.total, currency);
1206
1208
  format.totalNegative = actual.total.getIsNegative();
1207
1209
  }
1208
1210
 
1211
+ function calculatePercent() {
1212
+
1213
+ }
1214
+
1209
1215
  const unchanged = { up: false, down: false };
1210
1216
 
1211
1217
  return PositionGroup;