@decafhub/decaf-client-extras 0.0.5 → 0.1.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +15 -0
- package/commons/-currency.d.ts +22 -6
- package/commons/-currency.js +12 -6
- package/commons/{-date-type.d.ts → -datetype.d.ts} +1 -1
- package/commons/{-date-type.js → -datetype.js} +2 -2
- package/commons/-id.d.ts +109 -17
- package/commons/-id.js +73 -0
- package/commons/index.d.ts +4 -1
- package/commons/index.js +17 -1
- package/es/commons/-currency.d.ts +22 -6
- package/es/commons/-currency.js +12 -6
- package/es/commons/{-date-type.d.ts → -datetype.d.ts} +1 -1
- package/es/commons/{-date-type.js → -datetype.js} +1 -1
- package/es/commons/-id.d.ts +109 -17
- package/es/commons/-id.js +70 -1
- package/es/commons/index.d.ts +4 -1
- package/es/commons/index.js +4 -1
- package/es/reports/valuation/-remote-valuation-report-portfolio.d.ts +15 -15
- package/es/reports/valuation/-remote-valuation-report-portfolio.js +32 -32
- package/es/reports/valuation/-remote-valuation-report-shared.d.ts +4 -4
- package/es/reports/valuation/-remote-valuation-report-shared.js +29 -26
- package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +1 -3
- package/es/reports/valuation/-valuation-report-portfolio.d.ts +14 -14
- package/es/reports/valuation/-valuation-report-shared.d.ts +6 -6
- package/nix/default.nix +59 -0
- package/nix/sources.json +14 -0
- package/nix/sources.nix +194 -0
- package/package.json +2 -2
- package/reports/valuation/-remote-valuation-report-portfolio.d.ts +15 -15
- package/reports/valuation/-remote-valuation-report-portfolio.js +31 -31
- package/reports/valuation/-remote-valuation-report-shared.d.ts +4 -4
- package/reports/valuation/-remote-valuation-report-shared.js +28 -25
- package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +7 -9
- package/reports/valuation/-valuation-report-portfolio.d.ts +14 -14
- package/reports/valuation/-valuation-report-shared.d.ts +6 -6
- package/shell.nix +5 -20
- package/src/commons/-currency.test.ts +27 -0
- package/src/commons/-currency.ts +24 -9
- package/src/commons/-datetype.test.ts +10 -0
- package/src/commons/{-date-type.ts → -datetype.ts} +1 -1
- package/src/commons/-id.test.ts +27 -0
- package/src/commons/-id.ts +112 -17
- package/src/commons/index.ts +4 -1
- package/src/index.test.ts +5 -5
- package/src/reports/valuation/-remote-valuation-report-portfolio.ts +54 -54
- package/src/reports/valuation/-remote-valuation-report-shared.ts +34 -31
- package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +5 -7
- package/src/reports/valuation/-valuation-report-portfolio.ts +20 -20
- package/src/reports/valuation/-valuation-report-shared.ts +13 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Decimal, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
-
import {
|
|
2
|
+
import { CurrencyCode, DateType, DecafAccountId, DecafArtifactId, DecafArtifactTypeId, DecafPortfolioId } from '../../commons';
|
|
3
3
|
/**
|
|
4
4
|
* Type definition for base valuation report.
|
|
5
5
|
*/
|
|
@@ -31,7 +31,7 @@ export interface BaseValuationReport {
|
|
|
31
31
|
* Type definition for account reference in valuation reports.
|
|
32
32
|
*/
|
|
33
33
|
export interface ValuationReportAccount {
|
|
34
|
-
id:
|
|
34
|
+
id: DecafAccountId;
|
|
35
35
|
guid: string;
|
|
36
36
|
name: string;
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ export interface ValuationReportAccount {
|
|
|
39
39
|
* Type definition for portfolio reference in valuation reports.
|
|
40
40
|
*/
|
|
41
41
|
export interface ValuationReportPortfolio {
|
|
42
|
-
id:
|
|
42
|
+
id: DecafPortfolioId;
|
|
43
43
|
guid: string;
|
|
44
44
|
name: string;
|
|
45
45
|
}
|
|
@@ -155,7 +155,7 @@ export interface ValuationReportAccrualByCurrency {
|
|
|
155
155
|
* Type definition of the FINREA artifact type.
|
|
156
156
|
*/
|
|
157
157
|
export interface ValuationReportArtifactType {
|
|
158
|
-
id:
|
|
158
|
+
id: DecafArtifactTypeId;
|
|
159
159
|
name: string;
|
|
160
160
|
order: number;
|
|
161
161
|
}
|
|
@@ -163,7 +163,7 @@ export interface ValuationReportArtifactType {
|
|
|
163
163
|
* Type definition for the artifact as reported in the valuation.
|
|
164
164
|
*/
|
|
165
165
|
export interface ValuationReportArtifact {
|
|
166
|
-
id:
|
|
166
|
+
id: DecafArtifactId;
|
|
167
167
|
guid: string;
|
|
168
168
|
type: ValuationReportArtifactType;
|
|
169
169
|
stype: Maybe<string>;
|
|
@@ -179,7 +179,7 @@ export interface ValuationReportArtifact {
|
|
|
179
179
|
isin: Maybe<string>;
|
|
180
180
|
figi: Maybe<string>;
|
|
181
181
|
expiry: Maybe<SDate>;
|
|
182
|
-
underlyingId: Maybe<
|
|
182
|
+
underlyingId: Maybe<DecafArtifactId>;
|
|
183
183
|
}
|
|
184
184
|
export interface ValuationReportFxRate {
|
|
185
185
|
ccy1: CurrencyCode;
|
package/nix/default.nix
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{ ... }:
|
|
2
|
+
|
|
3
|
+
let
|
|
4
|
+
## Set the name:
|
|
5
|
+
name = "decaf-client-javascript-extras";
|
|
6
|
+
|
|
7
|
+
## Repository root:
|
|
8
|
+
root = ../.;
|
|
9
|
+
|
|
10
|
+
## Import sources:
|
|
11
|
+
sources = import ./sources.nix;
|
|
12
|
+
|
|
13
|
+
## Import telosnix:
|
|
14
|
+
telosnix = import sources.telosnix { };
|
|
15
|
+
|
|
16
|
+
## Import nixpkgs:
|
|
17
|
+
pkgs = import telosnix.pkgs-sources.stable { };
|
|
18
|
+
|
|
19
|
+
## Get the devshell:
|
|
20
|
+
devshell = telosnix.tools.devshell {
|
|
21
|
+
name = "${name}-devshell";
|
|
22
|
+
src = ./.;
|
|
23
|
+
quickstart = ../README.md;
|
|
24
|
+
guide = [
|
|
25
|
+
{ name = "readme"; title = "Introduction"; path = ../README.md; }
|
|
26
|
+
];
|
|
27
|
+
extensions = { };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
## Declare dependencies for our shell:
|
|
31
|
+
deps = [
|
|
32
|
+
pkgs.git
|
|
33
|
+
pkgs.nodejs
|
|
34
|
+
pkgs.yarn
|
|
35
|
+
|
|
36
|
+
devshell
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
## Define our shell:
|
|
40
|
+
shell = pkgs.mkShell {
|
|
41
|
+
buildInputs = deps;
|
|
42
|
+
|
|
43
|
+
shellHook = ''
|
|
44
|
+
## Greet:
|
|
45
|
+
devsh welcome
|
|
46
|
+
'';
|
|
47
|
+
|
|
48
|
+
DEVSHELL_ROOT = "${toString root}";
|
|
49
|
+
DECAF_JS_SKIP_POSTINSTALL = "1";
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
in
|
|
53
|
+
{
|
|
54
|
+
name = name;
|
|
55
|
+
pkgs = pkgs;
|
|
56
|
+
sources = sources;
|
|
57
|
+
telosnix = telosnix;
|
|
58
|
+
shell = shell;
|
|
59
|
+
}
|
package/nix/sources.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"telosnix": {
|
|
3
|
+
"branch": "v0.0.6",
|
|
4
|
+
"description": null,
|
|
5
|
+
"homepage": null,
|
|
6
|
+
"owner": "telostat",
|
|
7
|
+
"repo": "telos.nix",
|
|
8
|
+
"rev": "c0b76b80df8c8cc61383bee9fdcb81e45b53f919",
|
|
9
|
+
"sha256": "08kd5ivhm3hjkiw28cifmbjywbm7fsvzbwb7prsdnqmam6ij278i",
|
|
10
|
+
"type": "tarball",
|
|
11
|
+
"url": "https://github.com/telostat/telos.nix/archive/c0b76b80df8c8cc61383bee9fdcb81e45b53f919.tar.gz",
|
|
12
|
+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/nix/sources.nix
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# This file has been generated by Niv.
|
|
2
|
+
|
|
3
|
+
let
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# The fetchers. fetch_<type> fetches specs of type <type>.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
fetch_file = pkgs: name: spec:
|
|
10
|
+
let
|
|
11
|
+
name' = sanitizeName name + "-src";
|
|
12
|
+
in
|
|
13
|
+
if spec.builtin or true then
|
|
14
|
+
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
|
15
|
+
else
|
|
16
|
+
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
|
17
|
+
|
|
18
|
+
fetch_tarball = pkgs: name: spec:
|
|
19
|
+
let
|
|
20
|
+
name' = sanitizeName name + "-src";
|
|
21
|
+
in
|
|
22
|
+
if spec.builtin or true then
|
|
23
|
+
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
|
24
|
+
else
|
|
25
|
+
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
|
26
|
+
|
|
27
|
+
fetch_git = name: spec:
|
|
28
|
+
let
|
|
29
|
+
ref =
|
|
30
|
+
if spec ? ref then spec.ref else
|
|
31
|
+
if spec ? branch then "refs/heads/${spec.branch}" else
|
|
32
|
+
if spec ? tag then "refs/tags/${spec.tag}" else
|
|
33
|
+
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
|
34
|
+
submodules = if spec ? submodules then spec.submodules else false;
|
|
35
|
+
submoduleArg =
|
|
36
|
+
let
|
|
37
|
+
nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0;
|
|
38
|
+
emptyArgWithWarning =
|
|
39
|
+
if submodules == true
|
|
40
|
+
then
|
|
41
|
+
builtins.trace
|
|
42
|
+
(
|
|
43
|
+
"The niv input \"${name}\" uses submodules "
|
|
44
|
+
+ "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
|
|
45
|
+
+ "does not support them"
|
|
46
|
+
)
|
|
47
|
+
{}
|
|
48
|
+
else {};
|
|
49
|
+
in
|
|
50
|
+
if nixSupportsSubmodules
|
|
51
|
+
then { inherit submodules; }
|
|
52
|
+
else emptyArgWithWarning;
|
|
53
|
+
in
|
|
54
|
+
builtins.fetchGit
|
|
55
|
+
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);
|
|
56
|
+
|
|
57
|
+
fetch_local = spec: spec.path;
|
|
58
|
+
|
|
59
|
+
fetch_builtin-tarball = name: throw
|
|
60
|
+
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
|
61
|
+
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
|
62
|
+
|
|
63
|
+
fetch_builtin-url = name: throw
|
|
64
|
+
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
|
65
|
+
$ niv modify ${name} -a type=file -a builtin=true'';
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
# Various helpers
|
|
69
|
+
#
|
|
70
|
+
|
|
71
|
+
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
|
72
|
+
sanitizeName = name:
|
|
73
|
+
(
|
|
74
|
+
concatMapStrings (s: if builtins.isList s then "-" else s)
|
|
75
|
+
(
|
|
76
|
+
builtins.split "[^[:alnum:]+._?=-]+"
|
|
77
|
+
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
# The set of packages used when specs are fetched using non-builtins.
|
|
82
|
+
mkPkgs = sources: system:
|
|
83
|
+
let
|
|
84
|
+
sourcesNixpkgs =
|
|
85
|
+
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
|
86
|
+
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
|
87
|
+
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
|
88
|
+
in
|
|
89
|
+
if builtins.hasAttr "nixpkgs" sources
|
|
90
|
+
then sourcesNixpkgs
|
|
91
|
+
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
|
92
|
+
import <nixpkgs> {}
|
|
93
|
+
else
|
|
94
|
+
abort
|
|
95
|
+
''
|
|
96
|
+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
|
97
|
+
add a package called "nixpkgs" to your sources.json.
|
|
98
|
+
'';
|
|
99
|
+
|
|
100
|
+
# The actual fetching function.
|
|
101
|
+
fetch = pkgs: name: spec:
|
|
102
|
+
|
|
103
|
+
if ! builtins.hasAttr "type" spec then
|
|
104
|
+
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
|
105
|
+
else if spec.type == "file" then fetch_file pkgs name spec
|
|
106
|
+
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
|
107
|
+
else if spec.type == "git" then fetch_git name spec
|
|
108
|
+
else if spec.type == "local" then fetch_local spec
|
|
109
|
+
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
|
110
|
+
else if spec.type == "builtin-url" then fetch_builtin-url name
|
|
111
|
+
else
|
|
112
|
+
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
|
113
|
+
|
|
114
|
+
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
|
115
|
+
# the path directly as opposed to the fetched source.
|
|
116
|
+
replace = name: drv:
|
|
117
|
+
let
|
|
118
|
+
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
|
119
|
+
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
|
120
|
+
in
|
|
121
|
+
if ersatz == "" then drv else
|
|
122
|
+
# this turns the string into an actual Nix path (for both absolute and
|
|
123
|
+
# relative paths)
|
|
124
|
+
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
|
125
|
+
|
|
126
|
+
# Ports of functions for older nix versions
|
|
127
|
+
|
|
128
|
+
# a Nix version of mapAttrs if the built-in doesn't exist
|
|
129
|
+
mapAttrs = builtins.mapAttrs or (
|
|
130
|
+
f: set: with builtins;
|
|
131
|
+
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
|
135
|
+
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
|
136
|
+
|
|
137
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
|
138
|
+
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
|
139
|
+
|
|
140
|
+
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
|
141
|
+
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
|
142
|
+
concatMapStrings = f: list: concatStrings (map f list);
|
|
143
|
+
concatStrings = builtins.concatStringsSep "";
|
|
144
|
+
|
|
145
|
+
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
|
146
|
+
optionalAttrs = cond: as: if cond then as else {};
|
|
147
|
+
|
|
148
|
+
# fetchTarball version that is compatible between all the versions of Nix
|
|
149
|
+
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
|
150
|
+
let
|
|
151
|
+
inherit (builtins) lessThan nixVersion fetchTarball;
|
|
152
|
+
in
|
|
153
|
+
if lessThan nixVersion "1.12" then
|
|
154
|
+
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
|
155
|
+
else
|
|
156
|
+
fetchTarball attrs;
|
|
157
|
+
|
|
158
|
+
# fetchurl version that is compatible between all the versions of Nix
|
|
159
|
+
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
|
160
|
+
let
|
|
161
|
+
inherit (builtins) lessThan nixVersion fetchurl;
|
|
162
|
+
in
|
|
163
|
+
if lessThan nixVersion "1.12" then
|
|
164
|
+
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
|
165
|
+
else
|
|
166
|
+
fetchurl attrs;
|
|
167
|
+
|
|
168
|
+
# Create the final "sources" from the config
|
|
169
|
+
mkSources = config:
|
|
170
|
+
mapAttrs (
|
|
171
|
+
name: spec:
|
|
172
|
+
if builtins.hasAttr "outPath" spec
|
|
173
|
+
then abort
|
|
174
|
+
"The values in sources.json should not have an 'outPath' attribute"
|
|
175
|
+
else
|
|
176
|
+
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
|
177
|
+
) config.sources;
|
|
178
|
+
|
|
179
|
+
# The "config" used by the fetchers
|
|
180
|
+
mkConfig =
|
|
181
|
+
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
|
182
|
+
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
|
183
|
+
, system ? builtins.currentSystem
|
|
184
|
+
, pkgs ? mkPkgs sources system
|
|
185
|
+
}: rec {
|
|
186
|
+
# The sources, i.e. the attribute set of spec name to spec
|
|
187
|
+
inherit sources;
|
|
188
|
+
|
|
189
|
+
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
|
190
|
+
inherit pkgs;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
in
|
|
194
|
+
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decafhub/decaf-client-extras",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "DECAF Client Extras",
|
|
5
5
|
"author": "Teloscube Pte Ltd",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@decafhub/decaf-client": "^0.3.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@telostat/prelude": "^0.
|
|
32
|
+
"@telostat/prelude": "^0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@commitlint/cli": "^17.3.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecafClient } from '@decafhub/decaf-client';
|
|
2
2
|
import { CustomError, Either, SDate, SDateTime } from '@telostat/prelude';
|
|
3
|
-
import {
|
|
3
|
+
import { CurrencyCode, DateType, DecafActionId, DecafExternalValuationId, DecafOhlcSeriesId, DecafPortfolioId, DecafPrincipalId, DecafShareClassFeeScheduleId, DecafShareClassId } from '../../commons';
|
|
4
4
|
import { RemoteBaseValuationReport } from './-remote-valuation-report-shared';
|
|
5
5
|
import { PortfolioValuationReport, PortfolioValuationReportShareClassValue } from './-valuation-report-portfolio';
|
|
6
6
|
import { ValuationReportPortfolio } from './-valuation-report-shared';
|
|
@@ -23,7 +23,7 @@ export interface PortfolioValuationReportQuery {
|
|
|
23
23
|
/**
|
|
24
24
|
* Portfolio the valuation report is requested for.
|
|
25
25
|
*/
|
|
26
|
-
portfolio:
|
|
26
|
+
portfolio: DecafPortfolioId;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Type definition for the remote (raw) portfolio valuation report data.
|
|
@@ -58,13 +58,13 @@ export interface RemoteValuationShareClassValue {
|
|
|
58
58
|
* Type definition for share class on the remote portfolio valuation report.
|
|
59
59
|
*/
|
|
60
60
|
export interface RemoteValuationShareClass {
|
|
61
|
-
id:
|
|
61
|
+
id: DecafShareClassId;
|
|
62
62
|
created: SDateTime;
|
|
63
|
-
creator:
|
|
63
|
+
creator: DecafPrincipalId;
|
|
64
64
|
updated: SDateTime;
|
|
65
|
-
updater:
|
|
65
|
+
updater: DecafPrincipalId;
|
|
66
66
|
guid: string;
|
|
67
|
-
portfolio:
|
|
67
|
+
portfolio: DecafPortfolioId;
|
|
68
68
|
name: string;
|
|
69
69
|
currency: CurrencyCode;
|
|
70
70
|
isin?: string;
|
|
@@ -76,11 +76,11 @@ export interface RemoteValuationShareClass {
|
|
|
76
76
|
subredperiod?: string;
|
|
77
77
|
freqmngt?: number;
|
|
78
78
|
freqperf?: number;
|
|
79
|
-
benchmark?:
|
|
79
|
+
benchmark?: DecafOhlcSeriesId;
|
|
80
80
|
description?: string;
|
|
81
|
-
feeschedules:
|
|
82
|
-
effectivefeeschedule?:
|
|
83
|
-
subscriptions:
|
|
81
|
+
feeschedules: DecafShareClassFeeScheduleId[];
|
|
82
|
+
effectivefeeschedule?: DecafShareClassFeeScheduleId;
|
|
83
|
+
subscriptions: DecafActionId[];
|
|
84
84
|
outstanding?: number;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -88,14 +88,14 @@ export interface RemoteValuationShareClass {
|
|
|
88
88
|
* report.
|
|
89
89
|
*/
|
|
90
90
|
export interface RemoteValuationExternalValue {
|
|
91
|
-
id:
|
|
91
|
+
id: DecafExternalValuationId;
|
|
92
92
|
created: SDateTime;
|
|
93
|
-
creator:
|
|
93
|
+
creator: DecafPrincipalId;
|
|
94
94
|
updated: SDateTime;
|
|
95
|
-
updater:
|
|
95
|
+
updater: DecafPrincipalId;
|
|
96
96
|
guid: string;
|
|
97
|
-
portfolio:
|
|
98
|
-
shareclass?:
|
|
97
|
+
portfolio: DecafPortfolioId;
|
|
98
|
+
shareclass?: DecafShareClassId;
|
|
99
99
|
date: SDate;
|
|
100
100
|
ccy: CurrencyCode;
|
|
101
101
|
shares?: number;
|
|
@@ -103,7 +103,7 @@ function toShareClassValue(x) {
|
|
|
103
103
|
feeScheduleIds: x.shareclass.feeschedules,
|
|
104
104
|
effectiveFeeScheduleId: prelude_1.Maybe.fromNullable(x.shareclass.effectivefeeschedule),
|
|
105
105
|
subscriptionIds: x.shareclass.subscriptions,
|
|
106
|
-
outstanding: (0, prelude_1.
|
|
106
|
+
outstanding: (0, prelude_1.decimalFromNullable)(x.shareclass.outstanding),
|
|
107
107
|
},
|
|
108
108
|
external: prelude_1.Maybe.fromNullable(x.external).map(function (ev) { return ({
|
|
109
109
|
id: ev.id,
|
|
@@ -116,36 +116,36 @@ function toShareClassValue(x) {
|
|
|
116
116
|
shareclass: prelude_1.Maybe.fromNullable(ev.shareclass),
|
|
117
117
|
date: ev.date,
|
|
118
118
|
ccy: ev.ccy,
|
|
119
|
-
shares: (0, prelude_1.
|
|
120
|
-
price: (0, prelude_1.
|
|
121
|
-
nav: (0, prelude_1.
|
|
122
|
-
aum: (0, prelude_1.
|
|
123
|
-
hedgepnl: (0, prelude_1.
|
|
124
|
-
feemngt: (0, prelude_1.
|
|
125
|
-
feeperf: (0, prelude_1.
|
|
126
|
-
otheraccrued: (0, prelude_1.
|
|
127
|
-
totalaccrued: (0, prelude_1.
|
|
128
|
-
subred: (0, prelude_1.
|
|
129
|
-
perfdaily: (0, prelude_1.
|
|
130
|
-
perfweekly: (0, prelude_1.
|
|
131
|
-
perfmonthly: (0, prelude_1.
|
|
132
|
-
perfytd: (0, prelude_1.
|
|
133
|
-
perfstart: (0, prelude_1.
|
|
134
|
-
coefficient: (0, prelude_1.
|
|
119
|
+
shares: (0, prelude_1.decimalFromNullable)(ev.shares),
|
|
120
|
+
price: (0, prelude_1.decimalFromNullable)(ev.price),
|
|
121
|
+
nav: (0, prelude_1.decimalFromNullable)(ev.nav),
|
|
122
|
+
aum: (0, prelude_1.decimalFromNullable)(ev.aum),
|
|
123
|
+
hedgepnl: (0, prelude_1.decimalFromNullable)(ev.hedgepnl),
|
|
124
|
+
feemngt: (0, prelude_1.decimalFromNullable)(ev.feemngt),
|
|
125
|
+
feeperf: (0, prelude_1.decimalFromNullable)(ev.feeperf),
|
|
126
|
+
otheraccrued: (0, prelude_1.decimalFromNullable)(ev.otheraccrued),
|
|
127
|
+
totalaccrued: (0, prelude_1.decimalFromNullable)(ev.totalaccrued),
|
|
128
|
+
subred: (0, prelude_1.decimalFromNullable)(ev.subred),
|
|
129
|
+
perfdaily: (0, prelude_1.decimalFromNullable)(ev.perfdaily),
|
|
130
|
+
perfweekly: (0, prelude_1.decimalFromNullable)(ev.perfweekly),
|
|
131
|
+
perfmonthly: (0, prelude_1.decimalFromNullable)(ev.perfmonthly),
|
|
132
|
+
perfytd: (0, prelude_1.decimalFromNullable)(ev.perfytd),
|
|
133
|
+
perfstart: (0, prelude_1.decimalFromNullable)(ev.perfstart),
|
|
134
|
+
coefficient: (0, prelude_1.decimalFromNullable)(ev.coefficient),
|
|
135
135
|
}); }),
|
|
136
|
-
nav: (0, prelude_1.
|
|
137
|
-
navAdjusted: (0, prelude_1.
|
|
138
|
-
navAdjustedTotal: (0, prelude_1.
|
|
139
|
-
coefficient: (0, prelude_1.
|
|
140
|
-
gavRefccy: (0, prelude_1.
|
|
141
|
-
gavClsccy: (0, prelude_1.
|
|
142
|
-
sharecountPrev: (0, prelude_1.
|
|
143
|
-
sharecountCurr: (0, prelude_1.
|
|
144
|
-
sharecountDiff: (0, prelude_1.
|
|
145
|
-
pxRefCcy: (0, prelude_1.
|
|
146
|
-
pxClsCcy: (0, prelude_1.
|
|
147
|
-
ytdExt: (0, prelude_1.
|
|
148
|
-
ytdInt: (0, prelude_1.
|
|
136
|
+
nav: (0, prelude_1.unsafeDecimal)(x.nav),
|
|
137
|
+
navAdjusted: (0, prelude_1.unsafeDecimal)(x.nav_adjusted),
|
|
138
|
+
navAdjustedTotal: (0, prelude_1.unsafeDecimal)(x.nav_adjusted_total),
|
|
139
|
+
coefficient: (0, prelude_1.unsafeDecimal)(x.coefficient),
|
|
140
|
+
gavRefccy: (0, prelude_1.unsafeDecimal)(x.gav_refccy),
|
|
141
|
+
gavClsccy: (0, prelude_1.unsafeDecimal)(x.gav_clsccy),
|
|
142
|
+
sharecountPrev: (0, prelude_1.unsafeDecimal)(x.sharecount_prev),
|
|
143
|
+
sharecountCurr: (0, prelude_1.unsafeDecimal)(x.sharecount_curr),
|
|
144
|
+
sharecountDiff: (0, prelude_1.unsafeDecimal)(x.sharecount_diff),
|
|
145
|
+
pxRefCcy: (0, prelude_1.decimalFromNullable)(x.px_refccy),
|
|
146
|
+
pxClsCcy: (0, prelude_1.decimalFromNullable)(x.px_clsccy),
|
|
147
|
+
ytdExt: (0, prelude_1.decimalFromNullable)(x.ytdext),
|
|
148
|
+
ytdInt: (0, prelude_1.decimalFromNullable)(x.ytdint),
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
exports.toShareClassValue = toShareClassValue;
|
|
@@ -162,7 +162,7 @@ function recompilePortfolioValuationReport(x) {
|
|
|
162
162
|
var baseReport = (0, _remote_valuation_report_shared_1.recompileBaseValuationReport)(x);
|
|
163
163
|
// Add consolidated valuation report specific fields and return:
|
|
164
164
|
return baseReport.map(function (report) {
|
|
165
|
-
return __assign(__assign({}, report), { portfolio: x.portfolio, subscriptions: (0, prelude_1.
|
|
165
|
+
return __assign(__assign({}, report), { portfolio: x.portfolio, subscriptions: (0, prelude_1.decimalFromNullable)(x.subscriptions).orDefault(prelude_1.zero), shareClassValues: x.scvals.map(toShareClassValue) });
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
exports.recompilePortfolioValuationReport = recompilePortfolioValuationReport;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomError, Decimal, Either, Maybe, SDate, SDateTime } from '@telostat/prelude';
|
|
2
|
-
import {
|
|
2
|
+
import { CurrencyCode, DateType, DecafArtifactId, DecafArtifactTypeId } from '../../commons';
|
|
3
3
|
import { BaseValuationReport, BaseValuationReportHolding, ValuationReportAccount, ValuationReportAccounts, ValuationReportAccrual, ValuationReportArtifact, ValuationReportFigureOrgRef, ValuationReportHolding } from './-valuation-report-shared';
|
|
4
4
|
export interface RemoteBaseValuationReport {
|
|
5
5
|
reported: SDateTime;
|
|
@@ -161,10 +161,10 @@ export interface RemoteValuationReportChildHolding {
|
|
|
161
161
|
* Valuation artifact.
|
|
162
162
|
*/
|
|
163
163
|
export interface RemoteValuationReportArtifact {
|
|
164
|
-
id:
|
|
164
|
+
id: DecafArtifactId;
|
|
165
165
|
guid: string;
|
|
166
166
|
type: {
|
|
167
|
-
id:
|
|
167
|
+
id: DecafArtifactTypeId;
|
|
168
168
|
name: string;
|
|
169
169
|
order: number;
|
|
170
170
|
};
|
|
@@ -181,7 +181,7 @@ export interface RemoteValuationReportArtifact {
|
|
|
181
181
|
isin?: string;
|
|
182
182
|
figi?: string;
|
|
183
183
|
expiry?: SDate;
|
|
184
|
-
underlying_id?:
|
|
184
|
+
underlying_id?: DecafArtifactId;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* Valuation accrual.
|
|
@@ -22,7 +22,7 @@ function toArtifact(x) {
|
|
|
22
22
|
symbol: x.symbol,
|
|
23
23
|
name: (0, prelude_1.sanitizedNonEmptyText)(x.name),
|
|
24
24
|
ccy: prelude_1.Maybe.fromNullable(x.ccy),
|
|
25
|
-
quantity: (0, prelude_1.
|
|
25
|
+
quantity: (0, prelude_1.unsafeDecimal)(x.quantity),
|
|
26
26
|
country: (0, prelude_1.sanitizedNonEmptyText)(x.country),
|
|
27
27
|
issuer: (0, prelude_1.sanitizedNonEmptyText)(x.issuer),
|
|
28
28
|
sector: (0, prelude_1.sanitizedNonEmptyText)(x.sector),
|
|
@@ -38,14 +38,17 @@ exports.toArtifact = toArtifact;
|
|
|
38
38
|
function toAccrual(x) {
|
|
39
39
|
return {
|
|
40
40
|
name: x.name,
|
|
41
|
-
value: (0, prelude_1.
|
|
41
|
+
value: (0, prelude_1.unsafeDecimal)(x.value),
|
|
42
42
|
accounts: x.accounts.map(function (y) { return ({
|
|
43
43
|
account: y.account,
|
|
44
|
-
value: (0, prelude_1.
|
|
44
|
+
value: (0, prelude_1.unsafeDecimal)(y.value),
|
|
45
45
|
accruals: y.accruals.map(function (z) { return ({
|
|
46
46
|
artifact: toArtifact(z.artifact),
|
|
47
47
|
ccy: z.ccy,
|
|
48
|
-
value: {
|
|
48
|
+
value: {
|
|
49
|
+
org: (0, prelude_1.decimalFromNullable)(z.value.org).orDefault(prelude_1.zero),
|
|
50
|
+
ref: (0, prelude_1.decimalFromNullable)(z.value.ref).orDefault(prelude_1.zero),
|
|
51
|
+
},
|
|
49
52
|
}); }),
|
|
50
53
|
}); }),
|
|
51
54
|
};
|
|
@@ -53,22 +56,22 @@ function toAccrual(x) {
|
|
|
53
56
|
exports.toAccrual = toAccrual;
|
|
54
57
|
function toOrgRef(x) {
|
|
55
58
|
return {
|
|
56
|
-
org: (0, prelude_1.
|
|
57
|
-
ref: (0, prelude_1.
|
|
59
|
+
org: (0, prelude_1.decimalFromNullable)(x.org).orDefault(prelude_1.zero),
|
|
60
|
+
ref: (0, prelude_1.decimalFromNullable)(x.ref).orDefault(prelude_1.zero),
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
exports.toOrgRef = toOrgRef;
|
|
61
64
|
function toMaybeOrgRef(x) {
|
|
62
65
|
return prelude_1.Maybe.fromNullable(x).chain(function (_a) {
|
|
63
66
|
var org = _a.org, ref = _a.ref;
|
|
64
|
-
return (0, prelude_1.
|
|
67
|
+
return (0, prelude_1.decimalFromNullable)(org).chain(function (o) { return (0, prelude_1.decimalFromNullable)(ref).chain(function (r) { return (0, prelude_1.Just)({ org: o, ref: r }); }); });
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
exports.toMaybeOrgRef = toMaybeOrgRef;
|
|
68
71
|
function toBaseHolding(nav, x) {
|
|
69
72
|
return {
|
|
70
73
|
artifact: toArtifact(x.artifact),
|
|
71
|
-
quantity: (0, prelude_1.
|
|
74
|
+
quantity: (0, prelude_1.unsafeDecimal)(x.quantity),
|
|
72
75
|
investment: {
|
|
73
76
|
px: toOrgRef(x.investment.px),
|
|
74
77
|
txncosts: toMaybeOrgRef(x.investment.txncosts),
|
|
@@ -87,12 +90,12 @@ function toBaseHolding(nav, x) {
|
|
|
87
90
|
abs: toOrgRef(x.valuation.exposure.abs),
|
|
88
91
|
},
|
|
89
92
|
},
|
|
90
|
-
valuePercentage: (0, prelude_1.safeDiv)((0, prelude_1.
|
|
91
|
-
netExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.
|
|
92
|
-
absExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.
|
|
93
|
-
change: (0, prelude_1.
|
|
94
|
-
pnl: (0, prelude_1.
|
|
95
|
-
pnlToInvestment: (0, prelude_1.
|
|
93
|
+
valuePercentage: (0, prelude_1.safeDiv)((0, prelude_1.decimalFromNullable)(x.valuation.value.net.ref).orDefault(prelude_1.zero), nav),
|
|
94
|
+
netExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.decimalFromNullable)(x.valuation.exposure.net.ref).orDefault(prelude_1.zero), nav),
|
|
95
|
+
absExposurePercentage: (0, prelude_1.safeDiv)((0, prelude_1.decimalFromNullable)(x.valuation.exposure.abs.ref).orDefault(prelude_1.zero), nav),
|
|
96
|
+
change: (0, prelude_1.decimalFromNullable)(x.change),
|
|
97
|
+
pnl: (0, prelude_1.decimalFromNullable)(x.pnl).orDefault(prelude_1.zero),
|
|
98
|
+
pnlToInvestment: (0, prelude_1.decimalFromNullable)(x.pnl_to_investment),
|
|
96
99
|
opendate: x.opendate,
|
|
97
100
|
lastdate: x.lastdate,
|
|
98
101
|
};
|
|
@@ -115,7 +118,7 @@ exports.toHolding = toHolding;
|
|
|
115
118
|
* report.
|
|
116
119
|
*/
|
|
117
120
|
function recompileBaseValuationReport(x) {
|
|
118
|
-
var nav = (0, prelude_1.
|
|
121
|
+
var nav = (0, prelude_1.decimalFromNullable)(x.nav).orDefault(prelude_1.zero);
|
|
119
122
|
var report = {
|
|
120
123
|
asof: x.reported,
|
|
121
124
|
date: x.asof,
|
|
@@ -124,20 +127,20 @@ function recompileBaseValuationReport(x) {
|
|
|
124
127
|
accounts: x.accounts,
|
|
125
128
|
holdings: x.holdings.map(function (rh) { return toHolding(nav, rh); }),
|
|
126
129
|
accruals: x.accruals.map(toAccrual),
|
|
127
|
-
fxRates: x.fxrates.map(function (r) { return ({ ccy1: r.ccy1, ccy2: r.ccy2, value: (0, prelude_1.
|
|
130
|
+
fxRates: x.fxrates.map(function (r) { return ({ ccy1: r.ccy1, ccy2: r.ccy2, value: (0, prelude_1.unsafeDecimal)(r.value), asof: r.asof }); }),
|
|
128
131
|
figures: {
|
|
129
|
-
investment: (0, prelude_1.
|
|
132
|
+
investment: (0, prelude_1.decimalFromNullable)(x.investment).orDefault(prelude_1.zero),
|
|
130
133
|
valuation: {
|
|
131
|
-
net: (0, prelude_1.
|
|
132
|
-
abs: (0, prelude_1.
|
|
134
|
+
net: (0, prelude_1.decimalFromNullable)(x.valuation_net).orDefault(prelude_1.zero),
|
|
135
|
+
abs: (0, prelude_1.decimalFromNullable)(x.valuation_abs).orDefault(prelude_1.zero),
|
|
133
136
|
},
|
|
134
|
-
accrued: (0, prelude_1.
|
|
135
|
-
liabilities: (0, prelude_1.
|
|
136
|
-
gav: (0, prelude_1.
|
|
137
|
+
accrued: (0, prelude_1.decimalFromNullable)(x.accrued).orDefault(prelude_1.zero),
|
|
138
|
+
liabilities: (0, prelude_1.decimalFromNullable)(x.liabilities).orDefault(prelude_1.zero),
|
|
139
|
+
gav: (0, prelude_1.decimalFromNullable)(x.gav).orDefault(prelude_1.zero),
|
|
137
140
|
nav: nav,
|
|
138
|
-
aum: (0, prelude_1.
|
|
139
|
-
pnl: (0, prelude_1.
|
|
140
|
-
pnlToInvestment: (0, prelude_1.
|
|
141
|
+
aum: (0, prelude_1.decimalFromNullable)(x.aum).orDefault(prelude_1.zero),
|
|
142
|
+
pnl: (0, prelude_1.decimalFromNullable)(x.pnl).orDefault(prelude_1.zero),
|
|
143
|
+
pnlToInvestment: (0, prelude_1.decimalFromNullable)(x.pnl_to_investment),
|
|
141
144
|
},
|
|
142
145
|
};
|
|
143
146
|
return (0, prelude_1.Right)(report);
|