@decafhub/decaf-client-extras 0.0.3 → 0.0.5

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.
Files changed (32) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/README.md +13 -1
  4. package/commons/-currency.d.ts +8 -8
  5. package/commons/-currency.js +7 -7
  6. package/commons/-date-type.d.ts +1 -1
  7. package/commons/-id.d.ts +14 -14
  8. package/es/commons/-currency.d.ts +8 -8
  9. package/es/commons/-currency.js +7 -7
  10. package/es/commons/-date-type.d.ts +1 -1
  11. package/es/commons/-id.d.ts +14 -14
  12. package/es/reports/valuation/-remote-valuation-report-consolidated.d.ts +1 -1
  13. package/es/reports/valuation/-remote-valuation-report-consolidated.js +1 -1
  14. package/es/reports/valuation/-remote-valuation-report-portfolio.d.ts +1 -1
  15. package/es/reports/valuation/-remote-valuation-report-portfolio.js +1 -1
  16. package/es/reports/valuation/-valuation-report-consolidated.d.ts +1 -1
  17. package/es/reports/valuation/-valuation-report-holdings-tree/-machinery.js +5 -2
  18. package/es/reports/valuation/-valuation-report-shared.d.ts +2 -2
  19. package/package.json +21 -21
  20. package/reports/valuation/-remote-valuation-report-consolidated.d.ts +1 -1
  21. package/reports/valuation/-remote-valuation-report-consolidated.js +2 -2
  22. package/reports/valuation/-remote-valuation-report-portfolio.d.ts +1 -1
  23. package/reports/valuation/-remote-valuation-report-portfolio.js +2 -2
  24. package/reports/valuation/-valuation-report-consolidated.d.ts +1 -1
  25. package/reports/valuation/-valuation-report-holdings-tree/-machinery.js +7 -2
  26. package/reports/valuation/-valuation-report-shared.d.ts +2 -2
  27. package/src/commons/-currency.ts +7 -7
  28. package/src/index.test.ts +31 -2
  29. package/src/reports/valuation/-remote-valuation-report-consolidated.ts +1 -1
  30. package/src/reports/valuation/-remote-valuation-report-portfolio.ts +1 -1
  31. package/src/reports/valuation/-valuation-report-holdings-tree/-machinery.ts +13 -2
  32. package/src/reports/valuation/-valuation-report-shared.ts +1 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.0.3"
