@barchart/portfolio-api-common 1.0.92 → 1.0.96
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.
|
@@ -58,10 +58,9 @@ module.exports = (() => {
|
|
|
58
58
|
this._dataFormat.total = null;
|
|
59
59
|
this._dataFormat.totalNegative = false;
|
|
60
60
|
this._dataFormat.summaryTotalCurrent = null;
|
|
61
|
-
this._dataActual.
|
|
61
|
+
this._dataActual.summaryTotalCurrentNegative = false;
|
|
62
62
|
this._dataFormat.summaryTotalPrevious = null;
|
|
63
|
-
|
|
64
|
-
this._dataFormat.unrealizedTodayNegative = false;
|
|
63
|
+
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
65
64
|
|
|
66
65
|
this._items.forEach((item) => {
|
|
67
66
|
item.registerPriceChangeHandler((data, sender) => {
|
|
@@ -211,6 +210,7 @@ module.exports = (() => {
|
|
|
211
210
|
format.income = formatCurrency(actual.income, currency);
|
|
212
211
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|
|
213
212
|
format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
|
|
213
|
+
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
function calculatePriceData(group, item, forceRefresh) {
|
|
@@ -186,7 +186,7 @@ module.exports = (() => {
|
|
|
186
186
|
if (summary && price) {
|
|
187
187
|
const period = summary.period;
|
|
188
188
|
|
|
189
|
-
let unrealizedCurrent = summary.open.multiply(price).add(summary.end.basis);
|
|
189
|
+
let unrealizedCurrent = summary.end.open.multiply(price).add(summary.end.basis);
|
|
190
190
|
|
|
191
191
|
let summaryTotalCurrent = period.realized.add(period.income).add(unrealizedCurrent);
|
|
192
192
|
let summaryTotalCurrentChange;
|
|
@@ -245,9 +245,9 @@ module.exports = (() => {
|
|
|
245
245
|
.withField('portfolio', DataType.STRING)
|
|
246
246
|
.withField('position', DataType.STRING)
|
|
247
247
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
248
|
-
.withField('instrument.name', DataType.STRING)
|
|
249
|
-
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'))
|
|
250
|
-
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'))
|
|
248
|
+
.withField('instrument.name', DataType.STRING, true)
|
|
249
|
+
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
|
|
250
|
+
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
251
251
|
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
252
252
|
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
253
253
|
.withField('date', DataType.DAY)
|
|
@@ -272,11 +272,6 @@ module.exports = (() => {
|
|
|
272
272
|
.withField('portfolio', DataType.STRING)
|
|
273
273
|
.withField('position', DataType.STRING)
|
|
274
274
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
275
|
-
.withField('instrument.name', DataType.STRING)
|
|
276
|
-
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'))
|
|
277
|
-
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'))
|
|
278
|
-
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
279
|
-
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
280
275
|
.withField('date', DataType.DAY)
|
|
281
276
|
.withField('price', DataType.DECIMAL)
|
|
282
277
|
.withField('quantity', DataType.DECIMAL)
|
|
@@ -288,6 +283,11 @@ module.exports = (() => {
|
|
|
288
283
|
.withField('portfolio', DataType.STRING)
|
|
289
284
|
.withField('position', DataType.STRING)
|
|
290
285
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
286
|
+
.withField('instrument.name', DataType.STRING, true)
|
|
287
|
+
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
|
|
288
|
+
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
289
|
+
.withField('instrument.symbol.barchart', DataType.STRING, true)
|
|
290
|
+
.withField('instrument.symbol.display', DataType.STRING, true)
|
|
291
291
|
.withField('date', DataType.DAY)
|
|
292
292
|
.withField('price', DataType.DECIMAL)
|
|
293
293
|
.withField('quantity', DataType.DECIMAL)
|
|
@@ -388,8 +388,8 @@ module.exports = (() => {
|
|
|
388
388
|
.withField('portfolio', DataType.STRING)
|
|
389
389
|
.withField('position', DataType.STRING)
|
|
390
390
|
.withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
|
|
391
|
-
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'))
|
|
392
|
-
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'))
|
|
391
|
+
.withField('instrument.type', DataType.forEnum(InstrumentType, 'InstrumentType'), true)
|
|
392
|
+
.withField('instrument.currency', DataType.forEnum(Currency, 'Currency'), true)
|
|
393
393
|
.withField('date', DataType.DAY)
|
|
394
394
|
.withField('amount', DataType.DECIMAL)
|
|
395
395
|
.withField('fee', DataType.DECIMAL, true)
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1038,10 +1038,9 @@ module.exports = (() => {
|
|
|
1038
1038
|
this._dataFormat.total = null;
|
|
1039
1039
|
this._dataFormat.totalNegative = false;
|
|
1040
1040
|
this._dataFormat.summaryTotalCurrent = null;
|
|
1041
|
-
this._dataActual.
|
|
1041
|
+
this._dataActual.summaryTotalCurrentNegative = false;
|
|
1042
1042
|
this._dataFormat.summaryTotalPrevious = null;
|
|
1043
|
-
|
|
1044
|
-
this._dataFormat.unrealizedTodayNegative = false;
|
|
1043
|
+
this._dataFormat.summaryTotalPreviousNegative = false;
|
|
1045
1044
|
|
|
1046
1045
|
this._items.forEach((item) => {
|
|
1047
1046
|
item.registerPriceChangeHandler((data, sender) => {
|
|
@@ -1191,6 +1190,7 @@ module.exports = (() => {
|
|
|
1191
1190
|
format.income = formatCurrency(actual.income, currency);
|
|
1192
1191
|
format.summaryTotalCurrent = formatCurrency(updates.summaryTotalCurrent, currency);
|
|
1193
1192
|
format.summaryTotalPrevious = formatCurrency(updates.summaryTotalPrevious, currency);
|
|
1193
|
+
format.summaryTotalPreviousNegative = updates.summaryTotalPrevious.getIsNegative();
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
1196
|
function calculatePriceData(group, item, forceRefresh) {
|
|
@@ -1547,7 +1547,7 @@ module.exports = (() => {
|
|
|
1547
1547
|
if (summary && price) {
|
|
1548
1548
|
const period = summary.period;
|
|
1549
1549
|
|
|
1550
|
-
let unrealizedCurrent = summary.open.multiply(price).add(summary.end.basis);
|
|
1550
|
+
let unrealizedCurrent = summary.end.open.multiply(price).add(summary.end.basis);
|
|
1551
1551
|
|
|
1552
1552
|
let summaryTotalCurrent = period.realized.add(period.income).add(unrealizedCurrent);
|
|
1553
1553
|
let summaryTotalCurrentChange;
|
|
@@ -3222,9 +3222,9 @@ module.exports = function () {
|
|
|
3222
3222
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
3223
3223
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
3224
3224
|
|
|
3225
|
-
if (a._big.gt(b)) {
|
|
3225
|
+
if (a._big.gt(b._big)) {
|
|
3226
3226
|
return 1;
|
|
3227
|
-
} else if (a._big.lt(b)) {
|
|
3227
|
+
} else if (a._big.lt(b._big)) {
|
|
3228
3228
|
return -1;
|
|
3229
3229
|
} else {
|
|
3230
3230
|
return 0;
|