@barchart/portfolio-api-common 1.0.200 → 1.0.201
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.
|
@@ -206,6 +206,21 @@ module.exports = (() => {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Updates the portfolio data. For example, a portfolio's name might change.
|
|
211
|
+
*
|
|
212
|
+
* @public
|
|
213
|
+
* @param {Object} portfolio
|
|
214
|
+
*/
|
|
215
|
+
updatePortfolio(portfolio) {
|
|
216
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
217
|
+
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
218
|
+
|
|
219
|
+
this.startTransaction(() => {
|
|
220
|
+
getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(item => item.updatePortfolio(portfolio));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
209
224
|
/**
|
|
210
225
|
* Removes an existing portfolio, and all of it's positions, from the container. This
|
|
211
226
|
* also triggers removal of the portfolio and it's positions from any applicable
|
|
@@ -463,6 +463,12 @@ module.exports = (() => {
|
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
|
|
466
|
+
this._disposeStack.push(item.registerPortfolioChangeHandler((portfolio, sender) => {
|
|
467
|
+
const descriptionSelector = this._definition.descriptionSelector;
|
|
468
|
+
|
|
469
|
+
this._description = descriptionSelector(this._items[0]);
|
|
470
|
+
}));
|
|
471
|
+
|
|
466
472
|
this._disposeStack.push(quoteBinding);
|
|
467
473
|
this._disposeStack.push(newsBinding);
|
|
468
474
|
this._disposeStack.push(fundamentalBinding);
|
|
@@ -73,6 +73,7 @@ module.exports = (() => {
|
|
|
73
73
|
this._quoteChangedEvent = new Event(this);
|
|
74
74
|
this._newsExistsChangedEvent = new Event(this);
|
|
75
75
|
this._fundamentalDataChangeEvent = new Event(this);
|
|
76
|
+
this._portfolioChangedEvent = new Event(this);
|
|
76
77
|
this._positionItemDisposeEvent = new Event(this);
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -146,6 +147,19 @@ module.exports = (() => {
|
|
|
146
147
|
return this._currentQuote;
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
updatePortfolio(portfolio) {
|
|
151
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
152
|
+
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
153
|
+
|
|
154
|
+
if (portfolio.portfolio !== this._portfolio.portfolio) {
|
|
155
|
+
throw new Error('Unable to move position into new portfolio.');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (this._portfolio !== portfolio) {
|
|
159
|
+
this._portfolioChangedEvent.fire(this._portfolio = portfolio);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
149
163
|
/**
|
|
150
164
|
* Sets the current quote -- causing position-level data (e.g. market value) to
|
|
151
165
|
* be recalculated.
|
|
@@ -241,6 +255,17 @@ module.exports = (() => {
|
|
|
241
255
|
return this._newsExistsChangedEvent.register(handler);
|
|
242
256
|
}
|
|
243
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Registers an observer changes to portfolio metadata.
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
* @param {Function} handler
|
|
263
|
+
* @returns {Disposable}
|
|
264
|
+
*/
|
|
265
|
+
registerPortfolioChangeHandler(handler) {
|
|
266
|
+
return this._portfolioChangedEvent.register(handler);
|
|
267
|
+
}
|
|
268
|
+
|
|
244
269
|
/**
|
|
245
270
|
* Registers an observer for object disposal.
|
|
246
271
|
*
|
|
@@ -258,6 +283,7 @@ module.exports = (() => {
|
|
|
258
283
|
this._quoteChangedEvent.clear();
|
|
259
284
|
this._newsExistsChangedEvent.clear();
|
|
260
285
|
this._fundamentalDataChangeEvent.clear();
|
|
286
|
+
this._portfolioChangedEvent.clear();
|
|
261
287
|
this._positionItemDisposeEvent.clear();
|
|
262
288
|
}
|
|
263
289
|
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -922,6 +922,21 @@ module.exports = (() => {
|
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
924
|
|
|
925
|
+
/**
|
|
926
|
+
* Updates the portfolio data. For example, a portfolio's name might change.
|
|
927
|
+
*
|
|
928
|
+
* @public
|
|
929
|
+
* @param {Object} portfolio
|
|
930
|
+
*/
|
|
931
|
+
updatePortfolio(portfolio) {
|
|
932
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
933
|
+
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
934
|
+
|
|
935
|
+
this.startTransaction(() => {
|
|
936
|
+
getPositionItemsForPortfolio(this._items, portfolio.portfolio).forEach(item => item.updatePortfolio(portfolio));
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
|
|
925
940
|
/**
|
|
926
941
|
* Removes an existing portfolio, and all of it's positions, from the container. This
|
|
927
942
|
* also triggers removal of the portfolio and it's positions from any applicable
|
|
@@ -2042,6 +2057,12 @@ module.exports = (() => {
|
|
|
2042
2057
|
});
|
|
2043
2058
|
}
|
|
2044
2059
|
|
|
2060
|
+
this._disposeStack.push(item.registerPortfolioChangeHandler((portfolio, sender) => {
|
|
2061
|
+
const descriptionSelector = this._definition.descriptionSelector;
|
|
2062
|
+
|
|
2063
|
+
this._description = descriptionSelector(this._items[0]);
|
|
2064
|
+
}));
|
|
2065
|
+
|
|
2045
2066
|
this._disposeStack.push(quoteBinding);
|
|
2046
2067
|
this._disposeStack.push(newsBinding);
|
|
2047
2068
|
this._disposeStack.push(fundamentalBinding);
|
|
@@ -2411,6 +2432,7 @@ module.exports = (() => {
|
|
|
2411
2432
|
this._quoteChangedEvent = new Event(this);
|
|
2412
2433
|
this._newsExistsChangedEvent = new Event(this);
|
|
2413
2434
|
this._fundamentalDataChangeEvent = new Event(this);
|
|
2435
|
+
this._portfolioChangedEvent = new Event(this);
|
|
2414
2436
|
this._positionItemDisposeEvent = new Event(this);
|
|
2415
2437
|
}
|
|
2416
2438
|
|
|
@@ -2484,6 +2506,19 @@ module.exports = (() => {
|
|
|
2484
2506
|
return this._currentQuote;
|
|
2485
2507
|
}
|
|
2486
2508
|
|
|
2509
|
+
updatePortfolio(portfolio) {
|
|
2510
|
+
assert.argumentIsRequired(portfolio, 'portfolio', Object);
|
|
2511
|
+
assert.argumentIsRequired(portfolio.portfolio, 'portfolio.portfolio', String);
|
|
2512
|
+
|
|
2513
|
+
if (portfolio.portfolio !== this._portfolio.portfolio) {
|
|
2514
|
+
throw new Error('Unable to move position into new portfolio.');
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
if (this._portfolio !== portfolio) {
|
|
2518
|
+
this._portfolioChangedEvent.fire(this._portfolio = portfolio);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2487
2522
|
/**
|
|
2488
2523
|
* Sets the current quote -- causing position-level data (e.g. market value) to
|
|
2489
2524
|
* be recalculated.
|
|
@@ -2579,6 +2614,17 @@ module.exports = (() => {
|
|
|
2579
2614
|
return this._newsExistsChangedEvent.register(handler);
|
|
2580
2615
|
}
|
|
2581
2616
|
|
|
2617
|
+
/**
|
|
2618
|
+
* Registers an observer changes to portfolio metadata.
|
|
2619
|
+
*
|
|
2620
|
+
* @public
|
|
2621
|
+
* @param {Function} handler
|
|
2622
|
+
* @returns {Disposable}
|
|
2623
|
+
*/
|
|
2624
|
+
registerPortfolioChangeHandler(handler) {
|
|
2625
|
+
return this._portfolioChangedEvent.register(handler);
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2582
2628
|
/**
|
|
2583
2629
|
* Registers an observer for object disposal.
|
|
2584
2630
|
*
|
|
@@ -2596,6 +2642,7 @@ module.exports = (() => {
|
|
|
2596
2642
|
this._quoteChangedEvent.clear();
|
|
2597
2643
|
this._newsExistsChangedEvent.clear();
|
|
2598
2644
|
this._fundamentalDataChangeEvent.clear();
|
|
2645
|
+
this._portfolioChangedEvent.clear();
|
|
2599
2646
|
this._positionItemDisposeEvent.clear();
|
|
2600
2647
|
}
|
|
2601
2648
|
|