@barchart/portfolio-api-common 1.2.81 → 1.2.82
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.
- package/lib/processing/PositionContainer.js +16 -2
- package/lib/processing/PositionItem.js +13 -18
- package/package.json +1 -1
- package/test/SpecRunner.js +29 -20
|
@@ -382,14 +382,28 @@ module.exports = (() => {
|
|
|
382
382
|
assert.argumentIsRequired(position, 'position', Object);
|
|
383
383
|
assert.argumentIsRequired(position.position, 'position.position', String);
|
|
384
384
|
|
|
385
|
-
const item = this._items.find(
|
|
385
|
+
const item = this._items.find(i => i.position.position === position.position);
|
|
386
386
|
|
|
387
387
|
if (item) {
|
|
388
|
-
item.setPositionLock(
|
|
388
|
+
item.setPositionLock(position);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Returns all positions which are currently locked (for editing).
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
* @returns {Array.<Object>}
|
|
398
|
+
*/
|
|
399
|
+
getLockedPositions() {
|
|
400
|
+
return this._items.filter((i) => {
|
|
401
|
+
return i.data.locked;
|
|
402
|
+
}).map((i) => {
|
|
403
|
+
return i.position;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
393
407
|
/**
|
|
394
408
|
* Performs a batch update of both position quotes and forex quotes,
|
|
395
409
|
* triggering updates to position(s) and data aggregation(s).
|
|
@@ -70,7 +70,7 @@ module.exports = (() => {
|
|
|
70
70
|
|
|
71
71
|
this._data.newsExists = false;
|
|
72
72
|
this._data.fundamental = { };
|
|
73
|
-
this._data.locked =
|
|
73
|
+
this._data.locked = getIsLocked(position);
|
|
74
74
|
|
|
75
75
|
calculateStaticData(this);
|
|
76
76
|
calculatePriceData(this, null);
|
|
@@ -242,18 +242,20 @@ module.exports = (() => {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
* Sets position lock status.
|
|
245
|
+
* Sets a position's lock status.
|
|
246
246
|
*
|
|
247
247
|
* @public
|
|
248
|
-
* @param {
|
|
248
|
+
* @param {Object} position
|
|
249
249
|
*/
|
|
250
|
-
setPositionLock(
|
|
251
|
-
assert.argumentIsRequired(
|
|
250
|
+
setPositionLock(position) {
|
|
251
|
+
assert.argumentIsRequired(position, 'position');
|
|
252
252
|
|
|
253
253
|
if (this.getIsDisposed()) {
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
const value = getIsLocked(position);
|
|
258
|
+
|
|
257
259
|
if (this._data.locked !== value) {
|
|
258
260
|
this._lockChangedEvent.fire(this._data.locked = value);
|
|
259
261
|
}
|
|
@@ -337,19 +339,6 @@ module.exports = (() => {
|
|
|
337
339
|
this._positionItemDisposeEvent.clear();
|
|
338
340
|
}
|
|
339
341
|
|
|
340
|
-
/**
|
|
341
|
-
* Given a position object, returns its lock (for editing) status.
|
|
342
|
-
*
|
|
343
|
-
* @public
|
|
344
|
-
* @param {Object{}} position
|
|
345
|
-
* @returns {Boolean}
|
|
346
|
-
*/
|
|
347
|
-
static getIsLocked(position) {
|
|
348
|
-
assert.argumentIsRequired(position, 'position');
|
|
349
|
-
|
|
350
|
-
return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
342
|
toString() {
|
|
354
343
|
return '[PositionItem]';
|
|
355
344
|
}
|
|
@@ -538,5 +527,11 @@ module.exports = (() => {
|
|
|
538
527
|
return summary;
|
|
539
528
|
}
|
|
540
529
|
|
|
530
|
+
function getIsLocked(position) {
|
|
531
|
+
assert.argumentIsRequired(position, 'position');
|
|
532
|
+
|
|
533
|
+
return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
|
|
534
|
+
}
|
|
535
|
+
|
|
541
536
|
return PositionItem;
|
|
542
537
|
})();
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1761,14 +1761,28 @@ module.exports = (() => {
|
|
|
1761
1761
|
assert.argumentIsRequired(position, 'position', Object);
|
|
1762
1762
|
assert.argumentIsRequired(position.position, 'position.position', String);
|
|
1763
1763
|
|
|
1764
|
-
const item = this._items.find(
|
|
1764
|
+
const item = this._items.find(i => i.position.position === position.position);
|
|
1765
1765
|
|
|
1766
1766
|
if (item) {
|
|
1767
|
-
item.setPositionLock(
|
|
1767
|
+
item.setPositionLock(position);
|
|
1768
1768
|
}
|
|
1769
1769
|
}
|
|
1770
1770
|
}
|
|
1771
1771
|
|
|
1772
|
+
/**
|
|
1773
|
+
* Returns all positions which are currently locked (for editing).
|
|
1774
|
+
*
|
|
1775
|
+
* @public
|
|
1776
|
+
* @returns {Array.<Object>}
|
|
1777
|
+
*/
|
|
1778
|
+
getLockedPositions() {
|
|
1779
|
+
return this._items.filter((i) => {
|
|
1780
|
+
return i.data.locked;
|
|
1781
|
+
}).map((i) => {
|
|
1782
|
+
return i.position;
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1772
1786
|
/**
|
|
1773
1787
|
* Performs a batch update of both position quotes and forex quotes,
|
|
1774
1788
|
* triggering updates to position(s) and data aggregation(s).
|
|
@@ -3282,7 +3296,7 @@ module.exports = (() => {
|
|
|
3282
3296
|
|
|
3283
3297
|
this._data.newsExists = false;
|
|
3284
3298
|
this._data.fundamental = { };
|
|
3285
|
-
this._data.locked =
|
|
3299
|
+
this._data.locked = getIsLocked(position);
|
|
3286
3300
|
|
|
3287
3301
|
calculateStaticData(this);
|
|
3288
3302
|
calculatePriceData(this, null);
|
|
@@ -3454,18 +3468,20 @@ module.exports = (() => {
|
|
|
3454
3468
|
}
|
|
3455
3469
|
|
|
3456
3470
|
/**
|
|
3457
|
-
* Sets position lock status.
|
|
3471
|
+
* Sets a position's lock status.
|
|
3458
3472
|
*
|
|
3459
3473
|
* @public
|
|
3460
|
-
* @param {
|
|
3474
|
+
* @param {Object} position
|
|
3461
3475
|
*/
|
|
3462
|
-
setPositionLock(
|
|
3463
|
-
assert.argumentIsRequired(
|
|
3476
|
+
setPositionLock(position) {
|
|
3477
|
+
assert.argumentIsRequired(position, 'position');
|
|
3464
3478
|
|
|
3465
3479
|
if (this.getIsDisposed()) {
|
|
3466
3480
|
return;
|
|
3467
3481
|
}
|
|
3468
3482
|
|
|
3483
|
+
const value = getIsLocked(position);
|
|
3484
|
+
|
|
3469
3485
|
if (this._data.locked !== value) {
|
|
3470
3486
|
this._lockChangedEvent.fire(this._data.locked = value);
|
|
3471
3487
|
}
|
|
@@ -3549,19 +3565,6 @@ module.exports = (() => {
|
|
|
3549
3565
|
this._positionItemDisposeEvent.clear();
|
|
3550
3566
|
}
|
|
3551
3567
|
|
|
3552
|
-
/**
|
|
3553
|
-
* Given a position object, returns its lock (for editing) status.
|
|
3554
|
-
*
|
|
3555
|
-
* @public
|
|
3556
|
-
* @param {Object{}} position
|
|
3557
|
-
* @returns {Boolean}
|
|
3558
|
-
*/
|
|
3559
|
-
static getIsLocked(position) {
|
|
3560
|
-
assert.argumentIsRequired(position, 'position');
|
|
3561
|
-
|
|
3562
|
-
return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
|
|
3563
|
-
}
|
|
3564
|
-
|
|
3565
3568
|
toString() {
|
|
3566
3569
|
return '[PositionItem]';
|
|
3567
3570
|
}
|
|
@@ -3750,6 +3753,12 @@ module.exports = (() => {
|
|
|
3750
3753
|
return summary;
|
|
3751
3754
|
}
|
|
3752
3755
|
|
|
3756
|
+
function getIsLocked(position) {
|
|
3757
|
+
assert.argumentIsRequired(position, 'position');
|
|
3758
|
+
|
|
3759
|
+
return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3753
3762
|
return PositionItem;
|
|
3754
3763
|
})();
|
|
3755
3764
|
|