@barchart/portfolio-api-common 1.0.81 → 1.0.85

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
  }
@@ -225,16 +228,14 @@ module.exports = (() => {
225
228
  }, {
226
229
  market: Decimal.ZERO,
227
230
  marketDirection: unchanged,
228
- unrealizedToday: Decimal.ZERO,
229
- unrealizedTodayDirection: 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
 
@@ -256,20 +257,20 @@ module.exports = (() => {
256
257
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
257
258
  format.market = formatCurrency(actual.market, currency);
258
259
  format.marketPercent = formatPercent(actual.marketPercent, 2);
260
+
261
+ if (updates.marketDirection.up || updates.marketDirection.down) {
262
+ format.marketDirection = unchanged;
263
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
264
+ }
265
+
259
266
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
260
267
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
261
268
  format.total = formatCurrency(actual.total, currency);
262
269
  format.totalNegative = actual.total.getIsNegative();
270
+ }
263
271
 
264
- if (updates.marketDirection.up || updates.marketDirection.down) {
265
- format.marketDirection = unchanged;
266
- format.marketDirection = updates.marketDirection;
267
- }
272
+ function calculatePercent() {
268
273
 
269
- if (updates.unrealizedTodayDirection.up || updates.unrealizedTodayDirection.down) {
270
- format.unrealizedTodayDirection = unchanged;
271
- format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
272
- }
273
274
  }
274
275
 
275
276
  const unchanged = { up: false, down: false };
@@ -159,7 +159,7 @@ module.exports = (() => {
159
159
  }
160
160
 
161
161
  toString() {
162
- return '[TransactionSchema]';
162
+ return `[TransactionSchema (code=${this.code})]`;
163
163
  }
164
164
  }
165
165
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.81",
3
+ "version": "1.0.85",
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
  }
@@ -1164,16 +1167,14 @@ module.exports = (() => {
1164
1167
  }, {
1165
1168
  market: Decimal.ZERO,
1166
1169
  marketDirection: unchanged,
1167
- unrealizedToday: Decimal.ZERO,
1168
- unrealizedTodayDirection: 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
 
@@ -1195,20 +1196,20 @@ module.exports = (() => {
1195
1196
  actual.total = updates.unrealizedToday.add(actual.realized).add(actual.income);
1196
1197
  format.market = formatCurrency(actual.market, currency);
1197
1198
  format.marketPercent = formatPercent(actual.marketPercent, 2);
1199
+
1200
+ if (updates.marketDirection.up || updates.marketDirection.down) {
1201
+ format.marketDirection = unchanged;
1202
+ setTimeout(() => format.marketDirection = updates.marketDirection, 0);
1203
+ }
1204
+
1198
1205
  format.unrealizedToday = formatCurrency(actual.unrealizedToday, currency);
1199
1206
  format.unrealizedTodayNegative = actual.unrealizedToday.getIsNegative();
1200
1207
  format.total = formatCurrency(actual.total, currency);
1201
1208
  format.totalNegative = actual.total.getIsNegative();
1209
+ }
1202
1210
 
1203
- if (updates.marketDirection.up || updates.marketDirection.down) {
1204
- format.marketDirection = unchanged;
1205
- format.marketDirection = updates.marketDirection;
1206
- }
1211
+ function calculatePercent() {
1207
1212
 
1208
- if (updates.unrealizedTodayDirection.up || updates.unrealizedTodayDirection.down) {
1209
- format.unrealizedTodayDirection = unchanged;
1210
- format.unrealizedTodayDirection = updates.unrealizedTodayDirection;
1211
- }
1212
1213
  }
1213
1214
 
1214
1215
  const unchanged = { up: false, down: false };