@decafhub/decaf-client-extras 0.0.4 → 0.0.5
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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/commons/-currency.d.ts +1 -1
- package/commons/-date-type.d.ts +1 -1
- package/commons/-id.d.ts +14 -14
- package/es/commons/-currency.d.ts +1 -1
- package/es/commons/-date-type.d.ts +1 -1
- package/es/commons/-id.d.ts +14 -14
- package/es/reports/valuation/-valuation-report-consolidated.d.ts +1 -1
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +5 -2
- package/es/reports/valuation/-valuation-report-shared.d.ts +1 -1
- package/package.json +16 -16
- package/reports/valuation/-remote-valuation-report-consolidated.js +1 -1
- package/reports/valuation/-remote-valuation-report-portfolio.js +1 -1
- package/reports/valuation/-valuation-report-consolidated.d.ts +1 -1
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +7 -2
- package/reports/valuation/-valuation-report-shared.d.ts +1 -1
- package/src/index.test.ts +31 -2
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.5](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.0.4...v0.0.5) (2022-12-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* exclude cash holdings from total exposure calculation ([09d7133](https://github.com/teloscube/decaf-client-javascript-extras/commit/09d7133515d9670dc3c5a641dd84d1e57fa5d5ee))
|
|
9
|
+
|
|
3
10
|
## [0.0.4](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.0.3...v0.0.4) (2022-11-07)
|
|
4
11
|
|
|
5
12
|
|
package/commons/-currency.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { Maybe, NewTypeWithPhantom } from '@telostat/prelude';
|
|
|
9
9
|
*
|
|
10
10
|
* A currency code is (typically) defined as all-uppercase, three letters.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
|
|
13
13
|
/**
|
|
14
14
|
* Attempts to create a {@link CurrencyCode} value with the given currency code.
|
|
15
15
|
*
|
package/commons/-date-type.d.ts
CHANGED
package/commons/-id.d.ts
CHANGED
|
@@ -3,56 +3,56 @@ import { NewTypeWithPhantom } from '@telostat/prelude';
|
|
|
3
3
|
* Type definition for identifiers with value spaces discriminated over the
|
|
4
4
|
* given phantom type.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type Id<P, V> = NewTypeWithPhantom<P, V>;
|
|
7
7
|
/**
|
|
8
8
|
* Type definition for DECAF artifact identifiers.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
|
|
11
11
|
/**
|
|
12
12
|
* Type definition for DECAF artifact type identifiers.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
|
|
15
15
|
/**
|
|
16
16
|
* Type definition for DECAF share class identifiers.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
|
|
19
19
|
/**
|
|
20
20
|
* Type definition for DECAF principal identifiers.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
|
|
23
23
|
/**
|
|
24
24
|
* Type definition for DECAF institution identifiers.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
|
|
27
27
|
/**
|
|
28
28
|
* Type definition for DECAF team identifiers.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
|
|
31
31
|
/**
|
|
32
32
|
* Type definition for DECAF portfolio identifiers.
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
|
|
35
35
|
/**
|
|
36
36
|
* Type definition for DECAF portfolio group identifiers.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
|
|
39
39
|
/**
|
|
40
40
|
* Type definition for DECAF account identifiers.
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
|
|
43
43
|
/**
|
|
44
44
|
* Type definition for DECAF OHLC series identifiers.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
|
|
47
47
|
/**
|
|
48
48
|
* Type definition for DECAF share class fee schedule identifiers.
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
|
|
51
51
|
/**
|
|
52
52
|
* Type definition for DECAF action identifiers.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
|
|
55
55
|
/**
|
|
56
56
|
* Type definition for DECAF external valuation identifiers.
|
|
57
57
|
*/
|
|
58
|
-
export
|
|
58
|
+
export type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
|
|
@@ -9,7 +9,7 @@ import { Maybe, NewTypeWithPhantom } from '@telostat/prelude';
|
|
|
9
9
|
*
|
|
10
10
|
* A currency code is (typically) defined as all-uppercase, three letters.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
|
|
13
13
|
/**
|
|
14
14
|
* Attempts to create a {@link CurrencyCode} value with the given currency code.
|
|
15
15
|
*
|
package/es/commons/-id.d.ts
CHANGED
|
@@ -3,56 +3,56 @@ import { NewTypeWithPhantom } from '@telostat/prelude';
|
|
|
3
3
|
* Type definition for identifiers with value spaces discriminated over the
|
|
4
4
|
* given phantom type.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type Id<P, V> = NewTypeWithPhantom<P, V>;
|
|
7
7
|
/**
|
|
8
8
|
* Type definition for DECAF artifact identifiers.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
|
|
11
11
|
/**
|
|
12
12
|
* Type definition for DECAF artifact type identifiers.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
|
|
15
15
|
/**
|
|
16
16
|
* Type definition for DECAF share class identifiers.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
|
|
19
19
|
/**
|
|
20
20
|
* Type definition for DECAF principal identifiers.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
|
|
23
23
|
/**
|
|
24
24
|
* Type definition for DECAF institution identifiers.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
|
|
27
27
|
/**
|
|
28
28
|
* Type definition for DECAF team identifiers.
|
|
29
29
|
*/
|
|
30
|
-
export
|
|
30
|
+
export type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
|
|
31
31
|
/**
|
|
32
32
|
* Type definition for DECAF portfolio identifiers.
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
|
|
35
35
|
/**
|
|
36
36
|
* Type definition for DECAF portfolio group identifiers.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
|
|
39
39
|
/**
|
|
40
40
|
* Type definition for DECAF account identifiers.
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
|
|
43
43
|
/**
|
|
44
44
|
* Type definition for DECAF OHLC series identifiers.
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
|
|
47
47
|
/**
|
|
48
48
|
* Type definition for DECAF share class fee schedule identifiers.
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
|
|
51
51
|
/**
|
|
52
52
|
* Type definition for DECAF action identifiers.
|
|
53
53
|
*/
|
|
54
|
-
export
|
|
54
|
+
export type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
|
|
55
55
|
/**
|
|
56
56
|
* Type definition for DECAF external valuation identifiers.
|
|
57
57
|
*/
|
|
58
|
-
export
|
|
58
|
+
export type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
|
|
@@ -15,7 +15,7 @@ export interface ConsolidatedValuationReport extends BaseValuationReport {
|
|
|
15
15
|
/**
|
|
16
16
|
* Type definition for container types to be consolidated.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
|
|
19
19
|
/**
|
|
20
20
|
* Type definition for valuation report containers.
|
|
21
21
|
*/
|
|
@@ -23,8 +23,11 @@ export function updateTotals(nav, investment, tree) {
|
|
|
23
23
|
const children = tree.children;
|
|
24
24
|
const netValue = sumDecimals(holdings.map((x) => x.valuation.value.net.ref)).add(sumDecimals(children.map((x) => x.totals.netValue)));
|
|
25
25
|
const absValue = sumDecimals(holdings.map((x) => x.valuation.value.abs.ref)).add(sumDecimals(children.map((x) => x.totals.absValue)));
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const holdingsForExposure = holdings.filter((h) => !(h.artifact.type.id === 'CCY' ||
|
|
27
|
+
h.artifact.type.id === 'DEPO' ||
|
|
28
|
+
h.artifact.type.id === 'LOAN'));
|
|
29
|
+
const netExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.net.ref)).add(sumDecimals(children.map((x) => x.totals.netExposure)));
|
|
30
|
+
const absExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.abs.ref)).add(sumDecimals(children.map((x) => x.totals.absExposure)));
|
|
28
31
|
const pnl = sumDecimals(holdings.map((x) => x.pnl)).add(sumDecimals(children.map((x) => x.totals.pnl)));
|
|
29
32
|
const accruedsHoldings = holdings.map((x) => x.investment.accrued.map((x) => x.ref));
|
|
30
33
|
const accruedsChildren = children.map((x) => x.totals.accrued);
|
|
@@ -53,7 +53,7 @@ export interface ValuationReportAccounts {
|
|
|
53
53
|
/**
|
|
54
54
|
* The definition for valuation report holding classification.
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
|
|
57
57
|
/**
|
|
58
58
|
* Type definition for valuation report holding classification node.
|
|
59
59
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decafhub/decaf-client-extras",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "DECAF Client Extras",
|
|
5
5
|
"author": "Teloscube Pte Ltd",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,33 +29,33 @@
|
|
|
29
29
|
"@decafhub/decaf-client": "^0.3.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@telostat/prelude": "^0.1.
|
|
32
|
+
"@telostat/prelude": "^0.1.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@commitlint/cli": "^17.
|
|
36
|
-
"@commitlint/config-conventional": "^17.
|
|
35
|
+
"@commitlint/cli": "^17.3.0",
|
|
36
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
37
37
|
"@decafhub/decaf-client": "^0.3.1",
|
|
38
|
-
"@types/jest": "^29.2.
|
|
39
|
-
"@types/node": "^18.11.
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
38
|
+
"@types/jest": "^29.2.4",
|
|
39
|
+
"@types/node": "^18.11.18",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
41
|
+
"@typescript-eslint/parser": "^5.47.1",
|
|
42
42
|
"dotenv": "^16.0.3",
|
|
43
|
-
"eslint": "^8.
|
|
43
|
+
"eslint": "^8.30.0",
|
|
44
44
|
"eslint-config-prettier": "^8.5.0",
|
|
45
45
|
"eslint-config-standard": "^17.0.0",
|
|
46
46
|
"eslint-plugin-import": "^2.26.0",
|
|
47
|
-
"eslint-plugin-n": "^15.
|
|
47
|
+
"eslint-plugin-n": "^15.6.0",
|
|
48
48
|
"eslint-plugin-prettier": "^4.2.1",
|
|
49
49
|
"eslint-plugin-promise": "^6.1.1",
|
|
50
50
|
"eslint-plugin-standard": "^5.0.0",
|
|
51
51
|
"gh-pages": "^4.0.0",
|
|
52
|
-
"husky": "^8.0.
|
|
53
|
-
"jest": "^29.
|
|
54
|
-
"lint-staged": "^13.0
|
|
55
|
-
"prettier": "^2.
|
|
52
|
+
"husky": "^8.0.2",
|
|
53
|
+
"jest": "^29.3.1",
|
|
54
|
+
"lint-staged": "^13.1.0",
|
|
55
|
+
"prettier": "^2.8.1",
|
|
56
56
|
"ts-jest": "^29.0.3",
|
|
57
|
-
"typedoc": "^0.23.
|
|
58
|
-
"typescript": "^4.
|
|
57
|
+
"typedoc": "^0.23.23",
|
|
58
|
+
"typescript": "^4.9.4"
|
|
59
59
|
},
|
|
60
60
|
"lint-staged": {
|
|
61
61
|
"src/**/*.{ts,tsx}": [
|
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -15,7 +15,7 @@ export interface ConsolidatedValuationReport extends BaseValuationReport {
|
|
|
15
15
|
/**
|
|
16
16
|
* Type definition for container types to be consolidated.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
|
|
19
19
|
/**
|
|
20
20
|
* Type definition for valuation report containers.
|
|
21
21
|
*/
|
|
@@ -63,8 +63,13 @@ function updateTotals(nav, investment, tree) {
|
|
|
63
63
|
var children = tree.children;
|
|
64
64
|
var netValue = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.value.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netValue; })));
|
|
65
65
|
var absValue = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.value.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absValue; })));
|
|
66
|
-
var
|
|
67
|
-
|
|
66
|
+
var holdingsForExposure = holdings.filter(function (h) {
|
|
67
|
+
return !(h.artifact.type.id === 'CCY' ||
|
|
68
|
+
h.artifact.type.id === 'DEPO' ||
|
|
69
|
+
h.artifact.type.id === 'LOAN');
|
|
70
|
+
});
|
|
71
|
+
var netExposure = (0, prelude_1.sumDecimals)(holdingsForExposure.map(function (x) { return x.valuation.exposure.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netExposure; })));
|
|
72
|
+
var absExposure = (0, prelude_1.sumDecimals)(holdingsForExposure.map(function (x) { return x.valuation.exposure.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absExposure; })));
|
|
68
73
|
var pnl = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.pnl; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.pnl; })));
|
|
69
74
|
var accruedsHoldings = holdings.map(function (x) { return x.investment.accrued.map(function (x) { return x.ref; }); });
|
|
70
75
|
var accruedsChildren = children.map(function (x) { return x.totals.accrued; });
|
|
@@ -53,7 +53,7 @@ export interface ValuationReportAccounts {
|
|
|
53
53
|
/**
|
|
54
54
|
* The definition for valuation report holding classification.
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
|
|
57
57
|
/**
|
|
58
58
|
* Type definition for valuation report holding classification node.
|
|
59
59
|
*/
|
package/src/index.test.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { buildDecafClient, DecafClient, gql } from '@decafhub/decaf-client';
|
|
2
|
-
import { mk, PDateTime } from '@telostat/prelude';
|
|
2
|
+
import { mk, PDateTime, safeDiv, zero } from '@telostat/prelude';
|
|
3
3
|
import { fail } from 'assert';
|
|
4
4
|
import { PortfolioId } from './commons';
|
|
5
|
-
import {
|
|
5
|
+
import { makeValuationReportHoldingsTree } from './reports/valuation/';
|
|
6
|
+
import {
|
|
7
|
+
fetchPortfolioValuationReport,
|
|
8
|
+
fetchRemotePortfolioValuationReport,
|
|
9
|
+
} from './reports/valuation/-remote-valuation-report-portfolio';
|
|
6
10
|
|
|
7
11
|
const API_URL = process.env.TESTING_API_URL;
|
|
8
12
|
const API_KEY = process.env.TESTING_API_KEY;
|
|
@@ -64,4 +68,29 @@ describe('Main', () => {
|
|
|
64
68
|
},
|
|
65
69
|
});
|
|
66
70
|
});
|
|
71
|
+
|
|
72
|
+
test('get a portfolio report, check the tree', async () => {
|
|
73
|
+
const eValue = await fetchPortfolioValuationReport(client, {
|
|
74
|
+
portfolio: portfolioId,
|
|
75
|
+
date: PDateTime(new Date()).format('YYYY-MM-DD'),
|
|
76
|
+
dateType: 'settlement',
|
|
77
|
+
currency: mk('EUR'),
|
|
78
|
+
});
|
|
79
|
+
eValue.caseOf({
|
|
80
|
+
Left: (e) => fail('Error while fetching the remote portfolio report: ' + e.msg),
|
|
81
|
+
Right: (value) => {
|
|
82
|
+
console.log(`Success! remote valuation for portfolio ID ${value.portfolio.id} is reported at ${value.asof}`);
|
|
83
|
+
|
|
84
|
+
expect(value).toBeDefined();
|
|
85
|
+
|
|
86
|
+
const nav = value.figures.nav;
|
|
87
|
+
const inv = value.figures.investment;
|
|
88
|
+
const holdings = value.holdings;
|
|
89
|
+
const tree = makeValuationReportHoldingsTree(nav, inv, holdings);
|
|
90
|
+
|
|
91
|
+
expect(tree).toBeDefined();
|
|
92
|
+
expect(safeDiv(tree.totals.netExposure, nav).orDefault(zero)).toEqual(tree.totals.netExposureRatio);
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
});
|
|
67
96
|
});
|
|
@@ -2,6 +2,7 @@ import { Decimal, safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
|
|
|
2
2
|
import { Just, Maybe, Nothing } from 'purify-ts';
|
|
3
3
|
import { List } from 'purify-ts/List';
|
|
4
4
|
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
5
|
+
import { ArtifactTypeId } from '../../../commons';
|
|
5
6
|
import { ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
|
|
6
7
|
import { compareStringArrays } from './-utils';
|
|
7
8
|
|
|
@@ -36,10 +37,20 @@ export function updateTotals(
|
|
|
36
37
|
const absValue = sumDecimals(holdings.map((x) => x.valuation.value.abs.ref)).add(
|
|
37
38
|
sumDecimals(children.map((x) => x.totals.absValue))
|
|
38
39
|
);
|
|
39
|
-
|
|
40
|
+
|
|
41
|
+
const holdingsForExposure = holdings.filter(
|
|
42
|
+
(h) =>
|
|
43
|
+
!(
|
|
44
|
+
h.artifact.type.id === ('CCY' as unknown as ArtifactTypeId) ||
|
|
45
|
+
h.artifact.type.id === ('DEPO' as unknown as ArtifactTypeId) ||
|
|
46
|
+
h.artifact.type.id === ('LOAN' as unknown as ArtifactTypeId)
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const netExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.net.ref)).add(
|
|
40
51
|
sumDecimals(children.map((x) => x.totals.netExposure))
|
|
41
52
|
);
|
|
42
|
-
const absExposure = sumDecimals(
|
|
53
|
+
const absExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.abs.ref)).add(
|
|
43
54
|
sumDecimals(children.map((x) => x.totals.absExposure))
|
|
44
55
|
);
|
|
45
56
|
const pnl = sumDecimals(holdings.map((x) => x.pnl)).add(sumDecimals(children.map((x) => x.totals.pnl)));
|