@barchart/portfolio-api-common 1.2.147 → 1.3.4

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/.jshintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "validthis": true
3
+ }
@@ -45,7 +45,7 @@ module.exports = (() => {
45
45
  *
46
46
  * @public
47
47
  * @static
48
- * @param {Array.<Object>} transactions
48
+ * @param {Object[]} transactions
49
49
  * @param {Boolean=} strict
50
50
  * @returns {Boolean}
51
51
  */
@@ -59,7 +59,7 @@ module.exports = (() => {
59
59
  *
60
60
  * @public
61
61
  * @static
62
- * @param {Array.<Object>} transactions
62
+ * @param {Object[]} transactions
63
63
  * @returns {Boolean}
64
64
  */
65
65
  static validateReferences(transactions) {
@@ -97,7 +97,7 @@ module.exports = (() => {
97
97
  *
98
98
  * @public
99
99
  * @static
100
- * @param {Array.<Object>} transactions
100
+ * @param {Object[]} transactions
101
101
  * @param {Boolean=} strict
102
102
  * @returns {Number}
103
103
  */
@@ -116,7 +116,7 @@ module.exports = (() => {
116
116
  * @param {InstrumentType} instrumentType
117
117
  * @param {Boolean=} userInitiated
118
118
  * @param {PositionDirection=} currentDirection
119
- * @returns {Array.<TransactionType>}
119
+ * @returns {TransactionType[]}
120
120
  */
121
121
  static getTransactionTypesFor(instrumentType, userInitiated, currentDirection) {
122
122
  assert.argumentIsRequired(instrumentType, 'instrumentType', InstrumentType, 'InstrumentType');
@@ -141,7 +141,7 @@ module.exports = (() => {
141
141
  *
142
142
  * @public
143
143
  * @static
144
- * @returns {Array.<TransactionType>}
144
+ * @returns {TransactionType[]}
145
145
  */
146
146
  static getUserInitiatedTransactionTypes() {
147
147
  return array.unique(Object.keys(validTransactionTypes).reduce((types, key) => {
@@ -28,8 +28,8 @@ module.exports = (() => {
28
28
  *
29
29
  * @public
30
30
  * @static
31
- * @param {Array.<Object>} transactions
32
- * @param {Array.<Object>} positions
31
+ * @param {Object[]} transactions
32
+ * @param {Object[]} positions
33
33
  * @param {Boolean=} descending
34
34
  * @returns {Array}
35
35
  */
@@ -97,7 +97,7 @@ module.exports = (() => {
97
97
  *
98
98
  * @public
99
99
  * @static
100
- * @param {Array.<Object>} transactions
100
+ * @param {Object[]} transactions
101
101
  * @param {Boolean=} descending
102
102
  * @returns {Array}
103
103
  */
@@ -39,10 +39,10 @@ module.exports = (() => {
39
39
  * changes) for each level of grouping.
40
40
  *
41
41
  * @public
42
- * @param {Array.<PositionTreeDefinition>} definitions
43
- * @param {Array.<Object>} portfolios - The portfolios.
44
- * @param {Array.<Object>} positions - The positions (for all of the portfolios).
45
- * @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
42
+ * @param {PositionTreeDefinition[]} definitions
43
+ * @param {Object[]} portfolios - The portfolios.
44
+ * @param {Object[]} positions - The positions (for all of the portfolios).
45
+ * @param {Object[]} summaries - The positions summaries (for all of the positions).
46
46
  * @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
47
47
  * @param {Day=} reportDate - The end date for the report frame.
48
48
  */
@@ -172,6 +172,53 @@ module.exports = (() => {
172
172
  recalculatePercentages.call(this);
173
173
  }
174
174
 
175
+ /**
176
+ * Returns Barchart's user identifier for the container's portfolios. If
177
+ * the container has no portfolios, a null value is returned.
178
+ *
179
+ * @public
180
+ * @returns {String|null}
181
+ */
182
+ getBarchartUserId() {
183
+ let returnRef = null;
184
+
185
+ const keys = Object.keys(this._portfolios);
186
+
187
+ if (keys.length > 0) {
188
+ const firstKey = keys[0];
189
+ const firstPortfolio = this._portfolios[firstKey];
190
+
191
+ returnRef = firstPortfolio.user;
192
+ }
193
+
194
+ return returnRef;
195
+ }
196
+
197
+ /**
198
+ * Returns customer's user identifier for the container's portfolios. If
199
+ * the container has no portfolios, or if the portfolio(s) are not owned
200
+ * by a remote customer, a null value is returned.
201
+ *
202
+ * @public
203
+ * @returns {String|null}
204
+ */
205
+ getCustomerUserId() {
206
+ let returnRef = null;
207
+
208
+ const keys = Object.keys(this._portfolios);
209
+
210
+ if (keys.length > 0) {
211
+ const firstKey = keys[0];
212
+ const firstPortfolio = this._portfolios[firstKey];
213
+
214
+ if (firstPortfolio.legacy && firstPortfolio.legacy.user) {
215
+ returnRef = firstPortfolio.legacy.user;
216
+ }
217
+ }
218
+
219
+ return returnRef;
220
+ }
221
+
175
222
  /**
176
223
  * Adds a new portfolio to the container, injecting it into aggregation
177
224
  * trees, as necessary.
@@ -284,7 +331,7 @@ module.exports = (() => {
284
331
  *
285
332
  * @public
286
333
  * @param {Object} position
287
- * @param {Array.<Object>} summaries
334
+ * @param {Object>[]} summaries
288
335
  */
289
336
  updatePosition(position, summaries) {
290
337
  assert.argumentIsRequired(position, 'position', Object);
@@ -387,7 +434,7 @@ module.exports = (() => {
387
434
  *
388
435
  * @public
389
436
  * @param {Boolean} display - If true, all "display" symbols are returned; otherwise Barchart symbols are returned.
390
- * @returns {Array.<String>}
437
+ * @returns {String[]}
391
438
  */
392
439
  getPositionSymbols(display) {
393
440
  const symbols = this._items.reduce((symbols, item) => {
@@ -451,8 +498,8 @@ module.exports = (() => {
451
498
  * triggering updates to position(s) and data aggregation(s).
452
499
  *
453
500
  * @public
454
- * @param {Array.<Object>} positionQuotes
455
- * @param {Array.<Object>} forexQuotes
501
+ * @param {Object[]} positionQuotes
502
+ * @param {Object[]} forexQuotes
456
503
  */
457
504
  setQuotes(positionQuotes, forexQuotes) {
458
505
  assert.argumentIsArray(positionQuotes, 'positionQuotes');
@@ -514,7 +561,7 @@ module.exports = (() => {
514
561
  * Returns all forex symbols that are required to do currency translations.
515
562
  *
516
563
  * @public
517
- * @returns {Array.<String>}
564
+ * @returns {String[]}
518
565
  */
519
566
  getForexSymbols() {
520
567
  return this._forexSymbols;
@@ -524,7 +571,7 @@ module.exports = (() => {
524
571
  * Returns all current forex quotes.
525
572
  *
526
573
  * @public
527
- * @returns {Array.<Object>}
574
+ * @returns {Object[]}
528
575
  */
529
576
  getForexQuotes() {
530
577
  return this._forexQuotes;
@@ -586,7 +633,7 @@ module.exports = (() => {
586
633
  *
587
634
  * @public
588
635
  * @param {String} name
589
- * @param {Array.<String>} keys
636
+ * @param {String[]} keys
590
637
  * @returns {PositionGroup}
591
638
  */
592
639
  getGroup(name, keys) {
@@ -602,8 +649,8 @@ module.exports = (() => {
602
649
  *
603
650
  * @public
604
651
  * @param {String} name
605
- * @param {Array.<String>} keys
606
- * @returns {Array.<PositionGroup>}
652
+ * @param {String[]} keys
653
+ * @returns {PositionGroup[]}
607
654
  */
608
655
  getGroups(name, keys) {
609
656
  assert.argumentIsRequired(name, 'name', String);
@@ -642,7 +689,7 @@ module.exports = (() => {
642
689
  * Returns all portfolios in the container.
643
690
  *
644
691
  * @public
645
- * @returns {Array.<Object>}
692
+ * @returns {Object[]}
646
693
  */
647
694
  getPortfolios() {
648
695
  return Object.keys(this._portfolios).map(id => this._portfolios[id]);
@@ -653,7 +700,7 @@ module.exports = (() => {
653
700
  *
654
701
  * @public
655
702
  * @param {String} portfolio
656
- * @returns {Array.<Object>}
703
+ * @returns {Object[]}
657
704
  */
658
705
  getPositions(portfolio) {
659
706
  assert.argumentIsRequired(portfolio, 'portfolio', String);
@@ -26,7 +26,7 @@ module.exports = (() => {
26
26
  * @public
27
27
  * @param {PositionContainer} container
28
28
  * @param {LevelDefinition} definition
29
- * @param {Array.<PositionItem>} items
29
+ * @param {PositionItem[]} items
30
30
  * @param {Currency} currency
31
31
  * @param {String} key
32
32
  * @param {String} description
@@ -361,7 +361,7 @@ module.exports = (() => {
361
361
  * Sets the list of items which are excluded from group aggregation calculations.
362
362
  *
363
363
  * @public
364
- * @param {Array.<Object>} items
364
+ * @param {Object[]} items
365
365
  */
366
366
  setExcludedItems(items) {
367
367
  this._excludedItems = items;
@@ -382,7 +382,7 @@ module.exports = (() => {
382
382
  * Causes aggregated data to be recalculated using a new exchange rate.
383
383
  *
384
384
  * @public
385
- * @param {Array.<Rate>} rate
385
+ * @param {Rate[]} rates
386
386
  */
387
387
  setForexRates(rates) {
388
388
  this._rates = rates;
@@ -20,7 +20,7 @@ module.exports = (() => {
20
20
  * @param {Object} portfolio
21
21
  * @param {Object} position
22
22
  * @param {Object} currentSummary
23
- * @param {Array.<Object>} previousSummaries
23
+ * @param {Object[]} previousSummaries
24
24
  * @param {Boolean} reporting
25
25
  */
26
26
  class PositionItem extends Disposable {
@@ -570,15 +570,13 @@ module.exports = (() => {
570
570
  data.periodUnrealized = periodUnrealized;
571
571
  data.periodUnrealizedChange = periodUnrealizedChange;
572
572
  } else {
573
- data.unrealized = Decimal.ZERO;
574
573
  data.unrealizedChange = Decimal.ZERO;
575
-
574
+ data.periodUnrealizedChange = Decimal.ZERO;
576
575
  data.periodGainChange = Decimal.ZERO;
577
576
  }
578
577
  } else {
579
- data.unrealized = Decimal.ZERO;
580
578
  data.unrealizedChange = Decimal.ZERO;
581
-
579
+ data.periodUnrealizedChange = Decimal.ZERO;
582
580
  data.periodGainChange = Decimal.ZERO;
583
581
  }
584
582
  }
@@ -19,7 +19,7 @@ module.exports = (() => {
19
19
  * @param {PositionLevelDefinition~keySelector} keySelector
20
20
  * @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
21
21
  * @param {PositionLevelDefinition~currencySelector} currencySelector
22
- * @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
22
+ * @param {PositionLevelDefinition~RequiredGroup[]=} requiredGroups
23
23
  * @param {Boolean=} aggregateCash
24
24
  * @param {Function=} requiredGroupGenerator
25
25
  */
@@ -10,8 +10,8 @@ module.exports = (() => {
10
10
  *
11
11
  * @public
12
12
  * @param {String} name
13
- * @param {Array.<PositionLevelDefinition>} definitions
14
- * @oaram {Array.<String>=} exclusionDependencies
13
+ * @param {PositionLevelDefinition[]} definitions
14
+ * @oaram {String[]=} exclusionDependencies
15
15
  */
16
16
  class PositionTreeDefinitions {
17
17
  constructor(name, definitions, exclusionDependencies) {
@@ -44,7 +44,7 @@ module.exports = (() => {
44
44
  * bottom-most level of the tree (i.e. leaf nodes).
45
45
  *
46
46
  * @public
47
- * @returns {Array.<PositionLevelDefinitions>}
47
+ * @returns {PositionLevelDefinitions>[]}
48
48
  */
49
49
  get definitions() {
50
50
  return this._definitions;
@@ -55,7 +55,7 @@ module.exports = (() => {
55
55
  * group (from the current tree) is excluded.
56
56
  *
57
57
  * @public
58
- * @returns {Array.<String>}
58
+ * @returns {String[]}
59
59
  */
60
60
  get exclusionDependencies() {
61
61
  return this._exclusionDependencies;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.147",
3
+ "version": "1.3.4",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {},
11
11
  "dependencies": {
12
- "@barchart/common-js": "~3.2.0",
12
+ "@barchart/common-js": "~3.3.0",
13
13
  "uuid": "3.1.0"
14
14
  },
15
15
  "devDependencies": {
@@ -21,7 +21,7 @@
21
21
  "glob": "^6.0.1",
22
22
  "gulp": "~3.9.0",
23
23
  "gulp-bump": "~1.0.0",
24
- "gulp-git": "~1.6.0",
24
+ "gulp-git": "^2.5.1",
25
25
  "gulp-jasmine": "^2.2.1",
26
26
  "gulp-jshint": "~2.1.0",
27
27
  "gulp-util": "^3.0.7",
@@ -1232,7 +1232,7 @@ module.exports = (() => {
1232
1232
  *
1233
1233
  * @public
1234
1234
  * @static
1235
- * @param {Array.<Object>} transactions
1235
+ * @param {Object[]} transactions
1236
1236
  * @param {Boolean=} strict
1237
1237
  * @returns {Boolean}
1238
1238
  */
@@ -1246,7 +1246,7 @@ module.exports = (() => {
1246
1246
  *
1247
1247
  * @public
1248
1248
  * @static
1249
- * @param {Array.<Object>} transactions
1249
+ * @param {Object[]} transactions
1250
1250
  * @returns {Boolean}
1251
1251
  */
1252
1252
  static validateReferences(transactions) {
@@ -1284,7 +1284,7 @@ module.exports = (() => {
1284
1284
  *
1285
1285
  * @public
1286
1286
  * @static
1287
- * @param {Array.<Object>} transactions
1287
+ * @param {Object[]} transactions
1288
1288
  * @param {Boolean=} strict
1289
1289
  * @returns {Number}
1290
1290
  */
@@ -1303,7 +1303,7 @@ module.exports = (() => {
1303
1303
  * @param {InstrumentType} instrumentType
1304
1304
  * @param {Boolean=} userInitiated
1305
1305
  * @param {PositionDirection=} currentDirection
1306
- * @returns {Array.<TransactionType>}
1306
+ * @returns {TransactionType[]}
1307
1307
  */
1308
1308
  static getTransactionTypesFor(instrumentType, userInitiated, currentDirection) {
1309
1309
  assert.argumentIsRequired(instrumentType, 'instrumentType', InstrumentType, 'InstrumentType');
@@ -1328,7 +1328,7 @@ module.exports = (() => {
1328
1328
  *
1329
1329
  * @public
1330
1330
  * @static
1331
- * @returns {Array.<TransactionType>}
1331
+ * @returns {TransactionType[]}
1332
1332
  */
1333
1333
  static getUserInitiatedTransactionTypes() {
1334
1334
  return array.unique(Object.keys(validTransactionTypes).reduce((types, key) => {
@@ -1525,10 +1525,10 @@ module.exports = (() => {
1525
1525
  * changes) for each level of grouping.
1526
1526
  *
1527
1527
  * @public
1528
- * @param {Array.<PositionTreeDefinition>} definitions
1529
- * @param {Array.<Object>} portfolios - The portfolios.
1530
- * @param {Array.<Object>} positions - The positions (for all of the portfolios).
1531
- * @param {Array.<Object>} summaries - The positions summaries (for all of the positions).
1528
+ * @param {PositionTreeDefinition[]} definitions
1529
+ * @param {Object[]} portfolios - The portfolios.
1530
+ * @param {Object[]} positions - The positions (for all of the portfolios).
1531
+ * @param {Object[]} summaries - The positions summaries (for all of the positions).
1532
1532
  * @param {PositionSummaryFrame=} reportFrame - If specified, locks the current (and previous) periods to a specific frame, use for reporting.
1533
1533
  * @param {Day=} reportDate - The end date for the report frame.
1534
1534
  */
@@ -1658,6 +1658,53 @@ module.exports = (() => {
1658
1658
  recalculatePercentages.call(this);
1659
1659
  }
1660
1660
 
1661
+ /**
1662
+ * Returns Barchart's user identifier for the container's portfolios. If
1663
+ * the container has no portfolios, a null value is returned.
1664
+ *
1665
+ * @public
1666
+ * @returns {String|null}
1667
+ */
1668
+ getBarchartUserId() {
1669
+ let returnRef = null;
1670
+
1671
+ const keys = Object.keys(this._portfolios);
1672
+
1673
+ if (keys.length > 0) {
1674
+ const firstKey = keys[0];
1675
+ const firstPortfolio = this._portfolios[firstKey];
1676
+
1677
+ returnRef = firstPortfolio.user;
1678
+ }
1679
+
1680
+ return returnRef;
1681
+ }
1682
+
1683
+ /**
1684
+ * Returns customer's user identifier for the container's portfolios. If
1685
+ * the container has no portfolios, or if the portfolio(s) are not owned
1686
+ * by a remote customer, a null value is returned.
1687
+ *
1688
+ * @public
1689
+ * @returns {String|null}
1690
+ */
1691
+ getCustomerUserId() {
1692
+ let returnRef = null;
1693
+
1694
+ const keys = Object.keys(this._portfolios);
1695
+
1696
+ if (keys.length > 0) {
1697
+ const firstKey = keys[0];
1698
+ const firstPortfolio = this._portfolios[firstKey];
1699
+
1700
+ if (firstPortfolio.legacy && firstPortfolio.legacy.user) {
1701
+ returnRef = firstPortfolio.legacy.user;
1702
+ }
1703
+ }
1704
+
1705
+ return returnRef;
1706
+ }
1707
+
1661
1708
  /**
1662
1709
  * Adds a new portfolio to the container, injecting it into aggregation
1663
1710
  * trees, as necessary.
@@ -1770,7 +1817,7 @@ module.exports = (() => {
1770
1817
  *
1771
1818
  * @public
1772
1819
  * @param {Object} position
1773
- * @param {Array.<Object>} summaries
1820
+ * @param {Object>[]} summaries
1774
1821
  */
1775
1822
  updatePosition(position, summaries) {
1776
1823
  assert.argumentIsRequired(position, 'position', Object);
@@ -1873,7 +1920,7 @@ module.exports = (() => {
1873
1920
  *
1874
1921
  * @public
1875
1922
  * @param {Boolean} display - If true, all "display" symbols are returned; otherwise Barchart symbols are returned.
1876
- * @returns {Array.<String>}
1923
+ * @returns {String[]}
1877
1924
  */
1878
1925
  getPositionSymbols(display) {
1879
1926
  const symbols = this._items.reduce((symbols, item) => {
@@ -1937,8 +1984,8 @@ module.exports = (() => {
1937
1984
  * triggering updates to position(s) and data aggregation(s).
1938
1985
  *
1939
1986
  * @public
1940
- * @param {Array.<Object>} positionQuotes
1941
- * @param {Array.<Object>} forexQuotes
1987
+ * @param {Object[]} positionQuotes
1988
+ * @param {Object[]} forexQuotes
1942
1989
  */
1943
1990
  setQuotes(positionQuotes, forexQuotes) {
1944
1991
  assert.argumentIsArray(positionQuotes, 'positionQuotes');
@@ -2000,7 +2047,7 @@ module.exports = (() => {
2000
2047
  * Returns all forex symbols that are required to do currency translations.
2001
2048
  *
2002
2049
  * @public
2003
- * @returns {Array.<String>}
2050
+ * @returns {String[]}
2004
2051
  */
2005
2052
  getForexSymbols() {
2006
2053
  return this._forexSymbols;
@@ -2010,7 +2057,7 @@ module.exports = (() => {
2010
2057
  * Returns all current forex quotes.
2011
2058
  *
2012
2059
  * @public
2013
- * @returns {Array.<Object>}
2060
+ * @returns {Object[]}
2014
2061
  */
2015
2062
  getForexQuotes() {
2016
2063
  return this._forexQuotes;
@@ -2072,7 +2119,7 @@ module.exports = (() => {
2072
2119
  *
2073
2120
  * @public
2074
2121
  * @param {String} name
2075
- * @param {Array.<String>} keys
2122
+ * @param {String[]} keys
2076
2123
  * @returns {PositionGroup}
2077
2124
  */
2078
2125
  getGroup(name, keys) {
@@ -2088,8 +2135,8 @@ module.exports = (() => {
2088
2135
  *
2089
2136
  * @public
2090
2137
  * @param {String} name
2091
- * @param {Array.<String>} keys
2092
- * @returns {Array.<PositionGroup>}
2138
+ * @param {String[]} keys
2139
+ * @returns {PositionGroup[]}
2093
2140
  */
2094
2141
  getGroups(name, keys) {
2095
2142
  assert.argumentIsRequired(name, 'name', String);
@@ -2128,7 +2175,7 @@ module.exports = (() => {
2128
2175
  * Returns all portfolios in the container.
2129
2176
  *
2130
2177
  * @public
2131
- * @returns {Array.<Object>}
2178
+ * @returns {Object[]}
2132
2179
  */
2133
2180
  getPortfolios() {
2134
2181
  return Object.keys(this._portfolios).map(id => this._portfolios[id]);
@@ -2139,7 +2186,7 @@ module.exports = (() => {
2139
2186
  *
2140
2187
  * @public
2141
2188
  * @param {String} portfolio
2142
- * @returns {Array.<Object>}
2189
+ * @returns {Object[]}
2143
2190
  */
2144
2191
  getPositions(portfolio) {
2145
2192
  assert.argumentIsRequired(portfolio, 'portfolio', String);
@@ -2548,7 +2595,7 @@ module.exports = (() => {
2548
2595
  * @public
2549
2596
  * @param {PositionContainer} container
2550
2597
  * @param {LevelDefinition} definition
2551
- * @param {Array.<PositionItem>} items
2598
+ * @param {PositionItem[]} items
2552
2599
  * @param {Currency} currency
2553
2600
  * @param {String} key
2554
2601
  * @param {String} description
@@ -2883,7 +2930,7 @@ module.exports = (() => {
2883
2930
  * Sets the list of items which are excluded from group aggregation calculations.
2884
2931
  *
2885
2932
  * @public
2886
- * @param {Array.<Object>} items
2933
+ * @param {Object[]} items
2887
2934
  */
2888
2935
  setExcludedItems(items) {
2889
2936
  this._excludedItems = items;
@@ -2904,7 +2951,7 @@ module.exports = (() => {
2904
2951
  * Causes aggregated data to be recalculated using a new exchange rate.
2905
2952
  *
2906
2953
  * @public
2907
- * @param {Array.<Rate>} rate
2954
+ * @param {Rate[]} rates
2908
2955
  */
2909
2956
  setForexRates(rates) {
2910
2957
  this._rates = rates;
@@ -3562,7 +3609,7 @@ module.exports = (() => {
3562
3609
  * @param {Object} portfolio
3563
3610
  * @param {Object} position
3564
3611
  * @param {Object} currentSummary
3565
- * @param {Array.<Object>} previousSummaries
3612
+ * @param {Object[]} previousSummaries
3566
3613
  * @param {Boolean} reporting
3567
3614
  */
3568
3615
  class PositionItem extends Disposable {
@@ -4112,15 +4159,13 @@ module.exports = (() => {
4112
4159
  data.periodUnrealized = periodUnrealized;
4113
4160
  data.periodUnrealizedChange = periodUnrealizedChange;
4114
4161
  } else {
4115
- data.unrealized = Decimal.ZERO;
4116
4162
  data.unrealizedChange = Decimal.ZERO;
4117
-
4163
+ data.periodUnrealizedChange = Decimal.ZERO;
4118
4164
  data.periodGainChange = Decimal.ZERO;
4119
4165
  }
4120
4166
  } else {
4121
- data.unrealized = Decimal.ZERO;
4122
4167
  data.unrealizedChange = Decimal.ZERO;
4123
-
4168
+ data.periodUnrealizedChange = Decimal.ZERO;
4124
4169
  data.periodGainChange = Decimal.ZERO;
4125
4170
  }
4126
4171
  }
@@ -4300,7 +4345,7 @@ module.exports = (() => {
4300
4345
  * @param {PositionLevelDefinition~keySelector} keySelector
4301
4346
  * @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
4302
4347
  * @param {PositionLevelDefinition~currencySelector} currencySelector
4303
- * @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
4348
+ * @param {PositionLevelDefinition~RequiredGroup[]=} requiredGroups
4304
4349
  * @param {Boolean=} aggregateCash
4305
4350
  * @param {Function=} requiredGroupGenerator
4306
4351
  */
@@ -4601,8 +4646,8 @@ module.exports = (() => {
4601
4646
  *
4602
4647
  * @public
4603
4648
  * @param {String} name
4604
- * @param {Array.<PositionLevelDefinition>} definitions
4605
- * @oaram {Array.<String>=} exclusionDependencies
4649
+ * @param {PositionLevelDefinition[]} definitions
4650
+ * @oaram {String[]=} exclusionDependencies
4606
4651
  */
4607
4652
  class PositionTreeDefinitions {
4608
4653
  constructor(name, definitions, exclusionDependencies) {
@@ -4635,7 +4680,7 @@ module.exports = (() => {
4635
4680
  * bottom-most level of the tree (i.e. leaf nodes).
4636
4681
  *
4637
4682
  * @public
4638
- * @returns {Array.<PositionLevelDefinitions>}
4683
+ * @returns {PositionLevelDefinitions>[]}
4639
4684
  */
4640
4685
  get definitions() {
4641
4686
  return this._definitions;
@@ -4646,7 +4691,7 @@ module.exports = (() => {
4646
4691
  * group (from the current tree) is excluded.
4647
4692
  *
4648
4693
  * @public
4649
- * @returns {Array.<String>}
4694
+ * @returns {String[]}
4650
4695
  */
4651
4696
  get exclusionDependencies() {
4652
4697
  return this._exclusionDependencies;
@@ -5285,7 +5330,7 @@ module.exports = function () {
5285
5330
  *
5286
5331
  * @public
5287
5332
  * @param {*} value - The value of the node.
5288
- * @param {Tree} parent - The parent node. If not supplied, this will be the root node.
5333
+ * @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
5289
5334
  */
5290
5335
 
5291
5336
  var Tree = function () {
@@ -6431,7 +6476,20 @@ module.exports = function () {
6431
6476
  }
6432
6477
 
6433
6478
  /**
6434
- * Returns a new Day instance for the end of the month of the current instance.
6479
+ * Returns a new {@link Day} instance for the start of the month referenced by the current instance.
6480
+ *
6481
+ * @public
6482
+ * @returns {Day}
6483
+ */
6484
+
6485
+ }, {
6486
+ key: 'getStartOfMonth',
6487
+ value: function getStartOfMonth() {
6488
+ return new Day(this.year, this.month, 1);
6489
+ }
6490
+
6491
+ /**
6492
+ * Returns a new instance for the {@link Day} end of the month referenced by the current instance.
6435
6493
  *
6436
6494
  * @public
6437
6495
  * @returns {Day}
@@ -6583,7 +6641,7 @@ module.exports = function () {
6583
6641
  return this._month;
6584
6642
  }
6585
6643
 
6586
- /**
6644
+ /**day
6587
6645
  * The day of the month.
6588
6646
  *
6589
6647
  * @public
@@ -6604,7 +6662,7 @@ module.exports = function () {
6604
6662
  }
6605
6663
 
6606
6664
  /**
6607
- * Converts a string (which matches the output of {@link Day#format} into
6665
+ * Converts a string (which matches the output of {@link Day#format}) into
6608
6666
  * a {@link Day} instance.
6609
6667
  *
6610
6668
  * @public
@@ -6875,6 +6933,24 @@ module.exports = function () {
6875
6933
  return new Decimal(this._big.div(getBig(other)));
6876
6934
  }
6877
6935
 
6936
+ /**
6937
+ * Returns a new {@link Decimal} instance with a value that results
6938
+ * from raising the current instance to the power of the exponent
6939
+ * provided.
6940
+ *
6941
+ * @public
6942
+ * @param {Decimal|Number|String} exponent
6943
+ * @returns {Decimal}
6944
+ */
6945
+
6946
+ }, {
6947
+ key: 'raise',
6948
+ value: function raise(exponent) {
6949
+ assert.argumentIsRequired(exponent, 'exponent', Number);
6950
+
6951
+ return new Decimal(this._big.pow(exponent));
6952
+ }
6953
+
6878
6954
  /**
6879
6955
  * Returns a new {@link Decimal} with a value resulting from a rounding
6880
6956
  * operation on the current value.
@@ -7039,6 +7115,28 @@ module.exports = function () {
7039
7115
  return this._big.eq(getBig(other));
7040
7116
  }
7041
7117
 
7118
+ /**
7119
+ * Returns true is close to another value.
7120
+ *
7121
+ * @public
7122
+ * @param {Decimal|Number|String} other - The value to compare.
7123
+ * @param {Number} places - The significant digits.
7124
+ * @returns {Boolean}
7125
+ */
7126
+
7127
+ }, {
7128
+ key: 'getIsApproximate',
7129
+ value: function getIsApproximate(other, places) {
7130
+ if (places === 0) {
7131
+ return this.getIsEqual(other);
7132
+ }
7133
+
7134
+ var difference = this.subtract(other).absolute();
7135
+ var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
7136
+
7137
+ return difference.getIsLessThan(tolerance);
7138
+ }
7139
+
7042
7140
  /**
7043
7141
  * Returns true if the current instance is an integer (i.e. has no decimal
7044
7142
  * component).
@@ -8722,8 +8820,62 @@ module.exports = function () {
8722
8820
  }
8723
8821
 
8724
8822
  return found;
8823
+ },
8824
+
8825
+
8826
+ /**
8827
+ * Inserts an item into an array using a binary search is used to determine the
8828
+ * proper point for insertion and returns the same array.
8829
+ *
8830
+ * @static
8831
+ * @public
8832
+ * @param {Array} a
8833
+ * @param {*} item
8834
+ * @param {Function} comparator
8835
+ * @returns {Array}
8836
+ */
8837
+ insert: function insert(a, item, comparator) {
8838
+ assert.argumentIsArray(a, 'a');
8839
+ assert.argumentIsRequired(comparator, 'comparator', Function);
8840
+
8841
+ if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
8842
+ a.push(item);
8843
+ } else if (comparator(item, a[0]) < 0) {
8844
+ a.unshift(item);
8845
+ } else {
8846
+ a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
8847
+ }
8848
+
8849
+ return a;
8725
8850
  }
8726
8851
  };
8852
+
8853
+ function binarySearch(array, item, comparator, start, end) {
8854
+ var size = end - start;
8855
+
8856
+ var midpointIndex = start + Math.floor(size / 2);
8857
+ var midpointItem = array[midpointIndex];
8858
+
8859
+ var comparison = comparator(item, midpointItem) > 0;
8860
+
8861
+ if (size < 2) {
8862
+ if (comparison > 0) {
8863
+ var finalIndex = array.length - 1;
8864
+
8865
+ if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
8866
+ return end + 1;
8867
+ } else {
8868
+ return end;
8869
+ }
8870
+ } else {
8871
+ return start;
8872
+ }
8873
+ } else if (comparison > 0) {
8874
+ return binarySearch(array, item, comparator, midpointIndex, end);
8875
+ } else {
8876
+ return binarySearch(array, item, comparator, start, midpointIndex);
8877
+ }
8878
+ }
8727
8879
  }();
8728
8880
 
8729
8881
  },{"./assert":29,"./is":33}],29:[function(require,module,exports){
@@ -8939,9 +9091,10 @@ module.exports = function () {
8939
9091
  /**
8940
9092
  * Checks to see if an attribute exists on the target object.
8941
9093
  *
9094
+ * @public
8942
9095
  * @static
8943
9096
  * @param {Object} target - The object to check for existence of the property.
8944
- * @param {String|Array.<String>} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
9097
+ * @param {String|String[]} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
8945
9098
  * @param {String=} separator - The separator (defaults to a period character).
8946
9099
  * @returns {boolean}
8947
9100
  */
@@ -8965,9 +9118,10 @@ module.exports = function () {
8965
9118
  * Returns a value from the target object. If the property doesn't exist; undefined
8966
9119
  * is returned.
8967
9120
  *
9121
+ * @public
8968
9122
  * @static
8969
9123
  * @param {Object} target - The object to read from.
8970
- * @param {String|Array.<String>} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
9124
+ * @param {String|String[]} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
8971
9125
  * @param {String=} separator - The separator (defaults to a period character).
8972
9126
  * @returns {*}
8973
9127
  */
@@ -9000,9 +9154,10 @@ module.exports = function () {
9000
9154
  /**
9001
9155
  * Writes a value to the target object.
9002
9156
  *
9157
+ * @public
9003
9158
  * @static
9004
9159
  * @param {Object} target - The object to write to.
9005
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
9160
+ * @param {String|String[]} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
9006
9161
  * @param {*} value - The value to assign.
9007
9162
  * @param {String=} separator - The separator (defaults to a period character).
9008
9163
  */
@@ -9027,9 +9182,10 @@ module.exports = function () {
9027
9182
  /**
9028
9183
  * Erases a property from the target object.
9029
9184
  *
9185
+ * @public
9030
9186
  * @static
9031
9187
  * @param {Object} target - The object to erase a property from.
9032
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
9188
+ * @param {String|String} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
9033
9189
  * @param {String=} separator - The separator (defaults to a period character).
9034
9190
  */
9035
9191
  erase: function erase(target, propertyNames, separator) {
@@ -9244,7 +9400,7 @@ module.exports = function () {
9244
9400
  * @static
9245
9401
  * @public
9246
9402
  * @param {*} candidate
9247
- * @returns {*|boolean}
9403
+ * @returns {boolean}
9248
9404
  */
9249
9405
  negative: function negative(candidate) {
9250
9406
  return this.number(candidate) && candidate < 0;
@@ -9955,6 +10111,20 @@ module.exports = function () {
9955
10111
  return dataTypeObject;
9956
10112
  }
9957
10113
 
10114
+ /**
10115
+ * References an array.
10116
+ *
10117
+ * @public
10118
+ * @static
10119
+ * @returns {DataType}
10120
+ */
10121
+
10122
+ }, {
10123
+ key: 'ARRAY',
10124
+ get: function get() {
10125
+ return dataTypeArray;
10126
+ }
10127
+
9958
10128
  /**
9959
10129
  * References a {@link Decimal} instance.
9960
10130
  *
@@ -10023,6 +10193,7 @@ module.exports = function () {
10023
10193
  var dataTypeNumber = new DataType('Number', null, null, is.number);
10024
10194
  var dataTypeBoolean = new DataType('Boolean', null, null, is.boolean);
10025
10195
  var dataTypeObject = new DataType('Object', null, null, is.object);
10196
+ var dataTypeArray = new DataType('Array', null, null, is.array);
10026
10197
 
10027
10198
  var dataTypeDecimal = new DataType('Decimal', null, function (x) {
10028
10199
  return Decimal.parse(x);
@@ -10045,7 +10216,7 @@ module.exports = function () {
10045
10216
  return x instanceof AdHoc;
10046
10217
  }, getBuilder(buildAdHoc));
10047
10218
 
10048
- var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
10219
+ var dataTypes = [dataTypeString, dataTypeNumber, dataTypeBoolean, dataTypeObject, dataTypeArray, dataTypeDecimal, dataTypeDay, dataTypeTimestamp, dataTypeAdHoc];
10049
10220
 
10050
10221
  function getBuilder(builder) {
10051
10222
  return function (data) {