@barchart/portfolio-api-common 1.2.86 → 1.2.87
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.
|
@@ -283,8 +283,17 @@ module.exports = (() => {
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
const existingBarchartSymbols = this.getPositionSymbols(false);
|
|
286
|
+
const existingPositionItem = this._items.find(item => item.position.position === position.position);
|
|
286
287
|
|
|
287
|
-
|
|
288
|
+
let currentQuote = null;
|
|
289
|
+
let previousQuote = null;
|
|
290
|
+
|
|
291
|
+
if (existingPositionItem) {
|
|
292
|
+
currentQuote = existingPositionItem.quote || null;
|
|
293
|
+
previousQuote = existingPositionItem.previousQuote || null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
removePositionItem.call(this, existingPositionItem);
|
|
288
297
|
|
|
289
298
|
summaries.forEach((summary) => {
|
|
290
299
|
addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
|
|
@@ -296,6 +305,14 @@ module.exports = (() => {
|
|
|
296
305
|
addBarchartSymbol(this._symbols, item);
|
|
297
306
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
298
307
|
|
|
308
|
+
if (previousQuote !== null) {
|
|
309
|
+
item.setQuote(previousQuote);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (currentQuote !== null) {
|
|
313
|
+
item.setQuote(currentQuote);
|
|
314
|
+
}
|
|
315
|
+
|
|
299
316
|
this._items.push(item);
|
|
300
317
|
|
|
301
318
|
const createGroupOrInjectItem = (parentTree, treeDefinition, levelDefinitions) => {
|
|
@@ -915,7 +932,7 @@ module.exports = (() => {
|
|
|
915
932
|
}
|
|
916
933
|
}
|
|
917
934
|
|
|
918
|
-
function createPositionItem(position) {
|
|
935
|
+
function createPositionItem(position, currentQuote, previousQuote) {
|
|
919
936
|
const portfolio = this._portfolios[position.portfolio];
|
|
920
937
|
|
|
921
938
|
let returnRef;
|
|
@@ -41,6 +41,7 @@ module.exports = (() => {
|
|
|
41
41
|
this._data.basis = null;
|
|
42
42
|
|
|
43
43
|
this._currentQuote = null;
|
|
44
|
+
this._previousQuote = null;
|
|
44
45
|
this._currentPrice = null;
|
|
45
46
|
|
|
46
47
|
this._data.currentPrice = null;
|
|
@@ -154,7 +155,7 @@ module.exports = (() => {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/**
|
|
157
|
-
* The
|
|
158
|
+
* The most recent quote for the symbol of the encapsulated position.
|
|
158
159
|
*
|
|
159
160
|
* @public
|
|
160
161
|
* @returns {null|Object}
|
|
@@ -163,6 +164,16 @@ module.exports = (() => {
|
|
|
163
164
|
return this._currentQuote;
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
/**
|
|
168
|
+
* The second most recent quote for the symbol of the encapsulated position.
|
|
169
|
+
*
|
|
170
|
+
* @public
|
|
171
|
+
* @returns {null|Object}
|
|
172
|
+
*/
|
|
173
|
+
get previousQuote() {
|
|
174
|
+
return this._previousQuote;
|
|
175
|
+
}
|
|
176
|
+
|
|
166
177
|
updatePortfolio(portfolio) {
|
|
167
178
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
168
179
|
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
@@ -200,6 +211,7 @@ module.exports = (() => {
|
|
|
200
211
|
this._currentPricePrevious = this._currentPrice;
|
|
201
212
|
this._currentPrice = quote.lastPrice;
|
|
202
213
|
|
|
214
|
+
this._previousQuote = this._currentQuote;
|
|
203
215
|
this._currentQuote = quote;
|
|
204
216
|
|
|
205
217
|
this._quoteChangedEvent.fire(this._currentQuote);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1662,8 +1662,17 @@ module.exports = (() => {
|
|
|
1662
1662
|
}
|
|
1663
1663
|
|
|
1664
1664
|
const existingBarchartSymbols = this.getPositionSymbols(false);
|
|
1665
|
+
const existingPositionItem = this._items.find(item => item.position.position === position.position);
|
|
1665
1666
|
|
|
1666
|
-
|
|
1667
|
+
let currentQuote = null;
|
|
1668
|
+
let previousQuote = null;
|
|
1669
|
+
|
|
1670
|
+
if (existingPositionItem) {
|
|
1671
|
+
currentQuote = existingPositionItem.quote || null;
|
|
1672
|
+
previousQuote = existingPositionItem.previousQuote || null;
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
removePositionItem.call(this, existingPositionItem);
|
|
1667
1676
|
|
|
1668
1677
|
summaries.forEach((summary) => {
|
|
1669
1678
|
addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
|
|
@@ -1675,6 +1684,14 @@ module.exports = (() => {
|
|
|
1675
1684
|
addBarchartSymbol(this._symbols, item);
|
|
1676
1685
|
addDisplaySymbol(this._symbolsDisplay, item);
|
|
1677
1686
|
|
|
1687
|
+
if (previousQuote !== null) {
|
|
1688
|
+
item.setQuote(previousQuote);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
if (currentQuote !== null) {
|
|
1692
|
+
item.setQuote(currentQuote);
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1678
1695
|
this._items.push(item);
|
|
1679
1696
|
|
|
1680
1697
|
const createGroupOrInjectItem = (parentTree, treeDefinition, levelDefinitions) => {
|
|
@@ -2294,7 +2311,7 @@ module.exports = (() => {
|
|
|
2294
2311
|
}
|
|
2295
2312
|
}
|
|
2296
2313
|
|
|
2297
|
-
function createPositionItem(position) {
|
|
2314
|
+
function createPositionItem(position, currentQuote, previousQuote) {
|
|
2298
2315
|
const portfolio = this._portfolios[position.portfolio];
|
|
2299
2316
|
|
|
2300
2317
|
let returnRef;
|
|
@@ -3277,6 +3294,7 @@ module.exports = (() => {
|
|
|
3277
3294
|
this._data.basis = null;
|
|
3278
3295
|
|
|
3279
3296
|
this._currentQuote = null;
|
|
3297
|
+
this._previousQuote = null;
|
|
3280
3298
|
this._currentPrice = null;
|
|
3281
3299
|
|
|
3282
3300
|
this._data.currentPrice = null;
|
|
@@ -3390,7 +3408,7 @@ module.exports = (() => {
|
|
|
3390
3408
|
}
|
|
3391
3409
|
|
|
3392
3410
|
/**
|
|
3393
|
-
* The
|
|
3411
|
+
* The most recent quote for the symbol of the encapsulated position.
|
|
3394
3412
|
*
|
|
3395
3413
|
* @public
|
|
3396
3414
|
* @returns {null|Object}
|
|
@@ -3399,6 +3417,16 @@ module.exports = (() => {
|
|
|
3399
3417
|
return this._currentQuote;
|
|
3400
3418
|
}
|
|
3401
3419
|
|
|
3420
|
+
/**
|
|
3421
|
+
* The second most recent quote for the symbol of the encapsulated position.
|
|
3422
|
+
*
|
|
3423
|
+
* @public
|
|
3424
|
+
* @returns {null|Object}
|
|
3425
|
+
*/
|
|
3426
|
+
get previousQuote() {
|
|
3427
|
+
return this._previousQuote;
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3402
3430
|
updatePortfolio(portfolio) {
|
|
3403
3431
|
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
3404
3432
|
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
@@ -3436,6 +3464,7 @@ module.exports = (() => {
|
|
|
3436
3464
|
this._currentPricePrevious = this._currentPrice;
|
|
3437
3465
|
this._currentPrice = quote.lastPrice;
|
|
3438
3466
|
|
|
3467
|
+
this._previousQuote = this._currentQuote;
|
|
3439
3468
|
this._currentQuote = quote;
|
|
3440
3469
|
|
|
3441
3470
|
this._quoteChangedEvent.fire(this._currentQuote);
|