@fintekkers/ledger-models 0.1.59 → 0.1.61

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 (57) hide show
  1. package/babel.config.js +3 -1
  2. package/index.js +1 -13
  3. package/index.js.map +1 -1
  4. package/index.ts +1 -18
  5. package/jest.config.js +4 -0
  6. package/node/fintekkers/models/security/security_pb.test.js +29 -30
  7. package/node/fintekkers/models/security/security_pb.test.js.map +1 -0
  8. package/node/fintekkers/models/security/security_pb.test.ts +33 -0
  9. package/node/wrappers/models/security/security.js +21 -18
  10. package/node/wrappers/models/security/security.js.map +1 -1
  11. package/node/wrappers/models/security/security.ts +22 -18
  12. package/node/wrappers/models/transaction/transaction.js +111 -0
  13. package/node/wrappers/models/transaction/transaction.js.map +1 -0
  14. package/node/wrappers/models/transaction/transaction.test.js +26 -0
  15. package/node/wrappers/models/transaction/transaction.test.js.map +1 -0
  16. package/node/wrappers/models/transaction/transaction.test.ts +37 -0
  17. package/node/wrappers/models/transaction/transaction.ts +139 -0
  18. package/node/wrappers/models/transaction/transaction_type.js +45 -0
  19. package/node/wrappers/models/transaction/transaction_type.js.map +1 -0
  20. package/node/wrappers/models/transaction/transaction_type.ts +47 -0
  21. package/node/wrappers/models/utils/date.js +25 -0
  22. package/node/wrappers/models/utils/date.js.map +1 -0
  23. package/node/wrappers/models/utils/date.ts +31 -0
  24. package/node/wrappers/models/utils/datetime.js +4 -4
  25. package/node/wrappers/models/utils/datetime.js.map +1 -1
  26. package/node/wrappers/models/utils/datetime.ts +4 -4
  27. package/node/wrappers/models/utils/serialization.test.js +14 -54
  28. package/node/wrappers/models/utils/serialization.test.js.map +1 -1
  29. package/node/wrappers/models/utils/serialization.test.ts +11 -7
  30. package/node/wrappers/services/portfolio-service/PortfolioService.js +6 -7
  31. package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
  32. package/node/wrappers/services/portfolio-service/PortfolioService.ts +8 -8
  33. package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +10 -9
  34. package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
  35. package/node/wrappers/{portfolio.test.ts → services/portfolio-service/portfolio.test.ts} +15 -11
  36. package/node/wrappers/services/position-service/PositionService.js +2 -5
  37. package/node/wrappers/services/position-service/PositionService.js.map +1 -1
  38. package/node/wrappers/services/position-service/PositionService.ts +4 -7
  39. package/node/wrappers/{position.test.js → services/position-service/position.test.js} +17 -20
  40. package/node/wrappers/services/position-service/position.test.js.map +1 -0
  41. package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +21 -28
  42. package/node/wrappers/services/security-service/SecurityService.js +2 -5
  43. package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
  44. package/node/wrappers/services/security-service/SecurityService.ts +2 -5
  45. package/node/wrappers/{security.test.js → services/security-service/security.test.js} +15 -16
  46. package/node/wrappers/services/security-service/security.test.js.map +1 -0
  47. package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +19 -17
  48. package/node/wrappers/services/transaction-service/TransactionService.js +143 -0
  49. package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -0
  50. package/node/wrappers/services/transaction-service/TransactionService.ts +96 -0
  51. package/node/wrappers/services/transaction-service/transaction.test.js +116 -0
  52. package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
  53. package/node/wrappers/services/transaction-service/transaction.test.ts +87 -0
  54. package/package.json +4 -2
  55. package/node/wrappers/portfolio.test.js.map +0 -1
  56. package/node/wrappers/position.test.js.map +0 -1
  57. package/node/wrappers/security.test.js.map +0 -1
