@barchart/portfolio-api-common 1.2.22 → 1.2.26

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.
@@ -117,7 +117,6 @@ module.exports = (() => {
117
117
  this._dataFormat.quoteChangeNegative = false;
118
118
 
119
119
  this._dataActual.currentPrice = null;
120
- this._dataActual.previousPrice = null;
121
120
  this._dataActual.basis = null;
122
121
  this._dataActual.realized = null;
123
122
  this._dataActual.income = null;
@@ -133,7 +132,6 @@ module.exports = (() => {
133
132
  this._dataActual.cashTotal = null;
134
133
 
135
134
  this._dataFormat.currentPrice = null;
136
- this._dataFormat.previousPrice = null;
137
135
  this._dataFormat.basis = null;
138
136
  this._dataFormat.realized = null;
139
137
  this._dataFormat.income = null;
@@ -189,6 +189,10 @@ module.exports = (() => {
189
189
  }
190
190
 
191
191
  if (this._currentPricePrevious !== quote.lastPrice) {
192
+ if (this._data.previousPrice === null && quote.previousPrice) {
193
+ this._data.previousPrice = quote.previousPrice;
194
+ }
195
+
192
196
  calculatePriceData(this, quote.lastPrice);
193
197
 
194
198
  this._currentPricePrevious = this._currentPrice;
@@ -406,15 +410,7 @@ module.exports = (() => {
406
410
 
407
411
  const summary = item.currentSummary;
408
412
 
409
- let priceToUse;
410
-
411
- if (price) {
412
- priceToUse = price;
413
- } else {
414
-
415
- }
416
-
417
- if (summary) {
413
+ if (summary && position.instrument.type !== InstrumentType.CASH) {
418
414
  let priceToUse;
419
415
 
420
416
  if (price) {
@@ -433,7 +429,7 @@ module.exports = (() => {
433
429
  let unrealized = summary.end.open.multiply(priceToUse).add(summary.end.basis);
434
430
  let unrealizedChange;
435
431
 
436
- if (data.unrealizedToday !== null) {
432
+ if (data.unrealized !== null) {
437
433
  unrealizedChange = unrealized.subtract(data.unrealized);
438
434
  } else {
439
435
  unrealizedChange = Decimal.ZERO;
@@ -420,6 +420,8 @@ module.exports = (() => {
420
420
  .withField('portfolio', DataType.STRING)
421
421
  .withField('position', DataType.STRING)
422
422
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
423
+ .withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
424
+ .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
423
425
  .withField('date', DataType.DAY)
424
426
  .withField('amount', DataType.DECIMAL)
425
427
  .withField('fee', DataType.DECIMAL, true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.22",
3
+ "version": "1.2.26",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -2322,7 +2322,6 @@ module.exports = (() => {
2322
2322
  this._dataFormat.quoteChangeNegative = false;
2323
2323
 
2324
2324
  this._dataActual.currentPrice = null;
2325
- this._dataActual.previousPrice = null;
2326
2325
  this._dataActual.basis = null;
2327
2326
  this._dataActual.realized = null;
2328
2327
  this._dataActual.income = null;
@@ -2338,7 +2337,6 @@ module.exports = (() => {
2338
2337
  this._dataActual.cashTotal = null;
2339
2338
 
2340
2339
  this._dataFormat.currentPrice = null;
2341
- this._dataFormat.previousPrice = null;
2342
2340
  this._dataFormat.basis = null;
2343
2341
  this._dataFormat.realized = null;
2344
2342
  this._dataFormat.income = null;
@@ -3256,6 +3254,10 @@ module.exports = (() => {
3256
3254
  }
3257
3255
 
3258
3256
  if (this._currentPricePrevious !== quote.lastPrice) {
3257
+ if (this._data.previousPrice === null && quote.previousPrice) {
3258
+ this._data.previousPrice = quote.previousPrice;
3259
+ }
3260
+
3259
3261
  calculatePriceData(this, quote.lastPrice);
3260
3262
 
3261
3263
  this._currentPricePrevious = this._currentPrice;
@@ -3473,15 +3475,7 @@ module.exports = (() => {
3473
3475
 
3474
3476
  const summary = item.currentSummary;
3475
3477
 
3476
- let priceToUse;
3477
-
3478
- if (price) {
3479
- priceToUse = price;
3480
- } else {
3481
-
3482
- }
3483
-
3484
- if (summary) {
3478
+ if (summary && position.instrument.type !== InstrumentType.CASH) {
3485
3479
  let priceToUse;
3486
3480
 
3487
3481
  if (price) {
@@ -3500,7 +3494,7 @@ module.exports = (() => {
3500
3494
  let unrealized = summary.end.open.multiply(priceToUse).add(summary.end.basis);
3501
3495
  let unrealizedChange;
3502
3496
 
3503
- if (data.unrealizedToday !== null) {
3497
+ if (data.unrealized !== null) {
3504
3498
  unrealizedChange = unrealized.subtract(data.unrealized);
3505
3499
  } else {
3506
3500
  unrealizedChange = Decimal.ZERO;