@decafhub/decaf-client-extras 0.4.0 → 0.5.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/.github/workflows/test.yml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +23 -0
- package/es/reports/valuation/-remote-valuation-report-account.d.ts +150 -0
- package/es/reports/valuation/-remote-valuation-report-account.js +135 -0
- package/es/reports/valuation/-valuation-report-account.d.ts +79 -0
- package/es/reports/valuation/-valuation-report-account.js +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +2 -2
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +5 -3
- package/es/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +3 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +6 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.js +29 -0
- package/es/reports/valuation/index.d.ts +3 -0
- package/es/reports/valuation/index.js +2 -0
- package/package.json +1 -1
- package/release-please-config.json +1 -0
- package/reports/valuation/-remote-valuation-report-account.d.ts +150 -0
- package/reports/valuation/-remote-valuation-report-account.js +196 -0
- package/reports/valuation/-valuation-report-account.d.ts +79 -0
- package/reports/valuation/-valuation-report-account.js +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +2 -2
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +5 -2
- package/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +3 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +6 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.js +59 -1
- package/reports/valuation/index.d.ts +3 -0
- package/reports/valuation/index.js +4 -1
- package/src/{index.test.ts → reports/index.test.ts} +70 -4
- package/src/reports/valuation/-remote-valuation-report-account.ts +297 -0
- package/src/reports/valuation/-valuation-report-account.ts +92 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +12 -4
- package/src/reports/valuation/-valuation-report-holdings-tree/-types.ts +10 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-utils.ts +43 -0
- package/src/reports/valuation/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.1](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.5.0...v0.5.1) (2024-08-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* make grouping option configurable for holdings tree function ([ae97991](https://github.com/teloscube/decaf-client-javascript-extras/commit/ae97991f23393d04d85f782baedbd635a247db88))
|
|
9
|
+
|
|
10
|
+
## [0.5.0](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.4.0...v0.5.0) (2024-08-14)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* drop support for Node 16 and add Node 22
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* implement account valuation report ([26cb078](https://github.com/teloscube/decaf-client-javascript-extras/commit/26cb078a3e9a13811366be1f22b25326bdc79fa9))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Miscellaneous Chores
|
|
23
|
+
|
|
24
|
+
* drop support for Node 16 and add Node 22 ([e23f398](https://github.com/teloscube/decaf-client-javascript-extras/commit/e23f398d19e1c95630e690ed8323e0561afae787))
|
|
25
|
+
|
|
3
26
|
## [0.4.0](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.3.0...v0.4.0) (2024-03-28)
|
|
4
27
|
|
|
5
28
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { DecafClient } from '@decafhub/decaf-client';
|
|
2
|
+
import { CustomError, Either, SDate, SDateTime } from '@telostat/prelude';
|
|
3
|
+
import { CurrencyCode, DateType, DecafAccountId, DecafActionId, DecafExternalValuationId, DecafOhlcSeriesId, DecafPortfolioId, DecafPrincipalId, DecafShareClassFeeScheduleId, DecafShareClassId } from '../../commons';
|
|
4
|
+
import { RemoteBaseValuationReport } from './-remote-valuation-report-shared';
|
|
5
|
+
import { ValuationReportAccount } from './-valuation-report-shared';
|
|
6
|
+
import { AccountValuationReport, AccountValuationReportShareClassValue } from './-valuation-report-account';
|
|
7
|
+
/**
|
|
8
|
+
* Remote account valuation report query type.
|
|
9
|
+
*/
|
|
10
|
+
export interface AccountValuationReportQuery {
|
|
11
|
+
/**
|
|
12
|
+
* Date of valuation report.
|
|
13
|
+
*/
|
|
14
|
+
date: SDate;
|
|
15
|
+
/**
|
|
16
|
+
* Date type of the valuation report.
|
|
17
|
+
*/
|
|
18
|
+
dateType: DateType;
|
|
19
|
+
/**
|
|
20
|
+
* Reference currency of the valuation report.
|
|
21
|
+
*/
|
|
22
|
+
currency: CurrencyCode;
|
|
23
|
+
/**
|
|
24
|
+
* Account the valuation report is requested for.
|
|
25
|
+
*/
|
|
26
|
+
account: DecafAccountId;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Type definition for the remote (raw) account valuation report data.
|
|
30
|
+
*/
|
|
31
|
+
export interface RemoteAccountValuationReport extends RemoteBaseValuationReport {
|
|
32
|
+
account: ValuationReportAccount;
|
|
33
|
+
scvals: RemoteValuationShareClassValue[];
|
|
34
|
+
subscriptions?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type definition for share class valuation on the remote account valuation
|
|
38
|
+
* report.
|
|
39
|
+
*/
|
|
40
|
+
export interface RemoteValuationShareClassValue {
|
|
41
|
+
shareclass?: RemoteValuationShareClass;
|
|
42
|
+
external?: RemoteValuationExternalValue;
|
|
43
|
+
nav: number;
|
|
44
|
+
nav_adjusted: number;
|
|
45
|
+
nav_adjusted_total: number;
|
|
46
|
+
coefficient: number;
|
|
47
|
+
gav_refccy: number;
|
|
48
|
+
gav_clsccy: number;
|
|
49
|
+
sharecount_prev: number;
|
|
50
|
+
sharecount_curr: number;
|
|
51
|
+
sharecount_diff: number;
|
|
52
|
+
px_refccy: number;
|
|
53
|
+
px_clsccy: number;
|
|
54
|
+
ytdext?: number;
|
|
55
|
+
ytdint?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Type definition for share class on the remote account valuation report.
|
|
59
|
+
*/
|
|
60
|
+
export interface RemoteValuationShareClass {
|
|
61
|
+
id: DecafShareClassId;
|
|
62
|
+
created: SDateTime;
|
|
63
|
+
creator: DecafPrincipalId;
|
|
64
|
+
updated: SDateTime;
|
|
65
|
+
updater: DecafPrincipalId;
|
|
66
|
+
guid: string;
|
|
67
|
+
portfolio: DecafPortfolioId;
|
|
68
|
+
name: string;
|
|
69
|
+
currency: CurrencyCode;
|
|
70
|
+
isin?: string;
|
|
71
|
+
bbgticker?: string;
|
|
72
|
+
liquidity?: string;
|
|
73
|
+
jurisdiction?: string;
|
|
74
|
+
administrator?: string;
|
|
75
|
+
mininvestment?: number;
|
|
76
|
+
subredperiod?: string;
|
|
77
|
+
freqmngt?: number;
|
|
78
|
+
freqperf?: number;
|
|
79
|
+
benchmark?: DecafOhlcSeriesId;
|
|
80
|
+
description?: string;
|
|
81
|
+
feeschedules: DecafShareClassFeeScheduleId[];
|
|
82
|
+
effectivefeeschedule?: DecafShareClassFeeScheduleId;
|
|
83
|
+
subscriptions: DecafActionId[];
|
|
84
|
+
outstanding?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Type definition for external valuation on the remote account valuation
|
|
88
|
+
* report.
|
|
89
|
+
*/
|
|
90
|
+
export interface RemoteValuationExternalValue {
|
|
91
|
+
id: DecafExternalValuationId;
|
|
92
|
+
created: SDateTime;
|
|
93
|
+
creator: DecafPrincipalId;
|
|
94
|
+
updated: SDateTime;
|
|
95
|
+
updater: DecafPrincipalId;
|
|
96
|
+
guid: string;
|
|
97
|
+
portfolio: DecafPortfolioId;
|
|
98
|
+
shareclass?: DecafShareClassId;
|
|
99
|
+
date: SDate;
|
|
100
|
+
ccy: CurrencyCode;
|
|
101
|
+
shares?: number;
|
|
102
|
+
price?: number;
|
|
103
|
+
nav?: number;
|
|
104
|
+
aum?: number;
|
|
105
|
+
hedgepnl?: number;
|
|
106
|
+
feemngt?: number;
|
|
107
|
+
feeperf?: number;
|
|
108
|
+
otheraccrued?: number;
|
|
109
|
+
totalaccrued?: number;
|
|
110
|
+
subred?: number;
|
|
111
|
+
perfdaily?: number;
|
|
112
|
+
perfweekly?: number;
|
|
113
|
+
perfmonthly?: number;
|
|
114
|
+
perfytd?: number;
|
|
115
|
+
perfstart?: number;
|
|
116
|
+
coefficient?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Attempts to retrieve remote account valuation report.
|
|
120
|
+
*
|
|
121
|
+
* @param client DECAF Barista client.
|
|
122
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
123
|
+
* @returns Remote (raw) account valuation report data.
|
|
124
|
+
*/
|
|
125
|
+
export declare function fetchRemoteAccountValuationReport(client: DecafClient, query: AccountValuationReportQuery): Promise<Either<CustomError, RemoteAccountValuationReport>>;
|
|
126
|
+
/**
|
|
127
|
+
* Attempts to recompile remote valuation report share class value.
|
|
128
|
+
*
|
|
129
|
+
* @param x remote valuation report share class value object.
|
|
130
|
+
* @return Recompiled valuation report share class value object.
|
|
131
|
+
*/
|
|
132
|
+
export declare function toShareClassValue(s: RemoteValuationShareClassValue): AccountValuationReportShareClassValue;
|
|
133
|
+
/**
|
|
134
|
+
* Attempts to re-compile the raw, remote account valuation report and
|
|
135
|
+
* return it.
|
|
136
|
+
*
|
|
137
|
+
* @param x Raw, remote account valuation report.
|
|
138
|
+
* @returns Either of an error message or the re-compiled account valuation
|
|
139
|
+
* report.
|
|
140
|
+
*/
|
|
141
|
+
export declare function recompileAccountValuationReport(x: RemoteAccountValuationReport): Either<CustomError, AccountValuationReport>;
|
|
142
|
+
/**
|
|
143
|
+
* Attempts to retrieve remote account valuation report, compiles it to
|
|
144
|
+
* {@link AccountValuationReport} and return it.
|
|
145
|
+
*
|
|
146
|
+
* @param client DECAF Barista client.
|
|
147
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
148
|
+
* @returns Recompiled account valuation report data.
|
|
149
|
+
*/
|
|
150
|
+
export declare function fetchAccountValuationReport(client: DecafClient, query: AccountValuationReportQuery): Promise<Either<CustomError, AccountValuationReport>>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { customError, decimalFromNullable, Left, Maybe, Right, sanitizedNonEmptyText, unsafeDecimal, zero, } from '@telostat/prelude';
|
|
2
|
+
import { recompileBaseValuationReport } from './-remote-valuation-report-shared';
|
|
3
|
+
/**
|
|
4
|
+
* Attempts to retrieve remote account valuation report.
|
|
5
|
+
*
|
|
6
|
+
* @param client DECAF Barista client.
|
|
7
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
8
|
+
* @returns Remote (raw) account valuation report data.
|
|
9
|
+
*/
|
|
10
|
+
export async function fetchRemoteAccountValuationReport(client, query) {
|
|
11
|
+
return client.barista
|
|
12
|
+
.get('/reports/valuation/account/', {
|
|
13
|
+
params: {
|
|
14
|
+
ccy: query.currency,
|
|
15
|
+
date: query.date,
|
|
16
|
+
type: query.dateType,
|
|
17
|
+
account: `${query.account}`,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
.then((x) => Right(x.data))
|
|
21
|
+
.catch((err) => Left(customError('Error while attempting to fetch remote account valuation report', err)));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Attempts to recompile remote valuation report share class value.
|
|
25
|
+
*
|
|
26
|
+
* @param x remote valuation report share class value object.
|
|
27
|
+
* @return Recompiled valuation report share class value object.
|
|
28
|
+
*/
|
|
29
|
+
export function toShareClassValue(s) {
|
|
30
|
+
const shareclass = Maybe.fromNullable(s.shareclass).map((x) => ({
|
|
31
|
+
id: x.id,
|
|
32
|
+
created: x.created,
|
|
33
|
+
creator: Maybe.fromNullable(x.creator),
|
|
34
|
+
updated: x.updated,
|
|
35
|
+
updater: Maybe.fromNullable(x.updater),
|
|
36
|
+
guid: x.guid,
|
|
37
|
+
portfolio: x.portfolio,
|
|
38
|
+
name: x.name,
|
|
39
|
+
currency: x.currency,
|
|
40
|
+
isin: sanitizedNonEmptyText(x.isin),
|
|
41
|
+
bbgticker: sanitizedNonEmptyText(x.bbgticker),
|
|
42
|
+
liquidity: sanitizedNonEmptyText(x.liquidity),
|
|
43
|
+
jurisdiction: sanitizedNonEmptyText(x.jurisdiction),
|
|
44
|
+
administrator: sanitizedNonEmptyText(x.administrator),
|
|
45
|
+
minimumInvestment: Maybe.fromNullable(x.mininvestment),
|
|
46
|
+
subscriptionRedemptionPeriod: sanitizedNonEmptyText(x.subredperiod),
|
|
47
|
+
managementFeeFrequency: Maybe.fromNullable(x.freqmngt),
|
|
48
|
+
performanceFeeFrequency: Maybe.fromNullable(x.freqperf),
|
|
49
|
+
benchmark: Maybe.fromNullable(x.benchmark),
|
|
50
|
+
description: sanitizedNonEmptyText(x.description),
|
|
51
|
+
feeScheduleIds: x.feeschedules,
|
|
52
|
+
effectiveFeeScheduleId: Maybe.fromNullable(x.effectivefeeschedule),
|
|
53
|
+
subscriptionIds: x.subscriptions,
|
|
54
|
+
outstanding: decimalFromNullable(x.outstanding),
|
|
55
|
+
}));
|
|
56
|
+
return {
|
|
57
|
+
shareclass,
|
|
58
|
+
external: Maybe.fromNullable(s.external).map((ev) => ({
|
|
59
|
+
id: ev.id,
|
|
60
|
+
created: ev.created,
|
|
61
|
+
creator: Maybe.fromNullable(ev.updater),
|
|
62
|
+
updated: ev.updated,
|
|
63
|
+
updater: Maybe.fromNullable(ev.updater),
|
|
64
|
+
guid: ev.guid,
|
|
65
|
+
portfolio: ev.portfolio,
|
|
66
|
+
shareclass: Maybe.fromNullable(ev.shareclass),
|
|
67
|
+
date: ev.date,
|
|
68
|
+
ccy: ev.ccy,
|
|
69
|
+
shares: decimalFromNullable(ev.shares),
|
|
70
|
+
price: decimalFromNullable(ev.price),
|
|
71
|
+
nav: decimalFromNullable(ev.nav),
|
|
72
|
+
aum: decimalFromNullable(ev.aum),
|
|
73
|
+
hedgepnl: decimalFromNullable(ev.hedgepnl),
|
|
74
|
+
feemngt: decimalFromNullable(ev.feemngt),
|
|
75
|
+
feeperf: decimalFromNullable(ev.feeperf),
|
|
76
|
+
otheraccrued: decimalFromNullable(ev.otheraccrued),
|
|
77
|
+
totalaccrued: decimalFromNullable(ev.totalaccrued),
|
|
78
|
+
subred: decimalFromNullable(ev.subred),
|
|
79
|
+
perfdaily: decimalFromNullable(ev.perfdaily),
|
|
80
|
+
perfweekly: decimalFromNullable(ev.perfweekly),
|
|
81
|
+
perfmonthly: decimalFromNullable(ev.perfmonthly),
|
|
82
|
+
perfytd: decimalFromNullable(ev.perfytd),
|
|
83
|
+
perfstart: decimalFromNullable(ev.perfstart),
|
|
84
|
+
coefficient: decimalFromNullable(ev.coefficient),
|
|
85
|
+
})),
|
|
86
|
+
nav: unsafeDecimal(s.nav),
|
|
87
|
+
navAdjusted: unsafeDecimal(s.nav_adjusted),
|
|
88
|
+
navAdjustedTotal: unsafeDecimal(s.nav_adjusted_total),
|
|
89
|
+
coefficient: unsafeDecimal(s.coefficient),
|
|
90
|
+
gavRefccy: unsafeDecimal(s.gav_refccy),
|
|
91
|
+
gavClsccy: unsafeDecimal(s.gav_clsccy),
|
|
92
|
+
sharecountPrev: Maybe.fromNullable(s.sharecount_prev).map(unsafeDecimal),
|
|
93
|
+
sharecountCurr: Maybe.fromNullable(s.sharecount_curr).map(unsafeDecimal),
|
|
94
|
+
sharecountDiff: Maybe.fromNullable(s.sharecount_diff).map(unsafeDecimal),
|
|
95
|
+
pxRefCcy: decimalFromNullable(s.px_refccy),
|
|
96
|
+
pxClsCcy: decimalFromNullable(s.px_clsccy),
|
|
97
|
+
ytdExt: decimalFromNullable(s.ytdext),
|
|
98
|
+
ytdInt: decimalFromNullable(s.ytdint),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Attempts to re-compile the raw, remote account valuation report and
|
|
103
|
+
* return it.
|
|
104
|
+
*
|
|
105
|
+
* @param x Raw, remote account valuation report.
|
|
106
|
+
* @returns Either of an error message or the re-compiled account valuation
|
|
107
|
+
* report.
|
|
108
|
+
*/
|
|
109
|
+
export function recompileAccountValuationReport(x) {
|
|
110
|
+
// Attempt to get the base valuation report:
|
|
111
|
+
const baseReport = recompileBaseValuationReport(x);
|
|
112
|
+
// Add consolidated valuation report specific fields and return:
|
|
113
|
+
return baseReport.map((report) => {
|
|
114
|
+
return {
|
|
115
|
+
...report,
|
|
116
|
+
account: x.account,
|
|
117
|
+
subscriptions: decimalFromNullable(x.subscriptions).orDefault(zero),
|
|
118
|
+
shareClassValues: x.scvals.map(toShareClassValue),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Attempts to retrieve remote account valuation report, compiles it to
|
|
124
|
+
* {@link AccountValuationReport} and return it.
|
|
125
|
+
*
|
|
126
|
+
* @param client DECAF Barista client.
|
|
127
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
128
|
+
* @returns Recompiled account valuation report data.
|
|
129
|
+
*/
|
|
130
|
+
export async function fetchAccountValuationReport(client, query) {
|
|
131
|
+
// Attempt to fetch the remote, raw report:
|
|
132
|
+
const rawReport = await fetchRemoteAccountValuationReport(client, query);
|
|
133
|
+
// Attempt to recompile the report (if any) and return:
|
|
134
|
+
return rawReport.chain(recompileAccountValuationReport);
|
|
135
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
+
import { DecafActionId, CurrencyCode, DecafExternalValuationId, DecafOhlcSeriesId, DecafPortfolioId, DecafPrincipalId, DecafShareClassFeeScheduleId, DecafShareClassId } from '../../commons';
|
|
3
|
+
import { BaseValuationReport, ValuationReportAccount } from './-valuation-report-shared';
|
|
4
|
+
export interface AccountValuationReport extends BaseValuationReport {
|
|
5
|
+
account: ValuationReportAccount;
|
|
6
|
+
subscriptions: Decimal;
|
|
7
|
+
shareClassValues: AccountValuationReportShareClassValue[];
|
|
8
|
+
}
|
|
9
|
+
export interface AccountValuationReportShareClassValue {
|
|
10
|
+
shareclass: Maybe<AccountValuationReportShareClass>;
|
|
11
|
+
external: Maybe<AccountValuationReportExternalValue>;
|
|
12
|
+
nav: Decimal;
|
|
13
|
+
navAdjusted: Decimal;
|
|
14
|
+
navAdjustedTotal: Decimal;
|
|
15
|
+
coefficient: Decimal;
|
|
16
|
+
gavRefccy: Decimal;
|
|
17
|
+
gavClsccy: Decimal;
|
|
18
|
+
sharecountPrev: Maybe<Decimal>;
|
|
19
|
+
sharecountCurr: Maybe<Decimal>;
|
|
20
|
+
sharecountDiff: Maybe<Decimal>;
|
|
21
|
+
pxRefCcy: Maybe<Decimal>;
|
|
22
|
+
pxClsCcy: Maybe<Decimal>;
|
|
23
|
+
ytdExt: Maybe<Decimal>;
|
|
24
|
+
ytdInt: Maybe<Decimal>;
|
|
25
|
+
}
|
|
26
|
+
export interface AccountValuationReportShareClass {
|
|
27
|
+
id: DecafShareClassId;
|
|
28
|
+
created: SDateTime;
|
|
29
|
+
creator: Maybe<DecafPrincipalId>;
|
|
30
|
+
updated: SDateTime;
|
|
31
|
+
updater: Maybe<DecafPrincipalId>;
|
|
32
|
+
guid: string;
|
|
33
|
+
portfolio: DecafPortfolioId;
|
|
34
|
+
name: string;
|
|
35
|
+
currency: CurrencyCode;
|
|
36
|
+
isin: Maybe<string>;
|
|
37
|
+
bbgticker: Maybe<string>;
|
|
38
|
+
liquidity: Maybe<string>;
|
|
39
|
+
jurisdiction: Maybe<string>;
|
|
40
|
+
administrator: Maybe<string>;
|
|
41
|
+
minimumInvestment: Maybe<number>;
|
|
42
|
+
subscriptionRedemptionPeriod: Maybe<string>;
|
|
43
|
+
managementFeeFrequency: Maybe<number>;
|
|
44
|
+
performanceFeeFrequency: Maybe<number>;
|
|
45
|
+
benchmark: Maybe<DecafOhlcSeriesId>;
|
|
46
|
+
description: Maybe<string>;
|
|
47
|
+
feeScheduleIds: DecafShareClassFeeScheduleId[];
|
|
48
|
+
effectiveFeeScheduleId: Maybe<DecafShareClassFeeScheduleId>;
|
|
49
|
+
subscriptionIds: DecafActionId[];
|
|
50
|
+
outstanding: Maybe<Decimal>;
|
|
51
|
+
}
|
|
52
|
+
export interface AccountValuationReportExternalValue {
|
|
53
|
+
id: DecafExternalValuationId;
|
|
54
|
+
created: SDateTime;
|
|
55
|
+
creator: Maybe<DecafPrincipalId>;
|
|
56
|
+
updated: SDateTime;
|
|
57
|
+
updater: Maybe<DecafPrincipalId>;
|
|
58
|
+
guid: string;
|
|
59
|
+
portfolio: DecafPortfolioId;
|
|
60
|
+
shareclass: Maybe<DecafShareClassId>;
|
|
61
|
+
date: SDate;
|
|
62
|
+
ccy: CurrencyCode;
|
|
63
|
+
shares: Maybe<Decimal>;
|
|
64
|
+
price: Maybe<Decimal>;
|
|
65
|
+
nav: Maybe<Decimal>;
|
|
66
|
+
aum: Maybe<Decimal>;
|
|
67
|
+
hedgepnl: Maybe<Decimal>;
|
|
68
|
+
feemngt: Maybe<Decimal>;
|
|
69
|
+
feeperf: Maybe<Decimal>;
|
|
70
|
+
otheraccrued: Maybe<Decimal>;
|
|
71
|
+
totalaccrued: Maybe<Decimal>;
|
|
72
|
+
subred: Maybe<Decimal>;
|
|
73
|
+
perfdaily: Maybe<Decimal>;
|
|
74
|
+
perfweekly: Maybe<Decimal>;
|
|
75
|
+
perfmonthly: Maybe<Decimal>;
|
|
76
|
+
perfytd: Maybe<Decimal>;
|
|
77
|
+
perfstart: Maybe<Decimal>;
|
|
78
|
+
coefficient: Maybe<Decimal>;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Decimal } from '@telostat/prelude';
|
|
2
2
|
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
3
|
-
import { ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
|
|
3
|
+
import { AvailableAddresserKeys, ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
|
|
4
4
|
export declare function makeValuationReportHoldingsTreeNodeValue(): ValuationReportHoldingsTreeNodeValue;
|
|
5
5
|
export declare function updateTotals(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNodeValue;
|
|
6
6
|
export declare function resortChildren(node: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNode[];
|
|
7
7
|
export declare function retreatTree(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): void;
|
|
8
8
|
export declare function makeValuationReportHoldingsTreeNode(address: ValuationReportHoldingClassification): ValuationReportHoldingsTreeNode;
|
|
9
9
|
export declare function addValuationReportHoldingToTree(tree: ValuationReportHoldingsTreeNode, address: ValuationReportHoldingClassification, holding: ValuationReportHolding): void;
|
|
10
|
-
export declare function makeValuationReportHoldingsTree(nav: Decimal, investment: Decimal, holdings: ValuationReportHolding[]): ValuationReportHoldingsTreeNode;
|
|
10
|
+
export declare function makeValuationReportHoldingsTree(nav: Decimal, investment: Decimal, holdings: ValuationReportHolding[], addressKey?: AvailableAddresserKeys): ValuationReportHoldingsTreeNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Just, List, Maybe, Nothing, safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
|
|
2
|
-
import { compareStringArrays } from './-utils';
|
|
2
|
+
import { addressers, compareStringArrays } from './-utils';
|
|
3
3
|
export function makeValuationReportHoldingsTreeNodeValue() {
|
|
4
4
|
return {
|
|
5
5
|
investment: zero,
|
|
@@ -102,13 +102,15 @@ export function addValuationReportHoldingToTree(tree, address, holding) {
|
|
|
102
102
|
// Done, we append the holding to the current node and return from the procedure:
|
|
103
103
|
node.holdings.push(holding);
|
|
104
104
|
}
|
|
105
|
-
export function makeValuationReportHoldingsTree(nav, investment, holdings) {
|
|
105
|
+
export function makeValuationReportHoldingsTree(nav, investment, holdings, addressKey = 'classification') {
|
|
106
106
|
// Initialize the tree:
|
|
107
107
|
const tree = makeValuationReportHoldingsTreeNode([]);
|
|
108
108
|
tree.name = '« Total »';
|
|
109
109
|
// Iterate over the holdings and attempt to add to the tree:
|
|
110
110
|
for (const holding of holdings) {
|
|
111
|
-
|
|
111
|
+
// Get the address of the holding:
|
|
112
|
+
const address = addressers[addressKey](holding);
|
|
113
|
+
addValuationReportHoldingToTree(tree, address, holding);
|
|
112
114
|
}
|
|
113
115
|
// Retreat the tree:
|
|
114
116
|
retreatTree(nav, investment, tree);
|
|
@@ -21,3 +21,6 @@ export interface ValuationReportHoldingsTreeNodeValue {
|
|
|
21
21
|
pnl: Decimal;
|
|
22
22
|
pnlRatio: Decimal;
|
|
23
23
|
}
|
|
24
|
+
export type HoldingAddress = ValuationReportHoldingClassification;
|
|
25
|
+
export type HoldingAddresser = (holding: ValuationReportHolding) => HoldingAddress;
|
|
26
|
+
export type AvailableAddresserKeys = 'classification' | 'currency' | 'country' | 'issuer' | 'sector';
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
import { Maybe } from '@telostat/prelude';
|
|
2
|
+
import { ValuationReportHolding } from '../-valuation-report-shared';
|
|
3
|
+
import { AvailableAddresserKeys, HoldingAddresser } from './-types';
|
|
1
4
|
export declare function compareStringArrays(x: string[], y: string[]): number;
|
|
5
|
+
export declare function composeHoldingAddressers(addressers: Array<HoldingAddresser>): HoldingAddresser;
|
|
6
|
+
export declare function makeSimpleAddresser(def: string, labeler: (holding: ValuationReportHolding) => Maybe<string>): HoldingAddresser;
|
|
7
|
+
export declare const addressers: Record<AvailableAddresserKeys, HoldingAddresser>;
|
|
@@ -10,3 +10,32 @@ export function compareStringArrays(x, y) {
|
|
|
10
10
|
}
|
|
11
11
|
return Math.sign(xLen - yLen);
|
|
12
12
|
}
|
|
13
|
+
export function composeHoldingAddressers(addressers) {
|
|
14
|
+
return (holding) => addressers.reduce((p, c) => [...p, ...c(holding)], []);
|
|
15
|
+
}
|
|
16
|
+
export function makeSimpleAddresser(def, labeler) {
|
|
17
|
+
return (holding) => {
|
|
18
|
+
// Attempt to get the label:
|
|
19
|
+
const label = labeler(holding).orDefault('') || def;
|
|
20
|
+
// Get the value:
|
|
21
|
+
const value = label.toUpperCase();
|
|
22
|
+
// Done, return:
|
|
23
|
+
return [{ name: value, order: value }];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export const addressers = {
|
|
27
|
+
classification: (holding) => {
|
|
28
|
+
// Get the classification:
|
|
29
|
+
const classification = holding.classification;
|
|
30
|
+
// Build the address and return:
|
|
31
|
+
return classification.map((x) => ({
|
|
32
|
+
// label: x.name,
|
|
33
|
+
name: x.name.toUpperCase(),
|
|
34
|
+
order: `${x.order}`.toUpperCase(),
|
|
35
|
+
}));
|
|
36
|
+
},
|
|
37
|
+
currency: makeSimpleAddresser('[Undefined Currency]', (holding) => holding.artifact.ccy),
|
|
38
|
+
country: makeSimpleAddresser('[Undefined Country]', (holding) => holding.artifact.country),
|
|
39
|
+
issuer: makeSimpleAddresser('[Undefined Issuer]', (holding) => holding.artifact.issuer),
|
|
40
|
+
sector: makeSimpleAddresser('[Undefined Sector]', (holding) => holding.artifact.sector),
|
|
41
|
+
};
|
|
@@ -2,7 +2,10 @@ export { fetchConsolidatedValuationReport } from './-remote-valuation-report-con
|
|
|
2
2
|
export type { ConsolidatedValuationReportQuery } from './-remote-valuation-report-consolidated';
|
|
3
3
|
export { fetchPortfolioValuationReport } from './-remote-valuation-report-portfolio';
|
|
4
4
|
export type { PortfolioValuationReportQuery } from './-remote-valuation-report-portfolio';
|
|
5
|
+
export { fetchAccountValuationReport } from './-remote-valuation-report-account';
|
|
6
|
+
export type { AccountValuationReportQuery } from './-remote-valuation-report-account';
|
|
5
7
|
export * from './-valuation-report-consolidated';
|
|
6
8
|
export * from './-valuation-report-holdings-tree';
|
|
7
9
|
export * from './-valuation-report-portfolio';
|
|
8
10
|
export * from './-valuation-report-shared';
|
|
11
|
+
export * from './-valuation-report-account';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { fetchConsolidatedValuationReport } from './-remote-valuation-report-consolidated';
|
|
2
2
|
export { fetchPortfolioValuationReport } from './-remote-valuation-report-portfolio';
|
|
3
|
+
export { fetchAccountValuationReport } from './-remote-valuation-report-account';
|
|
3
4
|
export * from './-valuation-report-consolidated';
|
|
4
5
|
export * from './-valuation-report-holdings-tree';
|
|
5
6
|
export * from './-valuation-report-portfolio';
|
|
6
7
|
export * from './-valuation-report-shared';
|
|
8
|
+
export * from './-valuation-report-account';
|
package/package.json
CHANGED