@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.
- package/babel.config.js +3 -1
- package/index.js +1 -13
- package/index.js.map +1 -1
- package/index.ts +1 -18
- package/jest.config.js +4 -0
- package/node/fintekkers/models/security/security_pb.test.js +29 -30
- package/node/fintekkers/models/security/security_pb.test.js.map +1 -0
- package/node/fintekkers/models/security/security_pb.test.ts +33 -0
- package/node/wrappers/models/security/security.js +21 -18
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +22 -18
- package/node/wrappers/models/transaction/transaction.js +111 -0
- package/node/wrappers/models/transaction/transaction.js.map +1 -0
- package/node/wrappers/models/transaction/transaction.test.js +26 -0
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -0
- package/node/wrappers/models/transaction/transaction.test.ts +37 -0
- package/node/wrappers/models/transaction/transaction.ts +139 -0
- package/node/wrappers/models/transaction/transaction_type.js +45 -0
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -0
- package/node/wrappers/models/transaction/transaction_type.ts +47 -0
- package/node/wrappers/models/utils/date.js +25 -0
- package/node/wrappers/models/utils/date.js.map +1 -0
- package/node/wrappers/models/utils/date.ts +31 -0
- package/node/wrappers/models/utils/datetime.js +4 -4
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.ts +4 -4
- package/node/wrappers/models/utils/serialization.test.js +14 -54
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +11 -7
- package/node/wrappers/services/portfolio-service/PortfolioService.js +6 -7
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +8 -8
- package/node/wrappers/{portfolio.test.js → services/portfolio-service/portfolio.test.js} +10 -9
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -0
- package/node/wrappers/{portfolio.test.ts → services/portfolio-service/portfolio.test.ts} +15 -11
- package/node/wrappers/services/position-service/PositionService.js +2 -5
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -7
- package/node/wrappers/{position.test.js → services/position-service/position.test.js} +17 -20
- package/node/wrappers/services/position-service/position.test.js.map +1 -0
- package/node/wrappers/{position.test.ts → services/position-service/position.test.ts} +21 -28
- package/node/wrappers/services/security-service/SecurityService.js +2 -5
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +2 -5
- package/node/wrappers/{security.test.js → services/security-service/security.test.js} +15 -16
- package/node/wrappers/services/security-service/security.test.js.map +1 -0
- package/node/wrappers/{security.test.ts → services/security-service/security.test.ts} +19 -17
- package/node/wrappers/services/transaction-service/TransactionService.js +143 -0
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -0
- package/node/wrappers/services/transaction-service/TransactionService.ts +96 -0
- package/node/wrappers/services/transaction-service/transaction.test.js +116 -0
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -0
- package/node/wrappers/services/transaction-service/transaction.test.ts +87 -0
- package/package.json +4 -2
- package/node/wrappers/portfolio.test.js.map +0 -1
- package/node/wrappers/position.test.js.map +0 -1
- package/node/wrappers/security.test.js.map +0 -1
package/babel.config.js
CHANGED
package/index.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
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)();
|
|
12
|
-
// TODO - Transactions
|
|
13
|
-
// TODO - Positions
|
|
1
|
+
console.log('Done');
|
|
14
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
testPortfolio();
|
|
3
|
-
|
|
4
|
-
import { testSecurity } from './node/wrappers/security.test';
|
|
5
|
-
testSecurity();
|
|
6
|
-
|
|
7
|
-
//TODO: Add position convenience wrapper
|
|
8
|
-
import { testPosition } from './node/wrappers/position.test';
|
|
9
|
-
testPosition();
|
|
10
|
-
|
|
11
|
-
import { testSerialization } from './node/wrappers/models/utils/serialization.test';
|
|
12
|
-
testSerialization();
|
|
13
|
-
|
|
14
|
-
// TODO - Transactions
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// TODO - Positions
|
|
18
|
-
|
|
1
|
+
console.log('Done');
|
package/jest.config.js
ADDED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import fintekkers_models_util_local_date_pb from '../util/local_date_pb';
|
|
4
|
-
import fintekkers_models_util_local_timestamp_pb from '../util/local_timestamp_pb';
|
|
5
|
-
import fintekkers_models_util_uuid_pb from '../util/uuid_pb';
|
|
6
|
-
import fintekkers_models_security_identifier_identifier_pb from './identifier/identifier_pb';
|
|
7
|
-
import fintekkers_models_security_security_type_pb from './security_type_pb';
|
|
8
|
-
import fintekkers_models_security_security_pb from './security_pb';
|
|
9
|
-
import fintekkers_models_security_security_quantity_type_pb from './security_quantity_type_pb';
|
|
10
|
-
import fintekkers_models_security_coupon_frequency_pb from './coupon_frequency_pb';
|
|
11
|
-
import fintekkers_models_security_coupon_type_pb from './coupon_type_pb';
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
3
|
// Import or define the SecurityProto class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
var decimal_value_pb_1 = require("../util/decimal_value_pb");
|
|
5
|
+
var local_date_pb_1 = require("../util/local_date_pb");
|
|
6
|
+
var coupon_frequency_pb_1 = require("./coupon_frequency_pb");
|
|
7
|
+
var coupon_type_pb_1 = require("./coupon_type_pb");
|
|
8
|
+
var security_pb_1 = require("./security_pb");
|
|
9
|
+
var security_type_pb_1 = require("./security_type_pb");
|
|
10
|
+
test('create a security proto (from sue) object and test it can be read', function () {
|
|
11
|
+
// Usage example
|
|
12
|
+
var security = new security_pb_1.SecurityProto();
|
|
13
|
+
security.setObjectClass('SomeObjectClass');
|
|
14
|
+
security.setVersion('1.0');
|
|
15
|
+
security.setAssetClass('FixedIncome');
|
|
16
|
+
security.setCouponFrequency(coupon_frequency_pb_1.CouponFrequencyProto.ANNUALLY);
|
|
17
|
+
security.setCouponRate(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('0.05'));
|
|
18
|
+
security.setFaceValue(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
19
|
+
security.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
20
|
+
security.setDatedDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
21
|
+
security.setMaturityDate(new local_date_pb_1.LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
22
|
+
security.setSecurityType(security_type_pb_1.SecurityTypeProto.BOND_SECURITY);
|
|
23
|
+
security.setCouponType(coupon_type_pb_1.CouponTypeProto.FIXED);
|
|
24
|
+
// Serialize the object to a binary representation
|
|
25
|
+
var binaryData = security.serializeBinary();
|
|
26
|
+
// Deserialize the binary data back to a SecurityProto object
|
|
27
|
+
var deserializedSecurity = security_pb_1.SecurityProto.deserializeBinary(binaryData);
|
|
28
|
+
// Test that the deserialized object is the same as the original
|
|
29
|
+
expect(deserializedSecurity.toObject()).toEqual(security.toObject());
|
|
32
30
|
});
|
|
31
|
+
//# sourceMappingURL=security_pb.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security_pb.test.js","sourceRoot":"","sources":["security_pb.test.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAC3C,6DAA6D;AAC7D,uDAAuD;AACvD,6DAA6D;AAC7D,mDAAmD;AACnD,6CAA8C;AAC9C,uDAAuD;AAEvD,IAAI,CAAC,mEAAmE,EAAE;IACxE,gBAAgB;IAChB,IAAM,QAAQ,GAAG,IAAI,2BAAa,EAAE,CAAC;IAErC,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,0CAAoB,CAAC,QAAQ,CAAC,CAAC;IAC3D,QAAQ,CAAC,aAAa,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,YAAY,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAAC;IACrF,QAAQ,CAAC,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,eAAe,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,QAAQ,CAAC,eAAe,CAAC,oCAAiB,CAAC,aAAa,CAAC,CAAC;IAC1D,QAAQ,CAAC,aAAa,CAAC,gCAAe,CAAC,KAAK,CAAC,CAAA;IAE7C,kDAAkD;IAClD,IAAM,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;IAE9C,6DAA6D;IAC7D,IAAM,oBAAoB,GAAG,2BAAa,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAEzE,gEAAgE;IAChE,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Import or define the SecurityProto class
|
|
2
|
+
import { DecimalValueProto } from '../util/decimal_value_pb';
|
|
3
|
+
import { LocalDateProto } from '../util/local_date_pb';
|
|
4
|
+
import { CouponFrequencyProto } from './coupon_frequency_pb';
|
|
5
|
+
import { CouponTypeProto } from './coupon_type_pb';
|
|
6
|
+
import { SecurityProto } from './security_pb';
|
|
7
|
+
import { SecurityTypeProto } from './security_type_pb';
|
|
8
|
+
|
|
9
|
+
test('create a security proto (from sue) object and test it can be read', () => {
|
|
10
|
+
// Usage example
|
|
11
|
+
const security = new SecurityProto();
|
|
12
|
+
|
|
13
|
+
security.setObjectClass('SomeObjectClass');
|
|
14
|
+
security.setVersion('1.0');
|
|
15
|
+
security.setAssetClass('FixedIncome');
|
|
16
|
+
security.setCouponFrequency(CouponFrequencyProto.ANNUALLY);
|
|
17
|
+
security.setCouponRate(new DecimalValueProto().setArbitraryPrecisionValue('0.05'));
|
|
18
|
+
security.setFaceValue(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
19
|
+
security.setIssueDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
20
|
+
security.setDatedDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
21
|
+
security.setMaturityDate(new LocalDateProto().setYear(2023).setMonth(1).setDay(1));
|
|
22
|
+
security.setSecurityType(SecurityTypeProto.BOND_SECURITY);
|
|
23
|
+
security.setCouponType(CouponTypeProto.FIXED)
|
|
24
|
+
|
|
25
|
+
// Serialize the object to a binary representation
|
|
26
|
+
const binaryData = security.serializeBinary();
|
|
27
|
+
|
|
28
|
+
// Deserialize the binary data back to a SecurityProto object
|
|
29
|
+
const deserializedSecurity = SecurityProto.deserializeBinary(binaryData);
|
|
30
|
+
|
|
31
|
+
// Test that the deserialized object is the same as the original
|
|
32
|
+
expect(deserializedSecurity.toObject()).toEqual(security.toObject());
|
|
33
|
+
});
|
|
@@ -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.
|
|
11
|
+
return "ID[".concat(this.getID().toString(), "], ").concat(this.getSecurityID(), "[").concat(this.getIssuerName(), "]");
|
|
12
12
|
};
|
|
13
|
-
Security.prototype.
|
|
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.
|
|
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.
|
|
20
|
+
return this.getID();
|
|
21
21
|
case field_pb_1.FieldProto.AS_OF:
|
|
22
|
-
return this.
|
|
22
|
+
return this.getAsOf();
|
|
23
23
|
case field_pb_1.FieldProto.ASSET_CLASS:
|
|
24
|
-
return this.
|
|
24
|
+
return this.getAssetClass();
|
|
25
25
|
case field_pb_1.FieldProto.PRODUCT_CLASS:
|
|
26
|
-
return this.
|
|
26
|
+
return this.getProductClass();
|
|
27
27
|
case field_pb_1.FieldProto.PRODUCT_TYPE:
|
|
28
|
-
return this.
|
|
28
|
+
return this.getProductType();
|
|
29
29
|
case field_pb_1.FieldProto.IDENTIFIER:
|
|
30
|
-
return this.
|
|
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,36 +37,39 @@ var Security = /** @class */ (function () {
|
|
|
37
37
|
throw new Error("Field not mapped in Security wrapper: ".concat(field));
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
Security.prototype.
|
|
40
|
+
Security.prototype.getID = function () {
|
|
41
41
|
return uuid_1.UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
|
|
42
42
|
};
|
|
43
|
-
Security.prototype.
|
|
43
|
+
Security.prototype.getAsOf = function () {
|
|
44
44
|
return new datetime_1.ZonedDateTime(this.proto.getAsOf());
|
|
45
45
|
};
|
|
46
|
-
Security.prototype.
|
|
46
|
+
Security.prototype.getAssetClass = function () {
|
|
47
47
|
return this.proto.getAssetClass();
|
|
48
48
|
};
|
|
49
|
-
Security.prototype.
|
|
49
|
+
Security.prototype.getProductClass = function () {
|
|
50
50
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
51
51
|
};
|
|
52
|
-
Security.prototype.
|
|
52
|
+
Security.prototype.getProductType = function () {
|
|
53
53
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
54
54
|
};
|
|
55
|
-
Security.prototype.
|
|
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.
|
|
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.
|
|
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
|
-
return this.
|
|
72
|
+
return this.getID().equals(other.getID());
|
|
70
73
|
}
|
|
71
74
|
else {
|
|
72
75
|
return false;
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["security.ts"],"names":[],"mappings":";;AAAA,yEAA0E;AAG1E,8CAAkD;AAClD,sCAAqC;AAErC;I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AAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SAC3C;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.
|
|
15
|
+
return `ID[${this.getID().toString()}], ${this.getSecurityID()}[${this.getIssuerName()}]`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
getFields(): FieldProto[] {
|
|
19
19
|
return [FieldProto.ID, FieldProto.SECURITY_ID, FieldProto.AS_OF, FieldProto.ASSET_CLASS, FieldProto.IDENTIFIER];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
getField(field: FieldProto): any {
|
|
23
23
|
switch (field) {
|
|
24
24
|
case FieldProto.ID:
|
|
25
25
|
case FieldProto.SECURITY_ID:
|
|
26
|
-
return this.
|
|
26
|
+
return this.getID();
|
|
27
27
|
case FieldProto.AS_OF:
|
|
28
|
-
return this.
|
|
28
|
+
return this.getAsOf();
|
|
29
29
|
case FieldProto.ASSET_CLASS:
|
|
30
|
-
return this.
|
|
30
|
+
return this.getAssetClass();
|
|
31
31
|
case FieldProto.PRODUCT_CLASS:
|
|
32
|
-
return this.
|
|
32
|
+
return this.getProductClass();
|
|
33
33
|
case FieldProto.PRODUCT_TYPE:
|
|
34
|
-
return this.
|
|
34
|
+
return this.getProductType();
|
|
35
35
|
case FieldProto.IDENTIFIER:
|
|
36
|
-
return this.
|
|
36
|
+
return this.getSecurityID();
|
|
37
37
|
case FieldProto.TENOR:
|
|
38
38
|
case FieldProto.ADJUSTED_TENOR:
|
|
39
39
|
throw new Error('Not implemented yet');
|
|
@@ -44,44 +44,48 @@ class Security {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
getID(): UUID {
|
|
48
48
|
return UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
getAsOf(): ZonedDateTime {
|
|
52
52
|
return new ZonedDateTime(this.proto.getAsOf());
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
getAssetClass(): string {
|
|
56
56
|
return this.proto.getAssetClass();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
getProductClass(): string {
|
|
60
60
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
getProductType(): any {
|
|
64
64
|
throw new Error('Not implemented yet. See Java implementation for reference');
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
return this.
|
|
88
|
+
return this.getID().equals(other.getID());
|
|
85
89
|
} else {
|
|
86
90
|
return false;
|
|
87
91
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
4
|
+
var transaction_type_1 = require("./transaction_type");
|
|
5
|
+
var security_1 = require("../security/security");
|
|
6
|
+
var datetime_1 = require("../utils/datetime");
|
|
7
|
+
var uuid_1 = require("../utils/uuid");
|
|
8
|
+
var date_1 = require("../utils/date");
|
|
9
|
+
var decimal_js_1 = require("decimal.js");
|
|
10
|
+
var Transaction = /** @class */ (function () {
|
|
11
|
+
function Transaction(proto) {
|
|
12
|
+
this.proto = proto;
|
|
13
|
+
}
|
|
14
|
+
Transaction.prototype.toString = function () {
|
|
15
|
+
try {
|
|
16
|
+
var validTo = this.proto.getValidFrom() !== null ? this.proto.getValidTo().toString() : "NULL";
|
|
17
|
+
return "".concat(/*this.proto.isCancelled()*/ false ? "INVALIDATED: " : "", "TXN[").concat(this.getID().toString(), "], ") +
|
|
18
|
+
"TradeDate[".concat(this.getTradeDate().toString(), "], TxnType[").concat(this.getTransactionType(), "], Price[").concat(this.getPrice(), "], Quantity[").concat(this.getQuantity(), "], ") +
|
|
19
|
+
"AsOf[".concat(this.getAsOf().toString(), "], Portfolio[").concat(this.getPortfolio().getPortfolioName(), "], Issuer[").concat(this.getSecurity().getIssuerName(), "], ") +
|
|
20
|
+
"ValidFrom[".concat(this.proto.getValidFrom().toString(), "], ValidTo[").concat(validTo, "], Strategy[").concat(this.getStrategyAllocation().toString(), "]");
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
console.error(e);
|
|
24
|
+
return "WHOOPS";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
Transaction.prototype.get_fields = function () {
|
|
28
|
+
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];
|
|
29
|
+
};
|
|
30
|
+
Transaction.prototype.get_field = function (field) {
|
|
31
|
+
switch (field) {
|
|
32
|
+
case field_pb_1.FieldProto.ID:
|
|
33
|
+
case field_pb_1.FieldProto.SECURITY_ID:
|
|
34
|
+
return this.getID();
|
|
35
|
+
case field_pb_1.FieldProto.AS_OF:
|
|
36
|
+
return this.getAsOf();
|
|
37
|
+
case field_pb_1.FieldProto.ASSET_CLASS:
|
|
38
|
+
return this.getSecurity().getAssetClass();
|
|
39
|
+
case field_pb_1.FieldProto.PRODUCT_CLASS:
|
|
40
|
+
return this.getSecurity().getProductClass();
|
|
41
|
+
case field_pb_1.FieldProto.PRODUCT_TYPE:
|
|
42
|
+
return this.getSecurity().getProductType();
|
|
43
|
+
case field_pb_1.FieldProto.IDENTIFIER:
|
|
44
|
+
return this.getSecurity().getSecurityID();
|
|
45
|
+
case field_pb_1.FieldProto.TENOR:
|
|
46
|
+
case field_pb_1.FieldProto.ADJUSTED_TENOR:
|
|
47
|
+
throw new Error('Not implemented yet');
|
|
48
|
+
case field_pb_1.FieldProto.MATURITY_DATE:
|
|
49
|
+
throw new Error('Not implemented yet');
|
|
50
|
+
default:
|
|
51
|
+
throw new Error("Field not mapped in Security wrapper: ".concat(field));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
Transaction.prototype.getID = function () {
|
|
55
|
+
return uuid_1.UUID.fromU8Array(this.proto.getUuid().getRawUuid_asU8());
|
|
56
|
+
};
|
|
57
|
+
Transaction.prototype.getAsOf = function () {
|
|
58
|
+
return new datetime_1.ZonedDateTime(this.proto.getAsOf());
|
|
59
|
+
};
|
|
60
|
+
//TODO: Create Portfolio wrapper
|
|
61
|
+
Transaction.prototype.getPortfolio = function () {
|
|
62
|
+
return this.proto.getPortfolio();
|
|
63
|
+
};
|
|
64
|
+
Transaction.prototype.getSecurity = function () {
|
|
65
|
+
return new security_1.default(this.proto.getSecurity());
|
|
66
|
+
};
|
|
67
|
+
Transaction.prototype.getStrategyAllocation = function () {
|
|
68
|
+
return this.proto.getStrategyAllocation();
|
|
69
|
+
};
|
|
70
|
+
Transaction.prototype.getPrice = function () {
|
|
71
|
+
return this.proto.getPrice();
|
|
72
|
+
};
|
|
73
|
+
Transaction.prototype.getQuantity = function () {
|
|
74
|
+
return new decimal_js_1.Decimal(this.proto.getQuantity().getArbitraryPrecisionValue());
|
|
75
|
+
};
|
|
76
|
+
Transaction.prototype.getIssuerName = function () {
|
|
77
|
+
return this.getSecurity().getIssuerName();
|
|
78
|
+
};
|
|
79
|
+
Transaction.prototype.getDirectedQuantity = function () {
|
|
80
|
+
return this.getQuantity().mul(this.getTransactionType().getDirectionMultiplier());
|
|
81
|
+
};
|
|
82
|
+
Transaction.prototype.getTradeDate = function () {
|
|
83
|
+
return new date_1.LocalDate(this.proto.getTradeDate());
|
|
84
|
+
};
|
|
85
|
+
Transaction.prototype.getSettlementDate = function () {
|
|
86
|
+
return new date_1.LocalDate(this.proto.getSettlementDate());
|
|
87
|
+
};
|
|
88
|
+
Transaction.prototype.getTransactionType = function () {
|
|
89
|
+
return new transaction_type_1.TransactionType(this.proto.getTransactionType());
|
|
90
|
+
};
|
|
91
|
+
Transaction.prototype.getTradeName = function () {
|
|
92
|
+
return this.proto.getTradeName();
|
|
93
|
+
};
|
|
94
|
+
Transaction.prototype.getPositionStatus = function () {
|
|
95
|
+
return this.proto.getPositionStatus();
|
|
96
|
+
};
|
|
97
|
+
Transaction.prototype.getChildrenTransactions = function () {
|
|
98
|
+
return this.proto.getChildtransactionsList();
|
|
99
|
+
};
|
|
100
|
+
Transaction.prototype.equals = function (other) {
|
|
101
|
+
if (other instanceof Transaction) {
|
|
102
|
+
return this.getID().equals(other.getID());
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return Transaction;
|
|
109
|
+
}());
|
|
110
|
+
exports.default = Transaction;
|
|
111
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1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ACrC,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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
4
|
+
var uuid_1 = require("../utils/uuid");
|
|
5
|
+
var assert = require("assert");
|
|
6
|
+
var transaction_1 = require("./transaction");
|
|
7
|
+
var transaction_pb_1 = require("../../../fintekkers/models/transaction/transaction_pb");
|
|
8
|
+
var transaction_type_pb_1 = require("../../../fintekkers/models/transaction/transaction_type_pb");
|
|
9
|
+
var decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
10
|
+
test('test the transaction wrapper', function () {
|
|
11
|
+
testSerialization();
|
|
12
|
+
});
|
|
13
|
+
function testSerialization() {
|
|
14
|
+
var transaction = dummyTransaction();
|
|
15
|
+
assert(transaction.getTransactionType().toString() === 'BUY');
|
|
16
|
+
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
17
|
+
}
|
|
18
|
+
function dummyTransaction() {
|
|
19
|
+
return new transaction_1.default(new transaction_pb_1.TransactionProto()
|
|
20
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(uuid_1.UUID.random().toUUIDProto())
|
|
21
|
+
.setTradeDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
22
|
+
.setTransactionType(transaction_type_pb_1.TransactionTypeProto.BUY)
|
|
23
|
+
.setQuantity(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
24
|
+
.setSettlementDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1)));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=transaction.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;AAAA,+EAA+E;AAG/E,sCAAqC;AAErC,+BAAkC;AAClC,6CAAwC;AACxC,wFAAyF;AACzF,kGAAkG;AAIlG,qFAAqF;AAGrF,IAAI,CAAC,8BAA8B,EAAE;IACjC,iBAAiB,EAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,SAAS,iBAAiB;IACtB,IAAM,WAAW,GAAG,gBAAgB,EAAE,CAAC;IAEvC,MAAM,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,CAAC;IAE9D,MAAM,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB;IAErB,OAAO,IAAI,qBAAW,CAAC,IAAI,iCAAgB,EAAE;SAC5C,cAAc,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;SACtF,YAAY,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACtE,kBAAkB,CAAC,0CAAoB,CAAC,GAAG,CAAC;SAC5C,WAAW,CAAC,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;SAC1E,iBAAiB,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
2
|
+
import { UUIDProto } from '../../../fintekkers/models/util/uuid_pb';
|
|
3
|
+
import { ProtoSerializationUtil } from '../utils/serialization';
|
|
4
|
+
import { UUID } from '../utils/uuid';
|
|
5
|
+
|
|
6
|
+
import assert = require('assert');
|
|
7
|
+
import Transaction from './transaction';
|
|
8
|
+
import { TransactionProto } from '../../../fintekkers/models/transaction/transaction_pb';
|
|
9
|
+
import { TransactionTypeProto } from '../../../fintekkers/models/transaction/transaction_type_pb';
|
|
10
|
+
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
11
|
+
|
|
12
|
+
import { Timestamp } from '@grpc/grpc-js/build/src/generated/google/protobuf/Timestamp';
|
|
13
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
14
|
+
import { PriceProto } from '../../../fintekkers/models/price/price_pb';
|
|
15
|
+
|
|
16
|
+
test('test the transaction wrapper', () => {
|
|
17
|
+
testSerialization();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function testSerialization(): void {
|
|
21
|
+
const transaction = dummyTransaction();
|
|
22
|
+
|
|
23
|
+
assert(transaction.getTransactionType().toString() === 'BUY');
|
|
24
|
+
|
|
25
|
+
assert(transaction.getDirectedQuantity().toNumber() > 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function dummyTransaction() {
|
|
29
|
+
|
|
30
|
+
return new Transaction(new TransactionProto()
|
|
31
|
+
.setObjectClass('Transaction').setVersion('0.0.1').setUuid(UUID.random().toUUIDProto())
|
|
32
|
+
.setTradeDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1))
|
|
33
|
+
.setTransactionType(TransactionTypeProto.BUY)
|
|
34
|
+
.setQuantity(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'))
|
|
35
|
+
.setSettlementDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1)));
|
|
36
|
+
}
|
|
37
|
+
|