2
+ ".": "0.0.5"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.5](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.0.4...v0.0.5) (2022-12-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * exclude cash holdings from total exposure calculation ([09d7133](https://github.com/teloscube/decaf-client-javascript-extras/commit/09d7133515d9670dc3c5a641dd84d1e57fa5d5ee))
9
+
10
+ ## [0.0.4](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.0.3...v0.0.4) (2022-11-07)
11
+
12
+
13
+ ### Miscellaneous Chores
14
+
15
+ * release 0.0.4 ([b3f7a12](https://github.com/teloscube/decaf-client-javascript-extras/commit/b3f7a12b5dbd1ffac7db06f03958d71581889d92))
16
+
3
17
  ## [0.0.3](https://github.com/teloscube/decaf-client-javascript-extras/compare/v0.0.2...v0.0.3) (2022-08-25)
4
18
 
5
19
 
package/README.md CHANGED
@@ -4,7 +4,19 @@
4
4
  [![npm](https://img.shields.io/npm/dm/@decafhub/decaf-client-extras.svg)](https://www.npmjs.com/package/@decafhub/decaf-client-extras)
5
5
  ![GitHub](https://img.shields.io/github/license/teloscube/decaf-client-javascript-extras)
6
6
 
7
- > **TODO:** Add README content.
7
+ ## Install
8
+
9
+ Install @decafhub/decaf-client-extras along with its peer dependency @decafhub/decaf-client:
10
+
11
+ ```bash
12
+ npm install --save @decafhub/decaf-client-extras @decafhub/decaf-client
13
+ ```
14
+
15
+ Or with yarn:
16
+
17
+ ```bash
18
+ yarn add @decafhub/decaf-client-extras @decafhub/decaf-client
19
+ ```
8
20
 
9
21
  ## Testing
10
22
 
@@ -9,34 +9,34 @@ import { Maybe, NewTypeWithPhantom } from '@telostat/prelude';
9
9
  *
10
10
  * A currency code is (typically) defined as all-uppercase, three letters.
11
11
  */
12
- export declare type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
12
+ export type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
13
13
  /**
14
- * Attempts to create a [[CurrencyCode]] value with the given currency code.
14
+ * Attempts to create a {@link CurrencyCode} value with the given currency code.
15
15
  *
16
16
  * This function returns a `Maybe` value. For the version that throws an
17
- * error, see [[mkCurrencyCodeError]].
17
+ * error, see {@link mkCurrencyCodeError}.
18
18
  *
19
19
  * @param x A currency code represented as string.
20
20
  * @returns If the argument has leading or trailing spaces OR it is empty,
21
- * `Nothing` is retured, `Just` [[CurrencyCode]] otherwise.
21
+ * `Nothing` is retured, `Just` {@link CurrencyCode} otherwise.
22
22
  */
23
23
  export declare function mkCurrencyCode(x: string): Maybe<CurrencyCode>;
24
24
  /**
25
- * (Unsafely) attempts to create a [[CurrencyCode]] value with the given
25
+ * (Unsafely) attempts to create a {@link CurrencyCode} value with the given
26
26
  * currency code.
27
27
  *
28
28
  * This function may throw an error if the given argument is not a valid
29
- * currency code. For the monadic version, see [[mkCurrencyCode]].
29
+ * currency code. For the monadic version, see {@link mkCurrencyCode}.
30
30
  *
31
31
  * @param x A currency code represented as string.
32
32
  * @returns If the argument has leading or trailing spaces OR it is empty, an
33
- * error is thrown, [[CurrencyCode]] is returned otherwise.
33
+ * error is thrown, {@link CurrencyCode} is returned otherwise.
34
34
  */
35
35
  export declare function mkCurrencyCodeError(x: string): CurrencyCode;
36
36
  /**
37
37
  * Return the currency code as a string value.
38
38
  *
39
- * @param x [[CurrencyCode]] to be extracted string from.
39
+ * @param x {@link CurrencyCode} to be extracted string from.
40
40
  * @returns Currency code as a string.
41
41
  */
42
42
  export declare function unCurrencyCode(x: CurrencyCode): string;
@@ -8,29 +8,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.unCurrencyCode = exports.mkCurrencyCodeError = exports.mkCurrencyCode = void 0;
9
9
  var prelude_1 = require("@telostat/prelude");
10
10
  /**
11
- * Attempts to create a [[CurrencyCode]] value with the given currency code.
11
+ * Attempts to create a {@link CurrencyCode} value with the given currency code.
12
12
  *
13
13
  * This function returns a `Maybe` value. For the version that throws an
14
- * error, see [[mkCurrencyCodeError]].
14
+ * error, see {@link mkCurrencyCodeError}.
15
15
  *
16
16
  * @param x A currency code represented as string.
17
17
  * @returns If the argument has leading or trailing spaces OR it is empty,
18
- * `Nothing` is retured, `Just` [[CurrencyCode]] otherwise.
18
+ * `Nothing` is retured, `Just` {@link CurrencyCode} otherwise.
19
19
  */
20
20
  function mkCurrencyCode(x) {
21
21
  return x !== x.trim() || x === '' ? prelude_1.Nothing : (0, prelude_1.Just)((0, prelude_1.mkPhantom)(x));
22
22
  }
23
23
  exports.mkCurrencyCode = mkCurrencyCode;
24
24
  /**
25
- * (Unsafely) attempts to create a [[CurrencyCode]] value with the given
25
+ * (Unsafely) attempts to create a {@link CurrencyCode} value with the given
26
26
  * currency code.
27
27
  *
28
28
  * This function may throw an error if the given argument is not a valid
29
- * currency code. For the monadic version, see [[mkCurrencyCode]].
29
+ * currency code. For the monadic version, see {@link mkCurrencyCode}.
30
30
  *
31
31
  * @param x A currency code represented as string.
32
32
  * @returns If the argument has leading or trailing spaces OR it is empty, an
33
- * error is thrown, [[CurrencyCode]] is returned otherwise.
33
+ * error is thrown, {@link CurrencyCode} is returned otherwise.
34
34
  */
35
35
  function mkCurrencyCodeError(x) {
36
36
  return mkCurrencyCode(x).orDefaultLazy(function () {
@@ -41,7 +41,7 @@ exports.mkCurrencyCodeError = mkCurrencyCodeError;
41
41
  /**
42
42
  * Return the currency code as a string value.
43
43
  *
44
- * @param x [[CurrencyCode]] to be extracted string from.
44
+ * @param x {@link CurrencyCode} to be extracted string from.
45
45
  * @returns Currency code as a string.
46
46
  */
47
47
  function unCurrencyCode(x) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DECAF FINREA action date type type definition.
3
3
  */
4
- export declare type DateType = 'commitment' | 'settlement';
4
+ export type DateType = 'commitment' | 'settlement';
5
5
  /**
6
6
  * Translation table for DECAF FINREA action date types.
7
7
  */
package/commons/-id.d.ts CHANGED
@@ -3,56 +3,56 @@ import { NewTypeWithPhantom } from '@telostat/prelude';
3
3
  * Type definition for identifiers with value spaces discriminated over the
4
4
  * given phantom type.
5
5
  */
6
- export declare type Id<P, V> = NewTypeWithPhantom<P, V>;
6
+ export type Id<P, V> = NewTypeWithPhantom<P, V>;
7
7
  /**
8
8
  * Type definition for DECAF artifact identifiers.
9
9
  */
10
- export declare type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
10
+ export type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
11
11
  /**
12
12
  * Type definition for DECAF artifact type identifiers.
13
13
  */
14
- export declare type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
14
+ export type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
15
15
  /**
16
16
  * Type definition for DECAF share class identifiers.
17
17
  */
18
- export declare type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
18
+ export type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
19
19
  /**
20
20
  * Type definition for DECAF principal identifiers.
21
21
  */
22
- export declare type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
22
+ export type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
23
23
  /**
24
24
  * Type definition for DECAF institution identifiers.
25
25
  */
26
- export declare type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
26
+ export type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
27
27
  /**
28
28
  * Type definition for DECAF team identifiers.
29
29
  */
30
- export declare type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
30
+ export type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
31
31
  /**
32
32
  * Type definition for DECAF portfolio identifiers.
33
33
  */
34
- export declare type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
34
+ export type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
35
35
  /**
36
36
  * Type definition for DECAF portfolio group identifiers.
37
37
  */
38
- export declare type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
38
+ export type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
39
39
  /**
40
40
  * Type definition for DECAF account identifiers.
41
41
  */
42
- export declare type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
42
+ export type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
43
43
  /**
44
44
  * Type definition for DECAF OHLC series identifiers.
45
45
  */
46
- export declare type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
46
+ export type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
47
47
  /**
48
48
  * Type definition for DECAF share class fee schedule identifiers.
49
49
  */
50
- export declare type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
50
+ export type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
51
51
  /**
52
52
  * Type definition for DECAF action identifiers.
53
53
  */
54
- export declare type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
54
+ export type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
55
55
  /**
56
56
  * Type definition for DECAF external valuation identifiers.
57
57
  */
58
- export declare type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
58
+ export type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
@@ -9,34 +9,34 @@ import { Maybe, NewTypeWithPhantom } from '@telostat/prelude';
9
9
  *
10
10
  * A currency code is (typically) defined as all-uppercase, three letters.
11
11
  */
12
- export declare type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
12
+ export type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
13
13
  /**
14
- * Attempts to create a [[CurrencyCode]] value with the given currency code.
14
+ * Attempts to create a {@link CurrencyCode} value with the given currency code.
15
15
  *
16
16
  * This function returns a `Maybe` value. For the version that throws an
17
- * error, see [[mkCurrencyCodeError]].
17
+ * error, see {@link mkCurrencyCodeError}.
18
18
  *
19
19
  * @param x A currency code represented as string.
20
20
  * @returns If the argument has leading or trailing spaces OR it is empty,
21
- * `Nothing` is retured, `Just` [[CurrencyCode]] otherwise.
21
+ * `Nothing` is retured, `Just` {@link CurrencyCode} otherwise.
22
22
  */
23
23
  export declare function mkCurrencyCode(x: string): Maybe<CurrencyCode>;
24
24
  /**
25
- * (Unsafely) attempts to create a [[CurrencyCode]] value with the given
25
+ * (Unsafely) attempts to create a {@link CurrencyCode} value with the given
26
26
  * currency code.
27
27
  *
28
28
  * This function may throw an error if the given argument is not a valid
29
- * currency code. For the monadic version, see [[mkCurrencyCode]].
29
+ * currency code. For the monadic version, see {@link mkCurrencyCode}.
30
30
  *
31
31
  * @param x A currency code represented as string.
32
32
  * @returns If the argument has leading or trailing spaces OR it is empty, an
33
- * error is thrown, [[CurrencyCode]] is returned otherwise.
33
+ * error is thrown, {@link CurrencyCode} is returned otherwise.
34
34
  */
35
35
  export declare function mkCurrencyCodeError(x: string): CurrencyCode;
36
36
  /**
37
37
  * Return the currency code as a string value.
38
38
  *
39
- * @param x [[CurrencyCode]] to be extracted string from.
39
+ * @param x {@link CurrencyCode} to be extracted string from.
40
40
  * @returns Currency code as a string.
41
41
  */
42
42
  export declare function unCurrencyCode(x: CurrencyCode): string;
@@ -5,28 +5,28 @@
5
5
  */
6
6
  import { Just, mkPhantom, Nothing, unPhantom } from '@telostat/prelude';
7
7
  /**
8
- * Attempts to create a [[CurrencyCode]] value with the given currency code.
8
+ * Attempts to create a {@link CurrencyCode} value with the given currency code.
9
9
  *
10
10
  * This function returns a `Maybe` value. For the version that throws an
11
- * error, see [[mkCurrencyCodeError]].
11
+ * error, see {@link mkCurrencyCodeError}.
12
12
  *
13
13
  * @param x A currency code represented as string.
14
14
  * @returns If the argument has leading or trailing spaces OR it is empty,
15
- * `Nothing` is retured, `Just` [[CurrencyCode]] otherwise.
15
+ * `Nothing` is retured, `Just` {@link CurrencyCode} otherwise.
16
16
  */
17
17
  export function mkCurrencyCode(x) {
18
18
  return x !== x.trim() || x === '' ? Nothing : Just(mkPhantom(x));
19
19
  }
20
20
  /**
21
- * (Unsafely) attempts to create a [[CurrencyCode]] value with the given
21
+ * (Unsafely) attempts to create a {@link CurrencyCode} value with the given
22
22
  * currency code.
23
23
  *
24
24
  * This function may throw an error if the given argument is not a valid
25
- * currency code. For the monadic version, see [[mkCurrencyCode]].
25
+ * currency code. For the monadic version, see {@link mkCurrencyCode}.
26
26
  *
27
27
  * @param x A currency code represented as string.
28
28
  * @returns If the argument has leading or trailing spaces OR it is empty, an
29
- * error is thrown, [[CurrencyCode]] is returned otherwise.
29
+ * error is thrown, {@link CurrencyCode} is returned otherwise.
30
30
  */
31
31
  export function mkCurrencyCodeError(x) {
32
32
  return mkCurrencyCode(x).orDefaultLazy(() => {
@@ -36,7 +36,7 @@ export function mkCurrencyCodeError(x) {
36
36
  /**
37
37
  * Return the currency code as a string value.
38
38
  *
39
- * @param x [[CurrencyCode]] to be extracted string from.
39
+ * @param x {@link CurrencyCode} to be extracted string from.
40
40
  * @returns Currency code as a string.
41
41
  */
42
42
  export function unCurrencyCode(x) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DECAF FINREA action date type type definition.
3
3
  */
4
- export declare type DateType = 'commitment' | 'settlement';
4
+ export type DateType = 'commitment' | 'settlement';
5
5
  /**
6
6
  * Translation table for DECAF FINREA action date types.
7
7
  */
@@ -3,56 +3,56 @@ import { NewTypeWithPhantom } from '@telostat/prelude';
3
3
  * Type definition for identifiers with value spaces discriminated over the
4
4
  * given phantom type.
5
5
  */
6
- export declare type Id<P, V> = NewTypeWithPhantom<P, V>;
6
+ export type Id<P, V> = NewTypeWithPhantom<P, V>;
7
7
  /**
8
8
  * Type definition for DECAF artifact identifiers.
9
9
  */
10
- export declare type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
10
+ export type ArtifactId = NewTypeWithPhantom<'DecafArtifact', string | number>;
11
11
  /**
12
12
  * Type definition for DECAF artifact type identifiers.
13
13
  */
14
- export declare type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
14
+ export type ArtifactTypeId = NewTypeWithPhantom<'DecafArtifactType', string>;
15
15
  /**
16
16
  * Type definition for DECAF share class identifiers.
17
17
  */
18
- export declare type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
18
+ export type ShareClassId = NewTypeWithPhantom<'DecafShareClass', string | number>;
19
19
  /**
20
20
  * Type definition for DECAF principal identifiers.
21
21
  */
22
- export declare type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
22
+ export type PrincipalId = NewTypeWithPhantom<'DecafPrincipal', string | number>;
23
23
  /**
24
24
  * Type definition for DECAF institution identifiers.
25
25
  */
26
- export declare type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
26
+ export type InstitutionId = NewTypeWithPhantom<'DecafInstitution', string | number>;
27
27
  /**
28
28
  * Type definition for DECAF team identifiers.
29
29
  */
30
- export declare type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
30
+ export type TeamId = NewTypeWithPhantom<'DecafTeam', string | number>;
31
31
  /**
32
32
  * Type definition for DECAF portfolio identifiers.
33
33
  */
34
- export declare type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
34
+ export type PortfolioId = NewTypeWithPhantom<'DecafPortfolio', string | number>;
35
35
  /**
36
36
  * Type definition for DECAF portfolio group identifiers.
37
37
  */
38
- export declare type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
38
+ export type PortfolioGroupId = NewTypeWithPhantom<'DecafPortfolioGroup', string | number>;
39
39
  /**
40
40
  * Type definition for DECAF account identifiers.
41
41
  */
42
- export declare type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
42
+ export type AccountId = NewTypeWithPhantom<'DecafAccount', string | number>;
43
43
  /**
44
44
  * Type definition for DECAF OHLC series identifiers.
45
45
  */
46
- export declare type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
46
+ export type OhlcSeriesId = NewTypeWithPhantom<'DecafOhlcSeries', string | number>;
47
47
  /**
48
48
  * Type definition for DECAF share class fee schedule identifiers.
49
49
  */
50
- export declare type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
50
+ export type ShareClassFeeScheduleId = NewTypeWithPhantom<'DecafShareClassFeeSchedule', string | number>;
51
51
  /**
52
52
  * Type definition for DECAF action identifiers.
53
53
  */
54
- export declare type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
54
+ export type ActionId = NewTypeWithPhantom<'DecafAction', string | number>;
55
55
  /**
56
56
  * Type definition for DECAF external valuation identifiers.
57
57
  */
58
- export declare type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
58
+ export type ExternalValuationId = NewTypeWithPhantom<'DecafExternalValuation', string | number>;
@@ -60,7 +60,7 @@ export declare function fetchRemoteConsolidatedValuationReport(client: DecafClie
60
60
  export declare function recompileConsolidatedValuationReport(x: RemoteConsolidatedValuationReport): Either<CustomError, ConsolidatedValuationReport>;
61
61
  /**
62
62
  * Attempts to retrieve remote consolidated valuation report, compiles it to
63
- * [[ConsolidatedValuationReport]] and return it.
63
+ * {@link ConsolidatedValuationReport} and return it.
64
64
  *
65
65
  * @param client DECAF Barista client.
66
66
  * @param query Remote consolidated valuation report endpoint query parameters.
@@ -42,7 +42,7 @@ export function recompileConsolidatedValuationReport(x) {
42
42
  }
43
43
  /**
44
44
  * Attempts to retrieve remote consolidated valuation report, compiles it to
45
- * [[ConsolidatedValuationReport]] and return it.
45
+ * {@link ConsolidatedValuationReport} and return it.
46
46
  *
47
47
  * @param client DECAF Barista client.
48
48
  * @param query Remote consolidated valuation report endpoint query parameters.
@@ -141,7 +141,7 @@ export declare function toShareClassValue(x: RemoteValuationShareClassValue): Po
141
141
  export declare function recompilePortfolioValuationReport(x: RemotePortfolioValuationReport): Either<CustomError, PortfolioValuationReport>;
142
142
  /**
143
143
  * Attempts to retrieve remote portfolio valuation report, compiles it to
144
- * [[PortfolioValuationReport]] and return it.
144
+ * {@link PortfolioValuationReport} and return it.
145
145
  *
146
146
  * @param client DECAF Barista client.
147
147
  * @param query Remote portolio valuation report endpoint query parameters.
@@ -120,7 +120,7 @@ export function recompilePortfolioValuationReport(x) {
120
120
  }
121
121
  /**
122
122
  * Attempts to retrieve remote portfolio valuation report, compiles it to
123
- * [[PortfolioValuationReport]] and return it.
123
+ * {@link PortfolioValuationReport} and return it.
124
124
  *
125
125
  * @param client DECAF Barista client.
126
126
  * @param query Remote portolio valuation report endpoint query parameters.
@@ -15,7 +15,7 @@ export interface ConsolidatedValuationReport extends BaseValuationReport {
15
15
  /**
16
16
  * Type definition for container types to be consolidated.
17
17
  */
18
- export declare type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
18
+ export type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
19
19
  /**
20
20
  * Type definition for valuation report containers.
21
21
  */
@@ -23,8 +23,11 @@ export function updateTotals(nav, investment, tree) {
23
23
  const children = tree.children;
24
24
  const netValue = sumDecimals(holdings.map((x) => x.valuation.value.net.ref)).add(sumDecimals(children.map((x) => x.totals.netValue)));
25
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)));
26
+ const holdingsForExposure = holdings.filter((h) => !(h.artifact.type.id === 'CCY' ||
27
+ h.artifact.type.id === 'DEPO' ||
28
+ h.artifact.type.id === 'LOAN'));
29
+ const netExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.net.ref)).add(sumDecimals(children.map((x) => x.totals.netExposure)));
30
+ const absExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.abs.ref)).add(sumDecimals(children.map((x) => x.totals.absExposure)));
28
31
  const pnl = sumDecimals(holdings.map((x) => x.pnl)).add(sumDecimals(children.map((x) => x.totals.pnl)));
29
32
  const accruedsHoldings = holdings.map((x) => x.investment.accrued.map((x) => x.ref));
30
33
  const accruedsChildren = children.map((x) => x.totals.accrued);
@@ -53,7 +53,7 @@ export interface ValuationReportAccounts {
53
53
  /**
54
54
  * The definition for valuation report holding classification.
55
55
  */
56
- export declare type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
56
+ export type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
57
57
  /**
58
58
  * Type definition for valuation report holding classification node.
59
59
  */
@@ -63,7 +63,7 @@ export interface ValuationReportHoldingClassificationNode {
63
63
  }
64
64
  /**
65
65
  * Type definition for base valuation report holding (shared by
66
- * [[ValuationReportHolding]] and [[ValuationReportChildHolding]]).
66
+ * {@link ValuationReportHolding} and {@link ValuationReportChildHolding}).
67
67
  */
68
68
  export interface BaseValuationReportHolding {
69
69
  artifact: ValuationReportArtifact;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decafhub/decaf-client-extras",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "DECAF Client Extras",
5
5
  "author": "Teloscube Pte Ltd",
6
6
  "license": "MIT",
@@ -26,36 +26,36 @@
26
26
  "node": ">=14"
27
27
  },
28
28
  "peerDependencies": {
29
- "@decafhub/decaf-client": "~0.2"
29
+ "@decafhub/decaf-client": "^0.3.1"
30
30
  },
31
31
  "dependencies": {
32
- "@telostat/prelude": "^0.1.1"
32
+ "@telostat/prelude": "^0.1.2"
33
33
  },
34
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",
35
+ "@commitlint/cli": "^17.3.0",
36
+ "@commitlint/config-conventional": "^17.3.0",
37
+ "@decafhub/decaf-client": "^0.3.1",
38
+ "@types/jest": "^29.2.4",
39
+ "@types/node": "^18.11.18",
40
+ "@typescript-eslint/eslint-plugin": "^5.47.1",
41
+ "@typescript-eslint/parser": "^5.47.1",
42
+ "dotenv": "^16.0.3",
43
+ "eslint": "^8.30.0",
44
44
  "eslint-config-prettier": "^8.5.0",
45
45
  "eslint-config-standard": "^17.0.0",
46
46
  "eslint-plugin-import": "^2.26.0",
47
- "eslint-plugin-n": "^15.2.4",
47
+ "eslint-plugin-n": "^15.6.0",
48
48
  "eslint-plugin-prettier": "^4.2.1",
49
- "eslint-plugin-promise": "^6.0.0",
49
+ "eslint-plugin-promise": "^6.1.1",
50
50
  "eslint-plugin-standard": "^5.0.0",
51
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"
52
+ "husky": "^8.0.2",
53
+ "jest": "^29.3.1",
54
+ "lint-staged": "^13.1.0",
55
+ "prettier": "^2.8.1",
56
+ "ts-jest": "^29.0.3",
57
+ "typedoc": "^0.23.23",
58
+ "typescript": "^4.9.4"
59
59
  },
60
60
  "lint-staged": {
61
61
  "src/**/*.{ts,tsx}": [
@@ -60,7 +60,7 @@ export declare function fetchRemoteConsolidatedValuationReport(client: DecafClie
60
60
  export declare function recompileConsolidatedValuationReport(x: RemoteConsolidatedValuationReport): Either<CustomError, ConsolidatedValuationReport>;
61
61
  /**
62
62
  * Attempts to retrieve remote consolidated valuation report, compiles it to
63
- * [[ConsolidatedValuationReport]] and return it.
63
+ * {@link ConsolidatedValuationReport} and return it.
64
64
  *
65
65
  * @param client DECAF Barista client.
66
66
  * @param query Remote consolidated valuation report endpoint query parameters.
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
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
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -90,7 +90,7 @@ function recompileConsolidatedValuationReport(x) {
90
90
  exports.recompileConsolidatedValuationReport = recompileConsolidatedValuationReport;
91
91
  /**
92
92
  * Attempts to retrieve remote consolidated valuation report, compiles it to
93
- * [[ConsolidatedValuationReport]] and return it.
93
+ * {@link ConsolidatedValuationReport} and return it.
94
94
  *
95
95
  * @param client DECAF Barista client.
96
96
  * @param query Remote consolidated valuation report endpoint query parameters.
@@ -141,7 +141,7 @@ export declare function toShareClassValue(x: RemoteValuationShareClassValue): Po
141
141
  export declare function recompilePortfolioValuationReport(x: RemotePortfolioValuationReport): Either<CustomError, PortfolioValuationReport>;
142
142
  /**
143
143
  * Attempts to retrieve remote portfolio valuation report, compiles it to
144
- * [[PortfolioValuationReport]] and return it.
144
+ * {@link PortfolioValuationReport} and return it.
145
145
  *
146
146
  * @param client DECAF Barista client.
147
147
  * @param query Remote portolio valuation report endpoint query parameters.
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
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
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -168,7 +168,7 @@ function recompilePortfolioValuationReport(x) {
168
168
  exports.recompilePortfolioValuationReport = recompilePortfolioValuationReport;
169
169
  /**
170
170
  * Attempts to retrieve remote portfolio valuation report, compiles it to
171
- * [[PortfolioValuationReport]] and return it.
171
+ * {@link PortfolioValuationReport} and return it.
172
172
  *
173
173
  * @param client DECAF Barista client.
174
174
  * @param query Remote portolio valuation report endpoint query parameters.
@@ -15,7 +15,7 @@ export interface ConsolidatedValuationReport extends BaseValuationReport {
15
15
  /**
16
16
  * Type definition for container types to be consolidated.
17
17
  */
18
- export declare type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
18
+ export type ConsolidatedValuationReportContainerType = 'account' | 'portfolio' | 'team' | 'custodian' | 'portfolio-group';
19
19
  /**
20
20
  * Type definition for valuation report containers.
21
21
  */
@@ -63,8 +63,13 @@ function updateTotals(nav, investment, tree) {
63
63
  var children = tree.children;
64
64
  var netValue = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.value.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netValue; })));
65
65
  var absValue = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.value.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absValue; })));
66
- var netExposure = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.exposure.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netExposure; })));
67
- var absExposure = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.valuation.exposure.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absExposure; })));
66
+ var holdingsForExposure = holdings.filter(function (h) {
67
+ return !(h.artifact.type.id === 'CCY' ||
68
+ h.artifact.type.id === 'DEPO' ||
69
+ h.artifact.type.id === 'LOAN');
70
+ });
71
+ var netExposure = (0, prelude_1.sumDecimals)(holdingsForExposure.map(function (x) { return x.valuation.exposure.net.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.netExposure; })));
72
+ var absExposure = (0, prelude_1.sumDecimals)(holdingsForExposure.map(function (x) { return x.valuation.exposure.abs.ref; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.absExposure; })));
68
73
  var pnl = (0, prelude_1.sumDecimals)(holdings.map(function (x) { return x.pnl; })).add((0, prelude_1.sumDecimals)(children.map(function (x) { return x.totals.pnl; })));
