@barchart/portfolio-api-common 1.2.8 → 1.2.12

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.
@@ -235,6 +235,17 @@ module.exports = (() => {
235
235
  return distributionFund;
236
236
  }
237
237
 
238
+ /**
239
+ * A mutual fund distribution in cash, reinvested.
240
+ *
241
+ * @public
242
+ * @static
243
+ * @returns {TransactionType}
244
+ */
245
+ static get DISTRIBUTION_REINVEST() {
246
+ return distributionReinvest;
247
+ }
248
+
238
249
  /**
239
250
  * A split.
240
251
  *
@@ -351,6 +362,7 @@ module.exports = (() => {
351
362
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
352
363
 
353
364
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
365
+ const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', false, false, false, true, false, false, true);
354
366
  const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
355
367
 
356
368
  const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
@@ -155,6 +155,7 @@ module.exports = (() => {
155
155
  associateTypes(InstrumentType.FUND, TransactionType.FEE, true, [ PositionDirection.LONG ]);
156
156
  associateTypes(InstrumentType.FUND, TransactionType.FEE_UNITS, false);
157
157
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_CASH, false);
158
+ associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_REINVEST, false);
158
159
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_FUND, false);
159
160
 
160
161
  associateTypes(InstrumentType.OTHER, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);
@@ -93,6 +93,7 @@ module.exports = (() => {
93
93
  return {
94
94
  date: t.date,
95
95
  type: t.type.display,
96
+ code: t.type.code,
96
97
  sequence: t.sequence,
97
98
  instrument: i,
98
99
  position: t.position
@@ -124,16 +125,25 @@ module.exports = (() => {
124
125
  });
125
126
 
126
127
  formatters.set(TransactionType.DIVIDEND_STOCK, (t) => {
127
- const shares = t.snapshot.open.subtract(t.quantity);
128
128
  const rate = (is.object(t.dividend) && is.string(t.dividend.rate)) || '';
129
129
 
130
130
  return {
131
131
  boughtSold: t.quantity,
132
- shares: shares,
132
+ shares: t.snapshot.open.subtract(t.quantity),
133
133
  rate: rate
134
134
  };
135
135
  });
136
136
 
137
+ formatters.set(TransactionType.DIVIDEND_REINVEST, (t) => {
138
+ return {
139
+ boughtSold: t.quantity,
140
+ shares: t.snapshot.open.subtract(t.quantity),
141
+ price: t.dividend.price,
142
+ fee: t.fee,
143
+ rate: t.dividend.rate
144
+ };
145
+ });
146
+
137
147
  formatters.set(TransactionType.DISTRIBUTION_CASH, (t) => {
138
148
  return {
139
149
  shares: t.snapshot.open,
@@ -142,20 +152,20 @@ module.exports = (() => {
142
152
  };
143
153
  });
144
154
 
145
- formatters.set(TransactionType.DIVIDEND_REINVEST, (t) => {
155
+ formatters.set(TransactionType.DISTRIBUTION_FUND, (t) => {
146
156
  return {
147
157
  shares: t.snapshot.open.subtract(t.quantity),
148
- price: t.dividend.price,
149
- fee: t.fee,
150
- total: t.quantity,
151
- rate: t.dividend.rate
158
+ fee: t.fee
152
159
  };
153
160
  });
154
161
 
155
- formatters.set(TransactionType.DISTRIBUTION_FUND, (t) => {
162
+ formatters.set(TransactionType.DISTRIBUTION_REINVEST, (t) => {
156
163
  return {
164
+ boughtSold: t.quantity,
157
165
  shares: t.snapshot.open.subtract(t.quantity),
158
- fee: t.fee
166
+ price: t.dividend.price,
167
+ fee: t.fee,
168
+ rate: t.dividend.rate
159
169
  };
160
170
  });
161
171
 
@@ -201,6 +201,7 @@ module.exports = (() => {
201
201
  .withField('split.reference', DataType.STRING, true)
202
202
  .withField('charge.amount', DataType.DECIMAL, true)
203
203
  .withField('income.amount', DataType.DECIMAL, true)
204
+ .withField('valuation.rate', DataType.DECIMAL, true)
204
205
  .withField('valuation.value', DataType.DECIMAL, true)
205
206
  .withField('system.sequence', DataType.NUMBER)
206
207
  .withField('system.version', DataType.STRING)
@@ -239,6 +240,7 @@ module.exports = (() => {
239
240
  .withField('split.reference', DataType.STRING, true)
240
241
  .withField('charge.amount', DataType.DECIMAL, true)
241
242
  .withField('income.amount', DataType.DECIMAL, true)
243
+ .withField('valuation.rate', DataType.DECIMAL, true)
242
244
  .withField('valuation.value', DataType.DECIMAL, true)
243
245
  .schema
244
246
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.8",
3
+ "version": "1.2.12",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -845,6 +845,17 @@ module.exports = (() => {
845
845
  return distributionFund;
846
846
  }
847
847
 
848
+ /**
849
+ * A mutual fund distribution in cash, reinvested.
850
+ *
851
+ * @public
852
+ * @static
853
+ * @returns {TransactionType}
854
+ */
855
+ static get DISTRIBUTION_REINVEST() {
856
+ return distributionReinvest;
857
+ }
858
+
848
859
  /**
849
860
  * A split.
850
861
  *
@@ -961,6 +972,7 @@ module.exports = (() => {
961
972
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
962
973
 
963
974
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
975
+ const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', false, false, false, true, false, false, true);
964
976
  const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
965
977
 
966
978
  const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
@@ -1132,6 +1144,7 @@ module.exports = (() => {
1132
1144
  associateTypes(InstrumentType.FUND, TransactionType.FEE, true, [ PositionDirection.LONG ]);
1133
1145
  associateTypes(InstrumentType.FUND, TransactionType.FEE_UNITS, false);
1134
1146
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_CASH, false);
1147
+ associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_REINVEST, false);
1135
1148
  associateTypes(InstrumentType.FUND, TransactionType.DISTRIBUTION_FUND, false);
1136
1149
 
1137
1150
  associateTypes(InstrumentType.OTHER, TransactionType.BUY, true, [ PositionDirection.LONG, PositionDirection.EVEN ]);