@barchart/portfolio-api-common 1.0.28 → 1.0.33

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.
@@ -313,10 +313,10 @@ module.exports = (() => {
313
313
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', false, false, true, false, false);
314
314
  const distributionFund = new TransactionType('DF', 'Distribution (Units)', false, false, false, true, false);
315
315
 
316
- const deposit = new TransactionType('D', 'Deposit', false, false, false, false, false);
317
- const withdrawal = new TransactionType('W', 'Withdrawal', false, false, false, false, false);
318
- const debit = new TransactionType('DR', 'Debit', false, false, false, false, false);
319
- const credit = new TransactionType('CR', 'Credit', false, false, false, false, false);
316
+ const deposit = new TransactionType('D', 'Deposit', false, false, false, true, false);
317
+ const withdrawal = new TransactionType('W', 'Withdrawal', false, false, false, false, true);
318
+ const debit = new TransactionType('DR', 'Debit', false, false, false, false, true);
319
+ const credit = new TransactionType('CR', 'Credit', false, false, false, true, false);
320
320
 
321
321
  const valuation = new TransactionType('V', 'Valuation', false, false, false, false, false);
322
322
  const income = new TransactionType('I', 'Income', false, false, true, false, false);
@@ -1,4 +1,4 @@
1
- const array = require('@barchart/common-js/lang/array')
1
+ const array = require('@barchart/common-js/lang/array'),
2
2
  assert = require('@barchart/common-js/lang/assert'),
3
3
  Decimal = require('@barchart/common-js/lang/Decimal'),
4
4
  formatter = require('@barchart/common-js/lang/formatter');
@@ -6,14 +6,17 @@ const array = require('@barchart/common-js/lang/array')
6
6
  module.exports = (() => {
7
7
 
8
8
  /**
9
- * Formats Position Summary records into groups based on instrument type
9
+ * Static utilities for formatting position summary records (into groups based on
10
+ * instrument type)
10
11
  *
12
+ * @public
11
13
  */
12
14
  class PositionSummaryFormatter{
13
-
14
15
  /**
15
16
  * The formatter
16
17
  *
18
+ * @public
19
+ * @static
17
20
  * @param {Array} summaries
18
21
  * @returns {Object}
19
22
  */
@@ -67,5 +70,4 @@ module.exports = (() => {
67
70
  };
68
71
 
69
72
  return PositionSummaryFormatter;
70
-
71
73
  })();
@@ -272,6 +272,11 @@ module.exports = (() => {
272
272
  .withField('portfolio', DataType.STRING)
273
273
  .withField('position', DataType.STRING)
274
274
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
275
+ .withField('instrument.name', DataType.STRING, true)
276
+ .withField('instrument.type', DataType.STRING, true)
277
+ .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
278
+ .withField('instrument.symbol.barchart', DataType.STRING, true)
279
+ .withField('instrument.symbol.display', DataType.STRING, true)
275
280
  .withField('date', DataType.DAY)
276
281
  .withField('price', DataType.DECIMAL)
277
282
  .withField('quantity', DataType.DECIMAL)
@@ -283,11 +288,6 @@ module.exports = (() => {
283
288
  .withField('portfolio', DataType.STRING)
284
289
  .withField('position', DataType.STRING)
285
290
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
286
- .withField('instrument.name', DataType.STRING, true)
287
- .withField('instrument.type', DataType.STRING, true)
288
- .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
289
- .withField('instrument.symbol.barchart', DataType.STRING, true)
290
- .withField('instrument.symbol.display', DataType.STRING, true)
291
291
  .withField('date', DataType.DAY)
292
292
  .withField('price', DataType.DECIMAL)
293
293
  .withField('quantity', DataType.DECIMAL)
@@ -301,8 +301,7 @@ module.exports = (() => {
301
301
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
302
302
  .withField('date', DataType.DAY)
303
303
  .withField('rate', DataType.DECIMAL)
304
- .withField('open', DataType.DECIMAL, true)
305
- .withField('effective', DataType.DAY, true)
304
+ .withField('effective', DataType.DAY)
306
305
  .withField('fee', DataType.DECIMAL, true)
307
306
  .schema
308
307
  );
@@ -313,8 +312,7 @@ module.exports = (() => {
313
312
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
314
313
  .withField('date', DataType.DAY)
315
314
  .withField('rate', DataType.DECIMAL)
316
- .withField('open', DataType.DECIMAL, true)
317
- .withField('effective', DataType.DAY, true)
315
+ .withField('effective', DataType.DAY)
318
316
  .withField('price', DataType.DECIMAL)
319
317
  .withField('fee', DataType.DECIMAL, true)
320
318
  .schema
@@ -326,8 +324,7 @@ module.exports = (() => {
326
324
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
327
325
  .withField('date', DataType.DAY)
328
326
  .withField('rate', DataType.DECIMAL)
329
- .withField('open', DataType.DECIMAL, true)
330
- .withField('effective', DataType.DAY, true)
327
+ .withField('effective', DataType.DAY)
331
328
  .withField('price', DataType.DECIMAL)
332
329
  .withField('fee', DataType.DECIMAL, true)
333
330
  .schema
@@ -339,8 +336,7 @@ module.exports = (() => {
339
336
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
340
337
  .withField('date', DataType.DAY)
341
338
  .withField('rate', DataType.DECIMAL)
342
- .withField('open', DataType.DECIMAL, true)
343
- .withField('effective', DataType.DAY, true)
339
+ .withField('effective', DataType.DAY)
344
340
  .withField('fee', DataType.DECIMAL, true)
345
341
  .schema
346
342
  );
@@ -351,8 +347,8 @@ module.exports = (() => {
351
347
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
352
348
  .withField('date', DataType.DAY)
353
349
  .withField('rate', DataType.DECIMAL)
354
- .withField('open', DataType.DECIMAL, true)
355
- .withField('effective', DataType.DAY, true)
350
+ .withField('effective', DataType.DAY)
351
+ .withField('price', DataType.DECIMAL)
356
352
  .withField('fee', DataType.DECIMAL, true)
357
353
  .schema
358
354
  );
@@ -364,7 +360,7 @@ module.exports = (() => {
364
360
  .withField('date', DataType.DAY)
365
361
  .withField('numerator', DataType.DECIMAL)
366
362
  .withField('denominator', DataType.DECIMAL)
367
- .withField('effective', DataType.DAY, true)
363
+ .withField('effective', DataType.DAY)
368
364
  .withField('fee', DataType.DECIMAL, true)
369
365
  .schema
370
366
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.28",
3
+ "version": "1.0.33",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -631,6 +631,37 @@ module.exports = function () {
631
631
  return Day.compareDays(this, other) > 0;
632
632
  }
633
633
 
634
+ /**
635
+ * Indicates the current day falls between two other days, inclusive
636
+ * of the range boundaries.
637
+ *
638
+ * @public
639
+ * @param {Day=} first
640
+ * @param {Day=} last
641
+ * @param {boolean=} exclusive
642
+ * @returns {boolean}
643
+ */
644
+
645
+ }, {
646
+ key: 'getIsContained',
647
+ value: function getIsContained(first, last) {
648
+ assert.argumentIsOptional(first, 'first', Day, 'Day');
649
+ assert.argumentIsOptional(last, 'last', Day, 'Day');
650
+
651
+ var notAfter = void 0;
652
+ var notBefore = void 0;
653
+
654
+ if (first && last && first.getIsAfter(last)) {
655
+ notBefore = false;
656
+ notAfter = false;
657
+ } else {
658
+ notAfter = !(last instanceof Day) || !this.getIsAfter(last);
659
+ notBefore = !(first instanceof Day) || !this.getIsBefore(first);
660
+ }
661
+
662
+ return notAfter && notBefore;
663
+ }
664
+
634
665
  /**
635
666
  * Indicates if another {@link Day} occurs after the current instance.
636
667
  *