@decafhub/decaf-client-extras 0.0.5 → 0.1.0
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 +15 -0
- package/commons/-currency.d.ts +22 -6
- package/commons/-currency.js +12 -6
- package/commons/{-date-type.d.ts → -datetype.d.ts} +1 -1
- package/commons/{-date-type.js → -datetype.js} +2 -2
- package/commons/-id.d.ts +109 -17
- package/commons/-id.js +73 -0
- package/commons/index.d.ts +4 -1
- package/commons/index.js +17 -1
- package/es/commons/-currency.d.ts +22 -6
- package/es/commons/-currency.js +12 -6
- package/es/commons/{-date-type.d.ts → -datetype.d.ts} +1 -1
- package/es/commons/{-date-type.js → -datetype.js} +1 -1
- package/es/commons/-id.d.ts +109 -17
- package/es/commons/-id.js +70 -1
- package/es/commons/index.d.ts +4 -1
- package/es/commons/index.js +4 -1
- package/es/reports/valuation/-remote-valuation-report-portfolio.d.ts +15 -15
- package/es/reports/valuation/-remote-valuation-report-portfolio.js +32 -32
- package/es/reports/valuation/-remote-valuation-report-shared.d.ts +4 -4
- package/es/reports/valuation/-remote-valuation-report-shared.js +29 -26
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +1 -3
- package/es/reports/valuation/-valuation-report-portfolio.d.ts +14 -14
- package/es/reports/valuation/-valuation-report-shared.d.ts +6 -6
- package/nix/default.nix +59 -0
- package/nix/sources.json +14 -0
- package/nix/sources.nix +194 -0
- package/package.json +2 -2
- package/reports/valuation/-remote-valuation-report-portfolio.d.ts +15 -15
- package/reports/valuation/-remote-valuation-report-portfolio.js +31 -31
- package/reports/valuation/-remote-valuation-report-shared.d.ts +4 -4
- package/reports/valuation/-remote-valuation-report-shared.js +28 -25
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +7 -9
- package/reports/valuation/-valuation-report-portfolio.d.ts +14 -14
- package/reports/valuation/-valuation-report-shared.d.ts +6 -6
- package/shell.nix +5 -20
- package/src/commons/-currency.test.ts +27 -0
- package/src/commons/-currency.ts +24 -9
- package/src/commons/-datetype.test.ts +10 -0
- package/src/commons/{-date-type.ts → -datetype.ts} +1 -1
- package/src/commons/-id.test.ts +27 -0
- package/src/commons/-id.ts +112 -17
- package/src/commons/index.ts +4 -1
- package/src/index.test.ts +5 -5
- package/src/reports/valuation/-remote-valuation-report-portfolio.ts +54 -54
- package/src/reports/valuation/-remote-valuation-report-shared.ts +34 -31
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +5 -7
- package/src/reports/valuation/-valuation-report-portfolio.ts +20 -20
- package/src/reports/valuation/-valuation-report-shared.ts +13 -6
package/es/commons/-id.d.ts
CHANGED
|
@@ -1,58 +1,150 @@
|
|
|
1
|
-
import { NewTypeWithPhantom } from '@telostat/prelude';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* This module provides a collection of DECAF record identifier type
|
|
3
|
+
* definitions. It is not exhaustive and it will be improved on an ongoing
|
|
4
|
+
* basis.
|
|
5
|
+
*
|
|
6
|
+
* Typically, a DECAF record identifier is either number or string. Some DECAF
|
|
7
|
+
* API endoints can consume string values even though a number is expected. We
|
|
8
|
+
* are sticking here to the original type: No `number | string` definitions.
|
|
9
|
+
*
|
|
10
|
+
* Methodologically, we are using a type trick to emulate newtypes in this
|
|
11
|
+
* module: For example, DECAF artifact identifier type is defined as:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* export type DecafArtifactId = number & { readonly __tag: unique symbol };
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* In runtime, there is only a number. The `& { readonly __tag: unique symbol }`
|
|
18
|
+
* is provided to the compiler to distinguish in between `number` identifier
|
|
19
|
+
* values which are representing different DECAF record types.
|
|
20
|
+
*
|
|
21
|
+
* The construction and deconstruction of DECAF record identifiers are done via,
|
|
22
|
+
* respecively, `mkDecafRecordId` and `unDecafRecordId`:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const exampleDecafArtifactIdValue: number = unDecafRecordId(exampleDecafArtifactId);
|
|
26
|
+
* const exampleDecafArtifactId: DecafArtifactId = mkDecafRecordId(42);
|
|
27
|
+
* expect(exampleDecafArtifactIdValue).toBe(42);
|
|
28
|
+
*
|
|
29
|
+
* const exampleDecafActionId: DecafActionId = mkDecafRecordId(42);
|
|
30
|
+
* const exampleDecafActionIdValue: number = unDecafRecordId(exampleDecafActionId);
|
|
31
|
+
* expect(exampleDecafActionIdValue).toBe(42);
|
|
32
|
+
*
|
|
33
|
+
* const exampleDecafArtifactTypeId: DecafArtifactTypeId = mkDecafRecordId('CCY');
|
|
34
|
+
* const exampleDecafArtifactTypeIdValue: string = unDecafRecordId(exampleDecafArtifactTypeId);
|
|
35
|
+
* expect(exampleDecafArtifactTypeIdValue).toBe('CCY');
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* To re-iterate, the runtime representation is not affected by how DECAF record
|
|
39
|
+
* identifier types are defined:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* interface DecafArtifact {
|
|
43
|
+
* id: DecafArtifactId;
|
|
44
|
+
* type: DecafArtifactTypeId;
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* const exampleDecafArtifact: DecafArtifact = { id: mkDecafRecordId(10), type: mkDecafRecordId('CCY') };
|
|
48
|
+
* expect(exampleDecafArtifact).toStrictEqual({ id: 10, type: 'CCY' });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
5
52
|
*/
|
|
6
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Type definition covering all possible DECAF record identifiers based on
|
|
55
|
+
* `number` values.
|
|
56
|
+
*
|
|
57
|
+
* This type definition must be extended whenever there is a new DECAF record
|
|
58
|
+
* identifier is defined in this module.
|
|
59
|
+
*/
|
|
60
|
+
export type _DecafRecordIdFromNumber = DecafArtifactId | DecafActionId;
|
|
61
|
+
/**
|
|
62
|
+
* Type definition covering all possible DECAF record identifiers based on
|
|
63
|
+
* `string` values.
|
|
64
|
+
*
|
|
65
|
+
* This type definition must be extended whenever there is a new DECAF record
|
|
66
|
+
* identifier is defined in this module.
|
|
67
|
+
*/
|
|
68
|
+
export type _DecafRecordIdFromString = DecafArtifactTypeId;
|
|
69
|
+
export declare function mkDecafRecordId<T extends _DecafRecordIdFromNumber>(x: number): T;
|
|
70
|
+
export declare function mkDecafRecordId<T extends _DecafRecordIdFromString>(x: string): T;
|
|
71
|
+
export declare function unDecafRecordId<T extends _DecafRecordIdFromNumber>(x: T): number;
|
|
72
|
+
export declare function unDecafRecordId<K extends _DecafRecordIdFromString>(x: K): string;
|
|
7
73
|
/**
|
|
8
74
|
* Type definition for DECAF artifact identifiers.
|
|
9
75
|
*/
|
|
10
|
-
export type
|
|
76
|
+
export type DecafArtifactId = number & {
|
|
77
|
+
readonly __tag: unique symbol;
|
|
78
|
+
};
|
|
11
79
|
/**
|
|
12
80
|
* Type definition for DECAF artifact type identifiers.
|
|
13
81
|
*/
|
|
14
|
-
export type
|
|
82
|
+
export type DecafArtifactTypeId = string & {
|
|
83
|
+
readonly __tag: unique symbol;
|
|
84
|
+
};
|
|
15
85
|
/**
|
|
16
86
|
* Type definition for DECAF share class identifiers.
|
|
17
87
|
*/
|
|
18
|
-
export type
|
|
88
|
+
export type DecafShareClassId = number & {
|
|
89
|
+
readonly __tag: unique symbol;
|
|
90
|
+
};
|
|
19
91
|
/**
|
|
20
92
|
* Type definition for DECAF principal identifiers.
|
|
21
93
|
*/
|
|
22
|
-
export type
|
|
94
|
+
export type DecafPrincipalId = number & {
|
|
95
|
+
readonly __tag: unique symbol;
|
|
96
|
+
};
|
|
23
97
|
/**
|
|
24
98
|
* Type definition for DECAF institution identifiers.
|
|
25
99
|
*/
|
|
26
|
-
export type
|
|
100
|
+
export type DecafInstitutionId = number & {
|
|
101
|
+
readonly __tag: unique symbol;
|
|
102
|
+
};
|
|
27
103
|
/**
|
|
28
104
|
* Type definition for DECAF team identifiers.
|
|
29
105
|
*/
|
|
30
|
-
export type
|
|
106
|
+
export type DecafTeamId = number & {
|
|
107
|
+
readonly __tag: unique symbol;
|
|
108
|
+
};
|
|
31
109
|
/**
|
|
32
110
|
* Type definition for DECAF portfolio identifiers.
|
|
33
111
|
*/
|
|
34
|
-
export type
|
|
112
|
+
export type DecafPortfolioId = number & {
|
|
113
|
+
readonly __tag: unique symbol;
|
|
114
|
+
};
|
|
35
115
|
/**
|
|
36
116
|
* Type definition for DECAF portfolio group identifiers.
|
|
37
117
|
*/
|
|
38
|
-
export type
|
|
118
|
+
export type DecafPortfolioGroupId = number & {
|
|
119
|
+
readonly __tag: unique symbol;
|
|
120
|
+
};
|
|
39
121
|
/**
|
|
40
122
|
* Type definition for DECAF account identifiers.
|
|
41
123
|
*/
|
|
42
|
-
export type
|
|
124
|
+
export type DecafAccountId = number & {
|
|
125
|
+
readonly __tag: unique symbol;
|
|
126
|
+
};
|
|
43
127
|
/**
|
|
44
128
|
* Type definition for DECAF OHLC series identifiers.
|
|
45
129
|
*/
|
|
46
|
-
export type
|
|
130
|
+
export type DecafOhlcSeriesId = number & {
|
|
131
|
+
readonly __tag: unique symbol;
|
|
132
|
+
};
|
|
47
133
|
/**
|
|
48
134
|
* Type definition for DECAF share class fee schedule identifiers.
|
|
49
135
|
*/
|
|
50
|
-
export type
|
|
136
|
+
export type DecafShareClassFeeScheduleId = number & {
|
|
137
|
+
readonly __tag: unique symbol;
|
|
138
|
+
};
|
|
51
139
|
/**
|
|
52
140
|
* Type definition for DECAF action identifiers.
|
|
53
141
|
*/
|
|
54
|
-
export type
|
|
142
|
+
export type DecafActionId = number & {
|
|
143
|
+
readonly __tag: unique symbol;
|
|
144
|
+
};
|
|
55
145
|
/**
|
|
56
146
|
* Type definition for DECAF external valuation identifiers.
|
|
57
147
|
*/
|
|
58
|
-
export type
|
|
148
|
+
export type DecafExternalValuationId = number & {
|
|
149
|
+
readonly __tag: unique symbol;
|
|
150
|
+
};
|
package/es/commons/-id.js
CHANGED
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This module provides a collection of DECAF record identifier type
|
|
3
|
+
* definitions. It is not exhaustive and it will be improved on an ongoing
|
|
4
|
+
* basis.
|
|
5
|
+
*
|
|
6
|
+
* Typically, a DECAF record identifier is either number or string. Some DECAF
|
|
7
|
+
* API endoints can consume string values even though a number is expected. We
|
|
8
|
+
* are sticking here to the original type: No `number | string` definitions.
|
|
9
|
+
*
|
|
10
|
+
* Methodologically, we are using a type trick to emulate newtypes in this
|
|
11
|
+
* module: For example, DECAF artifact identifier type is defined as:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* export type DecafArtifactId = number & { readonly __tag: unique symbol };
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* In runtime, there is only a number. The `& { readonly __tag: unique symbol }`
|
|
18
|
+
* is provided to the compiler to distinguish in between `number` identifier
|
|
19
|
+
* values which are representing different DECAF record types.
|
|
20
|
+
*
|
|
21
|
+
* The construction and deconstruction of DECAF record identifiers are done via,
|
|
22
|
+
* respecively, `mkDecafRecordId` and `unDecafRecordId`:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const exampleDecafArtifactIdValue: number = unDecafRecordId(exampleDecafArtifactId);
|
|
26
|
+
* const exampleDecafArtifactId: DecafArtifactId = mkDecafRecordId(42);
|
|
27
|
+
* expect(exampleDecafArtifactIdValue).toBe(42);
|
|
28
|
+
*
|
|
29
|
+
* const exampleDecafActionId: DecafActionId = mkDecafRecordId(42);
|
|
30
|
+
* const exampleDecafActionIdValue: number = unDecafRecordId(exampleDecafActionId);
|
|
31
|
+
* expect(exampleDecafActionIdValue).toBe(42);
|
|
32
|
+
*
|
|
33
|
+
* const exampleDecafArtifactTypeId: DecafArtifactTypeId = mkDecafRecordId('CCY');
|
|
34
|
+
* const exampleDecafArtifactTypeIdValue: string = unDecafRecordId(exampleDecafArtifactTypeId);
|
|
35
|
+
* expect(exampleDecafArtifactTypeIdValue).toBe('CCY');
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* To re-iterate, the runtime representation is not affected by how DECAF record
|
|
39
|
+
* identifier types are defined:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* interface DecafArtifact {
|
|
43
|
+
* id: DecafArtifactId;
|
|
44
|
+
* type: DecafArtifactTypeId;
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* const exampleDecafArtifact: DecafArtifact = { id: mkDecafRecordId(10), type: mkDecafRecordId('CCY') };
|
|
48
|
+
* expect(exampleDecafArtifact).toStrictEqual({ id: 10, type: 'CCY' });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Constructor for DECAF record identifiers.
|
|
55
|
+
*
|
|
56
|
+
* @param x Value to create DECAF record identifier from.
|
|
57
|
+
* @returns DECAF record identifier of type deduced from call-site usage.
|
|
58
|
+
*/
|
|
59
|
+
export function mkDecafRecordId(x) {
|
|
60
|
+
return x;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Deconstructor for DECAF record identifiers.
|
|
64
|
+
*
|
|
65
|
+
* @param x DECAF record identifier.
|
|
66
|
+
* @returns Value of the DECAF record identifier (deduced from call-site usage).
|
|
67
|
+
*/
|
|
68
|
+
export function unDecafRecordId(x) {
|
|
69
|
+
return x;
|
|
70
|
+
}
|
package/es/commons/index.d.ts
CHANGED
package/es/commons/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecafClient } from '@decafhub/decaf-client';
|
|
2
2
|
import { CustomError, Either, SDate, SDateTime } from '@telostat/prelude';
|
|
3
|
-
import {
|
|
3
|
+
import { CurrencyCode, DateType, DecafActionId, DecafExternalValuationId, DecafOhlcSeriesId, DecafPortfolioId, DecafPrincipalId, DecafShareClassFeeScheduleId, DecafShareClassId } from '../../commons';
|
|
4
4
|
import { RemoteBaseValuationReport } from './-remote-valuation-report-shared';
|
|
5
5
|
import { PortfolioValuationReport, PortfolioValuationReportShareClassValue } from './-valuation-report-portfolio';
|
|
6
6
|
import { ValuationReportPortfolio } from './-valuation-report-shared';
|
|
@@ -23,7 +23,7 @@ export interface PortfolioValuationReportQuery {
|
|
|
23
23
|
/**
|
|
24
24
|
* Portfolio the valuation report is requested for.
|
|
25
25
|
*/
|
|
26
|
-
portfolio:
|
|
26
|
+
portfolio: DecafPortfolioId;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Type definition for the remote (raw) portfolio valuation report data.
|
|
@@ -58,13 +58,13 @@ export interface RemoteValuationShareClassValue {
|
|
|
58
58
|
* Type definition for share class on the remote portfolio valuation report.
|
|
59
59
|
*/
|
|
60
60
|
export interface RemoteValuationShareClass {
|
|
61
|
-
id:
|
|
61
|
+
id: DecafShareClassId;
|
|
62
62
|
created: SDateTime;
|
|
63
|
-
creator:
|
|
63
|
+
creator: DecafPrincipalId;
|
|
64
64
|
updated: SDateTime;
|
|
65
|
-
updater:
|
|
65
|
+
updater: DecafPrincipalId;
|
|
66
66
|
guid: string;
|
|
67
|
-
portfolio:
|
|
67
|
+
portfolio: DecafPortfolioId;
|
|
68
68
|
name: string;
|
|
69
69
|
currency: CurrencyCode;
|
|
70
70
|
isin?: string;
|
|
@@ -76,11 +76,11 @@ export interface RemoteValuationShareClass {
|
|
|
76
76
|
subredperiod?: string;
|
|
77
77
|
freqmngt?: number;
|
|
78
78
|
freqperf?: number;
|
|
79
|
-
benchmark?:
|
|
79
|
+
benchmark?: DecafOhlcSeriesId;
|
|
80
80
|
description?: string;
|
|
81
|
-
feeschedules:
|
|
82
|
-
effectivefeeschedule?:
|
|
83
|
-
subscriptions:
|
|
81
|
+
feeschedules: DecafShareClassFeeScheduleId[];
|
|
82
|
+
effectivefeeschedule?: DecafShareClassFeeScheduleId;
|
|
83
|
+
subscriptions: DecafActionId[];
|
|
84
84
|
outstanding?: number;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -88,14 +88,14 @@ export interface RemoteValuationShareClass {
|
|
|
88
88
|
* report.
|
|
89
89
|
*/
|
|
90
90
|
export interface RemoteValuationExternalValue {
|
|
91
|
-
id:
|
|
91
|
+
id: DecafExternalValuationId;
|
|
92
92
|
created: SDateTime;
|
|
93
|
-
creator:
|
|
93
|
+
creator: DecafPrincipalId;
|
|
94
94
|
updated: SDateTime;
|
|
95
|
-
updater:
|
|
95
|
+
updater: DecafPrincipalId;
|
|
96
96
|
guid: string;
|
|
97
|
-
portfolio:
|
|
98
|
-
shareclass?:
|
|
97
|
+
portfolio: DecafPortfolioId;
|
|
98
|
+
shareclass?: DecafShareClassId;
|
|
99
99
|
date: SDate;
|
|
100
100
|
ccy: CurrencyCode;
|
|
101
101
|
shares?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { customError, decimalFromNullable, Left, Maybe, Right, sanitizedNonEmptyText, unsafeDecimal, zero, } from '@telostat/prelude';
|
|
2
2
|
import { recompileBaseValuationReport } from './-remote-valuation-report-shared';
|
|
3
3
|
/**
|
|
4
4
|
* Attempts to retrieve remote portfolio valuation report.
|
|
@@ -52,7 +52,7 @@ export function toShareClassValue(x) {
|
|
|
52
52
|
feeScheduleIds: x.shareclass.feeschedules,
|
|
53
53
|
effectiveFeeScheduleId: Maybe.fromNullable(x.shareclass.effectivefeeschedule),
|
|
54
54
|
subscriptionIds: x.shareclass.subscriptions,
|
|
55
|
-
outstanding:
|
|
55
|
+
outstanding: decimalFromNullable(x.shareclass.outstanding),
|
|
56
56
|
},
|
|
57
57
|
external: Maybe.fromNullable(x.external).map((ev) => ({
|
|
58
58
|
id: ev.id,
|
|
@@ -65,36 +65,36 @@ export function toShareClassValue(x) {
|
|
|
65
65
|
shareclass: Maybe.fromNullable(ev.shareclass),
|
|
66
66
|
date: ev.date,
|
|
67
67
|
ccy: ev.ccy,
|
|
68
|
-
shares:
|
|
69
|
-
price:
|
|
70
|
-
nav:
|
|
71
|
-
aum:
|
|
72
|
-
hedgepnl:
|
|
73
|
-
feemngt:
|
|
74
|
-
feeperf:
|
|
75
|
-
otheraccrued:
|
|
76
|
-
totalaccrued:
|
|
77
|
-
subred:
|
|
78
|
-
perfdaily:
|
|
79
|
-
perfweekly:
|
|
80
|
-
perfmonthly:
|
|
81
|
-
perfytd:
|
|
82
|
-
perfstart:
|
|
83
|
-
coefficient:
|
|
68
|
+
shares: decimalFromNullable(ev.shares),
|
|
69
|
+
price: decimalFromNullable(ev.price),
|
|
70
|
+
nav: decimalFromNullable(ev.nav),
|
|
71
|
+
aum: decimalFromNullable(ev.aum),
|
|
72
|
+
hedgepnl: decimalFromNullable(ev.hedgepnl),
|
|
73
|
+
feemngt: decimalFromNullable(ev.feemngt),
|
|
74
|
+
feeperf: decimalFromNullable(ev.feeperf),
|
|
75
|
+
otheraccrued: decimalFromNullable(ev.otheraccrued),
|
|
76
|
+
totalaccrued: decimalFromNullable(ev.totalaccrued),
|
|
77
|
+
subred: decimalFromNullable(ev.subred),
|
|
78
|
+
perfdaily: decimalFromNullable(ev.perfdaily),
|
|
79
|
+
perfweekly: decimalFromNullable(ev.perfweekly),
|
|
80
|
+
perfmonthly: decimalFromNullable(ev.perfmonthly),
|
|
81
|
+
perfytd: decimalFromNullable(ev.perfytd),
|
|
82
|
+
perfstart: decimalFromNullable(ev.perfstart),
|
|
83
|
+
coefficient: decimalFromNullable(ev.coefficient),
|
|
84
84
|
})),
|
|
85
|
-
nav:
|
|
86
|
-
navAdjusted:
|
|
87
|
-
navAdjustedTotal:
|
|
88
|
-
coefficient:
|
|
89
|
-
gavRefccy:
|
|
90
|
-
gavClsccy:
|
|
91
|
-
sharecountPrev:
|
|
92
|
-
sharecountCurr:
|
|
93
|
-
sharecountDiff:
|
|
94
|
-
pxRefCcy:
|
|
95
|
-
pxClsCcy:
|
|
96
|
-
ytdExt:
|
|
97
|
-
ytdInt:
|
|
85
|
+
nav: unsafeDecimal(x.nav),
|
|
86
|
+
navAdjusted: unsafeDecimal(x.nav_adjusted),
|
|
87
|
+
navAdjustedTotal: unsafeDecimal(x.nav_adjusted_total),
|
|
88
|
+
coefficient: unsafeDecimal(x.coefficient),
|
|
89
|
+
gavRefccy: unsafeDecimal(x.gav_refccy),
|
|
90
|
+
gavClsccy: unsafeDecimal(x.gav_clsccy),
|
|
91
|
+
sharecountPrev: unsafeDecimal(x.sharecount_prev),
|
|
92
|
+
sharecountCurr: unsafeDecimal(x.sharecount_curr),
|
|
93
|
+
sharecountDiff: unsafeDecimal(x.sharecount_diff),
|
|
94
|
+
pxRefCcy: decimalFromNullable(x.px_refccy),
|
|
95
|
+
pxClsCcy: decimalFromNullable(x.px_clsccy),
|
|
96
|
+
ytdExt: decimalFromNullable(x.ytdext),
|
|
97
|
+
ytdInt: decimalFromNullable(x.ytdint),
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -113,7 +113,7 @@ export function recompilePortfolioValuationReport(x) {
|
|
|
113
113
|
return {
|
|
114
114
|
...report,
|
|
115
115
|
portfolio: x.portfolio,
|
|
116
|
-
subscriptions:
|
|
116
|
+
subscriptions: decimalFromNullable(x.subscriptions).orDefault(zero),
|
|
117
117
|
shareClassValues: x.scvals.map(toShareClassValue),
|
|
118
118
|
};
|
|
119
119
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomError, Decimal, Either, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
-
import {
|
|
2
|
+
import { CurrencyCode, DateType, DecafArtifactId, DecafArtifactTypeId } from '../../commons';
|
|
3
3
|
import { BaseValuationReport, BaseValuationReportHolding, ValuationReportAccount, ValuationReportAccounts, ValuationReportAccrual, ValuationReportArtifact, ValuationReportFigureOrgRef, ValuationReportHolding } from './-valuation-report-shared';
|
|
4
4
|
export interface RemoteBaseValuationReport {
|
|
5
5
|
reported: SDateTime;
|
|
@@ -161,10 +161,10 @@ export interface RemoteValuationReportChildHolding {
|
|
|
161
161
|
* Valuation artifact.
|
|
162
162
|
*/
|
|
163
163
|
export interface RemoteValuationReportArtifact {
|
|
164
|
-
id:
|
|
164
|
+
id: DecafArtifactId;
|
|
165
165
|
guid: string;
|
|
166
166
|
type: {
|
|
167
|
-
id:
|
|
167
|
+
id: DecafArtifactTypeId;
|
|
168
168
|
name: string;
|
|
169
169
|
order: number;
|
|
170
170
|
};
|
|
@@ -181,7 +181,7 @@ export interface RemoteValuationReportArtifact {
|
|
|
181
181
|
isin?: string;
|
|
182
182
|
figi?: string;
|
|
183
183
|
expiry?: SDate;
|
|
184
|
-
underlying_id?:
|
|
184
|
+
underlying_id?: DecafArtifactId;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* Valuation accrual.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decimalFromNullable, Just, Maybe, Right, safeDiv, sanitizedNonEmptyText, unsafeDecimal, zero, } from '@telostat/prelude';
|
|
2
2
|
export function toArtifact(x) {
|
|
3
3
|
return {
|
|
4
4
|
id: x.id,
|
|
@@ -8,7 +8,7 @@ export function toArtifact(x) {
|
|
|
8
8
|
symbol: x.symbol,
|
|
9
9
|
name: sanitizedNonEmptyText(x.name),
|
|
10
10
|
ccy: Maybe.fromNullable(x.ccy),
|
|
11
|
-
quantity:
|
|
11
|
+
quantity: unsafeDecimal(x.quantity),
|
|
12
12
|
country: sanitizedNonEmptyText(x.country),
|
|
13
13
|
issuer: sanitizedNonEmptyText(x.issuer),
|
|
14
14
|
sector: sanitizedNonEmptyText(x.sector),
|
|
@@ -23,31 +23,34 @@ export function toArtifact(x) {
|
|
|
23
23
|
export function toAccrual(x) {
|
|
24
24
|
return {
|
|
25
25
|
name: x.name,
|
|
26
|
-
value:
|
|
26
|
+
value: unsafeDecimal(x.value),
|
|
27
27
|
accounts: x.accounts.map((y) => ({
|
|
28
28
|
account: y.account,
|
|
29
|
-
value:
|
|
29
|
+
value: unsafeDecimal(y.value),
|
|
30
30
|
accruals: y.accruals.map((z) => ({
|
|
31
31
|
artifact: toArtifact(z.artifact),
|
|
32
32
|
ccy: z.ccy,
|
|
33
|
-
value: {
|
|
33
|
+
value: {
|
|
34
|
+
org: decimalFromNullable(z.value.org).orDefault(zero),
|
|
35
|
+
ref: decimalFromNullable(z.value.ref).orDefault(zero),
|
|
36
|
+
},
|
|
34
37
|
})),
|
|
35
38
|
})),
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
export function toOrgRef(x) {
|
|
39
42
|
return {
|
|
40
|
-
org:
|
|
41
|
-
ref:
|
|
43
|
+
org: decimalFromNullable(x.org).orDefault(zero),
|
|
44
|
+
ref: decimalFromNullable(x.ref).orDefault(zero),
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
export function toMaybeOrgRef(x) {
|
|
45
|
-
return Maybe.fromNullable(x).chain(({ org, ref }) =>
|
|
48
|
+
return Maybe.fromNullable(x).chain(({ org, ref }) => decimalFromNullable(org).chain((o) => decimalFromNullable(ref).chain((r) => Just({ org: o, ref: r }))));
|
|
46
49
|
}
|
|
47
50
|
export function toBaseHolding(nav, x) {
|
|
48
51
|
return {
|
|
49
52
|
artifact: toArtifact(x.artifact),
|
|
50
|
-
quantity:
|
|
53
|
+
quantity: unsafeDecimal(x.quantity),
|
|
51
54
|
investment: {
|
|
52
55
|
px: toOrgRef(x.investment.px),
|
|
53
56
|
txncosts: toMaybeOrgRef(x.investment.txncosts),
|
|
@@ -66,12 +69,12 @@ export function toBaseHolding(nav, x) {
|
|
|
66
69
|
abs: toOrgRef(x.valuation.exposure.abs),
|
|
67
70
|
},
|
|
68
71
|
},
|
|
69
|
-
valuePercentage: safeDiv(
|
|
70
|
-
netExposurePercentage: safeDiv(
|
|
71
|
-
absExposurePercentage: safeDiv(
|
|
72
|
-
change:
|
|
73
|
-
pnl:
|
|
74
|
-
pnlToInvestment:
|
|
72
|
+
valuePercentage: safeDiv(decimalFromNullable(x.valuation.value.net.ref).orDefault(zero), nav),
|
|
73
|
+
netExposurePercentage: safeDiv(decimalFromNullable(x.valuation.exposure.net.ref).orDefault(zero), nav),
|
|
74
|
+
absExposurePercentage: safeDiv(decimalFromNullable(x.valuation.exposure.abs.ref).orDefault(zero), nav),
|
|
75
|
+
change: decimalFromNullable(x.change),
|
|
76
|
+
pnl: decimalFromNullable(x.pnl).orDefault(zero),
|
|
77
|
+
pnlToInvestment: decimalFromNullable(x.pnl_to_investment),
|
|
75
78
|
opendate: x.opendate,
|
|
76
79
|
lastdate: x.lastdate,
|
|
77
80
|
};
|
|
@@ -98,7 +101,7 @@ export function toHolding(nav, x) {
|
|
|
98
101
|
* report.
|
|
99
102
|
*/
|
|
100
103
|
export function recompileBaseValuationReport(x) {
|
|
101
|
-
const nav =
|
|
104
|
+
const nav = decimalFromNullable(x.nav).orDefault(zero);
|
|
102
105
|
const report = {
|
|
103
106
|
asof: x.reported,
|
|
104
107
|
date: x.asof,
|
|
@@ -107,20 +110,20 @@ export function recompileBaseValuationReport(x) {
|
|
|
107
110
|
accounts: x.accounts,
|
|
108
111
|
holdings: x.holdings.map((rh) => toHolding(nav, rh)),
|
|
109
112
|
accruals: x.accruals.map(toAccrual),
|
|
110
|
-
fxRates: x.fxrates.map((r) => ({ ccy1: r.ccy1, ccy2: r.ccy2, value:
|
|
113
|
+
fxRates: x.fxrates.map((r) => ({ ccy1: r.ccy1, ccy2: r.ccy2, value: unsafeDecimal(r.value), asof: r.asof })),
|
|
111
114
|
figures: {
|
|
112
|
-
investment:
|
|
115
|
+
investment: decimalFromNullable(x.investment).orDefault(zero),
|
|
113
116
|
valuation: {
|
|
114
|
-
net:
|
|
115
|
-
abs:
|
|
117
|
+
net: decimalFromNullable(x.valuation_net).orDefault(zero),
|
|
118
|
+
abs: decimalFromNullable(x.valuation_abs).orDefault(zero),
|
|
116
119
|
},
|
|
117
|
-
accrued:
|
|
118
|
-
liabilities:
|
|
119
|
-
gav:
|
|
120
|
+
accrued: decimalFromNullable(x.accrued).orDefault(zero),
|
|
121
|
+
liabilities: decimalFromNullable(x.liabilities).orDefault(zero),
|
|
122
|
+
gav: decimalFromNullable(x.gav).orDefault(zero),
|
|
120
123
|
nav,
|
|
121
|
-
aum:
|
|
122
|
-
pnl:
|
|
123
|
-
pnlToInvestment:
|
|
124
|
+
aum: decimalFromNullable(x.aum).orDefault(zero),
|
|
125
|
+
pnl: decimalFromNullable(x.pnl).orDefault(zero),
|
|
126
|
+
pnlToInvestment: decimalFromNullable(x.pnl_to_investment),
|
|
124
127
|
},
|
|
125
128
|
};
|
|
126
129
|
return Right(report);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
|
|
2
|
-
import { Just, Maybe, Nothing } from 'purify-ts';
|
|
3
|
-
import { List } from 'purify-ts/List';
|
|
1
|
+
import { Just, List, Maybe, Nothing, safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
|
|
4
2
|
import { compareStringArrays } from './-utils';
|
|
5
3
|
export function makeValuationReportHoldingsTreeNodeValue() {
|
|
6
4
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
-
import {
|
|
2
|
+
import { DecafActionId, CurrencyCode, DecafExternalValuationId, DecafOhlcSeriesId, DecafPortfolioId, DecafPrincipalId, DecafShareClassFeeScheduleId, DecafShareClassId } from '../../commons';
|
|
3
3
|
import { BaseValuationReport, ValuationReportPortfolio } from './-valuation-report-shared';
|
|
4
4
|
export interface PortfolioValuationReport extends BaseValuationReport {
|
|
5
5
|
portfolio: ValuationReportPortfolio;
|
|
@@ -24,13 +24,13 @@ export interface PortfolioValuationReportShareClassValue {
|
|
|
24
24
|
ytdInt: Maybe<Decimal>;
|
|
25
25
|
}
|
|
26
26
|
export interface PortfolioValuationReportShareClass {
|
|
27
|
-
id:
|
|
27
|
+
id: DecafShareClassId;
|
|
28
28
|
created: SDateTime;
|
|
29
|
-
creator: Maybe<
|
|
29
|
+
creator: Maybe<DecafPrincipalId>;
|
|
30
30
|
updated: SDateTime;
|
|
31
|
-
updater: Maybe<
|
|
31
|
+
updater: Maybe<DecafPrincipalId>;
|
|
32
32
|
guid: string;
|
|
33
|
-
portfolio:
|
|
33
|
+
portfolio: DecafPortfolioId;
|
|
34
34
|
name: string;
|
|
35
35
|
currency: CurrencyCode;
|
|
36
36
|
isin: Maybe<string>;
|
|
@@ -42,22 +42,22 @@ export interface PortfolioValuationReportShareClass {
|
|
|
42
42
|
subscriptionRedemptionPeriod: Maybe<string>;
|
|
43
43
|
managementFeeFrequency: Maybe<number>;
|
|
44
44
|
performanceFeeFrequency: Maybe<number>;
|
|
45
|
-
benchmark: Maybe<
|
|
45
|
+
benchmark: Maybe<DecafOhlcSeriesId>;
|
|
46
46
|
description: Maybe<string>;
|
|
47
|
-
feeScheduleIds:
|
|
48
|
-
effectiveFeeScheduleId: Maybe<
|
|
49
|
-
subscriptionIds:
|
|
47
|
+
feeScheduleIds: DecafShareClassFeeScheduleId[];
|
|
48
|
+
effectiveFeeScheduleId: Maybe<DecafShareClassFeeScheduleId>;
|
|
49
|
+
subscriptionIds: DecafActionId[];
|
|
50
50
|
outstanding: Maybe<Decimal>;
|
|
51
51
|
}
|
|
52
52
|
export interface PortfolioValuationReportExternalValue {
|
|
53
|
-
id:
|
|
53
|
+
id: DecafExternalValuationId;
|
|
54
54
|
created: SDateTime;
|
|
55
|
-
creator: Maybe<
|
|
55
|
+
creator: Maybe<DecafPrincipalId>;
|
|
56
56
|
updated: SDateTime;
|
|
57
|
-
updater: Maybe<
|
|
57
|
+
updater: Maybe<DecafPrincipalId>;
|
|
58
58
|
guid: string;
|
|
59
|
-
portfolio:
|
|
60
|
-
shareclass: Maybe<
|
|
59
|
+
portfolio: DecafPortfolioId;
|
|
60
|
+
shareclass: Maybe<DecafShareClassId>;
|
|
61
61
|
date: SDate;
|
|
62
62
|
ccy: CurrencyCode;
|
|
63
63
|
shares: Maybe<Decimal>;
|