@barchart/portfolio-api-common 1.2.32 → 1.2.36

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.
@@ -273,7 +273,7 @@ module.exports = (() => {
273
273
  }).thenBy((a, b) => {
274
274
  return comparators.compareStrings(a.instrument.id, b.instrument.id);
275
275
  }).thenBy((a, b) => {
276
- return comparators.compareStrings(a.sequence, b.sequence);
276
+ return comparators.compareNumbers(b.sequence, a.sequence);
277
277
  }).toComparator();
278
278
 
279
279
  return TransactionFormatter;
@@ -122,7 +122,7 @@ module.exports = (() => {
122
122
  }
123
123
 
124
124
  /**
125
- * The year-to-date position summary of the encapsulated position.
125
+ * The year-to-date summary of the encapsulated position.
126
126
  *
127
127
  * @public
128
128
  * @returns {Object}
@@ -101,7 +101,7 @@ module.exports = (() => {
101
101
  .withField('name', DataType.STRING)
102
102
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
103
103
  .withField('dates.create', DataType.DAY)
104
- .withField('dates.cash', DataType.DAY, true)
104
+ .withField('defaults.cash', DataType.BOOLEAN, true)
105
105
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
106
106
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
107
107
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
@@ -123,7 +123,7 @@ module.exports = (() => {
123
123
  .withField('name', DataType.STRING)
124
124
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
125
125
  .withField('dates.create', DataType.DAY)
126
- .withField('dates.cash', DataType.DAY, true)
126
+ .withField('defaults.cash', DataType.BOOLEAN, true)
127
127
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
128
128
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
129
129
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
@@ -146,7 +146,7 @@ module.exports = (() => {
146
146
  const create = new PortfolioSchema(SchemaBuilder.withName('create')
147
147
  .withField('name', DataType.STRING)
148
148
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
149
- .withField('dates.cash', DataType.DAY, true)
149
+ .withField('defaults.cash', DataType.BOOLEAN, true)
150
150
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'), true)
151
151
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
152
152
  .withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'), true)
@@ -158,6 +158,7 @@ module.exports = (() => {
158
158
  .withField('portfolio', DataType.STRING)
159
159
  .withField('name', DataType.STRING)
160
160
  .withField('timezone', DataType.forEnum(Timezones, 'Timezone'), true)
161
+ .withField('defaults.cash', DataType.BOOLEAN, true)
161
162
  .withField('defaults.currency', DataType.forEnum(Currency, 'Currency'), true)
162
163
  .withField('defaults.reinvest', DataType.BOOLEAN, true)
163
164
  .withField('miscellany', DataType.AD_HOC, true)
@@ -87,8 +87,9 @@ module.exports = (() => {
87
87
  .withField('position', DataType.STRING)
88
88
  .withField('open', DataType.BOOLEAN, true)
89
89
  .withField('transaction', DataType.NUMBER)
90
- .withField('valuation', DataType.forEnum(ValuationType, 'ValuationType'))
90
+ .withField('cash', DataType.BOOLEAN, true)
91
91
  .withField('reinvest', DataType.BOOLEAN, true)
92
+ .withField('valuation', DataType.forEnum(ValuationType, 'ValuationType'))
92
93
  .withField('snapshot.date', DataType.DAY)
93
94
  .withField('snapshot.open', DataType.DECIMAL)
94
95
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
@@ -120,8 +121,9 @@ module.exports = (() => {
120
121
  .withField('position', DataType.STRING)
121
122
  .withField('open', DataType.BOOLEAN, true)
122
123
  .withField('transaction', DataType.NUMBER)
123
- .withField('valuation', DataType.forEnum(ValuationType, 'ValuationType'))
124
+ .withField('cash', DataType.BOOLEAN, true)
124
125
  .withField('reinvest', DataType.BOOLEAN, true)
126
+ .withField('valuation', DataType.forEnum(ValuationType, 'ValuationType'))
125
127
  .withField('snapshot.date', DataType.DAY)
126
128
  .withField('snapshot.open', DataType.DECIMAL)
127
129
  .withField('snapshot.direction', DataType.forEnum(PositionDirection, 'PositionDirection'))
@@ -143,6 +145,7 @@ module.exports = (() => {
143
145
  .withField('mapping.currency', DataType.forEnum(Currency, 'Currency'), true)
144
146
  .withField('mapping.symbol.barchart', DataType.STRING, true)
145
147
  .withField('mapping.symbol.display', DataType.STRING, true)
148
+ .withField('cash', DataType.BOOLEAN, true)
146
149
  .withField('reinvest', DataType.BOOLEAN, true)
147
150
  .schema
148
151
  );
@@ -103,38 +103,6 @@ module.exports = (() => {
103
103
  return sellShort;
104
104
  }
105
105
 
106
- static get DIVIDEND() {
107
- return dividend;
108
- }
109
-
110
- static get DIVIDEND_REINVEST() {
111
- return dividendReinvest;
112
- }
113
-
114
- static get DIVIDEND_STOCK() {
115
- return dividendStock;
116
- }
117
-
118
- static get DISTRIBUTION_CASH() {
119
- return distributionCash;
120
- }
121
-
122
- static get DISTRIBUTION_FUND() {
123
- return distributionFund;
124
- }
125
-
126
- static get SPLIT() {
127
- return split;
128
- }
129
-
130
- static get FEE() {
131
- return fee;
132
- }
133
-
134
- static get FEE_UNITS() {
135
- return feeUnits;
136
- }
137
-
138
106
  static get DEPOSIT() {
139
107
  return deposit;
140
108
  }
@@ -143,14 +111,6 @@ module.exports = (() => {
143
111
  return withdrawal;
144
112
  }
145
113
 
146
- static get DEBIT() {
147
- return debit;
148
- }
149
-
150
- static get CREDIT() {
151
- return credit;
152
- }
153
-
154
114
  static get VALUATION() {
155
115
  return valuation;
156
116
  }
@@ -259,8 +219,9 @@ module.exports = (() => {
259
219
  .withField('price', DataType.DECIMAL)
260
220
  .withField('quantity', DataType.DECIMAL)
261
221
  .withField('fee', DataType.DECIMAL, true)
262
- .withField('force', DataType.BOOLEAN, true)
263
222
  .withField('reinvest', DataType.BOOLEAN, true)
223
+ .withField('cash', DataType.BOOLEAN, true)
224
+ .withField('force', DataType.BOOLEAN, true)
264
225
  .schema
265
226
  );
266
227
 
@@ -287,7 +248,6 @@ module.exports = (() => {
287
248
  .withField('quantity', DataType.DECIMAL)
288
249
  .withField('fee', DataType.DECIMAL, true)
289
250
  .withField('force', DataType.BOOLEAN, true)
290
- .withField('force', DataType.BOOLEAN, true)
291
251
  .schema
292
252
  );
293
253
 
@@ -305,83 +265,8 @@ module.exports = (() => {
305
265
  .withField('price', DataType.DECIMAL)
306
266
  .withField('quantity', DataType.DECIMAL)
307
267
  .withField('fee', DataType.DECIMAL, true)
308
- .withField('force', DataType.BOOLEAN, true)
309
268
  .withField('reinvest', DataType.BOOLEAN, true)
310
- .schema
311
- );
312
-
313
- const dividend = new TransactionSchema(SchemaBuilder.withName(TransactionType.DIVIDEND.code)
314
- .withField('portfolio', DataType.STRING)
315
- .withField('position', DataType.STRING)
316
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
317
- .withField('date', DataType.DAY)
318
- .withField('rate', DataType.DECIMAL)
319
- .withField('effective', DataType.DAY)
320
- .withField('fee', DataType.DECIMAL, true)
321
- .withField('force', DataType.BOOLEAN, true)
322
- .schema
323
- );
324
-
325
- const dividendReinvest = new TransactionSchema(SchemaBuilder.withName(TransactionType.DIVIDEND_REINVEST.code)
326
- .withField('portfolio', DataType.STRING)
327
- .withField('position', DataType.STRING)
328
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
329
- .withField('date', DataType.DAY)
330
- .withField('rate', DataType.DECIMAL)
331
- .withField('effective', DataType.DAY)
332
- .withField('price', DataType.DECIMAL)
333
- .withField('fee', DataType.DECIMAL, true)
334
- .withField('force', DataType.BOOLEAN, true)
335
- .schema
336
- );
337
-
338
- const dividendStock = new TransactionSchema(SchemaBuilder.withName(TransactionType.DIVIDEND_STOCK.code)
339
- .withField('portfolio', DataType.STRING)
340
- .withField('position', DataType.STRING)
341
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
342
- .withField('date', DataType.DAY)
343
- .withField('rate', DataType.DECIMAL)
344
- .withField('effective', DataType.DAY)
345
- .withField('price', DataType.DECIMAL)
346
- .withField('fee', DataType.DECIMAL, true)
347
- .withField('force', DataType.BOOLEAN, true)
348
- .schema
349
- );
350
-
351
- const distributionCash = new TransactionSchema(SchemaBuilder.withName(TransactionType.DISTRIBUTION_CASH.code)
352
- .withField('portfolio', DataType.STRING)
353
- .withField('position', DataType.STRING)
354
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
355
- .withField('date', DataType.DAY)
356
- .withField('rate', DataType.DECIMAL)
357
- .withField('effective', DataType.DAY)
358
- .withField('fee', DataType.DECIMAL, true)
359
- .withField('force', DataType.BOOLEAN, true)
360
- .schema
361
- );
362
-
363
- const distributionFund = new TransactionSchema(SchemaBuilder.withName(TransactionType.DISTRIBUTION_FUND.code)
364
- .withField('portfolio', DataType.STRING)
365
- .withField('position', DataType.STRING)
366
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
367
- .withField('date', DataType.DAY)
368
- .withField('rate', DataType.DECIMAL)
369
- .withField('effective', DataType.DAY)
370
- .withField('price', DataType.DECIMAL)
371
- .withField('fee', DataType.DECIMAL, true)
372
- .withField('force', DataType.BOOLEAN, true)
373
- .schema
374
- );
375
-
376
- const split = new TransactionSchema(SchemaBuilder.withName(TransactionType.SPLIT.code)
377
- .withField('portfolio', DataType.STRING)
378
- .withField('position', DataType.STRING)
379
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
380
- .withField('date', DataType.DAY)
381
- .withField('numerator', DataType.DECIMAL)
382
- .withField('denominator', DataType.DECIMAL)
383
- .withField('effective', DataType.DAY)
384
- .withField('fee', DataType.DECIMAL, true)
269
+ .withField('cash', DataType.BOOLEAN, true)
385
270
  .withField('force', DataType.BOOLEAN, true)
386
271
  .schema
387
272
  );
@@ -397,18 +282,6 @@ module.exports = (() => {
397
282
  .schema
398
283
  );
399
284
 
400
- const feeUnits = new TransactionSchema(SchemaBuilder.withName(TransactionType.FEE_UNITS.code)
401
- .withField('portfolio', DataType.STRING)
402
- .withField('position', DataType.STRING)
403
- .withField('sequence', DataType.NUMBER, true)
404
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
405
- .withField('date', DataType.DAY)
406
- .withField('fee', DataType.DECIMAL)
407
- .withField('price', DataType.DECIMAL)
408
- .withField('force', DataType.BOOLEAN, true)
409
- .schema
410
- );
411
-
412
285
  const deposit = new TransactionSchema(SchemaBuilder.withName(TransactionType.DEPOSIT.code)
413
286
  .withField('portfolio', DataType.STRING)
414
287
  .withField('position', DataType.STRING)
@@ -420,6 +293,7 @@ module.exports = (() => {
420
293
  .withField('amount', DataType.DECIMAL)
421
294
  .withField('fee', DataType.DECIMAL, true)
422
295
  .withField('force', DataType.BOOLEAN, true)
296
+ .withField('cash', DataType.BOOLEAN, true)
423
297
  .schema
424
298
  );
425
299
 
@@ -437,28 +311,6 @@ module.exports = (() => {
437
311
  .schema
438
312
  );
439
313
 
440
- const debit = new TransactionSchema(SchemaBuilder.withName(TransactionType.DEBIT.code)
441
- .withField('portfolio', DataType.STRING)
442
- .withField('position', DataType.STRING)
443
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
444
- .withField('date', DataType.DAY)
445
- .withField('amount', DataType.DECIMAL)
446
- .withField('fee', DataType.DECIMAL, true)
447
- .withField('force', DataType.BOOLEAN, true)
448
- .schema
449
- );
450
-
451
- const credit = new TransactionSchema(SchemaBuilder.withName(TransactionType.CREDIT.code)
452
- .withField('portfolio', DataType.STRING)
453
- .withField('position', DataType.STRING)
454
- .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
455
- .withField('date', DataType.DAY)
456
- .withField('amount', DataType.DECIMAL)
457
- .withField('fee', DataType.DECIMAL, true)
458
- .withField('force', DataType.BOOLEAN, true)
459
- .schema
460
- );
461
-
462
314
  const valuation = new TransactionSchema(SchemaBuilder.withName(TransactionType.VALUATION.code)
463
315
  .withField('portfolio', DataType.STRING)
464
316
  .withField('position', DataType.STRING)
@@ -492,12 +344,7 @@ module.exports = (() => {
492
344
  addSchemaToMap(TransactionType.SELL, sell);
493
345
  addSchemaToMap(TransactionType.BUY_SHORT, buyShort);
494
346
  addSchemaToMap(TransactionType.SELL_SHORT, sellShort);
495
- addSchemaToMap(TransactionType.DIVIDEND, dividend);
496
- addSchemaToMap(TransactionType.DIVIDEND_STOCK, dividendStock);
497
- addSchemaToMap(TransactionType.DIVIDEND_REINVEST, dividendReinvest);
498
- addSchemaToMap(TransactionType.SPLIT, split);
499
347
  addSchemaToMap(TransactionType.FEE, fee);
500
- addSchemaToMap(TransactionType.FEE_UNITS, feeUnits);
501
348
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
502
349
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
503
350
  addSchemaToMap(TransactionType.VALUATION, valuation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.32",
3
+ "version": "1.2.36",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -3187,7 +3187,7 @@ module.exports = (() => {
3187
3187
  }
3188
3188
 
3189
3189
  /**
3190
- * The year-to-date position summary of the encapsulated position.
3190
+ * The year-to-date summary of the encapsulated position.
3191
3191
  *
3192
3192
  * @public
3193
3193
  * @returns {Object}