@decafhub/decaf-client-extras 0.4.0 → 0.5.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/.github/workflows/test.yml +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +16 -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/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/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/index.ts +3 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { DecafClient } from '@decafhub/decaf-client';
|
|
2
|
+
import {
|
|
3
|
+
CustomError,
|
|
4
|
+
customError,
|
|
5
|
+
decimalFromNullable,
|
|
6
|
+
Either,
|
|
7
|
+
Left,
|
|
8
|
+
Maybe,
|
|
9
|
+
Right,
|
|
10
|
+
sanitizedNonEmptyText,
|
|
11
|
+
SDate,
|
|
12
|
+
SDateTime,
|
|
13
|
+
unsafeDecimal,
|
|
14
|
+
zero,
|
|
15
|
+
} from '@telostat/prelude';
|
|
16
|
+
import {
|
|
17
|
+
CurrencyCode,
|
|
18
|
+
DateType,
|
|
19
|
+
DecafAccountId,
|
|
20
|
+
DecafActionId,
|
|
21
|
+
DecafExternalValuationId,
|
|
22
|
+
DecafOhlcSeriesId,
|
|
23
|
+
DecafPortfolioId,
|
|
24
|
+
DecafPrincipalId,
|
|
25
|
+
DecafShareClassFeeScheduleId,
|
|
26
|
+
DecafShareClassId,
|
|
27
|
+
} from '../../commons';
|
|
28
|
+
import { recompileBaseValuationReport, RemoteBaseValuationReport } from './-remote-valuation-report-shared';
|
|
29
|
+
import { ValuationReportAccount } from './-valuation-report-shared';
|
|
30
|
+
import { AccountValuationReport, AccountValuationReportShareClassValue } from './-valuation-report-account';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Remote account valuation report query type.
|
|
34
|
+
*/
|
|
35
|
+
export interface AccountValuationReportQuery {
|
|
36
|
+
/**
|
|
37
|
+
* Date of valuation report.
|
|
38
|
+
*/
|
|
39
|
+
date: SDate;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Date type of the valuation report.
|
|
43
|
+
*/
|
|
44
|
+
dateType: DateType;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reference currency of the valuation report.
|
|
48
|
+
*/
|
|
49
|
+
currency: CurrencyCode;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Account the valuation report is requested for.
|
|
53
|
+
*/
|
|
54
|
+
account: DecafAccountId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Type definition for the remote (raw) account valuation report data.
|
|
59
|
+
*/
|
|
60
|
+
export interface RemoteAccountValuationReport extends RemoteBaseValuationReport {
|
|
61
|
+
account: ValuationReportAccount;
|
|
62
|
+
scvals: RemoteValuationShareClassValue[];
|
|
63
|
+
subscriptions?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Type definition for share class valuation on the remote account valuation
|
|
68
|
+
* report.
|
|
69
|
+
*/
|
|
70
|
+
export interface RemoteValuationShareClassValue {
|
|
71
|
+
shareclass?: RemoteValuationShareClass;
|
|
72
|
+
external?: RemoteValuationExternalValue;
|
|
73
|
+
nav: number;
|
|
74
|
+
nav_adjusted: number;
|
|
75
|
+
nav_adjusted_total: number;
|
|
76
|
+
coefficient: number;
|
|
77
|
+
gav_refccy: number;
|
|
78
|
+
gav_clsccy: number;
|
|
79
|
+
sharecount_prev: number;
|
|
80
|
+
sharecount_curr: number;
|
|
81
|
+
sharecount_diff: number;
|
|
82
|
+
px_refccy: number;
|
|
83
|
+
px_clsccy: number;
|
|
84
|
+
ytdext?: number;
|
|
85
|
+
ytdint?: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Type definition for share class on the remote account valuation report.
|
|
90
|
+
*/
|
|
91
|
+
export interface RemoteValuationShareClass {
|
|
92
|
+
id: DecafShareClassId;
|
|
93
|
+
created: SDateTime;
|
|
94
|
+
creator: DecafPrincipalId;
|
|
95
|
+
updated: SDateTime;
|
|
96
|
+
updater: DecafPrincipalId;
|
|
97
|
+
guid: string;
|
|
98
|
+
portfolio: DecafPortfolioId;
|
|
99
|
+
name: string;
|
|
100
|
+
currency: CurrencyCode;
|
|
101
|
+
isin?: string;
|
|
102
|
+
bbgticker?: string;
|
|
103
|
+
liquidity?: string;
|
|
104
|
+
jurisdiction?: string;
|
|
105
|
+
administrator?: string;
|
|
106
|
+
mininvestment?: number;
|
|
107
|
+
subredperiod?: string;
|
|
108
|
+
freqmngt?: number;
|
|
109
|
+
freqperf?: number;
|
|
110
|
+
benchmark?: DecafOhlcSeriesId;
|
|
111
|
+
description?: string;
|
|
112
|
+
feeschedules: DecafShareClassFeeScheduleId[];
|
|
113
|
+
effectivefeeschedule?: DecafShareClassFeeScheduleId;
|
|
114
|
+
subscriptions: DecafActionId[];
|
|
115
|
+
outstanding?: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Type definition for external valuation on the remote account valuation
|
|
120
|
+
* report.
|
|
121
|
+
*/
|
|
122
|
+
export interface RemoteValuationExternalValue {
|
|
123
|
+
id: DecafExternalValuationId;
|
|
124
|
+
created: SDateTime;
|
|
125
|
+
creator: DecafPrincipalId;
|
|
126
|
+
updated: SDateTime;
|
|
127
|
+
updater: DecafPrincipalId;
|
|
128
|
+
guid: string;
|
|
129
|
+
portfolio: DecafPortfolioId;
|
|
130
|
+
shareclass?: DecafShareClassId;
|
|
131
|
+
date: SDate;
|
|
132
|
+
ccy: CurrencyCode;
|
|
133
|
+
shares?: number;
|
|
134
|
+
price?: number;
|
|
135
|
+
nav?: number;
|
|
136
|
+
aum?: number;
|
|
137
|
+
hedgepnl?: number;
|
|
138
|
+
feemngt?: number;
|
|
139
|
+
feeperf?: number;
|
|
140
|
+
otheraccrued?: number;
|
|
141
|
+
totalaccrued?: number;
|
|
142
|
+
subred?: number;
|
|
143
|
+
perfdaily?: number;
|
|
144
|
+
perfweekly?: number;
|
|
145
|
+
perfmonthly?: number;
|
|
146
|
+
perfytd?: number;
|
|
147
|
+
perfstart?: number;
|
|
148
|
+
coefficient?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Attempts to retrieve remote account valuation report.
|
|
153
|
+
*
|
|
154
|
+
* @param client DECAF Barista client.
|
|
155
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
156
|
+
* @returns Remote (raw) account valuation report data.
|
|
157
|
+
*/
|
|
158
|
+
export async function fetchRemoteAccountValuationReport(
|
|
159
|
+
client: DecafClient,
|
|
160
|
+
query: AccountValuationReportQuery
|
|
161
|
+
): Promise<Either<CustomError, RemoteAccountValuationReport>> {
|
|
162
|
+
return client.barista
|
|
163
|
+
.get<RemoteAccountValuationReport>('/reports/valuation/account/', {
|
|
164
|
+
params: {
|
|
165
|
+
ccy: query.currency,
|
|
166
|
+
date: query.date,
|
|
167
|
+
type: query.dateType,
|
|
168
|
+
account: `${query.account}`,
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
.then((x) => Right(x.data))
|
|
172
|
+
.catch((err) => Left(customError('Error while attempting to fetch remote account valuation report', err)));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Attempts to recompile remote valuation report share class value.
|
|
177
|
+
*
|
|
178
|
+
* @param x remote valuation report share class value object.
|
|
179
|
+
* @return Recompiled valuation report share class value object.
|
|
180
|
+
*/
|
|
181
|
+
export function toShareClassValue(s: RemoteValuationShareClassValue): AccountValuationReportShareClassValue {
|
|
182
|
+
const shareclass = Maybe.fromNullable(s.shareclass).map((x) => ({
|
|
183
|
+
id: x.id,
|
|
184
|
+
created: x.created,
|
|
185
|
+
creator: Maybe.fromNullable(x.creator),
|
|
186
|
+
updated: x.updated,
|
|
187
|
+
updater: Maybe.fromNullable(x.updater),
|
|
188
|
+
guid: x.guid,
|
|
189
|
+
portfolio: x.portfolio,
|
|
190
|
+
name: x.name,
|
|
191
|
+
currency: x.currency,
|
|
192
|
+
isin: sanitizedNonEmptyText(x.isin),
|
|
193
|
+
bbgticker: sanitizedNonEmptyText(x.bbgticker),
|
|
194
|
+
liquidity: sanitizedNonEmptyText(x.liquidity),
|
|
195
|
+
jurisdiction: sanitizedNonEmptyText(x.jurisdiction),
|
|
196
|
+
administrator: sanitizedNonEmptyText(x.administrator),
|
|
197
|
+
minimumInvestment: Maybe.fromNullable(x.mininvestment),
|
|
198
|
+
subscriptionRedemptionPeriod: sanitizedNonEmptyText(x.subredperiod),
|
|
199
|
+
managementFeeFrequency: Maybe.fromNullable(x.freqmngt),
|
|
200
|
+
performanceFeeFrequency: Maybe.fromNullable(x.freqperf),
|
|
201
|
+
benchmark: Maybe.fromNullable(x.benchmark),
|
|
202
|
+
description: sanitizedNonEmptyText(x.description),
|
|
203
|
+
feeScheduleIds: x.feeschedules,
|
|
204
|
+
effectiveFeeScheduleId: Maybe.fromNullable(x.effectivefeeschedule),
|
|
205
|
+
subscriptionIds: x.subscriptions,
|
|
206
|
+
outstanding: decimalFromNullable(x.outstanding),
|
|
207
|
+
}));
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
shareclass,
|
|
211
|
+
external: Maybe.fromNullable(s.external).map((ev) => ({
|
|
212
|
+
id: ev.id,
|
|
213
|
+
created: ev.created,
|
|
214
|
+
creator: Maybe.fromNullable(ev.updater),
|
|
215
|
+
updated: ev.updated,
|
|
216
|
+
updater: Maybe.fromNullable(ev.updater),
|
|
217
|
+
guid: ev.guid,
|
|
218
|
+
portfolio: ev.portfolio,
|
|
219
|
+
shareclass: Maybe.fromNullable(ev.shareclass),
|
|
220
|
+
date: ev.date,
|
|
221
|
+
ccy: ev.ccy,
|
|
222
|
+
shares: decimalFromNullable(ev.shares),
|
|
223
|
+
price: decimalFromNullable(ev.price),
|
|
224
|
+
nav: decimalFromNullable(ev.nav),
|
|
225
|
+
aum: decimalFromNullable(ev.aum),
|
|
226
|
+
hedgepnl: decimalFromNullable(ev.hedgepnl),
|
|
227
|
+
feemngt: decimalFromNullable(ev.feemngt),
|
|
228
|
+
feeperf: decimalFromNullable(ev.feeperf),
|
|
229
|
+
otheraccrued: decimalFromNullable(ev.otheraccrued),
|
|
230
|
+
totalaccrued: decimalFromNullable(ev.totalaccrued),
|
|
231
|
+
subred: decimalFromNullable(ev.subred),
|
|
232
|
+
perfdaily: decimalFromNullable(ev.perfdaily),
|
|
233
|
+
perfweekly: decimalFromNullable(ev.perfweekly),
|
|
234
|
+
perfmonthly: decimalFromNullable(ev.perfmonthly),
|
|
235
|
+
perfytd: decimalFromNullable(ev.perfytd),
|
|
236
|
+
perfstart: decimalFromNullable(ev.perfstart),
|
|
237
|
+
coefficient: decimalFromNullable(ev.coefficient),
|
|
238
|
+
})),
|
|
239
|
+
nav: unsafeDecimal(s.nav),
|
|
240
|
+
navAdjusted: unsafeDecimal(s.nav_adjusted),
|
|
241
|
+
navAdjustedTotal: unsafeDecimal(s.nav_adjusted_total),
|
|
242
|
+
coefficient: unsafeDecimal(s.coefficient),
|
|
243
|
+
gavRefccy: unsafeDecimal(s.gav_refccy),
|
|
244
|
+
gavClsccy: unsafeDecimal(s.gav_clsccy),
|
|
245
|
+
sharecountPrev: Maybe.fromNullable(s.sharecount_prev).map(unsafeDecimal),
|
|
246
|
+
sharecountCurr: Maybe.fromNullable(s.sharecount_curr).map(unsafeDecimal),
|
|
247
|
+
sharecountDiff: Maybe.fromNullable(s.sharecount_diff).map(unsafeDecimal),
|
|
248
|
+
pxRefCcy: decimalFromNullable(s.px_refccy),
|
|
249
|
+
pxClsCcy: decimalFromNullable(s.px_clsccy),
|
|
250
|
+
ytdExt: decimalFromNullable(s.ytdext),
|
|
251
|
+
ytdInt: decimalFromNullable(s.ytdint),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Attempts to re-compile the raw, remote account valuation report and
|
|
257
|
+
* return it.
|
|
258
|
+
*
|
|
259
|
+
* @param x Raw, remote account valuation report.
|
|
260
|
+
* @returns Either of an error message or the re-compiled account valuation
|
|
261
|
+
* report.
|
|
262
|
+
*/
|
|
263
|
+
export function recompileAccountValuationReport(
|
|
264
|
+
x: RemoteAccountValuationReport
|
|
265
|
+
): Either<CustomError, AccountValuationReport> {
|
|
266
|
+
// Attempt to get the base valuation report:
|
|
267
|
+
const baseReport = recompileBaseValuationReport(x);
|
|
268
|
+
|
|
269
|
+
// Add consolidated valuation report specific fields and return:
|
|
270
|
+
return baseReport.map((report) => {
|
|
271
|
+
return {
|
|
272
|
+
...report,
|
|
273
|
+
account: x.account,
|
|
274
|
+
subscriptions: decimalFromNullable(x.subscriptions).orDefault(zero),
|
|
275
|
+
shareClassValues: x.scvals.map(toShareClassValue),
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Attempts to retrieve remote account valuation report, compiles it to
|
|
282
|
+
* {@link AccountValuationReport} and return it.
|
|
283
|
+
*
|
|
284
|
+
* @param client DECAF Barista client.
|
|
285
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
286
|
+
* @returns Recompiled account valuation report data.
|
|
287
|
+
*/
|
|
288
|
+
export async function fetchAccountValuationReport(
|
|
289
|
+
client: DecafClient,
|
|
290
|
+
query: AccountValuationReportQuery
|
|
291
|
+
): Promise<Either<CustomError, AccountValuationReport>> {
|
|
292
|
+
// Attempt to fetch the remote, raw report:
|
|
293
|
+
const rawReport = await fetchRemoteAccountValuationReport(client, query);
|
|
294
|
+
|
|
295
|
+
// Attempt to recompile the report (if any) and return:
|
|
296
|
+
return rawReport.chain(recompileAccountValuationReport);
|
|
297
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
+
import {
|
|
3
|
+
DecafActionId,
|
|
4
|
+
CurrencyCode,
|
|
5
|
+
DecafExternalValuationId,
|
|
6
|
+
DecafOhlcSeriesId,
|
|
7
|
+
DecafPortfolioId,
|
|
8
|
+
DecafPrincipalId,
|
|
9
|
+
DecafShareClassFeeScheduleId,
|
|
10
|
+
DecafShareClassId,
|
|
11
|
+
} from '../../commons';
|
|
12
|
+
import { BaseValuationReport, ValuationReportAccount } from './-valuation-report-shared';
|
|
13
|
+
|
|
14
|
+
export interface AccountValuationReport extends BaseValuationReport {
|
|
15
|
+
account: ValuationReportAccount;
|
|
16
|
+
subscriptions: Decimal;
|
|
17
|
+
shareClassValues: AccountValuationReportShareClassValue[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AccountValuationReportShareClassValue {
|
|
21
|
+
shareclass: Maybe<AccountValuationReportShareClass>;
|
|
22
|
+
external: Maybe<AccountValuationReportExternalValue>;
|
|
23
|
+
nav: Decimal;
|
|
24
|
+
navAdjusted: Decimal;
|
|
25
|
+
navAdjustedTotal: Decimal;
|
|
26
|
+
coefficient: Decimal;
|
|
27
|
+
gavRefccy: Decimal;
|
|
28
|
+
gavClsccy: Decimal;
|
|
29
|
+
sharecountPrev: Maybe<Decimal>;
|
|
30
|
+
sharecountCurr: Maybe<Decimal>;
|
|
31
|
+
sharecountDiff: Maybe<Decimal>;
|
|
32
|
+
pxRefCcy: Maybe<Decimal>;
|
|
33
|
+
pxClsCcy: Maybe<Decimal>;
|
|
34
|
+
ytdExt: Maybe<Decimal>;
|
|
35
|
+
ytdInt: Maybe<Decimal>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AccountValuationReportShareClass {
|
|
39
|
+
id: DecafShareClassId;
|
|
40
|
+
created: SDateTime;
|
|
41
|
+
creator: Maybe<DecafPrincipalId>;
|
|
42
|
+
updated: SDateTime;
|
|
43
|
+
updater: Maybe<DecafPrincipalId>;
|
|
44
|
+
guid: string;
|
|
45
|
+
portfolio: DecafPortfolioId;
|
|
46
|
+
name: string;
|
|
47
|
+
currency: CurrencyCode;
|
|
48
|
+
isin: Maybe<string>;
|
|
49
|
+
bbgticker: Maybe<string>;
|
|
50
|
+
liquidity: Maybe<string>;
|
|
51
|
+
jurisdiction: Maybe<string>;
|
|
52
|
+
administrator: Maybe<string>;
|
|
53
|
+
minimumInvestment: Maybe<number>;
|
|
54
|
+
subscriptionRedemptionPeriod: Maybe<string>;
|
|
55
|
+
managementFeeFrequency: Maybe<number>;
|
|
56
|
+
performanceFeeFrequency: Maybe<number>;
|
|
57
|
+
benchmark: Maybe<DecafOhlcSeriesId>;
|
|
58
|
+
description: Maybe<string>;
|
|
59
|
+
feeScheduleIds: DecafShareClassFeeScheduleId[];
|
|
60
|
+
effectiveFeeScheduleId: Maybe<DecafShareClassFeeScheduleId>;
|
|
61
|
+
subscriptionIds: DecafActionId[];
|
|
62
|
+
outstanding: Maybe<Decimal>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AccountValuationReportExternalValue {
|
|
66
|
+
id: DecafExternalValuationId;
|
|
67
|
+
created: SDateTime;
|
|
68
|
+
creator: Maybe<DecafPrincipalId>;
|
|
69
|
+
updated: SDateTime;
|
|
70
|
+
updater: Maybe<DecafPrincipalId>;
|
|
71
|
+
guid: string;
|
|
72
|
+
portfolio: DecafPortfolioId;
|
|
73
|
+
shareclass: Maybe<DecafShareClassId>;
|
|
74
|
+
date: SDate;
|
|
75
|
+
ccy: CurrencyCode;
|
|
76
|
+
shares: Maybe<Decimal>;
|
|
77
|
+
price: Maybe<Decimal>;
|
|
78
|
+
nav: Maybe<Decimal>;
|
|
79
|
+
aum: Maybe<Decimal>;
|
|
80
|
+
hedgepnl: Maybe<Decimal>;
|
|
81
|
+
feemngt: Maybe<Decimal>;
|
|
82
|
+
feeperf: Maybe<Decimal>;
|
|
83
|
+
otheraccrued: Maybe<Decimal>;
|
|
84
|
+
totalaccrued: Maybe<Decimal>;
|
|
85
|
+
subred: Maybe<Decimal>;
|
|
86
|
+
perfdaily: Maybe<Decimal>;
|
|
87
|
+
perfweekly: Maybe<Decimal>;
|
|
88
|
+
perfmonthly: Maybe<Decimal>;
|
|
89
|
+
perfytd: Maybe<Decimal>;
|
|
90
|
+
perfstart: Maybe<Decimal>;
|
|
91
|
+
coefficient: Maybe<Decimal>;
|
|
92
|
+
}
|
|
@@ -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';
|