@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
|
@@ -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,196 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.fetchAccountValuationReport = exports.recompileAccountValuationReport = exports.toShareClassValue = exports.fetchRemoteAccountValuationReport = void 0;
|
|
51
|
+
var prelude_1 = require("@telostat/prelude");
|
|
52
|
+
var _remote_valuation_report_shared_1 = require("./-remote-valuation-report-shared");
|
|
53
|
+
/**
|
|
54
|
+
* Attempts to retrieve remote account valuation report.
|
|
55
|
+
*
|
|
56
|
+
* @param client DECAF Barista client.
|
|
57
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
58
|
+
* @returns Remote (raw) account valuation report data.
|
|
59
|
+
*/
|
|
60
|
+
function fetchRemoteAccountValuationReport(client, query) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
return [2 /*return*/, client.barista
|
|
64
|
+
.get('/reports/valuation/account/', {
|
|
65
|
+
params: {
|
|
66
|
+
ccy: query.currency,
|
|
67
|
+
date: query.date,
|
|
68
|
+
type: query.dateType,
|
|
69
|
+
account: "".concat(query.account),
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
.then(function (x) { return (0, prelude_1.Right)(x.data); })
|
|
73
|
+
.catch(function (err) { return (0, prelude_1.Left)((0, prelude_1.customError)('Error while attempting to fetch remote account valuation report', err)); })];
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.fetchRemoteAccountValuationReport = fetchRemoteAccountValuationReport;
|
|
78
|
+
/**
|
|
79
|
+
* Attempts to recompile remote valuation report share class value.
|
|
80
|
+
*
|
|
81
|
+
* @param x remote valuation report share class value object.
|
|
82
|
+
* @return Recompiled valuation report share class value object.
|
|
83
|
+
*/
|
|
84
|
+
function toShareClassValue(s) {
|
|
85
|
+
var shareclass = prelude_1.Maybe.fromNullable(s.shareclass).map(function (x) { return ({
|
|
86
|
+
id: x.id,
|
|
87
|
+
created: x.created,
|
|
88
|
+
creator: prelude_1.Maybe.fromNullable(x.creator),
|
|
89
|
+
updated: x.updated,
|
|
90
|
+
updater: prelude_1.Maybe.fromNullable(x.updater),
|
|
91
|
+
guid: x.guid,
|
|
92
|
+
portfolio: x.portfolio,
|
|
93
|
+
name: x.name,
|
|
94
|
+
currency: x.currency,
|
|
95
|
+
isin: (0, prelude_1.sanitizedNonEmptyText)(x.isin),
|
|
96
|
+
bbgticker: (0, prelude_1.sanitizedNonEmptyText)(x.bbgticker),
|
|
97
|
+
liquidity: (0, prelude_1.sanitizedNonEmptyText)(x.liquidity),
|
|
98
|
+
jurisdiction: (0, prelude_1.sanitizedNonEmptyText)(x.jurisdiction),
|
|
99
|
+
administrator: (0, prelude_1.sanitizedNonEmptyText)(x.administrator),
|
|
100
|
+
minimumInvestment: prelude_1.Maybe.fromNullable(x.mininvestment),
|
|
101
|
+
subscriptionRedemptionPeriod: (0, prelude_1.sanitizedNonEmptyText)(x.subredperiod),
|
|
102
|
+
managementFeeFrequency: prelude_1.Maybe.fromNullable(x.freqmngt),
|
|
103
|
+
performanceFeeFrequency: prelude_1.Maybe.fromNullable(x.freqperf),
|
|
104
|
+
benchmark: prelude_1.Maybe.fromNullable(x.benchmark),
|
|
105
|
+
description: (0, prelude_1.sanitizedNonEmptyText)(x.description),
|
|
106
|
+
feeScheduleIds: x.feeschedules,
|
|
107
|
+
effectiveFeeScheduleId: prelude_1.Maybe.fromNullable(x.effectivefeeschedule),
|
|
108
|
+
subscriptionIds: x.subscriptions,
|
|
109
|
+
outstanding: (0, prelude_1.decimalFromNullable)(x.outstanding),
|
|
110
|
+
}); });
|
|
111
|
+
return {
|
|
112
|
+
shareclass: shareclass,
|
|
113
|
+
external: prelude_1.Maybe.fromNullable(s.external).map(function (ev) { return ({
|
|
114
|
+
id: ev.id,
|
|
115
|
+
created: ev.created,
|
|
116
|
+
creator: prelude_1.Maybe.fromNullable(ev.updater),
|
|
117
|
+
updated: ev.updated,
|
|
118
|
+
updater: prelude_1.Maybe.fromNullable(ev.updater),
|
|
119
|
+
guid: ev.guid,
|
|
120
|
+
portfolio: ev.portfolio,
|
|
121
|
+
shareclass: prelude_1.Maybe.fromNullable(ev.shareclass),
|
|
122
|
+
date: ev.date,
|
|
123
|
+
ccy: ev.ccy,
|
|
124
|
+
shares: (0, prelude_1.decimalFromNullable)(ev.shares),
|
|
125
|
+
price: (0, prelude_1.decimalFromNullable)(ev.price),
|
|
126
|
+
nav: (0, prelude_1.decimalFromNullable)(ev.nav),
|
|
127
|
+
aum: (0, prelude_1.decimalFromNullable)(ev.aum),
|
|
128
|
+
hedgepnl: (0, prelude_1.decimalFromNullable)(ev.hedgepnl),
|
|
129
|
+
feemngt: (0, prelude_1.decimalFromNullable)(ev.feemngt),
|
|
130
|
+
feeperf: (0, prelude_1.decimalFromNullable)(ev.feeperf),
|
|
131
|
+
otheraccrued: (0, prelude_1.decimalFromNullable)(ev.otheraccrued),
|
|
132
|
+
totalaccrued: (0, prelude_1.decimalFromNullable)(ev.totalaccrued),
|
|
133
|
+
subred: (0, prelude_1.decimalFromNullable)(ev.subred),
|
|
134
|
+
perfdaily: (0, prelude_1.decimalFromNullable)(ev.perfdaily),
|
|
135
|
+
perfweekly: (0, prelude_1.decimalFromNullable)(ev.perfweekly),
|
|
136
|
+
perfmonthly: (0, prelude_1.decimalFromNullable)(ev.perfmonthly),
|
|
137
|
+
perfytd: (0, prelude_1.decimalFromNullable)(ev.perfytd),
|
|
138
|
+
perfstart: (0, prelude_1.decimalFromNullable)(ev.perfstart),
|
|
139
|
+
coefficient: (0, prelude_1.decimalFromNullable)(ev.coefficient),
|
|
140
|
+
}); }),
|
|
141
|
+
nav: (0, prelude_1.unsafeDecimal)(s.nav),
|
|
142
|
+
navAdjusted: (0, prelude_1.unsafeDecimal)(s.nav_adjusted),
|
|
143
|
+
navAdjustedTotal: (0, prelude_1.unsafeDecimal)(s.nav_adjusted_total),
|
|
144
|
+
coefficient: (0, prelude_1.unsafeDecimal)(s.coefficient),
|
|
145
|
+
gavRefccy: (0, prelude_1.unsafeDecimal)(s.gav_refccy),
|
|
146
|
+
gavClsccy: (0, prelude_1.unsafeDecimal)(s.gav_clsccy),
|
|
147
|
+
sharecountPrev: prelude_1.Maybe.fromNullable(s.sharecount_prev).map(prelude_1.unsafeDecimal),
|
|
148
|
+
sharecountCurr: prelude_1.Maybe.fromNullable(s.sharecount_curr).map(prelude_1.unsafeDecimal),
|
|
149
|
+
sharecountDiff: prelude_1.Maybe.fromNullable(s.sharecount_diff).map(prelude_1.unsafeDecimal),
|
|
150
|
+
pxRefCcy: (0, prelude_1.decimalFromNullable)(s.px_refccy),
|
|
151
|
+
pxClsCcy: (0, prelude_1.decimalFromNullable)(s.px_clsccy),
|
|
152
|
+
ytdExt: (0, prelude_1.decimalFromNullable)(s.ytdext),
|
|
153
|
+
ytdInt: (0, prelude_1.decimalFromNullable)(s.ytdint),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
exports.toShareClassValue = toShareClassValue;
|
|
157
|
+
/**
|
|
158
|
+
* Attempts to re-compile the raw, remote account valuation report and
|
|
159
|
+
* return it.
|
|
160
|
+
*
|
|
161
|
+
* @param x Raw, remote account valuation report.
|
|
162
|
+
* @returns Either of an error message or the re-compiled account valuation
|
|
163
|
+
* report.
|
|
164
|
+
*/
|
|
165
|
+
function recompileAccountValuationReport(x) {
|
|
166
|
+
// Attempt to get the base valuation report:
|
|
167
|
+
var baseReport = (0, _remote_valuation_report_shared_1.recompileBaseValuationReport)(x);
|
|
168
|
+
// Add consolidated valuation report specific fields and return:
|
|
169
|
+
return baseReport.map(function (report) {
|
|
170
|
+
return __assign(__assign({}, report), { account: x.account, subscriptions: (0, prelude_1.decimalFromNullable)(x.subscriptions).orDefault(prelude_1.zero), shareClassValues: x.scvals.map(toShareClassValue) });
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
exports.recompileAccountValuationReport = recompileAccountValuationReport;
|
|
174
|
+
/**
|
|
175
|
+
* Attempts to retrieve remote account valuation report, compiles it to
|
|
176
|
+
* {@link AccountValuationReport} and return it.
|
|
177
|
+
*
|
|
178
|
+
* @param client DECAF Barista client.
|
|
179
|
+
* @param query Remote account valuation report endpoint query parameters.
|
|
180
|
+
* @returns Recompiled account valuation report data.
|
|
181
|
+
*/
|
|
182
|
+
function fetchAccountValuationReport(client, query) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
var rawReport;
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
switch (_a.label) {
|
|
187
|
+
case 0: return [4 /*yield*/, fetchRemoteAccountValuationReport(client, query)];
|
|
188
|
+
case 1:
|
|
189
|
+
rawReport = _a.sent();
|
|
190
|
+
// Attempt to recompile the report (if any) and return:
|
|
191
|
+
return [2 /*return*/, rawReport.chain(recompileAccountValuationReport)];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
exports.fetchAccountValuationReport = fetchAccountValuationReport;
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
|
@@ -165,8 +165,9 @@ function addValuationReportHoldingToTree(tree, address, holding) {
|
|
|
165
165
|
node.holdings.push(holding);
|
|
166
166
|
}
|
|
167
167
|
exports.addValuationReportHoldingToTree = addValuationReportHoldingToTree;
|
|
168
|
-
function makeValuationReportHoldingsTree(nav, investment, holdings) {
|
|
168
|
+
function makeValuationReportHoldingsTree(nav, investment, holdings, addressKey) {
|
|
169
169
|
var e_2, _a;
|
|
170
|
+
if (addressKey === void 0) { addressKey = 'classification'; }
|
|
170
171
|
// Initialize the tree:
|
|
171
172
|
var tree = makeValuationReportHoldingsTreeNode([]);
|
|
172
173
|
tree.name = '« Total »';
|
|
@@ -174,7 +175,9 @@ function makeValuationReportHoldingsTree(nav, investment, holdings) {
|
|
|
174
175
|
// Iterate over the holdings and attempt to add to the tree:
|
|
175
176
|
for (var holdings_1 = __values(holdings), holdings_1_1 = holdings_1.next(); !holdings_1_1.done; holdings_1_1 = holdings_1.next()) {
|
|
176
177
|
var holding = holdings_1_1.value;
|
|
177
|
-
|
|
178
|
+
// Get the address of the holding:
|
|
179
|
+
var address = _utils_1.addressers[addressKey](holding);
|
|
180
|
+
addValuationReportHoldingToTree(tree, address, holding);
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -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>;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
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
|
+
};
|
|
2
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareStringArrays = void 0;
|
|
28
|
+
exports.addressers = exports.makeSimpleAddresser = exports.composeHoldingAddressers = exports.compareStringArrays = void 0;
|
|
4
29
|
function compareStringArrays(x, y) {
|
|
5
30
|
var xLen = x.length;
|
|
6
31
|
var yLen = y.length;
|
|
@@ -14,3 +39,36 @@ function compareStringArrays(x, y) {
|
|
|
14
39
|
return Math.sign(xLen - yLen);
|
|
15
40
|
}
|
|
16
41
|
exports.compareStringArrays = compareStringArrays;
|
|
42
|
+
function composeHoldingAddressers(addressers) {
|
|
43
|
+
return function (holding) {
|
|
44
|
+
return addressers.reduce(function (p, c) { return __spreadArray(__spreadArray([], __read(p), false), __read(c(holding)), false); }, []);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.composeHoldingAddressers = composeHoldingAddressers;
|
|
48
|
+
function makeSimpleAddresser(def, labeler) {
|
|
49
|
+
return function (holding) {
|
|
50
|
+
// Attempt to get the label:
|
|
51
|
+
var label = labeler(holding).orDefault('') || def;
|
|
52
|
+
// Get the value:
|
|
53
|
+
var value = label.toUpperCase();
|
|
54
|
+
// Done, return:
|
|
55
|
+
return [{ name: value, order: value }];
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.makeSimpleAddresser = makeSimpleAddresser;
|
|
59
|
+
exports.addressers = {
|
|
60
|
+
classification: function (holding) {
|
|
61
|
+
// Get the classification:
|
|
62
|
+
var classification = holding.classification;
|
|
63
|
+
// Build the address and return:
|
|
64
|
+
return classification.map(function (x) { return ({
|
|
65
|
+
// label: x.name,
|
|
66
|
+
name: x.name.toUpperCase(),
|
|
67
|
+
order: "".concat(x.order).toUpperCase(),
|
|
68
|
+
}); });
|
|
69
|
+
},
|
|
70
|
+
currency: makeSimpleAddresser('[Undefined Currency]', function (holding) { return holding.artifact.ccy; }),
|
|
71
|
+
country: makeSimpleAddresser('[Undefined Country]', function (holding) { return holding.artifact.country; }),
|
|
72
|
+
issuer: makeSimpleAddresser('[Undefined Issuer]', function (holding) { return holding.artifact.issuer; }),
|
|
73
|
+
sector: makeSimpleAddresser('[Undefined Sector]', function (holding) { return holding.artifact.sector; }),
|
|
74
|
+
};
|
|
@@ -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';
|
|
@@ -14,12 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.fetchPortfolioValuationReport = exports.fetchConsolidatedValuationReport = void 0;
|
|
17
|
+
exports.fetchAccountValuationReport = exports.fetchPortfolioValuationReport = exports.fetchConsolidatedValuationReport = void 0;
|
|
18
18
|
var _remote_valuation_report_consolidated_1 = require("./-remote-valuation-report-consolidated");
|
|
19
19
|
Object.defineProperty(exports, "fetchConsolidatedValuationReport", { enumerable: true, get: function () { return _remote_valuation_report_consolidated_1.fetchConsolidatedValuationReport; } });
|
|
20
20
|
var _remote_valuation_report_portfolio_1 = require("./-remote-valuation-report-portfolio");
|
|
21
21
|
Object.defineProperty(exports, "fetchPortfolioValuationReport", { enumerable: true, get: function () { return _remote_valuation_report_portfolio_1.fetchPortfolioValuationReport; } });
|
|
22
|
+
var _remote_valuation_report_account_1 = require("./-remote-valuation-report-account");
|
|
23
|
+
Object.defineProperty(exports, "fetchAccountValuationReport", { enumerable: true, get: function () { return _remote_valuation_report_account_1.fetchAccountValuationReport; } });
|
|
22
24
|
__exportStar(require("./-valuation-report-consolidated"), exports);
|
|
23
25
|
__exportStar(require("./-valuation-report-holdings-tree"), exports);
|
|
24
26
|
__exportStar(require("./-valuation-report-portfolio"), exports);
|
|
25
27
|
__exportStar(require("./-valuation-report-shared"), exports);
|
|
28
|
+
__exportStar(require("./-valuation-report-account"), exports);
|