@barchart/portfolio-api-common 1.11.3 → 1.11.7

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.
@@ -50,7 +50,7 @@ module.exports = (() => {
50
50
 
51
51
  if (instruments.hasOwnProperty(position)) {
52
52
  let instrument = instruments[position];
53
- let formatted = { instrument: instrument };
53
+ let formatted = { instrument: instrument, raw: {} };
54
54
 
55
55
  const formatterFunctions = formatters.get(transaction.type);
56
56
 
@@ -128,6 +128,8 @@ module.exports = (() => {
128
128
  f.position = t.position;
129
129
  f.open = t.snapshot.open;
130
130
  f.transaction = t.transaction;
131
+
132
+ f.raw.open = f.open.toFloat();
131
133
  };
132
134
 
133
135
  const averageCostFormatter = (t, f) => {
@@ -150,6 +152,9 @@ module.exports = (() => {
150
152
  f.price = t.trade.price;
151
153
  f.fee = t.fee;
152
154
  f.total = t.amount;
155
+ f.raw.total = f.total.toFloat();
156
+ f.raw.price = f.price.toFloat();
157
+ f.raw.boughtSold = f.boughtSold.toFloat();
153
158
  };
154
159
 
155
160
  const dividendFormatter = (t, f) => {
@@ -186,7 +191,12 @@ module.exports = (() => {
186
191
 
187
192
  if (t.dividend.native) {
188
193
  f.native = t.dividend.native;
194
+ f.raw.native = f.native.toFloat();
189
195
  }
196
+
197
+ f.raw.rate = f.rate.toFloat();
198
+ f.raw.shares = f.shares.toFloat();
199
+ f.raw.total = f.total.toFloat();
190
200
  };
191
201
 
192
202
  const distributionCashFormatter = (t, f) => {
@@ -223,7 +233,12 @@ module.exports = (() => {
223
233
 
224
234
  if (t.dividend.native) {
225
235
  f.native = t.dividend.native;
236
+ f.raw.native = f.native.toFloat();
226
237
  }
238
+
239
+ f.raw.rate = f.rate.toFloat();
240
+ f.raw.shares = f.shares.toFloat();
241
+ f.raw.total = f.total.toFloat();
227
242
  };
228
243
 
229
244
  const dividendReinvestFormatter = (t, f) => {
@@ -241,6 +256,11 @@ module.exports = (() => {
241
256
  f.rate = t.dividend.rate;
242
257
 
243
258
  f.shares = t.snapshot.open.subtract(t.quantity);
259
+
260
+ f.raw.rate = f.rate.toFloat();
261
+ f.raw.shares = f.shares.toFloat();
262
+ f.raw.price = f.price.toFloat();
263
+ f.raw.boughtSold = f.boughtSold.toFloat();
244
264
  };
245
265
 
246
266
  const distributionReinvestFormatter = (t, f) => {
@@ -258,6 +278,11 @@ module.exports = (() => {
258
278
  f.rate = t.dividend.rate;
259
279
 
260
280
  f.shares = t.snapshot.open.subtract(t.quantity);
281
+
282
+ f.raw.rate = f.rate.toFloat();
283
+ f.raw.shares = f.shares.toFloat();
284
+ f.raw.price = f.price.toFloat();
285
+ f.raw.boughtSold = f.boughtSold.toFloat();
261
286
  };
262
287
 
263
288
  const dividendStockFormatter = (t, f) => {
@@ -282,12 +307,18 @@ module.exports = (() => {
282
307
 
283
308
  f.rate = rate;
284
309
 
310
+ f.raw.rate = f.rate.toFloat();
311
+
285
312
  if (t.dividend.price) {
286
313
  f.price = t.dividend.price;
314
+ f.raw.price = f.price.toFloat();
287
315
  }
288
316
  }
289
317
 
290
318
  f.shares = t.snapshot.open.subtract(t.quantity);
319
+
320
+ f.raw.shares = f.shares.toFloat();
321
+ f.raw.boughtSold = f.boughtSold.toFloat();
291
322
  };
292
323
 
293
324
  const distributionFundFormatter = (t, f) => {
@@ -312,25 +343,34 @@ module.exports = (() => {
312
343
 
313
344
  f.rate = rate;
314
345
 
346
+ f.raw.rate = f.rate.toFloat();
347
+
315
348
  if (t.dividend.price) {
316
349
  f.price = t.dividend.price;
350
+ f.raw.price = f.price.toFloat();
317
351
  }
318
352
  }
319
353
 
320
354
  f.shares = t.snapshot.open.subtract(t.quantity);
355
+
356
+ f.raw.shares = f.shares.toFloat();
357
+ f.raw.boughtSold = f.boughtSold.toFloat();
321
358
  };
322
359
 
323
360
  const incomeFormatter = (t, f) => {
324
361
  f.total = t.income.amount;
362
+ f.raw.total = f.total.toFloat();
325
363
  };
326
364
 
327
365
  const feeFormatter = (t, f) => {
328
366
  f.fee = t.charge.amount;
329
367
  f.total = t.charge.amount;
368
+ f.raw.total = f.total.toFloat();
330
369
  };
331
370
 
332
371
  const feeUnitsFormatter = (t, f) => {
333
372
  f.boughtSold = t.quantity;
373
+ f.raw.boughtSold = f.boughtSold.toFloat();
334
374
  };
335
375
 
336
376
  const splitFormatter = (t, f) => {
@@ -347,6 +387,10 @@ module.exports = (() => {
347
387
  f.rate = rate;
348
388
 
349
389
  f.shares = t.snapshot.open.subtract(t.quantity);
390
+
391
+ f.raw.rate = f.rate.toFloat();
392
+ f.raw.shares = f.shares.toFloat();
393
+ f.raw.boughtSold = f.boughtSold.toFloat();
350
394
  };
351
395
 
352
396
  const valuationFormatter = (t, f) => {
@@ -365,10 +409,12 @@ module.exports = (() => {
365
409
  }
366
410
 
367
411
  f.price = rate;
412
+ f.raw.price = f.price.toFloat();
368
413
  };
369
414
 
370
415
  const cashFormatter = (t, f) => {
371
416
  f.total = t.quantity;
417
+ f.raw.total = f.total.toFloat();
372
418
  };
373
419
 
374
420
  const debitFormatter = (t, f) => {
@@ -393,6 +439,10 @@ module.exports = (() => {
393
439
  f.rate = rate;
394
440
 
395
441
  f.shares = t.snapshot.open.subtract(t.quantity);
442
+
443
+ f.raw.rate = f.rate.toFloat();
444
+ f.raw.shares = f.shares.toFloat();
445
+ f.raw.boughtSold = f.boughtSold.toFloat();
396
446
  };
397
447
 
398
448
  const spinoffFormatter = (t, f) => {
@@ -409,6 +459,10 @@ module.exports = (() => {
409
459
  f.rate = rate;
410
460
 
411
461
  f.shares = t.snapshot.open.subtract(t.quantity);
462
+
463
+ f.raw.rate = f.rate.toFloat();
464
+ f.raw.shares = f.shares.toFloat();
465
+ f.raw.boughtSold = f.boughtSold.toFloat();
412
466
  };
413
467
 
414
468
  const formatters = new Map();
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.11.3",
3
+ "version": "1.11.7",
4
4
  "description": "Common code used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
7
7
  "email": "bryan.ingle@barchart.com",
8
8
  "url": "http://www.barchart.com"
9
9
  },
10
+ "homepage": "https://github.com/barchart/portfolio-api-common#readme",
10
11
  "scripts": {},
11
12
  "dependencies": {
12
- "@barchart/common-js": "^3.5.1",
13
- "uuid": "^3.4.0"
13
+ "@barchart/common-js": "^4.9.1",
14
+ "uuid": "^8.3.2"
14
15
  },
15
16
  "devDependencies": {
16
17
  "@babel/core": "^7.6.2",