@fintekkers/ledger-models 0.0.103 → 0.1.60

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/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
+ // import { testPortfolio } from './node/wrappers/portfolio.test';
3
+ // testPortfolio();
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var portfolio_test_1 = require("./node/wrappers/portfolio.test");
4
- (0, portfolio_test_1.testPortfolio)();
5
- var security_test_1 = require("./node/wrappers/security.test");
6
- (0, security_test_1.testSecurity)();
7
- //TODO: Add position convenience wrapper
8
- var position_test_1 = require("./node/wrappers/position.test");
9
- (0, position_test_1.testPosition)();
10
- var serialization_test_1 = require("./node/wrappers/models/utils/serialization.test");
11
- (0, serialization_test_1.testSerialization)();
5
+ // import { testSecurity } from './node/wrappers/security.test';
6
+ // testSecurity();
7
+ // //TODO: Add position convenience wrapper
8
+ // import { testPosition } from './node/wrappers/position.test';
9
+ // testPosition();
10
+ // import { testSerialization } from './node/wrappers/models/utils/serialization.test';
11
+ // testSerialization();
12
12
  // TODO - Transactions
13
+ var transaction_test_1 = require("./node/wrappers/transaction.test");
14
+ (0, transaction_test_1.testTransaction)();
13
15
  // TODO - Positions
14
16
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,iEAA+D;AAC/D,IAAA,8BAAa,GAAE,CAAC;AAEhB,+DAA6D;AAC7D,IAAA,4BAAY,GAAE,CAAC;AAEf,wCAAwC;AACxC,+DAA6D;AAC7D,IAAA,4BAAY,GAAE,CAAC;AAEf,sFAAoF;AACpF,IAAA,sCAAiB,GAAE,CAAC;AAEpB,sBAAsB;AAGtB,mBAAmB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,mBAAmB;;AAEnB,gEAAgE;AAChE,kBAAkB;AAElB,2CAA2C;AAC3C,gEAAgE;AAChE,kBAAkB;AAElB,uFAAuF;AACvF,uBAAuB;AAEvB,sBAAsB;AAEtB,qEAAmE;AACnE,IAAA,kCAAe,GAAE,CAAC;AAClB,mBAAmB"}
package/index.ts CHANGED
@@ -1,18 +1,19 @@
1
- import { testPortfolio } from './node/wrappers/portfolio.test';
2
- testPortfolio();
1
+ // import { testPortfolio } from './node/wrappers/portfolio.test';
2
+ // testPortfolio();
3
3
 
4
- import { testSecurity } from './node/wrappers/security.test';
5
- testSecurity();
4
+ // import { testSecurity } from './node/wrappers/security.test';
5
+ // testSecurity();
6
6
 
7
- //TODO: Add position convenience wrapper
8
- import { testPosition } from './node/wrappers/position.test';
9
- testPosition();
7
+ // //TODO: Add position convenience wrapper
8
+ // import { testPosition } from './node/wrappers/position.test';
9
+ // testPosition();
10
10
 
11
- import { testSerialization } from './node/wrappers/models/utils/serialization.test';
12
- testSerialization();
11
+ // import { testSerialization } from './node/wrappers/models/utils/serialization.test';
12
+ // testSerialization();
13
13
 
14
14
  // TODO - Transactions
15
15
 
16
-
16
+ import { testTransaction } from './node/wrappers/transaction.test';
17
+ testTransaction();
17
18
  // TODO - Positions
18
19
 
