@decafhub/decaf-client-extras 0.0.1
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/.editorconfig +9 -0
- package/.env.example +4 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +23 -0
- package/.github/workflows/release-please.yml +47 -0
- package/.github/workflows/test.yml +29 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/commons/-currency.d.ts +42 -0
- package/commons/-currency.js +50 -0
- package/commons/-date-type.d.ts +11 -0
- package/commons/-date-type.js +10 -0
- package/commons/-id.d.ts +58 -0
- package/commons/-id.js +2 -0
- package/commons/index.d.ts +3 -0
- package/commons/index.js +19 -0
- package/es/commons/-currency.d.ts +42 -0
- package/es/commons/-currency.js +44 -0
- package/es/commons/-date-type.d.ts +11 -0
- package/es/commons/-date-type.js +7 -0
- package/es/commons/-id.d.ts +58 -0
- package/es/commons/-id.js +1 -0
- package/es/commons/index.d.ts +3 -0
- package/es/commons/index.js +3 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/reports/index.d.ts +1 -0
- package/es/reports/index.js +1 -0
- package/es/reports/valuation/-remote-valuation-report-consolidated.d.ts +69 -0
- package/es/reports/valuation/-remote-valuation-report-consolidated.js +56 -0
- package/es/reports/valuation/-remote-valuation-report-portfolio.d.ts +150 -0
- package/es/reports/valuation/-remote-valuation-report-portfolio.js +134 -0
- package/es/reports/valuation/-remote-valuation-report-shared.d.ts +233 -0
- package/es/reports/valuation/-remote-valuation-report-shared.js +127 -0
- package/es/reports/valuation/-valuation-report-consolidated.d.ts +35 -0
- package/es/reports/valuation/-valuation-report-consolidated.js +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +10 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +116 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +23 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-types.js +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.js +12 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/index.d.ts +2 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/index.js +2 -0
- package/es/reports/valuation/-valuation-report-portfolio.d.ts +79 -0
- package/es/reports/valuation/-valuation-report-portfolio.js +1 -0
- package/es/reports/valuation/-valuation-report-shared.d.ts +189 -0
- package/es/reports/valuation/-valuation-report-shared.js +6 -0
- package/es/reports/valuation/index.d.ts +8 -0
- package/es/reports/valuation/index.js +6 -0
- package/index.d.ts +3 -0
- package/index.js +32 -0
- package/jest.config.js +6 -0
- package/package.json +79 -0
- package/postinstall.sh +16 -0
- package/release-please-config.json +9 -0
- package/reports/index.d.ts +1 -0
- package/reports/index.js +27 -0
- package/reports/valuation/-remote-valuation-report-consolidated.d.ts +69 -0
- package/reports/valuation/-remote-valuation-report-consolidated.js +113 -0
- package/reports/valuation/-remote-valuation-report-portfolio.d.ts +150 -0
- package/reports/valuation/-remote-valuation-report-portfolio.js +191 -0
- package/reports/valuation/-remote-valuation-report-shared.d.ts +233 -0
- package/reports/valuation/-remote-valuation-report-shared.js +145 -0
- package/reports/valuation/-valuation-report-consolidated.d.ts +35 -0
- package/reports/valuation/-valuation-report-consolidated.js +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +10 -0
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +189 -0
- package/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +23 -0
- package/reports/valuation/-valuation-report-holdings-tree/-types.js +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +1 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.js +16 -0
- package/reports/valuation/-valuation-report-holdings-tree/index.d.ts +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/index.js +20 -0
- package/reports/valuation/-valuation-report-portfolio.d.ts +79 -0
- package/reports/valuation/-valuation-report-portfolio.js +2 -0
- package/reports/valuation/-valuation-report-shared.d.ts +189 -0
- package/reports/valuation/-valuation-report-shared.js +11 -0
- package/reports/valuation/index.d.ts +8 -0
- package/reports/valuation/index.js +25 -0
- package/shell.nix +21 -0
- package/src/commons/-currency.ts +55 -0
- package/src/commons/-date-type.ts +12 -0
- package/src/commons/-id.ts +72 -0
- package/src/commons/index.ts +3 -0
- package/src/index.test.ts +67 -0
- package/src/index.ts +3 -0
- package/src/reports/index.ts +1 -0
- package/src/reports/valuation/-remote-valuation-report-consolidated.ts +121 -0
- package/src/reports/valuation/-remote-valuation-report-portfolio.ts +294 -0
- package/src/reports/valuation/-remote-valuation-report-shared.ts +313 -0
- package/src/reports/valuation/-valuation-report-consolidated.ts +46 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +171 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-types.ts +25 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-utils.ts +15 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/index.ts +2 -0
- package/src/reports/valuation/-valuation-report-portfolio.ts +92 -0
- package/src/reports/valuation/-valuation-report-shared.ts +217 -0
- package/src/reports/valuation/index.ts +8 -0
- package/tsconfig.es.json +13 -0
- package/tsconfig.json +36 -0
- package/typedoc.json +8 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { CustomError, Decimal, Either, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
+
import { ArtifactId, ArtifactTypeId, CurrencyCode, DateType } from '../../commons';
|
|
3
|
+
import { BaseValuationReport, BaseValuationReportHolding, ValuationReportAccount, ValuationReportAccounts, ValuationReportAccrual, ValuationReportArtifact, ValuationReportFigureOrgRef, ValuationReportHolding } from './-valuation-report-shared';
|
|
4
|
+
export interface RemoteBaseValuationReport {
|
|
5
|
+
reported: SDateTime;
|
|
6
|
+
asof: SDate;
|
|
7
|
+
type: DateType;
|
|
8
|
+
ccy: CurrencyCode;
|
|
9
|
+
accounts: ValuationReportAccounts;
|
|
10
|
+
holdings: RemoteValuationReportHolding[];
|
|
11
|
+
accruals: RemoteValuationReportAccrual[];
|
|
12
|
+
investment?: number;
|
|
13
|
+
valuation_net?: number;
|
|
14
|
+
valuation_abs?: number;
|
|
15
|
+
accrued?: number;
|
|
16
|
+
liabilities?: number;
|
|
17
|
+
gav?: number;
|
|
18
|
+
nav?: number;
|
|
19
|
+
aum?: number;
|
|
20
|
+
pnl?: number;
|
|
21
|
+
pnl_to_investment?: number;
|
|
22
|
+
fxrates: RemoteValuationReportFxRate[];
|
|
23
|
+
}
|
|
24
|
+
export interface RemoteValuationReportFxRate {
|
|
25
|
+
ccy1: CurrencyCode;
|
|
26
|
+
ccy2: CurrencyCode;
|
|
27
|
+
value: number;
|
|
28
|
+
asof: SDate;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Valuation holding.
|
|
32
|
+
*/
|
|
33
|
+
export interface RemoteValuationReportHolding {
|
|
34
|
+
artifact: RemoteValuationReportArtifact;
|
|
35
|
+
tags: {
|
|
36
|
+
classification: {
|
|
37
|
+
name: string;
|
|
38
|
+
order?: string | number;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
quantity: number;
|
|
42
|
+
accounts: ValuationReportAccount[];
|
|
43
|
+
investment: {
|
|
44
|
+
px: {
|
|
45
|
+
org?: number;
|
|
46
|
+
ref?: number;
|
|
47
|
+
};
|
|
48
|
+
txncosts: {
|
|
49
|
+
org?: number;
|
|
50
|
+
ref?: number;
|
|
51
|
+
};
|
|
52
|
+
accrued: {
|
|
53
|
+
org?: number;
|
|
54
|
+
ref?: number;
|
|
55
|
+
};
|
|
56
|
+
value: {
|
|
57
|
+
org?: number;
|
|
58
|
+
ref?: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
valuation: {
|
|
62
|
+
px: {
|
|
63
|
+
org?: number;
|
|
64
|
+
ref?: number;
|
|
65
|
+
};
|
|
66
|
+
accrued: {
|
|
67
|
+
org?: number;
|
|
68
|
+
ref?: number;
|
|
69
|
+
};
|
|
70
|
+
value: {
|
|
71
|
+
net: {
|
|
72
|
+
org?: number;
|
|
73
|
+
ref?: number;
|
|
74
|
+
};
|
|
75
|
+
abs: {
|
|
76
|
+
org?: number;
|
|
77
|
+
ref?: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exposure: {
|
|
81
|
+
net: {
|
|
82
|
+
org?: number;
|
|
83
|
+
ref?: number;
|
|
84
|
+
};
|
|
85
|
+
abs: {
|
|
86
|
+
org?: number;
|
|
87
|
+
ref?: number;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
children: RemoteValuationReportChildHolding[];
|
|
92
|
+
change?: number;
|
|
93
|
+
pnl?: number;
|
|
94
|
+
pnl_to_investment?: number;
|
|
95
|
+
opendate: SDate;
|
|
96
|
+
lastdate: SDate;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Valuation child holding.
|
|
100
|
+
*/
|
|
101
|
+
export interface RemoteValuationReportChildHolding {
|
|
102
|
+
artifact: RemoteValuationReportArtifact;
|
|
103
|
+
tags: {};
|
|
104
|
+
quantity: number;
|
|
105
|
+
accounts: ValuationReportAccount[];
|
|
106
|
+
investment: {
|
|
107
|
+
px: {
|
|
108
|
+
org?: number;
|
|
109
|
+
ref?: number;
|
|
110
|
+
};
|
|
111
|
+
txncosts: {
|
|
112
|
+
org?: number;
|
|
113
|
+
ref?: number;
|
|
114
|
+
};
|
|
115
|
+
accrued: {
|
|
116
|
+
org?: number;
|
|
117
|
+
ref?: number;
|
|
118
|
+
};
|
|
119
|
+
value: {
|
|
120
|
+
org?: number;
|
|
121
|
+
ref?: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
valuation: {
|
|
125
|
+
px: {
|
|
126
|
+
org?: number;
|
|
127
|
+
ref?: number;
|
|
128
|
+
};
|
|
129
|
+
accrued: {
|
|
130
|
+
org?: number;
|
|
131
|
+
ref?: number;
|
|
132
|
+
};
|
|
133
|
+
value: {
|
|
134
|
+
net: {
|
|
135
|
+
org?: number;
|
|
136
|
+
ref?: number;
|
|
137
|
+
};
|
|
138
|
+
abs: {
|
|
139
|
+
org?: number;
|
|
140
|
+
ref?: number;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
exposure: {
|
|
144
|
+
net: {
|
|
145
|
+
org?: number;
|
|
146
|
+
ref?: number;
|
|
147
|
+
};
|
|
148
|
+
abs: {
|
|
149
|
+
org?: number;
|
|
150
|
+
ref?: number;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
change?: number;
|
|
155
|
+
pnl?: number;
|
|
156
|
+
pnl_to_investment?: number;
|
|
157
|
+
opendate: SDate;
|
|
158
|
+
lastdate: SDate;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Valuation artifact.
|
|
162
|
+
*/
|
|
163
|
+
export interface RemoteValuationReportArtifact {
|
|
164
|
+
id: ArtifactId;
|
|
165
|
+
guid: string;
|
|
166
|
+
type: {
|
|
167
|
+
id: ArtifactTypeId;
|
|
168
|
+
name: string;
|
|
169
|
+
order: number;
|
|
170
|
+
};
|
|
171
|
+
stype?: string;
|
|
172
|
+
symbol: string;
|
|
173
|
+
name?: string;
|
|
174
|
+
ccy?: CurrencyCode;
|
|
175
|
+
quantity: number;
|
|
176
|
+
country?: string;
|
|
177
|
+
issuer?: string;
|
|
178
|
+
sector?: string;
|
|
179
|
+
mic?: string;
|
|
180
|
+
ticker?: string;
|
|
181
|
+
isin?: string;
|
|
182
|
+
figi?: string;
|
|
183
|
+
expiry?: SDate;
|
|
184
|
+
underlying_id?: ArtifactId;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Valuation accrual.
|
|
188
|
+
*/
|
|
189
|
+
export interface RemoteValuationReportAccrual {
|
|
190
|
+
name: string;
|
|
191
|
+
value: number;
|
|
192
|
+
accounts: RemoteValuationReportAccrualByAccount[];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Valuation accrual by account.
|
|
196
|
+
*/
|
|
197
|
+
export interface RemoteValuationReportAccrualByAccount {
|
|
198
|
+
account: ValuationReportAccount;
|
|
199
|
+
value: number;
|
|
200
|
+
accruals: RemoteValuationReportAccrualByCurrency[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Valuation accrual by account by currency.
|
|
204
|
+
*/
|
|
205
|
+
export interface RemoteValuationReportAccrualByCurrency {
|
|
206
|
+
artifact: RemoteValuationReportArtifact;
|
|
207
|
+
ccy: CurrencyCode;
|
|
208
|
+
value: {
|
|
209
|
+
org?: number;
|
|
210
|
+
ref?: number;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export declare function toArtifact(x: RemoteValuationReportArtifact): ValuationReportArtifact;
|
|
214
|
+
export declare function toAccrual(x: RemoteValuationReportAccrual): ValuationReportAccrual;
|
|
215
|
+
export declare function toOrgRef(x: {
|
|
216
|
+
org?: number;
|
|
217
|
+
ref?: number;
|
|
218
|
+
}): ValuationReportFigureOrgRef;
|
|
219
|
+
export declare function toMaybeOrgRef(x?: {
|
|
220
|
+
org?: number;
|
|
221
|
+
ref?: number;
|
|
222
|
+
}): Maybe<ValuationReportFigureOrgRef>;
|
|
223
|
+
export declare function toBaseHolding(nav: Decimal, x: RemoteValuationReportHolding | RemoteValuationReportChildHolding): BaseValuationReportHolding;
|
|
224
|
+
export declare function toHolding(nav: Decimal, x: RemoteValuationReportHolding): ValuationReportHolding;
|
|
225
|
+
/**
|
|
226
|
+
* Attempts to re-compile the raw, remote base valuation report and
|
|
227
|
+
* return it.
|
|
228
|
+
*
|
|
229
|
+
* @param x Raw, remote base valuation report.
|
|
230
|
+
* @returns Either of an error message or the re-compiled base valuation
|
|
231
|
+
* report.
|
|
232
|
+
*/
|
|
233
|
+
export declare function recompileBaseValuationReport(x: RemoteBaseValuationReport): Either<CustomError, BaseValuationReport>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.recompileBaseValuationReport = exports.toHolding = exports.toBaseHolding = exports.toMaybeOrgRef = exports.toOrgRef = exports.toAccrual = exports.toArtifact = void 0;
|
|
15
|
+
var prelude_1 = require("@telostat/prelude");
|
|
16
|
+
function toArtifact(x) {
|
|
17
|
+
return {
|
|
18
|
+
id: x.id,
|
|
19
|
+
guid: x.guid,
|
|
20
|
+
type: x.type,
|
|
21
|
+
stype: (0, prelude_1.sanitizedNonEmptyText)(x.stype),
|
|
22
|
+
symbol: x.symbol,
|
|
23
|
+
name: (0, prelude_1.sanitizedNonEmptyText)(x.name),
|
|
24
|
+
ccy: prelude_1.Maybe.fromNullable(x.ccy),
|
|
25
|
+
quantity: (0, prelude_1.asDecimal)(x.quantity),
|
|
26
|
+
country: (0, prelude_1.sanitizedNonEmptyText)(x.country),
|
|
27
|
+
issuer: (0, prelude_1.sanitizedNonEmptyText)(x.issuer),
|
|
28
|
+
sector: (0, prelude_1.sanitizedNonEmptyText)(x.sector),
|
|
29
|
+
mic: (0, prelude_1.sanitizedNonEmptyText)(x.mic),
|
|
30
|
+
ticker: (0, prelude_1.sanitizedNonEmptyText)(x.ticker),
|
|
31
|
+
isin: (0, prelude_1.sanitizedNonEmptyText)(x.isin),
|
|
32
|
+
figi: (0, prelude_1.sanitizedNonEmptyText)(x.figi),
|
|
33
|
+
expiry: prelude_1.Maybe.fromNullable(x.expiry),
|
|
34
|
+
underlyingId: prelude_1.Maybe.fromNullable(x.underlying_id),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.toArtifact = toArtifact;
|
|
38
|
+
function toAccrual(x) {
|
|
39
|
+
return {
|
|
40
|
+
name: x.name,
|
|
41
|
+
value: (0, prelude_1.asDecimal)(x.value),
|
|
42
|
+
accounts: x.accounts.map(function (y) { return ({
|
|
43
|
+
account: y.account,
|
|
44
|
+
value: (0, prelude_1.asDecimal)(y.value),
|
|
45
|
+
accruals: y.accruals.map(function (z) { return ({
|
|
46
|
+
artifact: toArtifact(z.artifact),
|
|
47
|
+
ccy: z.ccy,
|
|
48
|
+
value: { org: (0, prelude_1.asDecimal)(z.value.org || 0), ref: (0, prelude_1.asDecimal)(z.value.ref || 0) },
|
|
49
|
+
}); }),
|
|
50
|
+
}); }),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.toAccrual = toAccrual;
|
|
54
|
+
function toOrgRef(x) {
|
|
55
|
+
return {
|
|
56
|
+
org: (0, prelude_1.maybeDecimal)(x.org).orDefault(prelude_1.zero),
|
|
57
|
+
ref: (0, prelude_1.maybeDecimal)(x.ref).orDefault(prelude_1.zero),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.toOrgRef = toOrgRef;
|
|
61
|
+
function toMaybeOrgRef(x) {
|
|
62
|
+
return prelude_1.Maybe.fromNullable(x).chain(function (_a) {
|
|
63
|
+
var org = _a.org, ref = _a.ref;
|
|
64
|
+
return (0, prelude_1.maybeDecimal)(org).chain(function (o) { return (0, prelude_1.maybeDecimal)(ref).chain(function (r) { return (0, prelude_1.Just)({ org: o, ref: r }); }); });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.toMaybeOrgRef = toMaybeOrgRef;
|
|
68
|
+
function toBaseHolding(nav, x) {
|
|
69
|
+
return {
|
|
70
|
+
artifact: toArtifact(x.artifact),
|
|
71
|
+
quantity: (0, prelude_1.asDecimal)(x.quantity),
|
|
72
|
+
investment: {
|
|
73
|
+
px: toOrgRef(x.investment.px),
|
|
74
|
+
txncosts: toMaybeOrgRef(x.investment.txncosts),
|
|
75
|
+
accrued: toMaybeOrgRef(x.investment.accrued),
|
|
76
|
+
value: toOrgRef(x.investment.value),
|
|
77
|
+
},
|
|
78
|
+
valuation: {
|
|
79
|
+
px: toOrgRef(x.valuation.px),
|
|
80
|
+
accrued: toMaybeOrgRef(x.valuation.accrued),
|
|
81
|
+
value: {
|
|
82
|
+
net: toOrgRef(x.valuation.value.net),
|
|
83
|
+
abs: toOrgRef(x.valuation.value.abs),
|
|
84
|
+
},
|
|
85
|
+
exposure: {
|
|
86
|
+
net: toOrgRef(x.valuation.exposure.net),
|
|
87
|
+
abs: toOrgRef(x.valuation.exposure.abs),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
valuePercentage: (0, prelude_1.safeDiv)((0, prelude_1.maybeDecimal)(x.valuation.value.net.ref).orDefault(prelude_1.zero), nav),
|
|
91
|
+
netExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.maybeDecimal)(x.valuation.exposure.net.ref).orDefault(prelude_1.zero), nav),
|
|
92
|
+
absExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.maybeDecimal)(x.valuation.exposure.abs.ref).orDefault(prelude_1.zero), nav),
|
|
93
|
+
change: (0, prelude_1.maybeDecimal)(x.change),
|
|
94
|
+
pnl: (0, prelude_1.maybeDecimal)(x.pnl).orDefault(prelude_1.zero),
|
|
95
|
+
pnlToInvestment: (0, prelude_1.maybeDecimal)(x.pnl_to_investment),
|
|
96
|
+
opendate: x.opendate,
|
|
97
|
+
lastdate: x.lastdate,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
exports.toBaseHolding = toBaseHolding;
|
|
101
|
+
function toHolding(nav, x) {
|
|
102
|
+
return __assign(__assign({}, toBaseHolding(nav, x)), { classification: x.tags.classification.map(function (n) { return (__assign(__assign({}, n), { order: n.order || '' })); }), accounts: x.accounts, children: prelude_1.Maybe.fromNullable(x.children)
|
|
103
|
+
.filter(function (mc) { return mc.length !== 0; })
|
|
104
|
+
.map(function (mc) {
|
|
105
|
+
return mc.map(function (c) { return (__assign(__assign({}, toBaseHolding(nav, c)), { account: c.accounts[0] })); });
|
|
106
|
+
}) });
|
|
107
|
+
}
|
|
108
|
+
exports.toHolding = toHolding;
|
|
109
|
+
/**
|
|
110
|
+
* Attempts to re-compile the raw, remote base valuation report and
|
|
111
|
+
* return it.
|
|
112
|
+
*
|
|
113
|
+
* @param x Raw, remote base valuation report.
|
|
114
|
+
* @returns Either of an error message or the re-compiled base valuation
|
|
115
|
+
* report.
|
|
116
|
+
*/
|
|
117
|
+
function recompileBaseValuationReport(x) {
|
|
118
|
+
var nav = (0, prelude_1.maybeDecimal)(x.nav).orDefault(prelude_1.zero);
|
|
119
|
+
var report = {
|
|
120
|
+
asof: x.reported,
|
|
121
|
+
date: x.asof,
|
|
122
|
+
dateType: x.type,
|
|
123
|
+
currency: x.ccy,
|
|
124
|
+
accounts: x.accounts,
|
|
125
|
+
holdings: x.holdings.map(function (rh) { return toHolding(nav, rh); }),
|
|
126
|
+
accruals: x.accruals.map(toAccrual),
|
|
127
|
+
fxRates: x.fxrates.map(function (r) { return ({ ccy1: r.ccy1, ccy2: r.ccy2, value: (0, prelude_1.asDecimal)(r.value), asof: r.asof }); }),
|
|
128
|
+
figures: {
|
|
129
|
+
investment: (0, prelude_1.maybeDecimal)(x.investment).orDefault(prelude_1.zero),
|
|
130
|
+
valuation: {
|
|
131
|
+
net: (0, prelude_1.maybeDecimal)(x.valuation_net).orDefault(prelude_1.zero),
|
|
132
|
+
abs: (0, prelude_1.maybeDecimal)(x.valuation_abs).orDefault(prelude_1.zero),
|
|
133
|
+
},
|
|
134
|
+
accrued: (0, prelude_1.maybeDecimal)(x.accrued).orDefault(prelude_1.zero),
|
|
135
|
+
liabilities: (0, prelude_1.maybeDecimal)(x.liabilities).orDefault(prelude_1.zero),
|
|
136
|
+
gav: (0, prelude_1.maybeDecimal)(x.gav).orDefault(prelude_1.zero),
|
|
137
|
+
nav: nav,
|
|
138
|
+
aum: (0, prelude_1.maybeDecimal)(x.aum).orDefault(prelude_1.zero),
|
|
139
|
+
pnl: (0, prelude_1.maybeDecimal)(x.pnl).orDefault(prelude_1.zero),
|
|
140
|
+
pnlToInvestment: (0, prelude_1.maybeDecimal)(x.pnl_to_investment),
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
return (0, prelude_1.Right)(report);
|
|
144
|
+
}
|
|
145
|
+
exports.recompileBaseValuationReport = recompileBaseValuationReport;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseValuationReport } from './-valuation-report-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Type definition for consolidated valuation report.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConsolidatedValuationReport extends BaseValuationReport {
|
|
6
|
+
/**
|
|
7
|
+
* Type of containers consolidated.
|
|
8
|
+
*/
|
|
9
|
+
containerType: ConsolidatedValuationReportContainerType;
|
|
10
|
+
/**
|
|
11
|
+
* Containers consolidated.
|
|
12
|
+
*/
|
|
13
|
+
containers: ConsolidatedValuationReportContainer[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type definition for container types to be consolidated.
|
|
17
|
+
*/
|
|
18
|
+
export declare type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
|
|
19
|
+
/**
|
|
20
|
+
* Type definition for valuation report containers.
|
|
21
|
+
*/
|
|
22
|
+
export interface ConsolidatedValuationReportContainer {
|
|
23
|
+
/**
|
|
24
|
+
* Id of the container.
|
|
25
|
+
*/
|
|
26
|
+
id: number;
|
|
27
|
+
/**
|
|
28
|
+
* GUID of the container.
|
|
29
|
+
*/
|
|
30
|
+
guid: string;
|
|
31
|
+
/**
|
|
32
|
+
* Name of the container.
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Decimal } from '@telostat/prelude';
|
|
2
|
+
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
3
|
+
import { ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
|
|
4
|
+
export declare function makeValuationReportHoldingsTreeNodeValue(): ValuationReportHoldingsTreeNodeValue;
|
|
5
|
+
export declare function updateTotals(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNodeValue;
|
|
6
|
+
export declare function resortChildren(node: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNode[];
|
|
7
|
+
export declare function retreatTree(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): void;
|
|
8
|
+
export declare function makeValuationReportHoldingsTreeNode(address: ValuationReportHoldingClassification): ValuationReportHoldingsTreeNode;
|
|
9
|
+
export declare function addValuationReportHoldingToTree(tree: ValuationReportHoldingsTreeNode, address: ValuationReportHoldingClassification, holding: ValuationReportHolding): void;
|
|
10
|
+
export declare function makeValuationReportHoldingsTree(nav: Decimal, investment: Decimal, holdings: ValuationReportHolding[]): ValuationReportHoldingsTreeNode;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
var __values = (this && this.__values) || function(o) {
|
|
28
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
+
if (m) return m.call(o);
|
|
30
|
+
if (o && typeof o.length === "number") return {
|
|
31
|
+
next: function () {
|
|
32
|
+
if (o && i >= o.length) o = void 0;
|
|
33
|
+
return { value: o && o[i++], done: !o };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.makeValuationReportHoldingsTree = exports.addValuationReportHoldingToTree = exports.makeValuationReportHoldingsTreeNode = exports.retreatTree = exports.resortChildren = exports.updateTotals = exports.makeValuationReportHoldingsTreeNodeValue = void 0;
|
|
40
|
+
var prelude_1 = require("@telostat/prelude");
|
|
41
|
+
var purify_ts_1 = require("purify-ts");
|
|
42
|
+
var List_1 = require("purify-ts/List");
|
|
43
|
+
var _utils_1 = require("./-utils");
|
|
44
|
+
function makeValuationReportHoldingsTreeNodeValue() {
|
|
45
|
+
return {
|
|
46
|
+
investment: prelude_1.zero,
|
|
47
|
+
accrued: purify_ts_1.Nothing,
|
|
48
|
+
netValue: prelude_1.zero,
|
|
49
|
+
netValueRatio: prelude_1.zero,
|
|
50
|
+
absValue: prelude_1.zero,
|
|
51
|
+
absValueRatio: prelude_1.zero,
|
|
52
|
+
netExposure: prelude_1.zero,
|
|
53
|
+
netExposureRatio: prelude_1.zero,
|
|
54
|
+
absExposure: prelude_1.zero,
|
|
55
|
+
absExposureRatio: prelude_1.zero,
|
|
56
|
+
pnl: prelude_1.zero,
|
|
57
|
+
pnlRatio: prelude_1.zero,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.makeValuationReportHoldingsTreeNodeValue = makeValuationReportHoldingsTreeNodeValue;
|
|
61
|
+
function updateTotals(nav, investment, tree) {
|
|
62
|
+
var holdings = tree.holdings;
|
|
63
|
+
var children = tree.children;
|
|
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
|
+
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 netExposure = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.exposure.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netExposure; })));
|
|
67
|
+
var absExposure = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.exposure.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absExposure; })));
|
|
68
|
+
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
|
+
var accruedsHoldings = holdings.map(function (x) { return x.investment.accrued.map(function (x) { return x.ref; }); });
|
|
70
|
+
var accruedsChildren = children.map(function (x) { return x.totals.accrued; });
|
|
71
|
+
var accrueds = purify_ts_1.Maybe.catMaybes(__spreadArray(__spreadArray([], __read(accruedsHoldings), false), __read(accruedsChildren), false));
|
|
72
|
+
return {
|
|
73
|
+
investment: (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.investment.value.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.investment; }))),
|
|
74
|
+
accrued: accrueds.length === 0 ? purify_ts_1.Nothing : (0, purify_ts_1.Just)((0, prelude_1.sumDecimals)(accrueds)),
|
|
75
|
+
netValue: netValue,
|
|
76
|
+
netValueRatio: (0, prelude_1.safeDiv)(netValue, nav).orDefault(prelude_1.zero),
|
|
77
|
+
absValue: absValue,
|
|
78
|
+
absValueRatio: (0, prelude_1.safeDiv)(absValue, nav).orDefault(prelude_1.zero),
|
|
79
|
+
netExposure: netExposure,
|
|
80
|
+
netExposureRatio: (0, prelude_1.safeDiv)(netExposure, nav).orDefault(prelude_1.zero),
|
|
81
|
+
absExposure: absExposure,
|
|
82
|
+
absExposureRatio: (0, prelude_1.safeDiv)(absExposure, nav).orDefault(prelude_1.zero),
|
|
83
|
+
pnl: pnl,
|
|
84
|
+
pnlRatio: (0, prelude_1.safeDiv)(pnl, investment).orDefault(prelude_1.zero),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.updateTotals = updateTotals;
|
|
88
|
+
function resortChildren(node) {
|
|
89
|
+
return node.children.sort(function (t1, t2) {
|
|
90
|
+
// Get current address segments:
|
|
91
|
+
var segment1 = List_1.List.last(t1.address);
|
|
92
|
+
var segment2 = List_1.List.last(t2.address);
|
|
93
|
+
// Compare and return:
|
|
94
|
+
return segment1
|
|
95
|
+
.chain(function (s1) { return segment2.chain(function (s2) { return (0, purify_ts_1.Just)((0, prelude_1.Tuple)(s1, s2)); }); })
|
|
96
|
+
.map(function (x) { return x.toArray(); })
|
|
97
|
+
.map(function (_a) {
|
|
98
|
+
var _b = __read(_a, 2), x = _b[0], y = _b[1];
|
|
99
|
+
return "".concat(x.order).localeCompare("".concat(y.order));
|
|
100
|
+
})
|
|
101
|
+
.orDefaultLazy(function () { return (segment1.isNothing() ? -1 : 1); });
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.resortChildren = resortChildren;
|
|
105
|
+
function retreatTree(nav, investment, tree) {
|
|
106
|
+
// First, retreat all children (recursive):
|
|
107
|
+
tree.children.forEach(function (x) { return retreatTree(nav, investment, x); });
|
|
108
|
+
// Recompute totals:
|
|
109
|
+
tree.totals = updateTotals(nav, investment, tree);
|
|
110
|
+
// Resort children:
|
|
111
|
+
tree.children = resortChildren(tree);
|
|
112
|
+
}
|
|
113
|
+
exports.retreatTree = retreatTree;
|
|
114
|
+
function makeValuationReportHoldingsTreeNode(address) {
|
|
115
|
+
return {
|
|
116
|
+
name: List_1.List.last(address)
|
|
117
|
+
.map(function (x) { return x.name; })
|
|
118
|
+
.orDefault(''),
|
|
119
|
+
address: address,
|
|
120
|
+
holdings: [],
|
|
121
|
+
children: [],
|
|
122
|
+
totals: makeValuationReportHoldingsTreeNodeValue(),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
exports.makeValuationReportHoldingsTreeNode = makeValuationReportHoldingsTreeNode;
|
|
126
|
+
function addValuationReportHoldingToTree(tree, address, holding) {
|
|
127
|
+
var e_1, _a;
|
|
128
|
+
// Get the starting (current) node:
|
|
129
|
+
var node = tree;
|
|
130
|
+
// Iterate over address and traverse the tree while adding new nodes when required:
|
|
131
|
+
var sofar = [];
|
|
132
|
+
var sofarAddress = [];
|
|
133
|
+
try {
|
|
134
|
+
for (var address_1 = __values(address), address_1_1 = address_1.next(); !address_1_1.done; address_1_1 = address_1.next()) {
|
|
135
|
+
var segment = address_1_1.value;
|
|
136
|
+
// Append to address buffer:
|
|
137
|
+
sofar.push(segment.name);
|
|
138
|
+
sofarAddress.push(segment);
|
|
139
|
+
// Attempt to find the child:
|
|
140
|
+
var child = node.children.find(function (n) {
|
|
141
|
+
return (0, _utils_1.compareStringArrays)(n.address.map(function (x) { return x.name; }), sofar) === 0;
|
|
142
|
+
});
|
|
143
|
+
// Add or use?
|
|
144
|
+
if (child === undefined) {
|
|
145
|
+
// Create the new node:
|
|
146
|
+
child = makeValuationReportHoldingsTreeNode(__spreadArray([], __read(sofarAddress), false));
|
|
147
|
+
// Add the new node to the current node as a child:
|
|
148
|
+
node.children.push(child);
|
|
149
|
+
}
|
|
150
|
+
// Set the current node to the child:
|
|
151
|
+
node = child;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
155
|
+
finally {
|
|
156
|
+
try {
|
|
157
|
+
if (address_1_1 && !address_1_1.done && (_a = address_1.return)) _a.call(address_1);
|
|
158
|
+
}
|
|
159
|
+
finally { if (e_1) throw e_1.error; }
|
|
160
|
+
}
|
|
161
|
+
// Done, we append the holding to the current node and return from the procedure:
|
|
162
|
+
node.holdings.push(holding);
|
|
163
|
+
}
|
|
164
|
+
exports.addValuationReportHoldingToTree = addValuationReportHoldingToTree;
|
|
165
|
+
function makeValuationReportHoldingsTree(nav, investment, holdings) {
|
|
166
|
+
var e_2, _a;
|
|
167
|
+
// Initialize the tree:
|
|
168
|
+
var tree = makeValuationReportHoldingsTreeNode([]);
|
|
169
|
+
tree.name = '« Total »';
|
|
170
|
+
try {
|
|
171
|
+
// Iterate over the holdings and attempt to add to the tree:
|
|
172
|
+
for (var holdings_1 = __values(holdings), holdings_1_1 = holdings_1.next(); !holdings_1_1.done; holdings_1_1 = holdings_1.next()) {
|
|
173
|
+
var holding = holdings_1_1.value;
|
|
174
|
+
addValuationReportHoldingToTree(tree, holding.classification, holding);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
178
|
+
finally {
|
|
179
|
+
try {
|
|
180
|
+
if (holdings_1_1 && !holdings_1_1.done && (_a = holdings_1.return)) _a.call(holdings_1);
|
|
181
|
+
}
|
|
182
|
+
finally { if (e_2) throw e_2.error; }
|
|
183
|
+
}
|
|
184
|
+
// Retreat the tree:
|
|
185
|
+
retreatTree(nav, investment, tree);
|
|
186
|
+
// Done, return:
|
|
187
|
+
return tree;
|
|
188
|
+
}
|
|
189
|
+
exports.makeValuationReportHoldingsTree = makeValuationReportHoldingsTree;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Decimal, Maybe } from '@telostat/prelude';
|
|
2
|
+
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
3
|
+
export interface ValuationReportHoldingsTreeNode {
|
|
4
|
+
name: string;
|
|
5
|
+
address: ValuationReportHoldingClassification;
|
|
6
|
+
holdings: ValuationReportHolding[];
|
|
7
|
+
children: ValuationReportHoldingsTreeNode[];
|
|
8
|
+
totals: ValuationReportHoldingsTreeNodeValue;
|
|
9
|
+
}
|
|
10
|
+
export interface ValuationReportHoldingsTreeNodeValue {
|
|
11
|
+
investment: Decimal;
|
|
12
|
+
accrued: Maybe<Decimal>;
|
|
13
|
+
netValue: Decimal;
|
|
14
|
+
netValueRatio: Decimal;
|
|
15
|
+
absValue: Decimal;
|
|
16
|
+
absValueRatio: Decimal;
|
|
17
|
+
netExposure: Decimal;
|
|
18
|
+
netExposureRatio: Decimal;
|
|
19
|
+
absExposure: Decimal;
|
|
20
|
+
absExposureRatio: Decimal;
|
|
21
|
+
pnl: Decimal;
|
|
22
|
+
pnlRatio: Decimal;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareStringArrays(x: string[], y: string[]): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareStringArrays = void 0;
|
|
4
|
+
function compareStringArrays(x, y) {
|
|
5
|
+
var xLen = x.length;
|
|
6
|
+
var yLen = y.length;
|
|
7
|
+
var minLength = Math.min(xLen, yLen);
|
|
8
|
+
for (var i = 0; i < minLength; i++) {
|
|
9
|
+
var comparison = (x[i] || '').localeCompare(y[i] || '');
|
|
10
|
+
if (comparison !== 0) {
|
|
11
|
+
return comparison;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return Math.sign(xLen - yLen);
|
|
15
|
+
}
|
|
16
|
+
exports.compareStringArrays = compareStringArrays;
|