@barchart/portfolio-api-common 1.2.114 → 1.2.115

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.
@@ -352,6 +352,17 @@ module.exports = (() => {
352
352
  static get DEBIT() {
353
353
  return debit;
354
354
  }
355
+
356
+ /**
357
+ * A system-generated transaction, indicating the security has stopped active trading.
358
+ *
359
+ * @public
360
+ * @static
361
+ * @returns {TransactionType}
362
+ */
363
+ static get DELIST() {
364
+ return delist;
365
+ }
355
366
 
356
367
  /**
357
368
  * A system-generated deposit, arising from another transaction.
@@ -401,6 +412,7 @@ module.exports = (() => {
401
412
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
402
413
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
403
414
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
415
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 0, false, false, false, false, false, false, false, false, false);
404
416
 
405
417
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
406
418
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -244,6 +244,7 @@ module.exports = (() => {
244
244
  associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_REINVEST, false);
245
245
  associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_STOCK, false);
246
246
  associateTypes(InstrumentType.EQUITY, TransactionType.SPLIT, false);
247
+ associateTypes(InstrumentType.EQUITY, TransactionType.DELIST, false);
247
248
 
248
249
  associateTypes(InstrumentType.FUND, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
249
250
  associateTypes(InstrumentType.FUND, TransactionType.SELL, true, [ PositionDirection.LONG ]);
@@ -252,6 +253,7 @@ module.exports = (() => {
252
253
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_CASH, false);
253
254
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_REINVEST, false);
254
255
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_FUND, false);
256
+ associateTypes(InstrumentType.FUND, TransactionType.DELIST, false);
255
257
 
256
258
  associateTypes(InstrumentType.OTHER, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
257
259
  associateTypes(InstrumentType.OTHER, TransactionType.SELL, true, [ PositionDirection.LONG ]);
@@ -216,7 +216,7 @@ module.exports = (() => {
216
216
  formatters.set(TransactionType.INCOME, (t) => {
217
217
  return {
218
218
  total: t.income.amount
219
- };
219
+ };
220
220
  });
221
221
 
222
222
  formatters.set(TransactionType.FEE, (t) => {
@@ -254,6 +254,10 @@ module.exports = (() => {
254
254
  price: rate
255
255
  };
256
256
  });
257
+
258
+ formatters.set(TransactionType.DELIST, () => {
259
+ return { };
260
+ });
257
261
 
258
262
  const cashFormatter = (t) => {
259
263
  return {
@@ -298,4 +302,4 @@ module.exports = (() => {
298
302
  .toComparator();
299
303
 
300
304
  return TransactionFormatter;
301
- })();
305
+ })();
@@ -113,6 +113,10 @@ module.exports = (() => {
113
113
  static get VALUATION() {
114
114
  return valuation;
115
115
  }
116
+
117
+ static get DELIST() {
118
+ return delist;
119
+ }
116
120
 
117
121
  static get INCOME() {
118
122
  return income;
@@ -322,8 +326,18 @@ module.exports = (() => {
322
326
  .withField('force', DataType.BOOLEAN, true)
323
327
  .schema
324
328
  );
325
-
326
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
329
+
330
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
331
+ .withField('portfolio', DataType.STRING)
332
+ .withField('position', DataType.STRING)
333
+ .withField('sequence', DataType.NUMBER, true)
334
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
335
+ .withField('date', DataType.DAY)
336
+ .withField('force', DataType.BOOLEAN, true)
337
+ .schema
338
+ );
339
+
340
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
327
341
  .withField('portfolio', DataType.STRING)
328
342
  .withField('position', DataType.STRING)
329
343
  .withField('sequence', DataType.NUMBER, true)
@@ -349,6 +363,7 @@ module.exports = (() => {
349
363
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
350
364
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
351
365
  addSchemaToMap(TransactionType.VALUATION, valuation);
366
+ addSchemaToMap(TransactionType.DELIST, delist);
352
367
  addSchemaToMap(TransactionType.INCOME, income);
353
368
 
354
369
  return TransactionSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.114",
3
+ "version": "1.2.115",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1089,6 +1089,17 @@ module.exports = (() => {
1089
1089
  static get DEBIT() {
1090
1090
  return debit;
1091
1091
  }
1092
+
1093
+ /**
1094
+ * A system-generated transaction, indicating the security has stopped active trading.
1095
+ *
1096
+ * @public
1097
+ * @static
1098
+ * @returns {TransactionType}
1099
+ */
1100
+ static get DELIST() {
1101
+ return delist;
1102
+ }
1092
1103
 
1093
1104
  /**
1094
1105
  * A system-generated deposit, arising from another transaction.
@@ -1138,6 +1149,7 @@ module.exports = (() => {
1138
1149
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
1139
1150
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
1140
1151
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
1152
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 0, false, false, false, false, false, false, false, false, false);
1141
1153
 
1142
1154
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
1143
1155
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -1401,6 +1413,7 @@ module.exports = (() => {
1401
1413
  associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_REINVEST, false);
1402
1414
  associateTypes(InstrumentType.EQUITY, TransactionType.DIVIDEND_STOCK, false);
1403
1415
  associateTypes(InstrumentType.EQUITY, TransactionType.SPLIT, false);
1416
+ associateTypes(InstrumentType.EQUITY, TransactionType.DELIST, false);
1404
1417
 
1405
1418
  associateTypes(InstrumentType.FUND, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
1406
1419
  associateTypes(InstrumentType.FUND, TransactionType.SELL, true, [ PositionDirection.LONG ]);
@@ -1409,6 +1422,7 @@ module.exports = (() => {
1409
1422
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_CASH, false);
1410
1423
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_REINVEST, false);
1411
1424
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_FUND, false);
1425
+ associateTypes(InstrumentType.FUND, TransactionType.DELIST, false);
1412
1426
 
1413
1427
  associateTypes(InstrumentType.OTHER, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
1414
1428
  associateTypes(InstrumentType.OTHER, TransactionType.SELL, true, [ PositionDirection.LONG ]);
@@ -4701,6 +4715,10 @@ module.exports = (() => {
4701
4715
  static get VALUATION() {
4702
4716
  return valuation;
4703
4717
  }
4718
+
4719
+ static get DELIST() {
4720
+ return delist;
4721
+ }
4704
4722
 
4705
4723
  static get INCOME() {
4706
4724
  return income;
@@ -4910,8 +4928,18 @@ module.exports = (() => {
4910
4928
  .withField('force', DataType.BOOLEAN, true)
4911
4929
  .schema
4912
4930
  );
4913
-
4914
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
4931
+
4932
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
4933
+ .withField('portfolio', DataType.STRING)
4934
+ .withField('position', DataType.STRING)
4935
+ .withField('sequence', DataType.NUMBER, true)
4936
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
4937
+ .withField('date', DataType.DAY)
4938
+ .withField('force', DataType.BOOLEAN, true)
4939
+ .schema
4940
+ );
4941
+
4942
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
4915
4943
  .withField('portfolio', DataType.STRING)
4916
4944
  .withField('position', DataType.STRING)
4917
4945
  .withField('sequence', DataType.NUMBER, true)
@@ -4937,6 +4965,7 @@ module.exports = (() => {
4937
4965
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
4938
4966
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
4939
4967
  addSchemaToMap(TransactionType.VALUATION, valuation);
4968
+ addSchemaToMap(TransactionType.DELIST, delist);
4940
4969
  addSchemaToMap(TransactionType.INCOME, income);
4941
4970
 
4942
4971
  return TransactionSchema;
@@ -17875,10 +17904,6 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
17875
17904
  });
17876
17905
  });
17877
17906
 
17878
-
17879
-
17880
- /////
17881
-
17882
17907
  describe('and month position summary ranges are processed for a transaction set that does not close', () => {
17883
17908
  let ranges;
17884
17909
 
@@ -17903,8 +17928,8 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
17903
17928
  ranges = PositionSummaryFrame.MONTHLY.getRanges(transactions);
17904
17929
  });
17905
17930
 
17906
- it('should have 2 ranges (assuming the current year is 2018 and the current month is November)', () => {
17907
- expect(ranges.length).toEqual(2);
17931
+ it('should have three ranges (assuming the current year is 2018 and the current month is December)', () => {
17932
+ expect(ranges.length).toEqual(3);
17908
17933
  });
17909
17934
 
17910
17935
  it('the first range should be from 2018-09-30 to 2018-10-31', () => {
@@ -17913,14 +17938,15 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
17913
17938
  });
17914
17939
 
17915
17940
  it('the second range should be from 2018-10-31 to 2018-11-30', () => {
17916
- expect(ranges[1].start.format()).toEqual('2018-10-31');
17917
- expect(ranges[1].end.format()).toEqual('2018-11-30');
17941
+ expect(ranges[1].start.format()).toEqual('2018-10-31');
17942
+ expect(ranges[1].end.format()).toEqual('2018-11-30');
17918
17943
  });
17919
- });
17920
-
17921
- ///////
17922
-
17923
17944
 
17945
+ it('the third range should be from 2018-10-31 to 2018-11-30', () => {
17946
+ expect(ranges[2].start.format()).toEqual('2018-11-30');
17947
+ expect(ranges[2].end.format()).toEqual('2018-12-31');
17948
+ });
17949
+ });
17924
17950
 
17925
17951
  describe('and getting the start date for yearly frames', () => {
17926
17952
  describe('for one year ago', function() {
@@ -311,10 +311,6 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
311
311
  });
312
312
  });
313
313
 
314
-
315
-
316
- /////
317
-
318
314
  describe('and month position summary ranges are processed for a transaction set that does not close', () => {
319
315
  let ranges;
320
316
 
@@ -339,8 +335,8 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
339
335
  ranges = PositionSummaryFrame.MONTHLY.getRanges(transactions);
340
336
  });
341
337
 
342
- it('should have 2 ranges (assuming the current year is 2018 and the current month is November)', () => {
343
- expect(ranges.length).toEqual(2);
338
+ it('should have three ranges (assuming the current year is 2018 and the current month is December)', () => {
339
+ expect(ranges.length).toEqual(3);
344
340
  });
345
341
 
346
342
  it('the first range should be from 2018-09-30 to 2018-10-31', () => {
@@ -349,14 +345,15 @@ describe('After the PositionSummaryFrame enumeration is initialized', () => {
349
345
  });
350
346
 
351
347
  it('the second range should be from 2018-10-31 to 2018-11-30', () => {
352
- expect(ranges[1].start.format()).toEqual('2018-10-31');
353
- expect(ranges[1].end.format()).toEqual('2018-11-30');
348
+ expect(ranges[1].start.format()).toEqual('2018-10-31');
349
+ expect(ranges[1].end.format()).toEqual('2018-11-30');
354
350
  });
355
- });
356
-
357
- ///////
358
-
359
351
 
352
+ it('the third range should be from 2018-10-31 to 2018-11-30', () => {
353
+ expect(ranges[2].start.format()).toEqual('2018-11-30');
354
+ expect(ranges[2].end.format()).toEqual('2018-12-31');
355
+ });
356
+ });
360
357
 
361
358
  describe('and getting the start date for yearly frames', () => {
362
359
  describe('for one year ago', function() {