69
74
  var accruedsHoldings = holdings.map(function (x) { return x.investment.accrued.map(function (x) { return x.ref; }); });
70
75
  var accruedsChildren = children.map(function (x) { return x.totals.accrued; });
@@ -53,7 +53,7 @@ export interface ValuationReportAccounts {
53
53
  /**
54
54
  * The definition for valuation report holding classification.
55
55
  */
56
- export declare type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
56
+ export type ValuationReportHoldingClassification = ValuationReportHoldingClassificationNode[];
57
57
  /**
58
58
  * Type definition for valuation report holding classification node.
59
59
  */
@@ -63,7 +63,7 @@ export interface ValuationReportHoldingClassificationNode {
63
63
  }
64
64
  /**
65
65
  * Type definition for base valuation report holding (shared by
66
- * [[ValuationReportHolding]] and [[ValuationReportChildHolding]]).
66
+ * {@link ValuationReportHolding} and {@link ValuationReportChildHolding}).
67
67
  */
68
68
  export interface BaseValuationReportHolding {
69
69
  artifact: ValuationReportArtifact;
@@ -14,29 +14,29 @@ import { Just, Maybe, mkPhantom, NewTypeWithPhantom, Nothing, unPhantom } from '
14
14
  export type CurrencyCode = NewTypeWithPhantom<'CurrencyCode', string>;
15
15
 
16
16
  /**
17
- * Attempts to create a [[CurrencyCode]] value with the given currency code.
17
+ * Attempts to create a {@link CurrencyCode} value with the given currency code.
18
18
  *
19
19
  * This function returns a `Maybe` value. For the version that throws an
20
- * error, see [[mkCurrencyCodeError]].
20
+ * error, see {@link mkCurrencyCodeError}.
21
21
  *
22
22
  * @param x A currency code represented as string.
23
23
  * @returns If the argument has leading or trailing spaces OR it is empty,
24
- * `Nothing` is retured, `Just` [[CurrencyCode]] otherwise.
24
+ * `Nothing` is retured, `Just` {@link CurrencyCode} otherwise.
25
25
  */
26
26
  export function mkCurrencyCode(x: string): Maybe<CurrencyCode> {
27
27
  return x !== x.trim() || x === '' ? Nothing : Just(mkPhantom(x));
28
28
  }
29
29
 
30
30
  /**
31
- * (Unsafely) attempts to create a [[CurrencyCode]] value with the given
31
+ * (Unsafely) attempts to create a {@link CurrencyCode} value with the given
32
32
  * currency code.
33
33
  *
34
34
  * This function may throw an error if the given argument is not a valid
35
- * currency code. For the monadic version, see [[mkCurrencyCode]].
35
+ * currency code. For the monadic version, see {@link mkCurrencyCode}.
36
36
  *
37
37
  * @param x A currency code represented as string.
38
38
  * @returns If the argument has leading or trailing spaces OR it is empty, an
39
- * error is thrown, [[CurrencyCode]] is returned otherwise.
39
+ * error is thrown, {@link CurrencyCode} is returned otherwise.
40
40
  */
41
41
  export function mkCurrencyCodeError(x: string): CurrencyCode {
42
42
  return mkCurrencyCode(x).orDefaultLazy(() => {
@@ -47,7 +47,7 @@ export function mkCurrencyCodeError(x: string): CurrencyCode {
47
47
  /**
48
48
  * Return the currency code as a string value.
49
49
  *
50
- * @param x [[CurrencyCode]] to be extracted string from.
50
+ * @param x {@link CurrencyCode} to be extracted string from.
51
51
  * @returns Currency code as a string.
52
52
  */
53
53
  export function unCurrencyCode(x: CurrencyCode): string {
package/src/index.test.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { buildDecafClient, DecafClient, gql } from '@decafhub/decaf-client';
2
- import { mk, PDateTime } from '@telostat/prelude';
2
+ import { mk, PDateTime, safeDiv, zero } from '@telostat/prelude';
3
3
  import { fail } from 'assert';
4
4
  import { PortfolioId } from './commons';
5
- import { fetchRemotePortfolioValuationReport } from './reports/valuation/-remote-valuation-report-portfolio';
5
+ import { makeValuationReportHoldingsTree } from './reports/valuation/';
6
+ import {
7
+ fetchPortfolioValuationReport,
8
+ fetchRemotePortfolioValuationReport,
9
+ } from './reports/valuation/-remote-valuation-report-portfolio';
6
10
 
7
11
  const API_URL = process.env.TESTING_API_URL;
8
12
  const API_KEY = process.env.TESTING_API_KEY;
@@ -64,4 +68,29 @@ describe('Main', () => {
64
68
  },
65
69
  });
66
70
  });
71
+
72
+ test('get a portfolio report, check the tree', async () => {
73
+ const eValue = await fetchPortfolioValuationReport(client, {
74
+ portfolio: portfolioId,
75
+ date: PDateTime(new Date()).format('YYYY-MM-DD'),
76
+ dateType: 'settlement',
77
+ currency: mk('EUR'),
78
+ });
79
+ eValue.caseOf({
80
+ Left: (e) => fail('Error while fetching the remote portfolio report: ' + e.msg),
81
+ Right: (value) => {
82
+ console.log(`Success! remote valuation for portfolio ID ${value.portfolio.id} is reported at ${value.asof}`);
83
+
84
+ expect(value).toBeDefined();
85
+
86
+ const nav = value.figures.nav;
87
+ const inv = value.figures.investment;
88
+ const holdings = value.holdings;
89
+ const tree = makeValuationReportHoldingsTree(nav, inv, holdings);
90
+
91
+ expect(tree).toBeDefined();
92
+ expect(safeDiv(tree.totals.netExposure, nav).orDefault(zero)).toEqual(tree.totals.netExposureRatio);
93
+ },
94
+ });
95
+ });
67
96
  });
@@ -103,7 +103,7 @@ export function recompileConsolidatedValuationReport(
103
103
 
104
104
  /**
105
105
  * Attempts to retrieve remote consolidated valuation report, compiles it to
106
- * [[ConsolidatedValuationReport]] and return it.
106
+ * {@link ConsolidatedValuationReport} and return it.
107
107
  *
108
108
  * @param client DECAF Barista client.
109
109
  * @param query Remote consolidated valuation report endpoint query parameters.
@@ -276,7 +276,7 @@ export function recompilePortfolioValuationReport(
276
276
 
277
277
  /**
278
278
  * Attempts to retrieve remote portfolio valuation report, compiles it to
279
- * [[PortfolioValuationReport]] and return it.
279
+ * {@link PortfolioValuationReport} and return it.
280
280
  *
281
281
  * @param client DECAF Barista client.
282
282
  * @param query Remote portolio valuation report endpoint query parameters.
@@ -2,6 +2,7 @@ import { Decimal, safeDiv, sumDecimals, Tuple, zero } from '@telostat/prelude';
2
2
  import { Just, Maybe, Nothing } from 'purify-ts';
3
3
  import { List } from 'purify-ts/List';
4
4
  import { ValuationReportHolding, ValuationReportHoldingClassification } from '../-valuation-report-shared';
5
+ import { ArtifactTypeId } from '../../../commons';
5
6
  import { ValuationReportHoldingsTreeNode, ValuationReportHoldingsTreeNodeValue } from './-types';
6
7
  import { compareStringArrays } from './-utils';
7
8
 
@@ -36,10 +37,20 @@ export function updateTotals(
36
37
  const absValue = sumDecimals(holdings.map((x) => x.valuation.value.abs.ref)).add(
37
38
  sumDecimals(children.map((x) => x.totals.absValue))
38
39
  );
39
- const netExposure = sumDecimals(holdings.map((x) => x.valuation.exposure.net.ref)).add(
40
+
41
+ const holdingsForExposure = holdings.filter(
42
+ (h) =>
43
+ !(
44
+ h.artifact.type.id === ('CCY' as unknown as ArtifactTypeId) ||
45
+ h.artifact.type.id === ('DEPO' as unknown as ArtifactTypeId) ||
46
+ h.artifact.type.id === ('LOAN' as unknown as ArtifactTypeId)
47
+ )
48
+ );
49
+
50
+ const netExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.net.ref)).add(
40
51
  sumDecimals(children.map((x) => x.totals.netExposure))
41
52
  );
42
- const absExposure = sumDecimals(holdings.map((x) => x.valuation.exposure.abs.ref)).add(
53
+ const absExposure = sumDecimals(holdingsForExposure.map((x) => x.valuation.exposure.abs.ref)).add(
43
54
  sumDecimals(children.map((x) => x.totals.absExposure))
44
55
  );
45
56
  const pnl = sumDecimals(holdings.map((x) => x.pnl)).add(sumDecimals(children.map((x) => x.totals.pnl)));
@@ -70,7 +70,7 @@ export interface ValuationReportHoldingClassificationNode {
70
70
 
71
71
  /**
72
72
  * Type definition for base valuation report holding (shared by
73
- * [[ValuationReportHolding]] and [[ValuationReportChildHolding]]).
73
+ * {@link ValuationReportHolding} and {@link ValuationReportChildHolding}).
74
74
  */
75
75
  export interface BaseValuationReportHolding {
76
76
  artifact: ValuationReportArtifact;