@barchart/portfolio-api-common 2.1.0 → 2.2.0

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.
@@ -454,9 +454,21 @@ module.exports = (() => {
454
454
  assert.argumentIsRequired(position, 'position', Object);
455
455
  assert.argumentIsRequired(position.position, 'position.position', String);
456
456
 
457
- removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
457
+ const positionItemToRemove = this._items.find(item => item.position.position === position.position);
458
+ const positionToRemove = positionItemToRemove ? positionItemToRemove.position || null : null;
459
+
460
+ removePositionItem.call(this, positionItemToRemove);
458
461
 
459
462
  recalculatePercentages.call(this);
463
+
464
+ if (positionToRemove) {
465
+ const existingBarchartSymbols = this.getPositionSymbols(false, false);
466
+ const removedBarchartSymbol = extractSymbolForBarchart(positionToRemove);
467
+
468
+ if (removedBarchartSymbol !== null && !existingBarchartSymbols.some(existingBarchartSymbol => existingBarchartSymbol === removedBarchartSymbol)) {
469
+ this._positionSymbolRemovedEvent.fire(removedBarchartSymbol);
470
+ }
471
+ }
460
472
  }
461
473
 
462
474
  /**
@@ -573,10 +585,12 @@ module.exports = (() => {
573
585
  * @public
574
586
  * @param {Object[]} positionQuotes
575
587
  * @param {Object[]} forexQuotes
588
+ * @param {Boolean=} force
576
589
  */
577
- setQuotes(positionQuotes, forexQuotes) {
590
+ setQuotes(positionQuotes, forexQuotes, force) {
578
591
  assert.argumentIsArray(positionQuotes, 'positionQuotes');
579
592
  assert.argumentIsArray(forexQuotes, 'forexQuotes');
593
+ assert.argumentIsOptional(force, 'force', Boolean);
580
594
 
581
595
  if (forexQuotes.length !== 0) {
582
596
  forexQuotes.forEach((quote) => {
@@ -600,7 +614,7 @@ module.exports = (() => {
600
614
 
601
615
  if (symbol) {
602
616
  if (this._symbols.hasOwnProperty(symbol)) {
603
- this._symbols[ symbol ].forEach(item => item.setQuote(quote));
617
+ this._symbols[ symbol ].forEach(item => item.setQuote(quote, force || false));
604
618
  }
605
619
  }
606
620
  });
@@ -240,15 +240,17 @@ module.exports = (() => {
240
240
  *
241
241
  * @public
242
242
  * @param {Object} quote
243
+ * @param {Boolean=} force
243
244
  */
244
- setQuote(quote) {
245
+ setQuote(quote, force) {
245
246
  assert.argumentIsRequired(quote, 'quote', Object);
247
+ assert.argumentIsOptional(force, 'force', Object);
246
248
 
247
249
  if (this.getIsDisposed()) {
248
250
  return;
249
251
  }
250
252
 
251
- if (this._currentPricePrevious !== quote.lastPrice) {
253
+ if (this._currentPricePrevious !== quote.lastPrice || force) {
252
254
  if (quote.previousPrice) {
253
255
  this._data.previousPrice = quote.previousPrice;
254
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Common JavaScript code used by Barchart's Portfolio Service",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",