@barchart/portfolio-api-common 1.2.6 → 1.2.10

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.
@@ -174,7 +174,7 @@ module.exports = (() => {
174
174
  static fromSymbolType(code) {
175
175
  assert.argumentIsRequired(code, 'code', Number);
176
176
 
177
- if (code === 1 || code === 6) {
177
+ if (code === 1 || code === 6 || code === 7 || code === 11) {
178
178
  return InstrumentType.EQUITY;
179
179
  } else if (code === 5 || code == 15) {
180
180
  return InstrumentType.FUND;
@@ -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);
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.6",
3
+ "version": "1.2.10",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -175,7 +175,7 @@ module.exports = (() => {
175
175
  static fromSymbolType(code) {
176
176
  assert.argumentIsRequired(code, 'code', Number);
177
177
 
178
- if (code === 1 || code === 6) {
178
+ if (code === 1 || code === 6 || code === 7 || code === 11) {
179
179
  return InstrumentType.EQUITY;
180
180
  } else if (code === 5 || code == 15) {
181
181
  return InstrumentType.FUND;
@@ -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);