@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,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
|
+
}
|
|
@@ -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);
|
|
@@ -2,12 +2,16 @@ import { buildDecafClient, DecafClient, gql } from '@decafhub/decaf-client';
|
|
|
2
2
|
import { safeDiv, zero } from '@telostat/prelude';
|
|
3
3
|
import { fail } from 'assert';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
|
-
import { DecafPortfolioId, mkCurrencyCodeError } from '
|
|
6
|
-
import { makeValuationReportHoldingsTree } from './
|
|
5
|
+
import { DecafAccountId, DecafPortfolioId, mkCurrencyCodeError } from '../commons';
|
|
6
|
+
import { makeValuationReportHoldingsTree } from './valuation';
|
|
7
7
|
import {
|
|
8
8
|
fetchPortfolioValuationReport,
|
|
9
9
|
fetchRemotePortfolioValuationReport,
|
|
10
|
-
} from './
|
|
10
|
+
} from './valuation/-remote-valuation-report-portfolio';
|
|
11
|
+
import {
|
|
12
|
+
fetchAccountValuationReport,
|
|
13
|
+
fetchRemoteAccountValuationReport,
|
|
14
|
+
} from './valuation/-remote-valuation-report-account';
|
|
11
15
|
|
|
12
16
|
const API_URL = process.env.TESTING_API_URL;
|
|
13
17
|
const API_KEY = process.env.TESTING_API_KEY;
|
|
@@ -22,9 +26,19 @@ const FIRST_PORTFOLIO_QUERY = gql`
|
|
|
22
26
|
}
|
|
23
27
|
`;
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
const FIRST_ACCOUNT_QUERY = gql`
|
|
30
|
+
query GetFirstAccount {
|
|
31
|
+
account(limit: 1) {
|
|
32
|
+
id
|
|
33
|
+
name
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
describe('Reports', () => {
|
|
26
39
|
let client: DecafClient;
|
|
27
40
|
let portfolioId: DecafPortfolioId;
|
|
41
|
+
let accountId: DecafAccountId;
|
|
28
42
|
|
|
29
43
|
beforeAll(() => {
|
|
30
44
|
jest.resetModules();
|
|
@@ -52,6 +66,16 @@ describe('Main', () => {
|
|
|
52
66
|
}
|
|
53
67
|
});
|
|
54
68
|
|
|
69
|
+
test('take the first account', async () => {
|
|
70
|
+
try {
|
|
71
|
+
const { data } = await client.microlot.query({ query: FIRST_ACCOUNT_QUERY });
|
|
72
|
+
accountId = data?.account?.[0].id;
|
|
73
|
+
expect(accountId).toBeDefined();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
fail('Error while fetching the first account');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
55
79
|
test('get a remote portfolio report successfuly', async () => {
|
|
56
80
|
const eValue = await fetchRemotePortfolioValuationReport(client, {
|
|
57
81
|
portfolio: portfolioId,
|
|
@@ -66,6 +90,7 @@ describe('Main', () => {
|
|
|
66
90
|
`Success! remote valuation for portfolio ID ${value.portfolio.id} is reported at ${value.reported}`
|
|
67
91
|
);
|
|
68
92
|
expect(value).toBeDefined();
|
|
93
|
+
expect(value.portfolio.id).toEqual(portfolioId);
|
|
69
94
|
},
|
|
70
95
|
});
|
|
71
96
|
});
|
|
@@ -94,4 +119,45 @@ describe('Main', () => {
|
|
|
94
119
|
},
|
|
95
120
|
});
|
|
96
121
|
});
|
|
122
|
+
|
|
123
|
+
test('get a remote account report successfuly', async () => {
|
|
124
|
+
const eValue = await fetchRemoteAccountValuationReport(client, {
|
|
125
|
+
account: accountId,
|
|
126
|
+
date: dayjs(new Date()).format('YYYY-MM-DD'),
|
|
127
|
+
dateType: 'settlement',
|
|
128
|
+
currency: mkCurrencyCodeError('EUR'),
|
|
129
|
+
});
|
|
130
|
+
eValue.caseOf({
|
|
131
|
+
Left: (e) => fail('Error while fetching the remote account report: ' + e.msg),
|
|
132
|
+
Right: (value) => {
|
|
133
|
+
console.log(`Success! remote valuation for account ID ${value.account.id} is reported at ${value.reported}`);
|
|
134
|
+
expect(value).toBeDefined();
|
|
135
|
+
expect(value.account.id).toEqual(accountId);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('get an account report, check the tree', async () => {
|
|
141
|
+
const eValue = await fetchAccountValuationReport(client, {
|
|
142
|
+
account: accountId,
|
|
143
|
+
date: dayjs(new Date()).format('YYYY-MM-DD'),
|
|
144
|
+
dateType: 'settlement',
|
|
145
|
+
currency: mkCurrencyCodeError('EUR'),
|
|
146
|
+
});
|
|
147
|
+
eValue.caseOf({
|
|
148
|
+
Left: (e) => fail('Error while fetching the remote account report: ' + String(e)),
|
|
149
|
+
Right: (value) => {
|
|
150
|
+
console.log(`Success! remote valuation for account ID ${value.account.id} is reported at ${value.asof}`);
|
|
151
|
+
|
|
152
|
+
expect(value).toBeDefined();
|
|
153
|
+
|
|
154
|
+
const nav = value.figures.nav;
|
|
155
|
+
const inv = value.figures.investment;
|
|
156
|
+
const holdings = value.holdings;
|
|
157
|
+
const tree = makeValuationReportHoldingsTree(nav, inv, holdings);
|
|
158
|
+
expect(tree).toBeDefined();
|
|
159
|
+
expect(safeDiv(tree.totals.netExposure, nav).orDefault(zero)).toEqual(tree.totals.netExposureRatio);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
});
|
|
97
163
|
});
|