@@ -8,26 +8,26 @@ var Security = /** @class */ (function () {
8
8
  this.proto = proto;
9
9
  }
10
10
  Security.prototype.toString = function () {
11
- return "ID[".concat(this.get_id().toString(), "], ").concat(this.get_security_id(), "[").concat(this.proto.getIssuerName(), "]");
11
+ return "ID[".concat(this.getID().toString(), "], ").concat(this.getSecurityID(), "[").concat(this.getIssuerName(), "]");
12
12
  };
13
- Security.prototype.get_fields = function () {
13
+ Security.prototype.getFields = function () {
14
14
  return [field_pb_1.FieldProto.ID, field_pb_1.FieldProto.SECURITY_ID, field_pb_1.FieldProto.AS_OF, field_pb_1.FieldProto.ASSET_CLASS, field_pb_1.FieldProto.IDENTIFIER];
15
15
  };
16
- Security.prototype.get_field = function (field) {
16
+ Security.prototype.getField = function (field) {
17
17
  switch (field) {
18
18
  case field_pb_1.FieldProto.ID:
19
19
  case field_pb_1.FieldProto.SECURITY_ID:
20
- return this.get_id();
20
+ return this.getID();
21
21
  case field_pb_1.FieldProto.AS_OF:
22
- return this.get_as_of();
22
+ return this.getAsOf();
23
23
  case field_pb_1.FieldProto.ASSET_CLASS:
24
- return this.get_asset_class();
24
+ return this.getAssetClass();
25
25
  case field_pb_1.FieldProto.PRODUCT_CLASS:
26
- return this.get_product_class();
26
+ return this.getProductClass();
27
27
  case field_pb_1.FieldProto.PRODUCT_TYPE:
28
- return this.get_product_type();
28
+ return this.getProductType();
29
29
  case field_pb_1.FieldProto.IDENTIFIER:
30
- return this.get_security_id();
30
+ return this.getSecurityID();
31
31
  case field_pb_1.FieldProto.TENOR:
32
32
  case field_pb_1.FieldProto.ADJUSTED_TENOR:
33
33
  throw new Error('Not implemented yet');
@@ -37,33 +37,36 @@ var Security = /** @class */ (function () {
37
37
  throw new Error("Field not mapped in Security wrapper: ".concat(field));
38
38
  }
39
39
  };
40
- Security.prototype.get_id = function () {
40
+ Security.prototype.getID = function () {
41
41
  return uuid_1.UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
42
42
  };
43
- Security.prototype.get_as_of = function () {
43
+ Security.prototype.getAsOf = function () {
44
44
  return new datetime_1.ZonedDateTime(this.proto.getAsOf());
45
45
  };
46
- Security.prototype.get_asset_class = function () {
46
+ Security.prototype.getAssetClass = function () {
47
47
  return this.proto.getAssetClass();
48
48
  };
49
- Security.prototype.get_product_class = function () {
49
+ Security.prototype.getProductClass = function () {
50
50
  throw new Error('Not implemented yet. See Java implementation for reference');
51
51
  };
52
- Security.prototype.get_product_type = function () {
52
+ Security.prototype.getProductType = function () {
53
53
  throw new Error('Not implemented yet. See Java implementation for reference');
54
54
  };
55
- Security.prototype.get_security_id = function () {
55
+ Security.prototype.getSecurityID = function () {
56
56
  // const id: IdentifierProto = this.proto.identifier;
57
57
  return this.proto.getIdentifier(); // Assuming you've implemented the Identifier class
58
58
  };
59
- Security.prototype.get_issue_date = function () {
59
+ Security.prototype.getIssueDate = function () {
60
60
  var date = this.proto.getIssueDate();
61
61
  return new Date(date.getYear(), date.getMonth(), date.getDay());
62
62
  };
63
- Security.prototype.get_maturity_date = function () {
63
+ Security.prototype.getMaturityDate = function () {
64
64
  var date = this.proto.getMaturityDate();
65
65
  return new Date(date.getYear(), date.getMonth(), date.getDay());
66
66
  };
67
+ Security.prototype.getIssuerName = function () {
68
+ return this.proto.getIssuerName();
69
+ };
67
70
  Security.prototype.equals = function (other) {
68
71
  if (other instanceof Security) {
69
72
  return this.get_id().equals(other.get_id());
@@ -1 +1 @@
1
- {"version":3,"file":"security.js","sourceRoot":"","sources":["security.ts"],"names":[],"mappings":";;AAAA,yEAA0E;AAG1E,8CAAkD;AAClD,sCAAqC;AAErC;IAGE,kBAAY,KAAoB;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,2BAAQ,GAAR;QACE,OAAO,aAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,gBAAM,IAAI,CAAC,eAAe,EAAE,cAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,MAAG,CAAC;IACrG,CAAC;IAED,6BAAU,GAAV;QACE,OAAO,CAAC,qBAAU,CAAC,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,qBAAU,CAAC,KAAK,EAAE,qBAAU,CAAC,WAAW,EAAE,qBAAU,CAAC,UAAU,CAAC,CAAC;IAClH,CAAC;IAED,4BAAS,GAAT,UAAU,KAAiB;QACzB,QAAQ,KAAK,EAAE;YACb,KAAK,qBAAU,CAAC,EAAE,CAAC;YACnB,KAAK,qBAAU,CAAC,WAAW;gBACzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,qBAAU,CAAC,KAAK;gBACnB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,KAAK,qBAAU,CAAC,WAAW;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AK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,gCAAa,GAAb;QACE,qDAAqD;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,mDAAmD;IACxF,CAAC;IAED,+BAAY,GAAZ;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACvC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,kCAAe,GAAf;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,gCAAa,GAAb;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;IAED,yBAAM,GAAN,UAAO,KAAe;QACpB,IAAI,KAAK,YAAY,QAAQ,EAAE;YAC7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;SAC7C;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAtFD,IAsFC;AAED,kBAAe,QAAQ,CAAC"}
@@ -12,28 +12,28 @@ class Security {
12
12
  }
13
13
 
14
14
  toString(): string {
15
- return `ID[${this.get_id().toString()}], ${this.get_security_id()}[${this.proto.getIssuerName()}]`;
15
+ return `ID[${this.getID().toString()}], ${this.getSecurityID()}[${this.getIssuerName()}]`;
16
16
  }
17
17
 
18
- get_fields(): FieldProto[] {
18
+ getFields(): FieldProto[] {
19
19
  return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
20
20
  }
21
21
 
22
- get_field(field: FieldProto): any {
22
+ getField(field: FieldProto): any {
23
23
  switch (field) {
24
24
  case FieldProto.ID:
25
25
  case FieldProto.SECURITY_ID:
26
- return this.get_id();
26
+ return this.getID();
27
27
  case FieldProto.AS_OF:
28
- return this.get_as_of();
28
+ return this.getAsOf();
29
29
  case FieldProto.ASSET_CLASS:
30
- return this.get_asset_class();
30
+ return this.getAssetClass();
31
31
  case FieldProto.PRODUCT_CLASS:
32
- return this.get_product_class();
32
+ return this.getProductClass();
33
33
  case FieldProto.PRODUCT_TYPE:
34
- return this.get_product_type();
34
+ return this.getProductType();
35
35
  case FieldProto.IDENTIFIER:
36
- return this.get_security_id();
36
+ return this.getSecurityID();
37
37
  case FieldProto.TENOR:
38
38
  case FieldProto.ADJUSTED_TENOR:
39
39
  throw new Error('Not implemented yet');
@@ -44,41 +44,45 @@ class Security {
44
44
  }
45
45
  }
46
46
 
47
- get_id(): UUID {
47
+ getID(): UUID {
48
48
  return UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
49
49
  }
50
50
 
51
- get_as_of(): ZonedDateTime {
51
+ getAsOf(): ZonedDateTime {
52
52
  return new ZonedDateTime(this.proto.getAsOf());
53
53
  }
54
54
 
55
- get_asset_class(): string {
55
+ getAssetClass(): string {
56
56
  return this.proto.getAssetClass();
57
57
  }
58
58
 
59
- get_product_class(): string {
59
+ getProductClass(): string {
60
60
  throw new Error('Not implemented yet. See Java implementation for reference');
61
61
  }
62
62
 
63
- get_product_type(): any {
63
+ getProductType(): any {
64
64
  throw new Error('Not implemented yet. See Java implementation for reference');
65
65
  }
66
66
 
67
- get_security_id(): IdentifierProto {
67
+ getSecurityID(): IdentifierProto {
68
68
  // const id: IdentifierProto = this.proto.identifier;
69
69
  return this.proto.getIdentifier(); // Assuming you've implemented the Identifier class
70
70
  }
71
71
 
72
- get_issue_date(): Date {
72
+ getIssueDate(): Date {
73
73
  const date = this.proto.getIssueDate();
74
74
  return new Date(date.getYear(), date.getMonth(), date.getDay());
75
75
  }
76
76
 
77
- get_maturity_date(): Date {
77
+ getMaturityDate(): Date {
78
78
  const date = this.proto.getMaturityDate();
79
79
  return new Date(date.getYear(), date.getMonth(), date.getDay());
80
80
  }
81
81
 
82
+ getIssuerName(): string {
83
+ return this.proto.getIssuerName();
84
+ }
85
+
82
86
  equals(other: Security): boolean {
83
87
  if (other instanceof Security) {
84
88
  return this.get_id().equals(other.get_id());
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
4
+ var security_1 = require("../security/security");
5
+ var datetime_1 = require("../utils/datetime");
6
+ var uuid_1 = require("../utils/uuid");
7
+ var decimal_js_1 = require("decimal.js");
8
+ var Transaction = /** @class */ (function () {
9
+ function Transaction(proto) {
10
+ this.proto = proto;
11
+ }
12
+ Transaction.prototype.toString = function () {
13
+ try {
14
+ var validTo = this.proto.getValidFrom() !== null ? this.proto.getValidTo().toString() : "NULL";
15
+ return "".concat(/*this.proto.isCancelled()*/ false ? "INVALIDATED: " : "", "TXN[").concat(this.getID().toString(), "], ") +
16
+ "TradeDate[".concat(this.getTradeDate().toString(), "], TxnType[").concat(this.getTransactionType(), "], Price[").concat(this.getPrice(), "], Quantity[").concat(this.getQuantity(), "], ") +
17
+ "AsOf[".concat(this.getAsOf().toString(), "], Portfolio[").concat(this.getPortfolio().getPortfolioName(), "], Issuer[").concat(this.getSecurity().getIssuerName(), "], ") +
18
+ "ValidFrom[".concat(this.proto.getValidFrom().toString(), "], ValidTo[").concat(validTo, "], Strategy[").concat(this.getStrategyAllocation().toString(), "]");
19
+ }
20
+ catch (e) {
21
+ console.error(e);
22
+ return "WHOOPS";
23
+ }
24
+ };
25
+ Transaction.prototype.get_fields = function () {
26
+ return [field_pb_1.FieldProto.ID, field_pb_1.FieldProto.SECURITY_ID, field_pb_1.FieldProto.AS_OF, field_pb_1.FieldProto.ASSET_CLASS, field_pb_1.FieldProto.IDENTIFIER];
27
+ };
28
+ Transaction.prototype.get_field = function (field) {
29
+ switch (field) {
30
+ case field_pb_1.FieldProto.ID:
31
+ case field_pb_1.FieldProto.SECURITY_ID:
32
+ return this.getID();
33
+ case field_pb_1.FieldProto.AS_OF:
34
+ return this.getAsOf();
35
+ case field_pb_1.FieldProto.ASSET_CLASS:
36
+ return this.getSecurity().getAssetClass();
37
+ case field_pb_1.FieldProto.PRODUCT_CLASS:
38
+ return this.getSecurity().getProductClass();
39
+ case field_pb_1.FieldProto.PRODUCT_TYPE:
40
+ return this.getSecurity().getProductType();
41
+ case field_pb_1.FieldProto.IDENTIFIER:
42
+ return this.getSecurity().getSecurityID();
43
+ case field_pb_1.FieldProto.TENOR:
44
+ case field_pb_1.FieldProto.ADJUSTED_TENOR:
45
+ throw new Error('Not implemented yet');
46
+ case field_pb_1.FieldProto.MATURITY_DATE:
47
+ throw new Error('Not implemented yet');
48
+ default:
49
+ throw new Error("Field not mapped in Security wrapper: ".concat(field));
50
+ }
51
+ };
52
+ Transaction.prototype.getID = function () {
53
+ return uuid_1.UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
54
+ };
55
+ Transaction.prototype.getAsOf = function () {
56
+ return new datetime_1.ZonedDateTime(this.proto.getAsOf());
57
+ };
58
+ //TODO: Create Portfolio wrapper
59
+ Transaction.prototype.getPortfolio = function () {
60
+ return this.proto.getPortfolio();
61
+ };
62
+ Transaction.prototype.getSecurity = function () {
63
+ return new security_1.default(this.proto.getSecurity());
64
+ };
65
+ Transaction.prototype.getStrategyAllocation = function () {
66
+ return this.proto.getStrategyAllocation();
67
+ };
68
+ Transaction.prototype.getPrice = function () {
69
+ return this.proto.getPrice();
70
+ };
71
+ Transaction.prototype.getSettlementDate = function () {
72
+ return this.proto.getSettlementDate();
73
+ };
74
+ Transaction.prototype.getQuantity = function () {
75
+ return new decimal_js_1.Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
76
+ };
77
+ Transaction.prototype.getIssuerName = function () {
78
+ return this.getSecurity().getIssuerName();
79
+ };
80
+ // public BigDecimal getDirectedQuantity() {
81
+ // return quantity.multiply(transactionType.getDirectionMultiplier());
82
+ // }
83
+ Transaction.prototype.getTradeDate = function () {
84
+ return this.proto.getTradeDate();
85
+ };
86
+ Transaction.prototype.getTransactionType = function () {
87
+ return this.getTransactionType();
88
+ };
89
+ Transaction.prototype.getTradeName = function () {
90
+ return this.proto.getTradeName();
91
+ };
92
+ Transaction.prototype.getPositionStatus = function () {
93
+ return this.proto.getPositionStatus();
94
+ };
95
+ Transaction.prototype.getChildrenTransactions = function () {
96
+ return this.proto.getChildtransactionsList();
97
+ };
98
+ Transaction.prototype.equals = function (other) {
99
+ if (other instanceof Transaction) {
100
+ return this.getID().equals(other.getID());
101
+ }
102
+ else {
103
+ return false;
104
+ }
105
+ };
106
+ return Transaction;
107
+ }());
108
+ exports.default = Transaction;
109
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["transaction.ts"],"names":[],"mappings":";;AACA,yEAA0E;AAQ1E,iDAA4C;AAC5C,8CAAkD;AAClD,sCAAqC;AACrC,yCAAqC;AAErC;IAGE,qBAAY,KAAuB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,8BAAQ,GAAR;QACE,IAAI;YACA,IAAM,OAAO,GACb,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAEjF,OAAO,UAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,iBAAO,IAAI,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAK;gBACtG,oBAA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AAE,CAAC,0BAA0B,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,mCAAa,GAAb;QACE,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;IAEH,8CAA8C;IAC9C,0EAA0E;IAC1E,IAAI;IAEF,kCAAY,GAAZ;QACE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;IAEC,wCAAkB,GAAlB;QACI,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACrC,CAAC;IAED,kCAAY,GAAZ;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;IAED,uCAAiB,GAAjB;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IAED,6CAAuB,GAAvB;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;IACjD,CAAC;IAGH,4BAAM,GAAN,UAAO,KAAkB;QACvB,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SAC3C;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IACH,kBAAC;AAAD,CAAC,AAxHD,IAwHC;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,137 @@
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 { StrategyAllocationProto } from "../../../fintekkers/models/strategy/strategy_allocation_pb";
7
+ import { TransactionProto } from "../../../fintekkers/models/transaction/transaction_pb";
8
+ import { TransactionTypeProto } from "../../../fintekkers/models/transaction/transaction_type_pb";
9
+ import { LocalDateProto } from "../../../fintekkers/models/util/local_date_pb";
10
+ import Security from "../security/security";
11
+ import { ZonedDateTime } from "../utils/datetime";
12
+ import { UUID } from "../utils/uuid";
13
+ import { Decimal } from "decimal.js";
14
+
15
+ class Transaction {
16
+ proto: TransactionProto;
17
+
18
+ constructor(proto: TransactionProto) {
19
+ this.proto = proto;
20
+ }
21
+
22
+ toString(): string {
23
+ try {
24
+ const validTo: string =
25
+ this.proto.getValidFrom() !== null ? this.proto.getValidTo().toString() : "NULL";
26
+
27
+ return `${/*this.proto.isCancelled()*/ false ? "INVALIDATED: " : ""}TXN[${this.getID().toString()}], ` +
28
+ `TradeDate[${this.getTradeDate().toString()}], TxnType[${this.getTransactionType()}], Price[${this.getPrice()}], Quantity[${this.getQuantity()}], ` +
29
+ `AsOf[${this.getAsOf().toString()}], Portfolio[${this.getPortfolio().getPortfolioName()}], Issuer[${this.getSecurity().getIssuerName()}], ` +
30
+ `ValidFrom[${this.proto.getValidFrom().toString()}], ValidTo[${validTo}], Strategy[${this.getStrategyAllocation().toString()}]`;
31
+ } catch (e) {
32
+ console.error(e);
33
+ return "WHOOPS";
34
+ }
35
+ }
36
+
37
+ get_fields(): FieldProto[] {
38
+ return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
39
+ }
40
+
41
+ get_field(field: FieldProto): any {
42
+ switch (field) {
43
+ case FieldProto.ID:
44
+ case FieldProto.SECURITY_ID:
45
+ return this.getID();
46
+ case FieldProto.AS_OF:
47
+ return this.getAsOf();
48
+ case FieldProto.ASSET_CLASS:
49
+ return this.getSecurity().getAssetClass();
50
+ case FieldProto.PRODUCT_CLASS:
51
+ return this.getSecurity().getProductClass();
52
+ case FieldProto.PRODUCT_TYPE:
53
+ return this.getSecurity().getProductType();
54
+ case FieldProto.IDENTIFIER:
55
+ return this.getSecurity().getSecurityID();
56
+ case FieldProto.TENOR:
57
+ case FieldProto.ADJUSTED_TENOR:
58
+ throw new Error('Not implemented yet');
59
+ case FieldProto.MATURITY_DATE:
60
+ throw new Error('Not implemented yet');
61
+ default:
62
+ throw new Error(`Field not mapped in Security wrapper: ${field}`);
63
+ }
64
+ }
65
+
66
+ getID(): UUID {
67
+ return UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
68
+ }
69
+
70
+ getAsOf(): ZonedDateTime {
71
+ return new ZonedDateTime(this.proto.getAsOf());
72
+ }
73
+
74
+ //TODO: Create Portfolio wrapper
75
+ getPortfolio(): PortfolioProto {
76
+ return this.proto.getPortfolio();
77
+ }
78
+
79
+ getSecurity(): Security {
80
+ return new Security(this.proto.getSecurity());
81
+ }
82
+
83
+ getStrategyAllocation(): StrategyAllocationProto {
84
+ return this.proto.getStrategyAllocation();
85
+ }
86
+
87
+ getPrice(): PriceProto {
88
+ return this.proto.getPrice();
89
+ }
90
+
91
+ getSettlementDate(): LocalDateProto {
92
+ return this.proto.getSettlementDate();
93
+ }
94
+
95
+ getQuantity(): Decimal {
96
+ return new Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
97
+ }
98
+
99
+ getIssuerName(): string {
100
+ return this.getSecurity().getIssuerName();
101
+ }
102
+
103
+ // public BigDecimal getDirectedQuantity() {
104
+ // return quantity.multiply(transactionType.getDirectionMultiplier());
105
+ // }
106
+
107
+ getTradeDate(): LocalDateProto {
108
+ return this.proto.getTradeDate();
109
+ }
110
+
111
+ getTransactionType() : TransactionTypeProto {
112
+ return this.getTransactionType();
113
+ }
114
+
115
+ getTradeName(): string {
116
+ return this.proto.getTradeName();
117
+ }
118
+
119
+ getPositionStatus(): PositionStatusProto {
120
+ return this.proto.getPositionStatus();
121
+ }
122
+
123
+ getChildrenTransactions(): TransactionProto[] {
124
+ return this.proto.getChildtransactionsList();
125
+ }
126
+
127
+
128
+ equals(other: Transaction): boolean {
129
+ if (other instanceof Transaction) {
130
+ return this.getID().equals(other.getID());
131
+ } else {
132
+ return false;
133
+ }
134
+ }
135
+ }
136
+
137
+ export default Transaction;
@@ -42,7 +42,7 @@ exports.testPosition = void 0;
42
42
  var field_pb_1 = require("../fintekkers/models/position/field_pb");
43
43
  //Requests & Services
44
44
  var PortfolioService_1 = require("./services/portfolio-service/PortfolioService");
45
- var util_1 = require("../wrappers/models/utils/util");
45
+ var util_1 = require("./models/utils/util");
46
46
  var PositionService_1 = require("./services/position-service/PositionService");
47
47
  var position_pb_1 = require("../fintekkers/models/position/position_pb");
48
48
  var query_position_request_pb_1 = require("../fintekkers/requests/position/query_position_request_pb");
@@ -1 +1 @@
1
- {"version":3,"file":"position.test.js","sourceRoot":"","sources":["position.test.ts"],"names":[],"mappings":";AAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAET,cAAc;AACd,mEAAoE;AAIpE,qBAAqB;AACrB,kFAAiF;AAIjF,sDAAkE;AAClE,+EAA8E;AAC9E,yEAAgH;AAChH,uGAAsG;AAEtG,wFAAyF;AACzF,iEAA6D;AAC7D,mFAA+E;AAC/E,uFAAuF;AACvF,oDAAwD;AAExD,uEAAwE;AAGxE,qEAAqE;AAErE,qLAAqL;AAErL,SAAe,YAAY,CAAC,QAAsB,EACtC,SAAwB,EACxB,QAAuB,EACvB,aAA+B,EAC/B,MAAoD,EACpD,kBAAuB,EAAE,KAA2B;IADpD,uBAAA,EAAA,UAAU,qBAAU,CAAC,SAAS,EAAE,qBAAU,CAAC,QAAQ,CAAC;IACpD,mCAAA,EAAA,uBAAuB;IAAE,sBAAA,EAAA,QAAQ,wBAAa,CAAC,GAAG,EAAE;;;;;;oBACtD,OAAO,GAAG,EAAE,CAAC;oBAEnB,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE;wBACvC,QAAQ,GAAG,IAAI,+BAAe,EAAE,CAAC;wBACvC,QAAQ,CAAC,kBAAkB,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC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,GAAG,SAAsC;oBAExD,sBAAO,SAAS,EAAC;;;;CACpB;AAED,SAAe,YAAY;;;;;;oBAEnB,GAAG,GAAG,wBAAa,CAAC,GAAG,EAAE,CAAC;oBAE1B,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;oBAE/B,qBAAM,gBAAgB,CAAC,eAAe,CACjD,GAAG,CAAC,aAAa,EAAE,EACnB,qBAAU,CAAC,cAAc,EACzB,+BAA+B,CAAC,EAAA;;oBAHlC,UAAU,GAAG,SAGqB;oBAChC,mBAAmB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;oBAE1B,qBAAM,YAAY,CAAC,IAAI,EAAE,mBAAmB,EAC1D,CAAC,yBAAY,CAAC,iBAAiB,CAAC,EAChC,+BAAiB,CAAC,WAAW,EAC7B,CAAC,qBAAU,CAAC,cAAc,EAAE,qBAAU,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAA;;oBAH3D,SAAS,GAAG,SAG+C;oBAG7D,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,UAAC,KAAK,IAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACzE,SAAS,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,UAAC,OAAO,IAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjF,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;;;;;CACxB;AAEQ,oCAAY"}
@@ -10,7 +10,7 @@ import { PortfolioService } from './services/portfolio-service/PortfolioService'
10
10
  import { PortfolioProto } from '../fintekkers/models/portfolio/portfolio_pb';
11
11
  import { QueryPortfolioRequestProto } from '../fintekkers/requests/portfolio/query_portfolio_request_pb';
12
12
 
13
- import { packStringIntoAny } from '../wrappers/models/utils/util';
13
+ import { packStringIntoAny } from './models/utils/util';
14
14
  import { PositionService } from './services/position-service/PositionService';
15
15
  import { PositionProto, PositionTypeProto, PositionViewProto } from '../fintekkers/models/position/position_pb';
16
16
  import { QueryPositionRequestProto } from '../fintekkers/requests/position/query_position_request_pb';
@@ -127,8 +127,10 @@ var PortfolioService = /** @class */ (function () {
127
127
  positionFilter = new position_filter_pb_1.PositionFilterProto();
128
128
  positionFilter.setObjectClass('PositionFilter');
129
129
  positionFilter.setVersion('0.0.1');
130
- fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
131
- positionFilter.setFiltersList([fieldMapEntry]);
130
+ if (fieldProto && fieldValue) {
131
+ fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
132
+ positionFilter.setFiltersList([fieldMapEntry]);
133
+ }
132
134
  searchRequest.setSearchPortfolioInput(positionFilter);
133
135
  tmpClient = this.client;
134
136
  listPortfolios = [];
@@ -1 +1 @@
1
- {"version":3,"file":"PortfolioService.js","sourceRoot":"","sources":["PortfolioService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAIjC,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,sHAA2G;AAC3G,gHAA+G;AAE/G,kHAAiH;AAGjH;IAGE;QACE,8FAA8F;QAC9F,IAAI,CAAC,MAAM,GAAG,IAAI,2CAAe,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;IACzF,CAAC;IAEK,kDAAuB,GAA7B,UAA8B,SAAyB;;;;;;wBAC/C,aAAa,GAAG,IAAI,yDAA2B,EAAE,CAAC;wBACxD,aAAa,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;wBACjD,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;wBAClC,aAAa,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;wBAE3C,2BAA2B,G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gB,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;wBA0BrC,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,uBAAC;AAAD,CAAC,AA/ED,IA+EC;AAEQ,4CAAgB"}
@@ -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
 
@@ -7,8 +7,8 @@ import { createFieldMapEntry } from '../../models/utils/util';
7
7
  import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
8
8
  import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
9
9
 
10
- import { ZonedDateTime } from '../../../wrappers/models/utils/datetime';
11
- import { packStringIntoAny } from '../../../wrappers/models/utils/util';
10
+ import { ZonedDateTime } from '../../models/utils/datetime';
11
+ import { packStringIntoAny } from '../../models/utils/util';
12
12
 
13
13
  // Model Utils
14
14
  import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
@@ -0,0 +1,147 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.TransactionService = void 0;
40
+ var grpc = require("@grpc/grpc-js");
41
+ var util_1 = require("util");
42
+ // Models
43
+ var transaction_1 = require("../../models/transaction/transaction");
44
+ var util_2 = require("../../models/utils/util");
45
+ // Model Utils
46
+ var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
47
+ // Requests & Services
48
+ var transaction_service_grpc_pb_1 = require("../../../fintekkers/services/transaction-service/transaction_service_grpc_pb");
49
+ var create_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/create_transaction_request_pb");
50
+ var query_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/query_transaction_request_pb");
51
+ var TransactionService = /** @class */ (function () {
52
+ function TransactionService() {
53
+ // this.client = new SecurityClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
54
+ this.client = new transaction_service_grpc_pb_1.TransactionClient('localhost:8082', grpc.credentials.createInsecure());
55
+ }
56
+ TransactionService.prototype.validateCreateTransaction = function (transaction) {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var createRequest, validateCreateOrUpdateAsync, response;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ createRequest = new create_transaction_request_pb_1.CreateTransactionRequestProto();
63
+ createRequest.setObjectClass('TransactionRequest');
64
+ createRequest.setVersion('0.0.1');
65
+ createRequest.setCreateTransactionInput(transaction.proto);
66
+ validateCreateOrUpdateAsync = (0, util_1.promisify)(this.client.validateCreateOrUpdate.bind(this.client));
67
+ return [4 /*yield*/, validateCreateOrUpdateAsync(createRequest)];
68
+ case 1:
69
+ response = _a.sent();
70
+ return [2 /*return*/, response];
71
+ }
72
+ });
73
+ });
74
+ };
75
+ TransactionService.prototype.createTransaction = function (transaction) {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var createRequest, createSecurityAsync, response;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ createRequest = new create_transaction_request_pb_1.CreateTransactionRequestProto();
82
+ createRequest.setObjectClass('TransactionRequest');
83
+ createRequest.setVersion('0.0.1');
84
+ createRequest.setCreateTransactionInput(transaction.proto);
85
+ createSecurityAsync = (0, util_1.promisify)(this.client.createOrUpdate.bind(this.client));
86
+ return [4 /*yield*/, createSecurityAsync(createRequest)];
87
+ case 1:
88
+ response = _a.sent();
89
+ return [2 /*return*/, response];
90
+ }
91
+ });
92
+ });
93
+ };
94
+ TransactionService.prototype.searchTransaction = function (asOf, fieldProto, fieldValue) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ function processStreamSynchronously() {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var stream2;
99
+ return __generator(this, function (_a) {
100
+ stream2 = tmpClient.search(searchRequest);
101
+ return [2 /*return*/, new Promise(function (resolve, reject) {
102
+ stream2.on('data', function (response) {
103
+ console.log('Result of the transaction search call');
104
+ console.log('Response:', response);
105
+ response.getTransactionResponseList().forEach(function (transaction) {
106
+ listTransactions.push(new transaction_1.default(transaction));
107
+ });
108
+ console.log('Size of transactions:', listTransactions.length);
109
+ });
110
+ stream2.on('end', function () {
111
+ console.log('Stream ended.');
112
+ resolve(listTransactions);
113
+ });
114
+ stream2.on('error', function (err) {
115
+ console.error('Error in the stream:', err);
116
+ reject(err);
117
+ });
118
+ })];
119
+ });
120
+ });
121
+ }
122
+ var searchRequest, positionFilter, fieldMapEntry, tmpClient, listTransactions;
123
+ return __generator(this, function (_a) {
124
+ switch (_a.label) {
125
+ case 0:
126
+ searchRequest = new query_transaction_request_pb_1.QueryTransactionRequestProto();
127
+ searchRequest.setObjectClass('SecurityRequest');
128
+ searchRequest.setVersion('0.0.1');
129
+ searchRequest.setAsOf(asOf);
130
+ positionFilter = new position_filter_pb_1.PositionFilterProto();
131
+ positionFilter.setObjectClass('PositionFilter');
132
+ positionFilter.setVersion('0.0.1');
133
+ fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
134
+ positionFilter.setFiltersList([fieldMapEntry]);
135
+ searchRequest.setSearchTransactionInput(positionFilter);
136
+ tmpClient = this.client;
137
+ listTransactions = [];
138
+ return [4 /*yield*/, processStreamSynchronously()];
139
+ case 1: return [2 /*return*/, _a.sent()];
140
+ }
141
+ });
142
+ });
143
+ };
144
+ return TransactionService;
145
+ }());
146
+ exports.TransactionService = TransactionService;
147
+ //# sourceMappingURL=TransactionService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionService.js","sourceRoot":"","sources":["TransactionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,6BAAiC;AAEjC,SAAS;AACT,oEAA+D;AAC/D,gDAA8D;AAI9D,cAAc;AACd,6FAA6F;AAG7F,sBAAsB;AACtB,4HAAiH;AACjH,wHAAuH;AAEvH,sHAAqH;AAIrH;IAGE;QACE,6FAA6F;QAC7F,IAAI,CAAC,MAAM,GAAG,IAAI,+CAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEK,sDAAyB,GAA/B,UAAgC,WAAwB;;;;;;wBAChD,aAAa,GAAG,IAAI,6DAA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c,CAAC,CAAC;wBAElD,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;wBAExB,gBAAgB,GAAkB,EAAE,CAAC;wBA4BpC,qBAAM,0BAA0B,EAAE,EAAA;4BAAzC,sBAAO,SAAkC,EAAC;;;;KAC3C;IACH,yBAAC;AAAD,CAAC,AA7ED,IA6EC;AAEQ,gDAAkB"}
@@ -0,0 +1,101 @@
1
+ import * as grpc from '@grpc/grpc-js';
2
+ import { promisify } from 'util';
3
+
4
+ // Models
5
+ import Transaction from '../../models/transaction/transaction';
6
+ import { createFieldMapEntry } from '../../models/utils/util';
7
+ import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
8
+ import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
9
+
10
+ // Model Utils
11
+ import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
12
+ import { FieldProto } from '../../../fintekkers/models/position/field_pb';
13
+
14
+ // Requests & Services
15
+ import { TransactionClient } from '../../../fintekkers/services/transaction-service/transaction_service_grpc_pb';
16
+ import { CreateTransactionRequestProto } from '../../../fintekkers/requests/transaction/create_transaction_request_pb';
17
+ import { CreateTransactionResponseProto } from '../../../fintekkers/requests/transaction/create_transaction_response_pb';
18
+ import { QueryTransactionRequestProto } from '../../../fintekkers/requests/transaction/query_transaction_request_pb';
19
+ import { QueryTransactionResponseProto } from '../../../fintekkers/requests/transaction/query_transaction_response_pb';
20
+
21
+
22
+ class TransactionService {
23
+ private client: TransactionClient;
24
+
25
+ constructor() {
26
+ // this.client = new SecurityClient('api.fintekkers.org:8082', grpc.credentials.createSsl());
27
+ this.client = new TransactionClient('localhost:8082', grpc.credentials.createInsecure());
28
+ }
29
+
30
+ async validateCreateTransaction(transaction: Transaction): Promise<SummaryProto> {
31
+ const createRequest = new CreateTransactionRequestProto();
32
+ createRequest.setObjectClass('TransactionRequest');
33
+ createRequest.setVersion('0.0.1');
34
+ createRequest.setCreateTransactionInput(transaction.proto);
35
+
36
+ const validateCreateOrUpdateAsync = promisify(this.client.validateCreateOrUpdate.bind(this.client));
37
+ const response = await validateCreateOrUpdateAsync(createRequest);
38
+ return response;
39
+ }
40
+
41
+ async createTransaction(transaction: Transaction): Promise<CreateTransactionResponseProto> {
42
+ const createRequest = new CreateTransactionRequestProto();
43
+ createRequest.setObjectClass('TransactionRequest');
44
+ createRequest.setVersion('0.0.1');
45
+ createRequest.setCreateTransactionInput(transaction.proto);
46
+
47
+ const createSecurityAsync = promisify(this.client.createOrUpdate.bind(this.client));
48
+ const response = await createSecurityAsync(createRequest);
49
+ return response;
50
+ }
51
+
52
+ async searchTransaction(asOf: LocalTimestampProto, fieldProto: FieldProto, fieldValue: string): Promise<Transaction[]> {
53
+ const searchRequest = new QueryTransactionRequestProto();
54
+ searchRequest.setObjectClass('SecurityRequest');
55
+ searchRequest.setVersion('0.0.1');
56
+ searchRequest.setAsOf(asOf);
57
+
58
+ const positionFilter = new PositionFilterProto();
59
+ positionFilter.setObjectClass('PositionFilter');
60
+ positionFilter.setVersion('0.0.1');
61
+
62
+ const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
63
+ positionFilter.setFiltersList([fieldMapEntry]);
64
+
65
+ searchRequest.setSearchTransactionInput(positionFilter);
66
+
67
+ const tmpClient = this.client;
68
+
69
+ const listTransactions: Transaction[] = [];
70
+
71
+ async function processStreamSynchronously(): Promise<Transaction[]> {
72
+ const stream2 = tmpClient.search(searchRequest);
73
+
74
+ return new Promise<Transaction[]>((resolve, reject) => {
75
+ stream2.on('data', (response:QueryTransactionResponseProto) => {
76
+ console.log('Result of the transaction search call');
77
+ console.log('Response:', response);
78
+ response.getTransactionResponseList().forEach((transaction) => {
79
+ listTransactions.push(new Transaction(transaction));
80
+ });
81
+
82
+ console.log('Size of transactions:', listTransactions.length );
83
+ });
84
+
85
+ stream2.on('end', () => {
86
+ console.log('Stream ended.');
87
+ resolve(listTransactions);
88
+ });
89
+
90
+ stream2.on('error', (err) => {
91
+ console.error('Error in the stream:', err);
92
+ reject(err);
93
+ });
94
+ });
95
+ }
96
+
97
+ return await processStreamSynchronously();
98
+ }
99
+ }
100
+
101
+ export { TransactionService };
@@ -0,0 +1,117 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.testTransaction = void 0;
40
+ // Models
41
+ var decimal_value_pb_1 = require("../fintekkers/models/util/decimal_value_pb");
42
+ var local_date_pb_1 = require("../fintekkers/models/util/local_date_pb");
43
+ // Model Utils
44
+ var field_pb_1 = require("../fintekkers/models/position/field_pb");
45
+ var uuid = require("./models/utils/uuid");
46
+ var dt = require("./models/utils/datetime");
47
+ var SecurityService_1 = require("./services/security-service/SecurityService");
48
+ var transaction_type_pb_1 = require("../fintekkers/models/transaction/transaction_type_pb");
49
+ var transaction_pb_1 = require("../fintekkers/models/transaction/transaction_pb");
50
+ var price_pb_1 = require("../fintekkers/models/price/price_pb");
51
+ var PortfolioService_1 = require("./services/portfolio-service/PortfolioService");
52
+ var TransactionService_1 = require("./services/transaction-service/TransactionService");
53
+ var transaction_1 = require("./models/transaction/transaction");
54
+ function testTransaction() {
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var id_proto, now, today, securityService, portfolioService, transactionService, fixedIncomeSecurities, security, portfolios, portfolio, transaction, createTransactionResponse, searchResults;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0:
60
+ id_proto = uuid.UUID.random().toUUIDProto();
61
+ now = dt.ZonedDateTime.now();
62
+ today = new local_date_pb_1.LocalDateProto().setDay(1).setMonth(1).setYear(2021);
63
+ securityService = new SecurityService_1.SecurityService();
64
+ portfolioService = new PortfolioService_1.PortfolioService();
65
+ transactionService = new TransactionService_1.TransactionService();
66
+ return [4 /*yield*/, securityService
67
+ .searchSecurity(now.to_date_proto(), field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income')
68
+ .then(function (fixedIncomeSecurities) {
69
+ return fixedIncomeSecurities;
70
+ })];
71
+ case 1:
72
+ fixedIncomeSecurities = _a.sent();
73
+ security = fixedIncomeSecurities[0];
74
+ return [4 /*yield*/, portfolioService.searchPortfolio(now.to_date_proto(), field_pb_1.FieldProto.PORTFOLIO_NAME, 'TEST PORTFOLIO')];
75
+ case 2:
76
+ portfolios = _a.sent();
77
+ if (portfolios === undefined) {
78
+ throw new Error('No portfolios found');
79
+ }
80
+ console.log('There are %d portfolios in this response', portfolios.length);
81
+ portfolio = portfolios[0];
82
+ if (portfolio.getPortfolioName().includes('Federal')) {
83
+ throw new Error('Portfolio is not a test portfolio! Abandoning test');
84
+ }
85
+ transaction = new transaction_pb_1.TransactionProto();
86
+ transaction.setObjectClass('Transaction');
87
+ transaction.setVersion('0.0.1');
88
+ transaction.setUuid(uuid.UUID.random().toUUIDProto());
89
+ transaction.setAsOf(now.to_date_proto());
90
+ transaction.setTradeDate(today);
91
+ transaction.setSettlementDate(today); //Same day settlement
92
+ transaction.setTransactionType(transaction_type_pb_1.TransactionTypeProto.BUY);
93
+ transaction.setPrice(new price_pb_1.PriceProto()
94
+ .setObjectClass('Price')
95
+ .setAsOf(now.to_date_proto())
96
+ .setVersion('0.0.1')
97
+ .setSecurity(security.proto)
98
+ .setUuid(uuid.UUID.random().toUUIDProto())
99
+ .setPrice(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('100.00')));
100
+ transaction.setQuantity(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('10000.00'));
101
+ transaction.setPortfolio(portfolio);
102
+ transaction.setSecurity(security.proto);
103
+ return [4 /*yield*/, transactionService.createTransaction(new transaction_1.default(transaction))];
104
+ case 3:
105
+ createTransactionResponse = _a.sent();
106
+ console.log(createTransactionResponse);
107
+ return [4 /*yield*/, transactionService.searchTransaction(now.to_date_proto(), field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income')];
108
+ case 4:
109
+ searchResults = _a.sent();
110
+ console.log('There are %d transactions in this response', searchResults.length);
111
+ return [2 /*return*/];
112
+ }
113
+ });
114
+ });
115
+ }
116
+ exports.testTransaction = testTransaction;
117
+ //# sourceMappingURL=transaction.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,+EAA+E;AAC/E,yEAAyE;AAEzE,cAAc;AACd,mEAAoE;AAEpE,0CAA4C;AAC5C,4CAA8C;AAE9C,+EAA8E;AAC9E,4FAA4F;AAC5F,kFAAmF;AACnF,gEAAiE;AACjE,kFAAiF;AACjF,wFAAuF;AACvF,gEAA2D;AAG3D,SAAe,eAAe;;;;;;oBACtB,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;oBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;oBAC7B,KAAK,GAAG,IAAI,8BAAc,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAEjE,eAAe,GAAG,IAAI,iCAAe,EAAE,CAAC;oBACxC,gBAAgB,GAAG,IAAI,mCAAgB,EAAE,CAAC;oBAC1C,kBAAkB,GAAG,IAAI,uCAAkB,EAAE,CAAC;oBAQxB,qBAAM,eAAe;6BAChD,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,cAAc,CAAC;6BAC3E,IAAI,CAAC,UAAC,qBAAqB;4BAC1B,OAAO,qBAAqB,CAAC;wBAC/B,CAAC,CAAC,EAAA;;oBAJE,qBAAqB,GAAG,SAI1B;oBAEE,QAA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AAC,KAAK,CAAC;yBAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;yBACzC,QAAQ,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAC1E,CAAC;oBACF,WAAW,CAAC,WAAW,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC,CAAC;oBACxF,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;oBACpC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAKuB,qBAAM,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,qBAAW,CAAC,WAAW,CAAC,CAAC,EAAA;;oBAAnI,yBAAyB,GAAkC,SAAwE;oBACvI,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;oBAEnB,qBAAM,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,WAAW,EAAE,cAAc,CAAC,EAAA;;oBAAvH,aAAa,GAAG,SAAuG;oBAC3H,OAAO,CAAC,GAAG,CAAC,4CAA4C,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;;;;;CACjF;AAEQ,0CAAe"}
@@ -0,0 +1,90 @@
1
+ // Models
2
+ import { DecimalValueProto } from '../fintekkers/models/util/decimal_value_pb';
3
+ import { LocalDateProto } from '../fintekkers/models/util/local_date_pb';
4
+
5
+ // Model Utils
6
+ import { FieldProto } from '../fintekkers/models/position/field_pb';
7
+
8
+ import * as uuid from './models/utils/uuid';
9
+ import * as dt from './models/utils/datetime';
10
+
11
+ import { SecurityService } from './services/security-service/SecurityService';
12
+ import { TransactionTypeProto } from '../fintekkers/models/transaction/transaction_type_pb';
13
+ import { TransactionProto } from '../fintekkers/models/transaction/transaction_pb';
14
+ import { PriceProto } from '../fintekkers/models/price/price_pb';
15
+ import { PortfolioService } from './services/portfolio-service/PortfolioService';
16
+ import { TransactionService } from './services/transaction-service/TransactionService';
17
+ import Transaction from './models/transaction/transaction';
18
+ import { CreateTransactionResponseProto } from '../fintekkers/requests/transaction/create_transaction_response_pb';
19
+
20
+ async function testTransaction(): Promise<void> {
21
+ const id_proto = uuid.UUID.random().toUUIDProto();
22
+ const now = dt.ZonedDateTime.now();
23
+ const today = new LocalDateProto().setDay(1).setMonth(1).setYear(2021);
24
+
25
+ const securityService = new SecurityService();
26
+ const portfolioService = new PortfolioService();
27
+ const transactionService = new TransactionService();
28
+
29
+ // let usd_security = await securityService
30
+ // .searchSecurity(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Cash')
31
+ // .then((securities) => {
32
+ // return securities[0];
33
+ // });
34
+
35
+ let fixedIncomeSecurities = await securityService
36
+ .searchSecurity(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Fixed Income')
37
+ .then((fixedIncomeSecurities) => {
38
+ return fixedIncomeSecurities;
39
+ });
40
+
41
+ let security = fixedIncomeSecurities[0];
42
+
43
+ let portfolios = await portfolioService.searchPortfolio(
44
+ now.to_date_proto(),
45
+ FieldProto.PORTFOLIO_NAME,
46
+ 'TEST PORTFOLIO');
47
+
48
+ if(portfolios === undefined) {
49
+ throw new Error('No portfolios found');
50
+ }
51
+
52
+ console.log('There are %d portfolios in this response', portfolios.length);
53
+ const portfolio = portfolios[0];
54
+
55
+ if(portfolio.getPortfolioName().includes('Federal')){
56
+ throw new Error('Portfolio is not a test portfolio! Abandoning test');
57
+ }
58
+
59
+ const transaction = new TransactionProto();
60
+ transaction.setObjectClass('Transaction');
61
+ transaction.setVersion('0.0.1');
62
+ transaction.setUuid(uuid.UUID.random().toUUIDProto());
63
+ transaction.setAsOf(now.to_date_proto());
64
+ transaction.setTradeDate(today);
65
+ transaction.setSettlementDate(today); //Same day settlement
66
+ transaction.setTransactionType(TransactionTypeProto.BUY);
67
+ transaction.setPrice(
68
+ new PriceProto()
69
+ .setObjectClass('Price')
70
+ .setAsOf(now.to_date_proto())
71
+ .setVersion('0.0.1')
72
+ .setSecurity(security.proto)
73
+ .setUuid(uuid.UUID.random().toUUIDProto())
74
+ .setPrice(new DecimalValueProto().setArbitraryPrecisionValue('100.00'))
75
+ );
76
+ transaction.setQuantity(new DecimalValueProto().setArbitraryPrecisionValue('10000.00'));
77
+ transaction.setPortfolio(portfolio);
78
+ transaction.setSecurity(security.proto);
79
+
80
+ // var validationSummary = await transactionService.validateCreateTransaction(new Transaction(transaction));
81
+ // console.log(validationSummary);
82
+
83
+ var createTransactionResponse:CreateTransactionResponseProto = await transactionService.createTransaction(new Transaction(transaction));
84
+ console.log(createTransactionResponse);
85
+
86
+ var searchResults = await transactionService.searchTransaction(now.to_date_proto(), FieldProto.ASSET_CLASS, 'Fixed Income');
87
+ console.log('There are %d transactions in this response', searchResults.length);
88
+ }
89
+
90
+ export { testTransaction };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@fintekkers/ledger-models",
3
- "todo" : "Replace the version with build script version number",
4
- "version": "0.0.103",
3
+ "todo": "Replace the version with build script version number",
4
+ "version": "0.1.60",
5
5
  "description": "ledger model protos ",
6
- "author": "Sam Sheridan",
6
+ "authors": [
7
+ "David Doherty",
8
+ "Sam Sheridan"
9
+ ],
7
10
  "license": "ISC",
8
11
  "main": "index.js",
9
12
  "type": "commonjs",
@@ -30,6 +33,7 @@
30
33
  "dependencies": {
31
34
  "@grpc/grpc-js": "^1.8.18",
32
35
  "bytebuffer": "^5.0.1",
36
+ "decimal.js": "^10.4.3",
33
37
  "luxon": "^3.3.0",
34
38
  "uuid": "^9.0.0"
35
39
  }
@@ -1,20 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/index.js",
15
- "outFiles": [
16
- "${workspaceFolder}/**/*.js"
17
- ]
18
- }
19
- ]
20
- }