@decafhub/decaf-client-extras 0.0.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/.editorconfig +9 -0
- package/.env.example +4 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +23 -0
- package/.github/workflows/release-please.yml +47 -0
- package/.github/workflows/test.yml +29 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/commons/-currency.d.ts +42 -0
- package/commons/-currency.js +50 -0
- package/commons/-date-type.d.ts +11 -0
- package/commons/-date-type.js +10 -0
- package/commons/-id.d.ts +58 -0
- package/commons/-id.js +2 -0
- package/commons/index.d.ts +3 -0
- package/commons/index.js +19 -0
- package/es/commons/-currency.d.ts +42 -0
- package/es/commons/-currency.js +44 -0
- package/es/commons/-date-type.d.ts +11 -0
- package/es/commons/-date-type.js +7 -0
- package/es/commons/-id.d.ts +58 -0
- package/es/commons/-id.js +1 -0
- package/es/commons/index.d.ts +3 -0
- package/es/commons/index.js +3 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/reports/index.d.ts +1 -0
- package/es/reports/index.js +1 -0
- package/es/reports/valuation/-remote-valuation-report-consolidated.d.ts +69 -0
- package/es/reports/valuation/-remote-valuation-report-consolidated.js +56 -0
- package/es/reports/valuation/-remote-valuation-report-portfolio.d.ts +150 -0
- package/es/reports/valuation/-remote-valuation-report-portfolio.js +134 -0
- package/es/reports/valuation/-remote-valuation-report-shared.d.ts +233 -0
- package/es/reports/valuation/-remote-valuation-report-shared.js +127 -0
- package/es/reports/valuation/-valuation-report-consolidated.d.ts +35 -0
- package/es/reports/valuation/-valuation-report-consolidated.js +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +10 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +116 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +23 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-types.js +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +1 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/-utils.js +12 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/index.d.ts +2 -0
- package/es/reports/valuation/-valuation-report-holdings-tree/index.js +2 -0
- package/es/reports/valuation/-valuation-report-portfolio.d.ts +79 -0
- package/es/reports/valuation/-valuation-report-portfolio.js +1 -0
- package/es/reports/valuation/-valuation-report-shared.d.ts +189 -0
- package/es/reports/valuation/-valuation-report-shared.js +6 -0
- package/es/reports/valuation/index.d.ts +8 -0
- package/es/reports/valuation/index.js +6 -0
- package/index.d.ts +3 -0
- package/index.js +32 -0
- package/jest.config.js +6 -0
- package/package.json +79 -0
- package/postinstall.sh +16 -0
- package/release-please-config.json +9 -0
- package/reports/index.d.ts +1 -0
- package/reports/index.js +27 -0
- package/reports/valuation/-remote-valuation-report-consolidated.d.ts +69 -0
- package/reports/valuation/-remote-valuation-report-consolidated.js +113 -0
- package/reports/valuation/-remote-valuation-report-portfolio.d.ts +150 -0
- package/reports/valuation/-remote-valuation-report-portfolio.js +191 -0
- package/reports/valuation/-remote-valuation-report-shared.d.ts +233 -0
- package/reports/valuation/-remote-valuation-report-shared.js +145 -0
- package/reports/valuation/-valuation-report-consolidated.d.ts +35 -0
- package/reports/valuation/-valuation-report-consolidated.js +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.d.ts +10 -0
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +189 -0
- package/reports/valuation/-valuation-report-holdings-tree/-types.d.ts +23 -0
- package/reports/valuation/-valuation-report-holdings-tree/-types.js +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.d.ts +1 -0
- package/reports/valuation/-valuation-report-holdings-tree/-utils.js +16 -0
- package/reports/valuation/-valuation-report-holdings-tree/index.d.ts +2 -0
- package/reports/valuation/-valuation-report-holdings-tree/index.js +20 -0
- package/reports/valuation/-valuation-report-portfolio.d.ts +79 -0
- package/reports/valuation/-valuation-report-portfolio.js +2 -0
- package/reports/valuation/-valuation-report-shared.d.ts +189 -0
- package/reports/valuation/-valuation-report-shared.js +11 -0
- package/reports/valuation/index.d.ts +8 -0
- package/reports/valuation/index.js +25 -0
- package/shell.nix +21 -0
- package/src/commons/-currency.ts +55 -0
- package/src/commons/-date-type.ts +12 -0
- package/src/commons/-id.ts +72 -0
- package/src/commons/index.ts +3 -0
- package/src/index.test.ts +67 -0
- package/src/index.ts +3 -0
- package/src/reports/index.ts +1 -0
- package/src/reports/valuation/-remote-valuation-report-consolidated.ts +121 -0
- package/src/reports/valuation/-remote-valuation-report-portfolio.ts +294 -0
- package/src/reports/valuation/-remote-valuation-report-shared.ts +313 -0
- package/src/reports/valuation/-valuation-report-consolidated.ts +46 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +171 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-types.ts +25 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/-utils.ts +15 -0
- package/src/reports/valuation/-valuation-report-holdings-tree/index.ts +2 -0
- package/src/reports/valuation/-valuation-report-portfolio.ts +92 -0
- package/src/reports/valuation/-valuation-report-shared.ts +217 -0
- package/src/reports/valuation/index.ts +8 -0
- package/tsconfig.es.json +13 -0
- package/tsconfig.json +36 -0
- package/typedoc.json +8 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseValuationReport } from './-valuation-report-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Type definition for consolidated valuation report.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConsolidatedValuationReport extends BaseValuationReport {
|
|
6
|
+
/**
|
|
7
|
+
* Type of containers consolidated.
|
|
8
|
+
*/
|
|
9
|
+
containerType: ConsolidatedValuationReportContainerType;
|
|
10
|
+
/**
|
|
11
|
+
* Containers consolidated.
|
|
12
|
+
*/
|
|
13
|
+
containers: ConsolidatedValuationReportContainer[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type definition for container types to be consolidated.
|
|
17
|
+
*/
|
|
18
|
+
export declare type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
|
|
19
|
+
/**
|
|
20
|
+
* Type definition for valuation report containers.
|
|
21
|
+
*/
|
|
22
|
+
export interface ConsolidatedValuationReportContainer {
|
|
23
|
+
/**
|
|
24
|
+
* Id of the container.
|
|
25
|
+
*/
|
|
26
|
+
id: number;
|
|
27
|
+
/**
|
|
28
|
+
* GUID of the container.
|
|
29
|
+
*/
|
|
30
|
+
guid: string;
|
|
31
|
+
/**
|
|
32
|
+
* Name of the container.
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Decimal } from '@telostat/prelude';
|
|
2
|
+
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
3
|
+
import { ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
|
|
4
|
+
export declare function makeValuationReportHoldingsTreeNodeValue(): ValuationReportHoldingsTreeNodeValue;
|
|
5
|
+
export declare function updateTotals(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNodeValue;
|
|
6
|
+
export declare function resortChildren(node: ValuationReportHoldingsTreeNode): ValuationReportHoldingsTreeNode[];
|
|
7
|
+
export declare function retreatTree(nav: Decimal, investment: Decimal, tree: ValuationReportHoldingsTreeNode): void;
|
|
8
|
+
export declare function makeValuationReportHoldingsTreeNode(address: ValuationReportHoldingClassification): ValuationReportHoldingsTreeNode;
|
|
9
|
+
export declare function addValuationReportHoldingToTree(tree: ValuationReportHoldingsTreeNode, address: ValuationReportHoldingClassification, holding: ValuationReportHolding): void;
|
|
10
|
+
export declare function makeValuationReportHoldingsTree(nav: Decimal, investment: Decimal, holdings: ValuationReportHolding[]): ValuationReportHoldingsTreeNode;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
|
|
2
|
+
import { Just, Maybe, Nothing } from 'purify-ts';
|
|
3
|
+
import { List } from 'purify-ts/List';
|
|
4
|
+
import { compareStringArrays } from './-utils';
|
|
5
|
+
export function makeValuationReportHoldingsTreeNodeValue() {
|
|
6
|
+
return {
|
|
7
|
+
investment: zero,
|
|
8
|
+
accrued: Nothing,
|
|
9
|
+
netValue: zero,
|
|
10
|
+
netValueRatio: zero,
|
|
11
|
+
absValue: zero,
|
|
12
|
+
absValueRatio: zero,
|
|
13
|
+
netExposure: zero,
|
|
14
|
+
netExposureRatio: zero,
|
|
15
|
+
absExposure: zero,
|
|
16
|
+
absExposureRatio: zero,
|
|
17
|
+
pnl: zero,
|
|
18
|
+
pnlRatio: zero,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function updateTotals(nav, investment, tree) {
|
|
22
|
+
const holdings = tree.holdings;
|
|
23
|
+
const children = tree.children;
|
|
24
|
+
const netValue = sumDecimals(holdings.map((x) => x.valuation.value.net.ref)).add(sumDecimals(children.map((x) => x.totals.netValue)));
|
|
25
|
+
const absValue = sumDecimals(holdings.map((x) => x.valuation.value.abs.ref)).add(sumDecimals(children.map((x) => x.totals.absValue)));
|
|
26
|
+
const netExposure = sumDecimals(holdings.map((x) => x.valuation.exposure.net.ref)).add(sumDecimals(children.map((x) => x.totals.netExposure)));
|
|
27
|
+
const absExposure = sumDecimals(holdings.map((x) => x.valuation.exposure.abs.ref)).add(sumDecimals(children.map((x) => x.totals.absExposure)));
|
|
28
|
+
const pnl = sumDecimals(holdings.map((x) => x.pnl)).add(sumDecimals(children.map((x) => x.totals.pnl)));
|
|
29
|
+
const accruedsHoldings = holdings.map((x) => x.investment.accrued.map((x) => x.ref));
|
|
30
|
+
const accruedsChildren = children.map((x) => x.totals.accrued);
|
|
31
|
+
const accrueds = Maybe.catMaybes([...accruedsHoldings, ...accruedsChildren]);
|
|
32
|
+
return {
|
|
33
|
+
investment: sumDecimals(holdings.map((x) => x.investment.value.ref)).add(sumDecimals(children.map((x) => x.totals.investment))),
|
|
34
|
+
accrued: accrueds.length === 0 ? Nothing : Just(sumDecimals(accrueds)),
|
|
35
|
+
netValue,
|
|
36
|
+
netValueRatio: safeDiv(netValue, nav).orDefault(zero),
|
|
37
|
+
absValue,
|
|
38
|
+
absValueRatio: safeDiv(absValue, nav).orDefault(zero),
|
|
39
|
+
netExposure,
|
|
40
|
+
netExposureRatio: safeDiv(netExposure, nav).orDefault(zero),
|
|
41
|
+
absExposure,
|
|
42
|
+
absExposureRatio: safeDiv(absExposure, nav).orDefault(zero),
|
|
43
|
+
pnl,
|
|
44
|
+
pnlRatio: safeDiv(pnl, investment).orDefault(zero),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function resortChildren(node) {
|
|
48
|
+
return node.children.sort((t1, t2) => {
|
|
49
|
+
// Get current address segments:
|
|
50
|
+
const segment1 = List.last(t1.address);
|
|
51
|
+
const segment2 = List.last(t2.address);
|
|
52
|
+
// Compare and return:
|
|
53
|
+
return segment1
|
|
54
|
+
.chain((s1) => segment2.chain((s2) => Just(Tuple(s1, s2))))
|
|
55
|
+
.map((x) => x.toArray())
|
|
56
|
+
.map(([x, y]) => `${x.order}`.localeCompare(`${y.order}`))
|
|
57
|
+
.orDefaultLazy(() => (segment1.isNothing() ? -1 : 1));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function retreatTree(nav, investment, tree) {
|
|
61
|
+
// First, retreat all children (recursive):
|
|
62
|
+
tree.children.forEach((x) => retreatTree(nav, investment, x));
|
|
63
|
+
// Recompute totals:
|
|
64
|
+
tree.totals = updateTotals(nav, investment, tree);
|
|
65
|
+
// Resort children:
|
|
66
|
+
tree.children = resortChildren(tree);
|
|
67
|
+
}
|
|
68
|
+
export function makeValuationReportHoldingsTreeNode(address) {
|
|
69
|
+
return {
|
|
70
|
+
name: List.last(address)
|
|
71
|
+
.map((x) => x.name)
|
|
72
|
+
.orDefault(''),
|
|
73
|
+
address,
|
|
74
|
+
holdings: [],
|
|
75
|
+
children: [],
|
|
76
|
+
totals: makeValuationReportHoldingsTreeNodeValue(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function addValuationReportHoldingToTree(tree, address, holding) {
|
|
80
|
+
// Get the starting (current) node:
|
|
81
|
+
let node = tree;
|
|
82
|
+
// Iterate over address and traverse the tree while adding new nodes when required:
|
|
83
|
+
const sofar = [];
|
|
84
|
+
const sofarAddress = [];
|
|
85
|
+
for (const segment of address) {
|
|
86
|
+
// Append to address buffer:
|
|
87
|
+
sofar.push(segment.name);
|
|
88
|
+
sofarAddress.push(segment);
|
|
89
|
+
// Attempt to find the child:
|
|
90
|
+
let child = node.children.find((n) => compareStringArrays(n.address.map((x) => x.name), sofar) === 0);
|
|
91
|
+
// Add or use?
|
|
92
|
+
if (child === undefined) {
|
|
93
|
+
// Create the new node:
|
|
94
|
+
child = makeValuationReportHoldingsTreeNode([...sofarAddress]);
|
|
95
|
+
// Add the new node to the current node as a child:
|
|
96
|
+
node.children.push(child);
|
|
97
|
+
}
|
|
98
|
+
// Set the current node to the child:
|
|
99
|
+
node = child;
|
|
100
|
+
}
|
|
101
|
+
// Done, we append the holding to the current node and return from the procedure:
|
|
102
|
+
node.holdings.push(holding);
|
|
103
|
+
}
|
|
104
|
+
export function makeValuationReportHoldingsTree(nav, investment, holdings) {
|
|
105
|
+
// Initialize the tree:
|
|
106
|
+
const tree = makeValuationReportHoldingsTreeNode([]);
|
|
107
|
+
tree.name = '« Total »';
|
|
108
|
+
// Iterate over the holdings and attempt to add to the tree:
|
|
109
|
+
for (const holding of holdings) {
|
|
110
|
+
addValuationReportHoldingToTree(tree, holding.classification, holding);
|
|
111
|
+
}
|
|
112
|
+
// Retreat the tree:
|
|
113
|
+
retreatTree(nav, investment, tree);
|
|
114
|
+
// Done, return:
|
|
115
|
+
return tree;
|
|
116
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Decimal, Maybe } from '@telostat/prelude';
|
|
2
|
+
import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
|
|
3
|
+
export interface ValuationReportHoldingsTreeNode {
|
|
4
|
+
name: string;
|
|
5
|
+
address: ValuationReportHoldingClassification;
|
|
6
|
+
holdings: ValuationReportHolding[];
|
|
7
|
+
children: ValuationReportHoldingsTreeNode[];
|
|
8
|
+
totals: ValuationReportHoldingsTreeNodeValue;
|
|
9
|
+
}
|
|
10
|
+
export interface ValuationReportHoldingsTreeNodeValue {
|
|
11
|
+
investment: Decimal;
|
|
12
|
+
accrued: Maybe<Decimal>;
|
|
13
|
+
netValue: Decimal;
|
|
14
|
+
netValueRatio: Decimal;
|
|
15
|
+
absValue: Decimal;
|
|
16
|
+
absValueRatio: Decimal;
|
|
17
|
+
netExposure: Decimal;
|
|
18
|
+
netExposureRatio: Decimal;
|
|
19
|
+
absExposure: Decimal;
|
|
20
|
+
absExposureRatio: Decimal;
|
|
21
|
+
pnl: Decimal;
|
|
22
|
+
pnlRatio: Decimal;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareStringArrays(x: string[], y: string[]): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function compareStringArrays(x, y) {
|
|
2
|
+
const xLen = x.length;
|
|
3
|
+
const yLen = y.length;
|
|
4
|
+
const minLength = Math.min(xLen, yLen);
|
|
5
|
+
for (let i = 0; i < minLength; i++) {
|
|
6
|
+
const comparison = (x[i] || '').localeCompare(y[i] || '');
|
|
7
|
+
if (comparison !== 0) {
|
|
8
|
+
return comparison;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return Math.sign(xLen - yLen);
|
|
12
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
+
import { ActionId, CurrencyCode, ExternalValuationId, OhlcSeriesId, PortfolioId, PrincipalId, ShareClassFeeScheduleId, ShareClassId } from '../../commons';
|
|
3
|
+
import { BaseValuationReport, ValuationReportPortfolio } from './-valuation-report-shared';
|
|
4
|
+
export interface PortfolioValuationReport extends BaseValuationReport {
|
|
5
|
+
portfolio: ValuationReportPortfolio;
|
|
6
|
+
subscriptions: Decimal;
|
|
7
|
+
shareClassValues: PortfolioValuationReportShareClassValue[];
|
|
8
|
+
}
|
|
9
|
+
export interface PortfolioValuationReportShareClassValue {
|
|
10
|
+
shareclass: PortfolioValuationReportShareClass;
|
|
11
|
+
external: Maybe<PortfolioValuationReportExternalValue>;
|
|
12
|
+
nav: Decimal;
|
|
13
|
+
navAdjusted: Decimal;
|
|
14
|
+
navAdjustedTotal: Decimal;
|
|
15
|
+
coefficient: Decimal;
|
|
16
|
+
gavRefccy: Decimal;
|
|
17
|
+
gavClsccy: Decimal;
|
|
18
|
+
sharecountPrev: Decimal;
|
|
19
|
+
sharecountCurr: Decimal;
|
|
20
|
+
sharecountDiff: Decimal;
|
|
21
|
+
pxRefCcy: Decimal;
|
|
22
|
+
pxClsCcy: Decimal;
|
|
23
|
+
ytdExt: Maybe<Decimal>;
|
|
24
|
+
ytdInt: Maybe<Decimal>;
|
|
25
|
+
}
|
|
26
|
+
export interface PortfolioValuationReportShareClass {
|
|
27
|
+
id: ShareClassId;
|
|
28
|
+
created: SDateTime;
|
|
29
|
+
creator: Maybe<PrincipalId>;
|
|
30
|
+
updated: SDateTime;
|
|
31
|
+
updater: Maybe<PrincipalId>;
|
|
32
|
+
guid: string;
|
|
33
|
+
portfolio: PortfolioId;
|
|
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<string>;
|
|
42
|
+
subscriptionRedemptionPeriod: Maybe<string>;
|
|
43
|
+
managementFeeFrequency: Maybe<number>;
|
|
44
|
+
performanceFeeFrequency: Maybe<number>;
|
|
45
|
+
benchmark: Maybe<OhlcSeriesId>;
|
|
46
|
+
description: Maybe<string>;
|
|
47
|
+
feeScheduleIds: ShareClassFeeScheduleId[];
|
|
48
|
+
effectiveFeeScheduleId: Maybe<ShareClassFeeScheduleId>;
|
|
49
|
+
subscriptionIds: ActionId[];
|
|
50
|
+
outstanding: Maybe<Decimal>;
|
|
51
|
+
}
|
|
52
|
+
export interface PortfolioValuationReportExternalValue {
|
|
53
|
+
id: ExternalValuationId;
|
|
54
|
+
created: SDateTime;
|
|
55
|
+
creator: Maybe<PrincipalId>;
|
|
56
|
+
updated: SDateTime;
|
|
57
|
+
updater: Maybe<PrincipalId>;
|
|
58
|
+
guid: string;
|
|
59
|
+
portfolio: PortfolioId;
|
|
60
|
+
shareclass: Maybe<ShareClassId>;
|
|
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 {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
+
import { AccountId, ArtifactId, ArtifactTypeId, CurrencyCode, DateType, PortfolioId } from '../../commons';
|
|
3
|
+
/**
|
|
4
|
+
* Type definition for base valuation report.
|
|
5
|
+
*/
|
|
6
|
+
export interface BaseValuationReport {
|
|
7
|
+
asof: SDateTime;
|
|
8
|
+
date: SDate;
|
|
9
|
+
dateType: DateType;
|
|
10
|
+
currency: CurrencyCode;
|
|
11
|
+
accounts: ValuationReportAccounts;
|
|
12
|
+
holdings: ValuationReportHolding[];
|
|
13
|
+
accruals: ValuationReportAccrual[];
|
|
14
|
+
fxRates: ValuationReportFxRate[];
|
|
15
|
+
figures: {
|
|
16
|
+
investment: Decimal;
|
|
17
|
+
valuation: {
|
|
18
|
+
net: Decimal;
|
|
19
|
+
abs: Decimal;
|
|
20
|
+
};
|
|
21
|
+
accrued: Decimal;
|
|
22
|
+
liabilities: Decimal;
|
|
23
|
+
gav: Decimal;
|
|
24
|
+
nav: Decimal;
|
|
25
|
+
aum: Decimal;
|
|
26
|
+
pnl: Decimal;
|
|
27
|
+
pnlToInvestment?: Maybe<Decimal>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Type definition for account reference in valuation reports.
|
|
32
|
+
*/
|
|
33
|
+
export interface ValuationReportAccount {
|
|
34
|
+
id: AccountId;
|
|
35
|
+
guid: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Type definition for portfolio reference in valuation reports.
|
|
40
|
+
*/
|
|
41
|
+
export interface ValuationReportPortfolio {
|
|
42
|
+
id: PortfolioId;
|
|
43
|
+
guid: string;
|
|
44
|
+
name: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Type definition for accounts which valuation report is compiled from.
|
|
48
|
+
*/
|
|
49
|
+
export interface ValuationReportAccounts {
|
|
50
|
+
custody: ValuationReportAccount[];
|
|
51
|
+
journal: ValuationReportAccount[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The definition for valuation report holding classification.
|
|
55
|
+
*/
|
|
56
|
+
export declare type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
|
|
57
|
+
/**
|
|
58
|
+
* Type definition for valuation report holding classification node.
|
|
59
|
+
*/
|
|
60
|
+
export interface ValuationReportHoldingClassificationNode {
|
|
61
|
+
name: string;
|
|
62
|
+
order: string | number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Type definition for base valuation report holding (shared by
|
|
66
|
+
* [[ValuationReportHolding]] and [[ValuationReportChildHolding]]).
|
|
67
|
+
*/
|
|
68
|
+
export interface BaseValuationReportHolding {
|
|
69
|
+
artifact: ValuationReportArtifact;
|
|
70
|
+
quantity: Decimal;
|
|
71
|
+
investment: ValuationReportHoldingFiguresInvestment;
|
|
72
|
+
valuation: ValuationReportHoldingFiguresValuation;
|
|
73
|
+
valuePercentage: Maybe<Decimal>;
|
|
74
|
+
netExposurePercentage: Maybe<Decimal>;
|
|
75
|
+
absExposurePercentage: Maybe<Decimal>;
|
|
76
|
+
change: Maybe<Decimal>;
|
|
77
|
+
pnl: Decimal;
|
|
78
|
+
pnlToInvestment: Maybe<Decimal>;
|
|
79
|
+
opendate: SDate;
|
|
80
|
+
lastdate: SDate;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Type definition for valuation report holding investment figures.
|
|
84
|
+
*/
|
|
85
|
+
export interface ValuationReportHoldingFiguresInvestment {
|
|
86
|
+
px: ValuationReportFigureOrgRef;
|
|
87
|
+
txncosts: Maybe<ValuationReportFigureOrgRef>;
|
|
88
|
+
accrued: Maybe<ValuationReportFigureOrgRef>;
|
|
89
|
+
value: ValuationReportFigureOrgRef;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Type definition for valuation report holding valuation figures.
|
|
93
|
+
*/
|
|
94
|
+
export interface ValuationReportHoldingFiguresValuation {
|
|
95
|
+
px: ValuationReportFigureOrgRef;
|
|
96
|
+
accrued: Maybe<ValuationReportFigureOrgRef>;
|
|
97
|
+
value: {
|
|
98
|
+
net: ValuationReportFigureOrgRef;
|
|
99
|
+
abs: ValuationReportFigureOrgRef;
|
|
100
|
+
};
|
|
101
|
+
exposure: {
|
|
102
|
+
net: ValuationReportFigureOrgRef;
|
|
103
|
+
abs: ValuationReportFigureOrgRef;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Type definition for valuation report figure value that is reported both in
|
|
108
|
+
* original currency and reference currency.
|
|
109
|
+
*/
|
|
110
|
+
export interface ValuationReportFigureOrgRef {
|
|
111
|
+
org: Decimal;
|
|
112
|
+
ref: Decimal;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Type definition for a valuation holding.
|
|
116
|
+
*/
|
|
117
|
+
export interface ValuationReportHolding extends BaseValuationReportHolding {
|
|
118
|
+
classification: ValuationReportHoldingClassification;
|
|
119
|
+
accounts: ValuationReportAccount[];
|
|
120
|
+
children: Maybe<ValuationReportChildHolding[]>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Type definition for a valuation holding child.
|
|
124
|
+
*/
|
|
125
|
+
export interface ValuationReportChildHolding extends BaseValuationReportHolding {
|
|
126
|
+
account: ValuationReportAccount;
|
|
127
|
+
}
|
|
128
|
+
export declare function isValuationHolding(x: ValuationReportHolding | ValuationReportChildHolding): x is ValuationReportHolding;
|
|
129
|
+
export declare function isValuationChildHolding(x: ValuationReportHolding | ValuationReportChildHolding): x is ValuationReportChildHolding;
|
|
130
|
+
/**
|
|
131
|
+
* Valuation accrual.
|
|
132
|
+
*/
|
|
133
|
+
export interface ValuationReportAccrual {
|
|
134
|
+
name: string;
|
|
135
|
+
value: Decimal;
|
|
136
|
+
accounts: ValuationReportAccrualByAccount[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Valuation accrual by account.
|
|
140
|
+
*/
|
|
141
|
+
export interface ValuationReportAccrualByAccount {
|
|
142
|
+
account: ValuationReportAccount;
|
|
143
|
+
value: Decimal;
|
|
144
|
+
accruals: ValuationReportAccrualByCurrency[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Valuation accrual by account by currency.
|
|
148
|
+
*/
|
|
149
|
+
export interface ValuationReportAccrualByCurrency {
|
|
150
|
+
artifact: ValuationReportArtifact;
|
|
151
|
+
ccy: CurrencyCode;
|
|
152
|
+
value: ValuationReportFigureOrgRef;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Type definition of the FINREA artifact type.
|
|
156
|
+
*/
|
|
157
|
+
export interface ValuationReportArtifactType {
|
|
158
|
+
id: ArtifactTypeId;
|
|
159
|
+
name: string;
|
|
160
|
+
order: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Type definition for the artifact as reported in the valuation.
|
|
164
|
+
*/
|
|
165
|
+
export interface ValuationReportArtifact {
|
|
166
|
+
id: ArtifactId;
|
|
167
|
+
guid: string;
|
|
168
|
+
type: ValuationReportArtifactType;
|
|
169
|
+
stype: Maybe<string>;
|
|
170
|
+
symbol: string;
|
|
171
|
+
name: Maybe<string>;
|
|
172
|
+
ccy: Maybe<CurrencyCode>;
|
|
173
|
+
quantity: Decimal;
|
|
174
|
+
country: Maybe<string>;
|
|
175
|
+
issuer: Maybe<string>;
|
|
176
|
+
sector: Maybe<string>;
|
|
177
|
+
mic: Maybe<string>;
|
|
178
|
+
ticker: Maybe<string>;
|
|
179
|
+
isin: Maybe<string>;
|
|
180
|
+
figi: Maybe<string>;
|
|
181
|
+
expiry: Maybe<SDate>;
|
|
182
|
+
underlyingId: Maybe<ArtifactId>;
|
|
183
|
+
}
|
|
184
|
+
export interface ValuationReportFxRate {
|
|
185
|
+
ccy1: CurrencyCode;
|
|
186
|
+
ccy2: CurrencyCode;
|
|
187
|
+
value: Decimal;
|
|
188
|
+
asof: SDate;
|
|
189
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { fetchConsolidatedValuationReport } from './-remote-valuation-report-consolidated';
|
|
2
|
+
export type { ConsolidatedValuationReportQuery } from './-remote-valuation-report-consolidated';
|
|
3
|
+
export { fetchPortfolioValuationReport } from './-remote-valuation-report-portfolio';
|
|
4
|
+
export type { PortfolioValuationReportQuery } from './-remote-valuation-report-portfolio';
|
|
5
|
+
export * from './-valuation-report-consolidated';
|
|
6
|
+
export * from './-valuation-report-holdings-tree';
|
|
7
|
+
export * from './-valuation-report-portfolio';
|
|
8
|
+
export * from './-valuation-report-shared';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { fetchConsolidatedValuationReport } from './-remote-valuation-report-consolidated';
|
|
2
|
+
export { fetchPortfolioValuationReport } from './-remote-valuation-report-portfolio';
|
|
3
|
+
export * from './-valuation-report-consolidated';
|
|
4
|
+
export * from './-valuation-report-holdings-tree';
|
|
5
|
+
export * from './-valuation-report-portfolio';
|
|
6
|
+
export * from './-valuation-report-shared';
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.reports = exports.commons = void 0;
|
|
30
|
+
__exportStar(require("./commons"), exports);
|
|
31
|
+
exports.commons = __importStar(require("./commons"));
|
|
32
|
+
exports.reports = __importStar(require("./reports"));
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@decafhub/decaf-client-extras",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "DECAF Client Extras",
|
|
5
|
+
"author": "Teloscube Pte Ltd",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"private": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/teloscube/decaf-client-javascript-extras",
|
|
10
|
+
"type": "git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/teloscube/decaf-client-javascript-extras",
|
|
13
|
+
"source": "./src/index.ts",
|
|
14
|
+
"main": "./index.js",
|
|
15
|
+
"module": "./es/index.js",
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "tsc --watch",
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"build": "rm -rf lib && tsc && tsc -p tsconfig.es.json && yarn make:docs",
|
|
21
|
+
"make:docs": "typedoc",
|
|
22
|
+
"deploy:docs": "gh-pages -d ./docs",
|
|
23
|
+
"prepare": "yarn build && ./postinstall.sh"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=14"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@decafhub/decaf-client": "~0.2"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@telostat/prelude": "^0.1.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@commitlint/cli": "^17.0.3",
|
|
36
|
+
"@commitlint/config-conventional": "^17.0.3",
|
|
37
|
+
"@decafhub/decaf-client": "^0.2.2",
|
|
38
|
+
"@types/jest": "^28.1.6",
|
|
39
|
+
"@types/node": "^18.6.1",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
41
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
42
|
+
"dotenv": "^16.0.1",
|
|
43
|
+
"eslint": "^8.20.0",
|
|
44
|
+
"eslint-config-prettier": "^8.5.0",
|
|
45
|
+
"eslint-config-standard": "^17.0.0",
|
|
46
|
+
"eslint-plugin-import": "^2.26.0",
|
|
47
|
+
"eslint-plugin-n": "^15.2.4",
|
|
48
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
49
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
50
|
+
"eslint-plugin-standard": "^5.0.0",
|
|
51
|
+
"gh-pages": "^4.0.0",
|
|
52
|
+
"husky": "^8.0.0",
|
|
53
|
+
"jest": "^28.1.3",
|
|
54
|
+
"lint-staged": "^13.0.3",
|
|
55
|
+
"prettier": "^2.7.1",
|
|
56
|
+
"ts-jest": "^28.0.7",
|
|
57
|
+
"typedoc": "^0.23.9",
|
|
58
|
+
"typescript": "^4.7.4"
|
|
59
|
+
},
|
|
60
|
+
"lint-staged": {
|
|
61
|
+
"src/**/*.{ts,tsx}": [
|
|
62
|
+
"./node_modules/.bin/prettier --write",
|
|
63
|
+
"./node_modules/.bin/eslint"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"prettier": {
|
|
67
|
+
"tabWidth": 2,
|
|
68
|
+
"printWidth": 120,
|
|
69
|
+
"useTabs": false,
|
|
70
|
+
"semi": true,
|
|
71
|
+
"singleQuote": true,
|
|
72
|
+
"trailingComma": "es5"
|
|
73
|
+
},
|
|
74
|
+
"commitlint": {
|
|
75
|
+
"extends": [
|
|
76
|
+
"@commitlint/config-conventional"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
package/postinstall.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
if [ -f .env ]; then
|
|
5
|
+
source .env
|
|
6
|
+
fi
|
|
7
|
+
|
|
8
|
+
if [ -n "$DECAF_JS_SKIP_POSTINSTALL" ]; then
|
|
9
|
+
yarn husky install
|
|
10
|
+
echo "Local Env detected. Skipping lib/ relocation..."
|
|
11
|
+
exit 0
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
echo 'Copying files from lib folder into root project folder...'
|
|
15
|
+
cp -r lib/* ./ && rm -rf lib
|
|
16
|
+
echo 'Done!'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as valuation from './valuation';
|