@@ -0,0 +1,139 @@
1
+ import { PortfolioProto } from "../../../fintekkers/models/portfolio/portfolio_pb";
2
+ import { FieldProto } from "../../../fintekkers/models/position/field_pb";
3
+ import { PositionStatusProto } from "../../../fintekkers/models/position/position_status_pb";
4
+ import { PriceProto } from "../../../fintekkers/models/price/price_pb";
5
+ import { IdentifierProto } from "../../../fintekkers/models/security/identifier/identifier_pb";
6
+ import { TransactionType } from "./transaction_type";
7
+ import { StrategyAllocationProto } from "../../../fintekkers/models/strategy/strategy_allocation_pb";
8
+ import { TransactionProto } from "../../../fintekkers/models/transaction/transaction_pb";
9
+ import { TransactionTypeProto } from "../../../fintekkers/models/transaction/transaction_type_pb";
10
+ import { LocalDateProto } from "../../../fintekkers/models/util/local_date_pb";
11
+ import Security from "../security/security";
12
+ import { ZonedDateTime } from "../utils/datetime";
13
+ import { UUID } from "../utils/uuid";
14
+ import { LocalDate } from "../utils/date";
15
+ import { Decimal } from "decimal.js";
16
+
17
+ class Transaction {
18
+ proto: TransactionProto;
19
+
20
+ constructor(proto: TransactionProto) {
21
+ this.proto = proto;
22
+ }
23
+
24
+ toString(): string {
25
+ try {
26
+ const validTo: string =
27
+ this.proto.getValidFrom() !== null ? this.proto.getValidTo().toString() : "NULL";
28
+
29
+ return `${/*this.proto.isCancelled()*/ false ? "INVALIDATED: " : ""}TXN[${this.getID().toString()}], ` +
30
+ `TradeDate[${this.getTradeDate().toString()}], TxnType[${this.getTransactionType()}], Price[${this.getPrice()}], Quantity[${this.getQuantity()}], ` +
31
+ `AsOf[${this.getAsOf().toString()}], Portfolio[${this.getPortfolio().getPortfolioName()}], Issuer[${this.getSecurity().getIssuerName()}], ` +
32
+ `ValidFrom[${this.proto.getValidFrom().toString()}], ValidTo[${validTo}], Strategy[${this.getStrategyAllocation().toString()}]`;
33
+ } catch (e) {
34
+ console.error(e);
35
+ return "WHOOPS";
36
+ }
37
+ }
38
+
39
+ get_fields(): FieldProto[] {
40
+ return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
41
+ }
42
+
43
+ get_field(field: FieldProto): any {
44
+ switch (field) {
45
+ case FieldProto.ID:
46
+ case FieldProto.SECURITY_ID:
47
+ return this.getID();
48
+ case FieldProto.AS_OF:
49
+ return this.getAsOf();
50
+ case FieldProto.ASSET_CLASS:
51
+ return this.getSecurity().getAssetClass();
52
+ case FieldProto.PRODUCT_CLASS:
53
+ return this.getSecurity().getProductClass();
54
+ case FieldProto.PRODUCT_TYPE:
55
+ return this.getSecurity().getProductType();
56
+ case FieldProto.IDENTIFIER:
57
+ return this.getSecurity().getSecurityID();
58
+ case FieldProto.TENOR:
59
+ case FieldProto.ADJUSTED_TENOR:
60
+ throw new Error('Not implemented yet');
61
+ case FieldProto.MATURITY_DATE:
62
+ throw new Error('Not implemented yet');
63
+ default:
64
+ throw new Error(`Field not mapped in Security wrapper: ${field}`);
65
+ }
66
+ }
67
+
68
+ getID(): UUID {
69
+ return UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
70
+ }
71
+
72
+ getAsOf(): ZonedDateTime {
73
+ return new ZonedDateTime(this.proto.getAsOf());
74
+ }
75
+
76
+ //TODO: Create Portfolio wrapper
77
+ getPortfolio(): PortfolioProto {
78
+ return this.proto.getPortfolio();
79
+ }
80
+
81
+ getSecurity(): Security {
82
+ return new Security(this.proto.getSecurity());
83
+ }
84
+
85
+ getStrategyAllocation(): StrategyAllocationProto {
86
+ return this.proto.getStrategyAllocation();
87
+ }
88
+
89
+ getPrice(): PriceProto {
90
+ return this.proto.getPrice();
91
+ }
92
+
93
+ getQuantity(): Decimal {
94
+ return new Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
95
+ }
96
+
97
+ getIssuerName(): string {
98
+ return this.getSecurity().getIssuerName();
99
+ }
100
+
101
+ getDirectedQuantity(): Decimal {
102
+ return this.getQuantity().mul(this.getTransactionType().getDirectionMultiplier());
103
+ }
104
+
105
+ getTradeDate(): LocalDate {
106
+ return new LocalDate(this.proto.getTradeDate());
107
+ }
108
+
109
+ getSettlementDate() : LocalDate {
110
+ return new LocalDate(this.proto.getSettlementDate());
111
+ }
112
+
113
+ getTransactionType() : TransactionType {
114
+ return new TransactionType(this.proto.getTransactionType());
115
+ }
116
+
117
+ getTradeName(): string {
118
+ return this.proto.getTradeName();
119
+ }
120
+
121
+ getPositionStatus(): PositionStatusProto {
122
+ return this.proto.getPositionStatus();
123
+ }
124
+
125
+ getChildrenTransactions(): TransactionProto[] {
126
+ return this.proto.getChildtransactionsList();
127
+ }
128
+
129
+
130
+ equals(other: Transaction): boolean {
131
+ if (other instanceof Transaction) {
132
+ return this.getID().equals(other.getID());
133
+ } else {
134
+ return false;
135
+ }
136
+ }
137
+ }
138
+
139
+ export default Transaction;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionType = void 0;
4
+ var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
5
+ var TransactionType = /** @class */ (function () {
6
+ function TransactionType(proto) {
7
+ this.proto = proto;
8
+ }
9
+ TransactionType.prototype.getDirectionMultiplier = function () {
10
+ switch (this.proto) {
11
+ case transaction_type_pb_1.TransactionTypeProto.BUY:
12
+ case transaction_type_pb_1.TransactionTypeProto.DEPOSIT:
13
+ case transaction_type_pb_1.TransactionTypeProto.MATURATION_OFFSET:
14
+ return 1;
15
+ case transaction_type_pb_1.TransactionTypeProto.SELL:
16
+ case transaction_type_pb_1.TransactionTypeProto.WITHDRAWAL:
17
+ case transaction_type_pb_1.TransactionTypeProto.MATURATION:
18
+ return -1;
19
+ case transaction_type_pb_1.TransactionTypeProto.UNKNOWN:
20
+ throw new Error('Unknown transaction type: ' + this.toString());
21
+ ;
22
+ }
23
+ };
24
+ /**
25
+ * NOTE that this method is not performant and should only be used for debugging purposes,
26
+ * or infrequently. If this is required for a high performance use case, please create a
27
+ * reverse map with the enum ID as the key and the enum desriptor as the value. There is
28
+ * nothing stopping this code from returning a value that does not map exactly to the enum
29
+ * value. E.g. rather than BUY, you could return Buy.
30
+ *
31
+ * @returns TransactionType as a string
32
+ */
33
+ TransactionType.prototype.toString = function () {
34
+ return TransactionType.ttEnumMap.get(this.proto);
35
+ };
36
+ return TransactionType;
37
+ }());
38
+ exports.TransactionType = TransactionType;
39
+ (function () {
40
+ TransactionType.ttEnumMap = new Map();
41
+ Object.keys(transaction_type_pb_1.TransactionTypeProto).forEach(function (key) {
42
+ TransactionType.ttEnumMap.set(transaction_type_pb_1.TransactionTypeProto[key], key);
43
+ });
44
+ })();
45
+ //# sourceMappingURL=transaction_type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction_type.js","sourceRoot":"","sources":["transaction_type.ts"],"names":[],"mappings":";;;AAAA,kGAAkG;AAElG;IAGI,yBAAY,KAA2B;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAYH,gDAAsB,GAAtB;QACI,QAAQ,IAAI,CAAC,KAAK,EAAE;YAChB,KAAK,0CAAoB,CAAC,GAAG,CAAC;YAC9B,KAAK,0CAAoB,CAAC,OAAO,CAAC;YAClC,KAAK,0CAAoB,CAAC,iBAAiB;gBACvC,OAAO,CAAC,CAAC;YACb,KAAK,0CAAoB,CAAC,IAAI,CAAC;YAC/B,KAAK,0CAAoB,CAAC,UAAU,CAAC;YACrC,KAAK,0CAAoB,CAAC,UAAU;gBAChC,OAAO,CAAC,CAAC,CAAC;YACd,KAAK,0CAAoB,CAAC,OAAO;gBAC7B,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAAE,CAAC;SACxE;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,kCAAQ,GAAR;QACE,OAAO,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IACL,sBAAC;AAAD,CAAC,AA5CD,IA4CC;AA5CY,0CAAe;AASxB;IACI,eAAe,CAAC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtD,MAAM,CAAC,IAAI,CAAC,0CAAoB,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;QACzC,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,0CAAoB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACP,CAAC,GAAA,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { TransactionTypeProto } from "../../../fintekkers/models/transaction/transaction_type_pb";
2
+
3
+ export class TransactionType {
4
+ proto: TransactionTypeProto;
5
+
6
+ constructor(proto: TransactionTypeProto) {
7
+ this.proto = proto;
8
+ }
9
+
10
+ static ttEnumMap: Map<number, string>;
11
+
12
+ static {
13
+ TransactionType.ttEnumMap = new Map<number, string>();
14
+
15
+ Object.keys(TransactionTypeProto).forEach(key => {
16
+ TransactionType.ttEnumMap.set(TransactionTypeProto[key], key);
17
+ });
18
+ }
19
+
20
+ getDirectionMultiplier(): number {
21
+ switch (this.proto) {
22
+ case TransactionTypeProto.BUY:
23
+ case TransactionTypeProto.DEPOSIT:
24
+ case TransactionTypeProto.MATURATION_OFFSET:
25
+ return 1;
26
+ case TransactionTypeProto.SELL:
27
+ case TransactionTypeProto.WITHDRAWAL:
28
+ case TransactionTypeProto.MATURATION:
29
+ return -1;
30
+ case TransactionTypeProto.UNKNOWN:
31
+ throw new Error('Unknown transaction type: '+this.toString()); );
32
+ }
33
+ }
34
+
35
+ /**
36
+ * NOTE that this method is not performant and should only be used for debugging purposes,
37
+ * or infrequently. If this is required for a high performance use case, please create a
38
+ * reverse map with the enum ID as the key and the enum desriptor as the value. There is
39
+ * nothing stopping this code from returning a value that does not map exactly to the enum
40
+ * value. E.g. rather than BUY, you could return Buy.
41
+ *
42
+ * @returns TransactionType as a string
43
+ */
44
+ toString() : string {
45
+ return TransactionType.ttEnumMap.get(this.proto);
46
+ }
47
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalDate = void 0;
4
+ var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
5
+ var LocalDate = /** @class */ (function () {
6
+ function LocalDate(proto) {
7
+ this.proto = proto;
8
+ }
9
+ LocalDate.prototype.toDate = function () {
10
+ return new Date(this.proto.getYear(), this.proto.getMonth(), this.proto.getDay());
11
+ };
12
+ LocalDate.prototype.toString = function () {
13
+ return this.proto.getYear() + '-' + this.proto.getMonth() + '-' + this.proto.getDay();
14
+ };
15
+ LocalDate.prototype.toProto = function () {
16
+ return this.proto;
17
+ };
18
+ LocalDate.today = function () {
19
+ var today = new Date();
20
+ return new LocalDate(new local_date_pb_1.LocalDateProto().setYear(today.getFullYear()).setMonth(today.getMonth()).setDay(today.getDate()));
21
+ };
22
+ return LocalDate;
23
+ }());
24
+ exports.LocalDate = LocalDate;
25
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["date.ts"],"names":[],"mappings":";;;AACA,+EAA+E;AAE/E;IAGE,mBAAY,KAAqB;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,0BAAM,GAAN;QACE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,4BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACxF,CAAC;IAED,2BAAO,GAAP;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,eAAK,GAAZ;QACE,IAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,SAAS,CAClB,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CACrG,CAAC;IACJ,CAAC;IACH,gBAAC;AAAD,CAAC,AAzBD,IAyBC;AAEQ,8BAAS"}
@@ -0,0 +1,31 @@
1
+ import { assert } from 'console';
2
+ import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
3
+
4
+ class LocalDate {
5
+ private proto: LocalDateProto;
6
+
7
+ constructor(proto: LocalDateProto) {
8
+ this.proto = proto;
9
+ }
10
+
11
+ toDate(): Date {
12
+ return new Date(this.proto.getYear(), this.proto.getMonth(), this.proto.getDay());
13
+ }
14
+
15
+ toString(): string {
16
+ return this.proto.getYear() + '-' + this.proto.getMonth() + '-' + this.proto.getDay();
17
+ }
18
+
19
+ toProto(): LocalDateProto {
20
+ return this.proto;
21
+ }
22
+
23
+ static today(): LocalDate {
24
+ const today = new Date();
25
+ return new LocalDate(
26
+ new LocalDateProto().setYear(today.getFullYear()).setMonth(today.getMonth()).setDay(today.getDate())
27
+ );
28
+ }
29
+ }
30
+
31
+ export { LocalDate };
@@ -9,7 +9,7 @@ var ZonedDateTime = /** @class */ (function () {
9
9
  function ZonedDateTime(proto) {
10
10
  this.proto = proto;
11
11
  }
12
- ZonedDateTime.prototype.to_datetime = function () {
12
+ ZonedDateTime.prototype.toDateTime = function () {
13
13
  // Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
14
14
  var unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
15
15
  var nanoseconds = this.proto.getTimestamp().getNanos();
@@ -19,9 +19,9 @@ var ZonedDateTime = /** @class */ (function () {
19
19
  return dateTime;
20
20
  };
21
21
  ZonedDateTime.prototype.toString = function () {
22
- return this.to_datetime().toString();
22
+ return this.toDateTime().toString();
23
23
  };
24
- ZonedDateTime.prototype.to_date_proto = function () {
24
+ ZonedDateTime.prototype.toProto = function () {
25
25
  return this.proto;
26
26
  };
27
27
  ZonedDateTime.now = function () {
@@ -59,5 +59,5 @@ exports.ZonedDateTime = ZonedDateTime;
59
59
  // }
60
60
  // ZonedDateTime.now = createTimestampWithCurrentTime;
61
61
  var now = ZonedDateTime.now();
62
- (0, console_1.assert)(now.to_datetime().toString() === now.toString());
62
+ (0, console_1.assert)(now.toDateTime().toString() === now.toString());
63
63
  //# sourceMappingURL=datetime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"datetime.js","sourceRoot":"","sources":["datetime.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,yFAAyF;AACzF,6EAAyE;AACzE,+BAAiC;AAEjC;IAGE,uBAAY,KAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mCAAW,GAAX;QACE,+GAA+G;QAC/G,IAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpE,IAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC;QAEzD,IAAI,QAAQ,GAAG,gBAAQ,CAAC,WAAW,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAE9F,gDAAgD;QAChD,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,gCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED,qCAAa,GAAb;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEM,iBAAG,GAAV;QACE,8EAA8E;QAC9E,IAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAErC,kDAAkD;QAClD,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,GAAG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AAC,CAAC;IAC3C,CAAC;IACH,oBAAC;AAAD,CAAC,AA9CD,IA8CC;AA0BQ,sCAAa;AAxBtB,6DAA6D;AAC7D,mFAAmF;AACnF,0CAA0C;AAE1C,uDAAuD;AACvD,0DAA0D;AAC1D,uFAAuF;AAEvF,2DAA2D;AAC3D,uCAAuC;AACvC,mCAAmC;AACnC,+BAA+B;AAE/B,sDAAsD;AACtD,oDAAoD;AACpD,4CAA4C;AAE5C,8CAA8C;AAC9C,IAAI;AAEJ,sDAAsD;AACtD,IAAM,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,gBAAM,EAAC,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC"}
@@ -10,7 +10,7 @@ class ZonedDateTime {
10
10
  this.proto = proto;
11
11
  }
12
12
 
13
- to_datetime(): DateTime {
13
+ toDateTime(): DateTime {
14
14
  // Creating a DateTime object with the current date and time in a specific time zone (e.g., 'America/New_York')
15
15
  const unixTimestampSeconds = this.proto.getTimestamp().getSeconds();
16
16
  const nanoseconds = this.proto.getTimestamp().getNanos();
@@ -23,10 +23,10 @@ class ZonedDateTime {
23
23
  }
24
24
 
25
25
  toString(): string {
26
- return this.to_datetime().toString();
26
+ return this.toDateTime().toString();
27
27
  }
28
28
 
29
- to_date_proto(): LocalTimestampProto {
29
+ toProto(): LocalTimestampProto {
30
30
  return this.proto;
31
31
  }
32
32
 
@@ -73,6 +73,6 @@ class ZonedDateTime {
73
73
 
74
74
  // ZonedDateTime.now = createTimestampWithCurrentTime;
75
75
  const now = ZonedDateTime.now();
76
- assert(now.to_datetime().toString() === now.toString());
76
+ assert(now.toDateTime().toString() === now.toString());
77
77
 
78
78
  export { ZonedDateTime };
@@ -1,64 +1,24 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.testSerialization = void 0;
40
3
  var serialization_1 = require("./serialization");
41
4
  var uuid_1 = require("./uuid");
42
5
  var assert = require("assert");
6
+ test('test creating a security against the api.fintekkers.org portfolio service', function () {
7
+ testSerialization();
8
+ });
43
9
  function testSerialization() {
44
- return __awaiter(this, void 0, void 0, function () {
45
- var serializedDate, deserializedDate, obj, serializedTimestamp, deserializedTimestamp;
46
- return __generator(this, function (_a) {
47
- checkUUID();
48
- serializedDate = serialization_1.ProtoSerializationUtil.serialize(new Date());
49
- console.log(serializedDate);
50
- deserializedDate = serialization_1.ProtoSerializationUtil.deserialize(serializedDate);
51
- console.log(deserializedDate);
52
- obj = new Date();
53
- serializedTimestamp = serialization_1.ProtoSerializationUtil.serialize(obj);
54
- console.log(serializedTimestamp);
55
- deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
56
- console.log(deserializedTimestamp);
57
- return [2 /*return*/];
58
- });
59
- });
10
+ checkUUID();
11
+ //TODO: Make these tests more robust
12
+ var serializedDate = serialization_1.ProtoSerializationUtil.serialize(new Date());
13
+ assert(serializedDate.toString().indexOf('2023') > -1);
14
+ var deserializedDate = serialization_1.ProtoSerializationUtil.deserialize(serializedDate);
15
+ assert(deserializedDate.toString().indexOf('2023') > -1);
16
+ var obj = new Date();
17
+ var serializedTimestamp = serialization_1.ProtoSerializationUtil.serialize(obj);
18
+ assert(serializedTimestamp.toString().indexOf('2023') > -1);
19
+ var deserializedTimestamp = serialization_1.ProtoSerializationUtil.deserialize(serializedTimestamp);
20
+ assert(deserializedTimestamp.toString().indexOf('2023') > -1);
60
21
  }
61
- exports.testSerialization = testSerialization;
62
22
  function checkUUID() {
63
23
  var uuid = uuid_1.UUID.random();
64
24
  var serializedUUID = serialization_1.ProtoSerializationUtil.serialize(uuid);
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.test.js","sourceRoot":"","sources":["serial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,IAAM,UAAU,GAAW,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3C,IAAM,cAAc,GAAW,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEnD,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IACzC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,CAAC"}
@@ -1,28 +1,32 @@
1
+ import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
1
2
  import { UUIDProto } from '../../../fintekkers/models/util/uuid_pb';
2
3
  import { ProtoSerializationUtil } from './serialization';
3
4
  import { UUID } from './uuid';
4
5
 
5
6
  import assert = require('assert');
7
+ test('test creating a security against the api.fintekkers.org portfolio service', () => {
8
+ testSerialization();
9
+ });
6
10
 
7
- async function testSerialization(): Promise<void> {
11
+ function testSerialization(): void {
8
12
  checkUUID();
9
13
 
14
+ //TODO: Make these tests more robust
15
+
10
16
  const serializedDate: any = ProtoSerializationUtil.serialize(new Date());
11
- console.log(serializedDate);
17
+ assert(serializedDate.toString().indexOf('2023') > -1);
12
18
 
13
19
  const deserializedDate: any = ProtoSerializationUtil.deserialize(serializedDate);
14
- console.log(deserializedDate);
20
+ assert(deserializedDate.toString().indexOf('2023') > -1);
15
21
 
16
22
  const obj = new Date();
17
23
  const serializedTimestamp: any = ProtoSerializationUtil.serialize(obj);
18
- console.log(serializedTimestamp);
24
+ assert(serializedTimestamp.toString().indexOf('2023') > -1);
19
25
 
20
26
  const deserializedTimestamp: any = ProtoSerializationUtil.deserialize(serializedTimestamp);
21
- console.log(deserializedTimestamp);
27
+ assert(deserializedTimestamp.toString().indexOf('2023') > -1);
22
28
  }
23
29
 
24
- export { testSerialization };
25
-
26
30
  function checkUUID() {
27
31
  const uuid: UUID = UUID.random();
28
32
  const serializedUUID: UUIDProto = ProtoSerializationUtil.serialize(uuid) as UUIDProto;
@@ -48,8 +48,8 @@ var query_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfol
48
48
  var create_portfolio_request_pb_1 = require("../../../fintekkers/requests/portfolio/create_portfolio_request_pb");
49
49
  var PortfolioService = /** @class */ (function () {
50
50
  function PortfolioService() {
51
- // this.client = new PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
52
- this.client = new portfolio_service_grpc_pb_1.PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
51
+ this.client = new portfolio_service_grpc_pb_1.PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
52
+ // this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
53
53
  }
54
54
  PortfolioService.prototype.validateCreatePortfolio = function (portfolio) {
55
55
  return __awaiter(this, void 0, void 0, function () {
@@ -98,14 +98,11 @@ var PortfolioService = /** @class */ (function () {
98
98
  stream2 = tmpClient.search(searchRequest);
99
99
  return [2 /*return*/, new Promise(function (resolve, reject) {
100
100
  stream2.on('data', function (response) {
101
- console.log('Result of the portfolio search call');
102
- console.log('Response:', response);
103
101
  response.getPortfolioResponseList().forEach(function (portfolio) {
104
102
  listPortfolios.push(portfolio);
105
103
  });
106
104
  });
107
105
  stream2.on('end', function () {
108
- console.log('Stream ended.');
109
106
  resolve(listPortfolios);
110
107
  });
111
108
  stream2.on('error', function (err) {
@@ -127,8 +124,10 @@ var PortfolioService = /** @class */ (function () {
127
124
  positionFilter = new position_filter_pb_1.PositionFilterProto();
128
125
  positionFilter.setObjectClass('PositionFilter');
129
126
  positionFilter.setVersion('0.0.1');
130
- fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
131
- positionFilter.setFiltersList([fieldMapEntry]);
127
+ if (fieldProto && fieldValue) {
128
+ fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
129
+ positionFilter.setFiltersList([fieldMapEntry]);
130
+ }
132
131
  searchRequest.setSearchPortfolioInput(positionFilter);
133
132
  tmpClient = this.client;
134
133
  listPortfolios = [];
@@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CAAC;gCAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,GAAG;oCACtB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;oCAC3C,MAAM,CAAC,GAAG,CAAC,CAAC;gCACd,CAAC,CAAC,CAAC;4BACL,CAAC,CAAC,EAAC;;;aACJ;;;;;wBAxCK,aAAa,GAAG,IAAI,uDAA0B,EAAE,CAAC;wBACvD,aAAa,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;wBACjD,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBAClC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBAGtB,cAAc,GAAG,IAAI,wCAAmB,EAAE,CAAC;wBACjD,cAAc,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;wBAChD,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBAEnC,IAAI,UAAU,IAAI,UAAU,EAAE;4BACtB,aAAa,GAAG,IAAA,0BAAmB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;4BAClE,cAAc,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;yBAChD;wBAED,aAAa,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;wBAEhD,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;wBAExB,cAAc,GAAqB,EAAE,CAAC;wBAuBrC,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,uBAAC;AAAD,CAAC,AA5ED,IA4EC;AAEQ,4CAAgB"}
@@ -22,8 +22,8 @@ class PortfolioService {
22
22
  private client: PortfolioClient;
23
23
 
24
24
  constructor() {
25
- // this.client = new PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
26
- this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
25
+ this.client = new PortfolioClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
26
+ // this.client = new PortfolioClient('localhost:8082', grpc.credentials.createInsecure());
27
27
  }
28
28
 
29
29
  async validateCreatePortfolio(portfolio: PortfolioProto): Promise<SummaryProto> {
@@ -48,7 +48,8 @@ class PortfolioService {
48
48
  return response;
49
49
  }
50
50
 
51
- async searchPortfolio(asOf: LocalTimestampProto, fieldProto: FieldProto, fieldValue: string): Promise<PortfolioProto[]> {
51
+ async searchPortfolio(asOf: LocalTimestampProto,
52
+ fieldProto?: FieldProto, fieldValue?: string): Promise<PortfolioProto[]> {
52
53
  const searchRequest = new QueryPortfolioRequestProto();
53
54
  searchRequest.setObjectClass('PortfolioRequest');
54
55
  searchRequest.setVersion('0.0.1');
@@ -59,8 +60,10 @@ class PortfolioService {
59
60
  positionFilter.setObjectClass('PositionFilter');
60
61
  positionFilter.setVersion('0.0.1');
61
62
 
62
- const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
63
- positionFilter.setFiltersList([fieldMapEntry]);
63
+ if (fieldProto && fieldValue) {
64
+ const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
65
+ positionFilter.setFiltersList([fieldMapEntry]);
66
+ }
64
67
 
65
68
  searchRequest.setSearchPortfolioInput(positionFilter);
66
69
 
@@ -73,15 +76,12 @@ class PortfolioService {
73
76
 
74
77
  return new Promise<PortfolioProto[]>((resolve, reject) => {
75
78
  stream2.on('data', (response:QueryPortfolioResponseProto) => {
76
- console.log('Result of the portfolio search call');
77
- console.log('Response:', response);
78
79
  response.getPortfolioResponseList().forEach((portfolio) => {
79
80
  listPortfolios.push(portfolio);
80
81
  });
81
82
  });
82
83
 
83
84
  stream2.on('end', () => {
84
- console.log('Stream ended.');
85
85
  resolve(listPortfolios);
86
86
  });
87
87
 
@@ -39,12 +39,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.testPortfolio = void 0;
41
41
  // Model Utils
42
- var field_pb_1 = require("../fintekkers/models/position/field_pb");
43
- var uuid = require("./models/utils/uuid");
44
- var dt = require("./models/utils/datetime");
42
+ var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
43
+ var uuid = require("../../models/utils/uuid");
44
+ var dt = require("../../models/utils/datetime");
45
45
  //Requests & Services
46
- var PortfolioService_1 = require("./services/portfolio-service/PortfolioService");
47
- var portfolio_pb_1 = require("../fintekkers/models/portfolio/portfolio_pb");
46
+ var PortfolioService_1 = require("./PortfolioService");
47
+ var portfolio_pb_1 = require("../../../fintekkers/models/portfolio/portfolio_pb");
48
+ test('test creating a portfolio against the api.fintekkers.org portfolio service', function () {
49
+ var isTrue = testPortfolio();
50
+ expect(isTrue).resolves.toBe(true);
51
+ }, 30000);
48
52
  function testPortfolio() {
49
53
  return __awaiter(this, void 0, void 0, function () {
50
54
  var id_proto, now, portfolioService, portfolio, validationSummary, createPortfolioResponse, searchResults;
@@ -63,16 +67,13 @@ function testPortfolio() {
63
67
  return [4 /*yield*/, portfolioService.validateCreatePortfolio(portfolio)];
64
68
  case 1:
65
69
  validationSummary = _a.sent();
66
- console.log(validationSummary);
67
70
  return [4 /*yield*/, portfolioService.createPortfolio(portfolio)];
68
71
  case 2:
69
72
  createPortfolioResponse = _a.sent();
70
- console.log(createPortfolioResponse);
71
73
  return [4 /*yield*/, portfolioService.searchPortfolio(now.to_date_proto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'Federal Reserve SOMA Holdings')];
72
74
  case 3:
73
75
  searchResults = _a.sent();
74
- console.log('There are %d securities in this response', searchResults.length);
75
- return [2 /*return*/];
76
+ return [2 /*return*/, true];
76
77
  }
77
78
  });
78
79
  });