@fintekkers/ledger-models 0.1.61 → 0.1.63
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/.env +3 -0
- package/node/fintekkers/models/position/field_pb.d.ts +1 -0
- package/node/fintekkers/models/position/field_pb.js +1 -0
- package/node/fintekkers/models/security/bond/auction_type_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/bond/auction_type_pb.d.ts +12 -0
- package/node/fintekkers/models/security/bond/auction_type_pb.js +33 -0
- package/node/fintekkers/models/security/bond/issuance_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/bond/issuance_pb.d.ts +85 -0
- package/node/fintekkers/models/security/bond/issuance_pb.js +652 -0
- package/node/fintekkers/models/security/security_pb.d.ts +6 -0
- package/node/fintekkers/models/security/security_pb.js +64 -2
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/portfolio/portfolio.js +41 -0
- package/node/wrappers/models/portfolio/portfolio.js.map +1 -0
- package/node/wrappers/models/portfolio/portfolio.ts +49 -0
- package/node/wrappers/models/position/position.js +14 -9
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test.js +43 -0
- package/node/wrappers/models/position/position.test.js.map +1 -0
- package/node/wrappers/models/position/position.test.ts +70 -0
- package/node/wrappers/models/position/position.ts +17 -10
- package/node/wrappers/models/position/positionfilter.js +35 -0
- package/node/wrappers/models/position/positionfilter.js.map +1 -0
- package/node/wrappers/models/position/positionfilter.ts +38 -0
- package/node/wrappers/models/security/security.test.js +33 -0
- package/node/wrappers/models/security/security.test.js.map +1 -0
- package/node/wrappers/models/security/security.test.ts +41 -0
- package/node/wrappers/models/transaction/transaction.js +6 -5
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.test.ts +1 -6
- package/node/wrappers/models/transaction/transaction.ts +31 -31
- package/node/wrappers/models/transaction/transaction_type.js +0 -1
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -1
- package/node/wrappers/models/transaction/transaction_type.ts +1 -1
- package/node/wrappers/models/utils/datetime.js +9 -0
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.ts +16 -4
- package/node/wrappers/models/utils/requestcontext.js +55 -0
- package/node/wrappers/models/utils/requestcontext.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext.ts +44 -0
- package/node/wrappers/models/utils/requestcontext_d.js +1 -0
- package/node/wrappers/models/utils/requestcontext_d.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext_d.ts +7 -0
- package/node/wrappers/models/utils/serialization.js +14 -4
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.js +8 -9
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +8 -10
- package/node/wrappers/models/utils/serialization.ts +46 -38
- package/node/wrappers/models/utils/serialization.util.js +108 -0
- package/node/wrappers/models/utils/serialization.util.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.js +36 -0
- package/node/wrappers/models/utils/serialization.util.test.js.map +1 -0
- package/node/wrappers/models/utils/serialization.util.test.ts +47 -0
- package/node/wrappers/models/utils/serialization.util.ts +121 -0
- package/node/wrappers/services/portfolio-service/PortfolioService.js +8 -16
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +14 -24
- package/node/wrappers/services/portfolio-service/portfolio.test.js +30 -34
- package/node/wrappers/services/portfolio-service/portfolio.test.js.map +1 -1
- package/node/wrappers/services/portfolio-service/portfolio.test.ts +9 -13
- package/node/wrappers/services/position-service/PositionService.js +4 -3
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +4 -19
- package/node/wrappers/services/position-service/position.test.js +24 -9
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/position-service/position.test.ts +57 -51
- package/node/wrappers/services/security-service/SecurityService.js +16 -15
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.ts +15 -18
- package/node/wrappers/services/security-service/security.maturityLadder.test.js +59 -0
- package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -0
- package/node/wrappers/services/security-service/security.maturityLadder.test.ts +39 -0
- package/node/wrappers/services/security-service/security.test.js +19 -7
- package/node/wrappers/services/security-service/security.test.js.map +1 -1
- package/node/wrappers/services/security-service/security.test.ts +11 -7
- package/node/wrappers/services/transaction-service/TransactionService.js +34 -47
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +16 -23
- package/node/wrappers/services/transaction-service/transaction.test.js +45 -12
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/transaction.test.ts +48 -21
- package/package.json +2 -1
- package/web/fintekkers/models/position/field_pb.d.ts +1 -0
- package/web/fintekkers/models/position/field_pb.js +1 -0
- package/web/fintekkers/models/security/bond/auction_type_pb.d.ts +8 -0
- package/web/fintekkers/models/security/bond/auction_type_pb.js +27 -0
- package/web/fintekkers/models/security/bond/issuance_pb.d.ts +82 -0
- package/web/fintekkers/models/security/bond/issuance_pb.js +646 -0
- package/web/fintekkers/models/security/security_pb.d.ts +7 -0
- package/web/fintekkers/models/security/security_pb.js +64 -2
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.d.ts +4 -0
- package/web/fintekkers/requests/transaction/query_transaction_request_pb.js +31 -1
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.d.ts +7 -0
- package/web/fintekkers/requests/transaction/query_transaction_response_pb.js +54 -1
- package/node/wrappers/models/utils/util.js +0 -28
- package/node/wrappers/models/utils/util.js.map +0 -1
- package/node/wrappers/models/utils/util.ts +0 -28
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
// Model Utils
|
|
40
|
+
var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
41
|
+
var SecurityService_1 = require("./SecurityService");
|
|
42
|
+
var positionfilter_1 = require("../../models/position/positionfilter");
|
|
43
|
+
test('test the api.fintekkers.org security service by creating a maturity ladder for the US government', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var securityService, positionFilter, securities;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
securityService = new SecurityService_1.SecurityService();
|
|
49
|
+
positionFilter = new positionfilter_1.PositionFilter();
|
|
50
|
+
positionFilter.addFilter(field_pb_1.FieldProto.SECURITY_ISSUER_NAME, "US Government");
|
|
51
|
+
return [4 /*yield*/, securityService.searchSecurityAsOfNow(positionFilter)];
|
|
52
|
+
case 1:
|
|
53
|
+
securities = _a.sent();
|
|
54
|
+
console.log(securities.length);
|
|
55
|
+
return [2 /*return*/];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}); }, 30000);
|
|
59
|
+
//# sourceMappingURL=security.maturityLadder.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.maturityLadder.test.js","sourceRoot":"","sources":["security.maturityLadder.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,cAAc;AACd,yEAA0E;AAM1E,qDAAoD;AACpD,uEAAsE;AAEtE,IAAI,CAAC,kGAAkG,EAAE;;;;;gBAG/F,eAAe,GAAG,IAAI,iCAAe,EAAE,CAAC;gBAExC,cAAc,GAAG,IAAI,+BAAc,EAAE,CAAC;gBAC5C,cAAc,CAAC,SAAS,CAAC,qBAAU,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC;gBACxD,qBAAM,eAAe,CAAC,qBAAqB,CAAC,cAAc,CAAC,EAAA;;gBAAxE,UAAU,GAAG,SAA2D;gBAG9E,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;;;;KASlC,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Models
|
|
2
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
4
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
5
|
+
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
6
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
7
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
8
|
+
|
|
9
|
+
// Model Utils
|
|
10
|
+
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
11
|
+
|
|
12
|
+
import * as uuid from '../../models/utils/uuid';
|
|
13
|
+
import * as dt from '../../models/utils/datetime';
|
|
14
|
+
|
|
15
|
+
import { CreateSecurityResponseProto } from '../../../fintekkers/requests/security/create_security_response_pb';
|
|
16
|
+
import { SecurityService } from './SecurityService';
|
|
17
|
+
import { PositionFilter } from '../../models/position/positionfilter';
|
|
18
|
+
|
|
19
|
+
test('test the api.fintekkers.org security service by creating a maturity ladder for the US government', async () => {
|
|
20
|
+
//TODO: Get list of all securities from the US government, with a maturity data beyond today's date
|
|
21
|
+
|
|
22
|
+
const securityService = new SecurityService();
|
|
23
|
+
|
|
24
|
+
const positionFilter = new PositionFilter();
|
|
25
|
+
positionFilter.addFilter(FieldProto.SECURITY_ISSUER_NAME, "US Government");
|
|
26
|
+
const securities = await securityService.searchSecurityAsOfNow(positionFilter);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
console.log(securities.length);
|
|
30
|
+
//TODO: Get oustanding amount of bond
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
//TODO: Map results into Map -> Date, Amount
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
//TODO: Loose end. Asset Class is a string. Maybe should be an 'extendible' enum
|
|
37
|
+
//TODO: Loose end. Security coupon rate, need to add validation logic so that coupon rate is a sensible number
|
|
38
|
+
}, 30000);
|
|
39
|
+
|
|
@@ -48,10 +48,19 @@ var field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
|
48
48
|
var uuid = require("../../models/utils/uuid");
|
|
49
49
|
var dt = require("../../models/utils/datetime");
|
|
50
50
|
var SecurityService_1 = require("./SecurityService");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
var positionfilter_1 = require("../../models/position/positionfilter");
|
|
52
|
+
test('test creating a security against the api.fintekkers.org security service', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
+
var isTrue;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, testSecurity()];
|
|
57
|
+
case 1:
|
|
58
|
+
isTrue = _a.sent();
|
|
59
|
+
expect(isTrue).toBe(true);
|
|
60
|
+
return [2 /*return*/];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}); }, 30000);
|
|
55
64
|
function testSecurity() {
|
|
56
65
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
66
|
var id_proto, now, securityService, usd_security, security, faceValue, couponRate, issueDate, maturityDate, validationSummary, createSecurityResponse, searchResults;
|
|
@@ -62,7 +71,7 @@ function testSecurity() {
|
|
|
62
71
|
now = dt.ZonedDateTime.now();
|
|
63
72
|
securityService = new SecurityService_1.SecurityService();
|
|
64
73
|
return [4 /*yield*/, securityService
|
|
65
|
-
.searchSecurity(now.
|
|
74
|
+
.searchSecurity(now.toProto(), new positionfilter_1.PositionFilter().addFilter(field_pb_1.FieldProto.ASSET_CLASS, 'Cash'))
|
|
66
75
|
.then(function (securities) {
|
|
67
76
|
return securities[0];
|
|
68
77
|
})];
|
|
@@ -73,7 +82,7 @@ function testSecurity() {
|
|
|
73
82
|
security.setVersion('0.0.1');
|
|
74
83
|
security.setUuid(id_proto);
|
|
75
84
|
security.setSettlementCurrency(usd_security.proto);
|
|
76
|
-
security.setAsOf(now.
|
|
85
|
+
security.setAsOf(now.toProto());
|
|
77
86
|
security.setAssetClass('FixedIncome');
|
|
78
87
|
security.setCouponFrequency(coupon_frequency_pb_1.CouponFrequencyProto.SEMIANNUALLY);
|
|
79
88
|
security.setCouponType(coupon_type_pb_1.CouponTypeProto.FIXED);
|
|
@@ -100,12 +109,15 @@ function testSecurity() {
|
|
|
100
109
|
return [4 /*yield*/, securityService.validateCreateSecurity(security)];
|
|
101
110
|
case 2:
|
|
102
111
|
validationSummary = _a.sent();
|
|
112
|
+
expect(validationSummary.getErrorsList().length).toBe(0);
|
|
103
113
|
return [4 /*yield*/, securityService.createSecurity(security)];
|
|
104
114
|
case 3:
|
|
105
115
|
createSecurityResponse = _a.sent();
|
|
106
|
-
|
|
116
|
+
expect(createSecurityResponse.getSecurityResponse()).toBeTruthy();
|
|
117
|
+
return [4 /*yield*/, securityService.searchSecurity(now.toProto(), new positionfilter_1.PositionFilter().addFilter(field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income'))];
|
|
107
118
|
case 4:
|
|
108
119
|
searchResults = _a.sent();
|
|
120
|
+
expect(searchResults.length).toBeGreaterThan(0);
|
|
109
121
|
return [2 /*return*/, true];
|
|
110
122
|
}
|
|
111
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.test.js","sourceRoot":"","sources":["security.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,+EAAgF;AAChF,+FAA+F;AAC/F,qFAAqF;AACrF,qFAAqF;AACrF,yFAAyF;AACzF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAGlD,qDAAoD;
|
|
1
|
+
{"version":3,"file":"security.test.js","sourceRoot":"","sources":["security.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,+EAAgF;AAChF,+FAA+F;AAC/F,qFAAqF;AACrF,qFAAqF;AACrF,yFAAyF;AACzF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAGlD,qDAAoD;AACpD,uEAAsE;AAEtE,IAAI,CAAC,0EAA0E,EAAE;;;;oBAChE,qBAAM,YAAY,EAAE,EAAA;;gBAA7B,MAAM,GAAG,SAAoB;gBACnC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;KAC3B,EAAE,KAAK,CAAC,CAAC;AAEV,SAAe,YAAY;;;;;;oBACnB,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;oBAC5C,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC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AAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;oBAEhD,sBAAO,IAAI,EAAC;;;;CACb"}
|
|
@@ -14,10 +14,11 @@ import * as dt from '../../models/utils/datetime';
|
|
|
14
14
|
|
|
15
15
|
import { CreateSecurityResponseProto } from '../../../fintekkers/requests/security/create_security_response_pb';
|
|
16
16
|
import { SecurityService } from './SecurityService';
|
|
17
|
+
import { PositionFilter } from '../../models/position/positionfilter';
|
|
17
18
|
|
|
18
|
-
test('test creating a security against the api.fintekkers.org
|
|
19
|
-
const isTrue = testSecurity();
|
|
20
|
-
expect(isTrue).
|
|
19
|
+
test('test creating a security against the api.fintekkers.org security service', async () => {
|
|
20
|
+
const isTrue = await testSecurity();
|
|
21
|
+
expect(isTrue).toBe(true);
|
|
21
22
|
}, 30000);
|
|
22
23
|
|
|
23
24
|
async function testSecurity(): Promise<boolean> {
|
|
@@ -27,7 +28,7 @@ async function testSecurity(): Promise<boolean> {
|
|
|
27
28
|
const securityService = new SecurityService();
|
|
28
29
|
|
|
29
30
|
let usd_security = await securityService
|
|
30
|
-
.searchSecurity(now.
|
|
31
|
+
.searchSecurity(now.toProto(), new PositionFilter().addFilter(FieldProto.ASSET_CLASS, 'Cash'))
|
|
31
32
|
.then((securities) => {
|
|
32
33
|
return securities[0];
|
|
33
34
|
});
|
|
@@ -37,7 +38,7 @@ async function testSecurity(): Promise<boolean> {
|
|
|
37
38
|
security.setVersion('0.0.1');
|
|
38
39
|
security.setUuid(id_proto);
|
|
39
40
|
security.setSettlementCurrency(usd_security.proto);
|
|
40
|
-
security.setAsOf(now.
|
|
41
|
+
security.setAsOf(now.toProto());
|
|
41
42
|
security.setAssetClass('FixedIncome');
|
|
42
43
|
security.setCouponFrequency(CouponFrequencyProto.SEMIANNUALLY);
|
|
43
44
|
security.setCouponType(CouponTypeProto.FIXED);
|
|
@@ -68,10 +69,13 @@ async function testSecurity(): Promise<boolean> {
|
|
|
68
69
|
security.setDescription('Dummy US Treasury 10Y Bond');
|
|
69
70
|
|
|
70
71
|
var validationSummary = await securityService.validateCreateSecurity(security);
|
|
72
|
+
expect(validationSummary.getErrorsList().length).toBe(0);
|
|
71
73
|
|
|
72
|
-
var createSecurityResponse:CreateSecurityResponseProto = await securityService.createSecurity(security);
|
|
74
|
+
var createSecurityResponse: CreateSecurityResponseProto = await securityService.createSecurity(security);
|
|
75
|
+
expect(createSecurityResponse.getSecurityResponse()).toBeTruthy();
|
|
73
76
|
|
|
74
|
-
var searchResults = await securityService.searchSecurity(now.
|
|
77
|
+
var searchResults = await securityService.searchSecurity(now.toProto(), new PositionFilter().addFilter(FieldProto.ASSET_CLASS, 'Fixed Income'));
|
|
78
|
+
expect(searchResults.length).toBeGreaterThan(0);
|
|
75
79
|
|
|
76
80
|
return true;
|
|
77
81
|
}
|
|
@@ -37,21 +37,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.TransactionService = void 0;
|
|
40
|
-
var grpc = require("@grpc/grpc-js");
|
|
41
40
|
var util_1 = require("util");
|
|
42
41
|
// Models
|
|
43
42
|
var transaction_1 = require("../../models/transaction/transaction");
|
|
44
|
-
var util_2 = require("../../models/utils/util");
|
|
45
43
|
// Model Utils
|
|
46
|
-
var position_filter_pb_1 = require("../../../fintekkers/models/position/position_filter_pb");
|
|
47
44
|
// Requests & Services
|
|
48
45
|
var transaction_service_grpc_pb_1 = require("../../../fintekkers/services/transaction-service/transaction_service_grpc_pb");
|
|
49
46
|
var create_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/create_transaction_request_pb");
|
|
50
47
|
var query_transaction_request_pb_1 = require("../../../fintekkers/requests/transaction/query_transaction_request_pb");
|
|
48
|
+
var requestcontext_1 = require("../../models/utils/requestcontext");
|
|
51
49
|
var TransactionService = /** @class */ (function () {
|
|
52
50
|
function TransactionService() {
|
|
53
|
-
this.client = new transaction_service_grpc_pb_1.TransactionClient(
|
|
54
|
-
// this.client = new TransactionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
51
|
+
this.client = new transaction_service_grpc_pb_1.TransactionClient(requestcontext_1.default.apiURL, requestcontext_1.default.apiCredentials);
|
|
55
52
|
}
|
|
56
53
|
TransactionService.prototype.validateCreateTransaction = function (transaction) {
|
|
57
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -91,51 +88,41 @@ var TransactionService = /** @class */ (function () {
|
|
|
91
88
|
});
|
|
92
89
|
});
|
|
93
90
|
};
|
|
94
|
-
TransactionService.prototype.searchTransaction = function (asOf,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
TransactionService.prototype.searchTransaction = function (asOf, positionFilter, maxResults) {
|
|
92
|
+
if (maxResults === void 0) { maxResults = 100; }
|
|
93
|
+
var searchRequest = new query_transaction_request_pb_1.QueryTransactionRequestProto();
|
|
94
|
+
searchRequest.setObjectClass('SecurityRequest');
|
|
95
|
+
searchRequest.setVersion('0.0.1');
|
|
96
|
+
searchRequest.setAsOf(asOf);
|
|
97
|
+
searchRequest.setSearchTransactionInput(positionFilter.toProto());
|
|
98
|
+
searchRequest.setLimit(maxResults);
|
|
99
|
+
var tmpClient = this.client;
|
|
100
|
+
function processStreamSynchronously() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var stream2, results;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
stream2 = tmpClient.search(searchRequest);
|
|
105
|
+
results = [];
|
|
106
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
107
|
+
stream2.on('data', function (response) {
|
|
108
|
+
response.getTransactionResponseList().forEach(function (transaction) {
|
|
109
|
+
var txn = new transaction_1.default(transaction);
|
|
110
|
+
results.push(txn);
|
|
113
111
|
});
|
|
114
|
-
})
|
|
115
|
-
|
|
112
|
+
});
|
|
113
|
+
stream2.on('end', function () {
|
|
114
|
+
console.log("Stream ended with ", results.length);
|
|
115
|
+
resolve(results);
|
|
116
|
+
});
|
|
117
|
+
stream2.on('error', function (err) {
|
|
118
|
+
console.error('Error in the stream:', err);
|
|
119
|
+
reject(err);
|
|
120
|
+
});
|
|
121
|
+
})];
|
|
116
122
|
});
|
|
117
|
-
}
|
|
118
|
-
var searchRequest, positionFilter, fieldMapEntry, tmpClient, listTransactions;
|
|
119
|
-
return __generator(this, function (_a) {
|
|
120
|
-
switch (_a.label) {
|
|
121
|
-
case 0:
|
|
122
|
-
searchRequest = new query_transaction_request_pb_1.QueryTransactionRequestProto();
|
|
123
|
-
searchRequest.setObjectClass('SecurityRequest');
|
|
124
|
-
searchRequest.setVersion('0.0.1');
|
|
125
|
-
searchRequest.setAsOf(asOf);
|
|
126
|
-
positionFilter = new position_filter_pb_1.PositionFilterProto();
|
|
127
|
-
positionFilter.setObjectClass('PositionFilter');
|
|
128
|
-
positionFilter.setVersion('0.0.1');
|
|
129
|
-
fieldMapEntry = (0, util_2.createFieldMapEntry)(fieldProto, fieldValue);
|
|
130
|
-
positionFilter.setFiltersList([fieldMapEntry]);
|
|
131
|
-
searchRequest.setSearchTransactionInput(positionFilter);
|
|
132
|
-
tmpClient = this.client;
|
|
133
|
-
listTransactions = [];
|
|
134
|
-
return [4 /*yield*/, processStreamSynchronously()];
|
|
135
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
136
|
-
}
|
|
137
123
|
});
|
|
138
|
-
}
|
|
124
|
+
}
|
|
125
|
+
return processStreamSynchronously();
|
|
139
126
|
};
|
|
140
127
|
return TransactionService;
|
|
141
128
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionService.js","sourceRoot":"","sources":["TransactionService.ts"],"names":[],"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AC;gCAClD,OAAO,CAAC,OAAO,CAAC,CAAC;4BACnB,CAAC,CAAC,CAAC;4BAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,GAAG;gCACtB,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC;gCAC3C,MAAM,CAAC,GAAG,CAAC,CAAC;4BACd,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,EAAC;;;SACJ;QAED,OAAO,0BAA0B,EAAE,CAAC;IACtC,CAAC;IACH,yBAAC;AAAD,CAAC,AAnED,IAmEC;AAEQ,gDAAkB"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import * as grpc from '@grpc/grpc-js';
|
|
2
1
|
import { promisify } from 'util';
|
|
3
2
|
|
|
4
3
|
// Models
|
|
5
4
|
import Transaction from '../../models/transaction/transaction';
|
|
6
|
-
import {
|
|
5
|
+
import { PositionFilter } from '../../models/position/positionfilter';
|
|
7
6
|
import { LocalTimestampProto } from '../../../fintekkers/models/util/local_timestamp_pb';
|
|
8
7
|
import { SummaryProto } from '../../../fintekkers/requests/util/errors/summary_pb';
|
|
9
8
|
|
|
10
9
|
// Model Utils
|
|
11
|
-
import { PositionFilterProto } from '../../../fintekkers/models/position/position_filter_pb';
|
|
12
|
-
import { FieldProto } from '../../../fintekkers/models/position/field_pb';
|
|
13
10
|
|
|
14
11
|
// Requests & Services
|
|
15
12
|
import { TransactionClient } from '../../../fintekkers/services/transaction-service/transaction_service_grpc_pb';
|
|
@@ -17,14 +14,14 @@ import { CreateTransactionRequestProto } from '../../../fintekkers/requests/tran
|
|
|
17
14
|
import { CreateTransactionResponseProto } from '../../../fintekkers/requests/transaction/create_transaction_response_pb';
|
|
18
15
|
import { QueryTransactionRequestProto } from '../../../fintekkers/requests/transaction/query_transaction_request_pb';
|
|
19
16
|
import { QueryTransactionResponseProto } from '../../../fintekkers/requests/transaction/query_transaction_response_pb';
|
|
17
|
+
import EnvConfig from '../../models/utils/requestcontext';
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
class TransactionService {
|
|
23
21
|
private client: TransactionClient;
|
|
24
22
|
|
|
25
23
|
constructor() {
|
|
26
|
-
this.client = new TransactionClient(
|
|
27
|
-
// this.client = new TransactionClient('localhost:8082', grpc.credentials.createInsecure());
|
|
24
|
+
this.client = new TransactionClient(EnvConfig.apiURL, EnvConfig.apiCredentials);
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
async validateCreateTransaction(transaction: Transaction): Promise<SummaryProto> {
|
|
@@ -49,47 +46,43 @@ class TransactionService {
|
|
|
49
46
|
return response;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
49
|
+
searchTransaction(asOf: LocalTimestampProto, positionFilter: PositionFilter, maxResults: number = 100):
|
|
50
|
+
Promise<Transaction[]> {
|
|
53
51
|
const searchRequest = new QueryTransactionRequestProto();
|
|
54
52
|
searchRequest.setObjectClass('SecurityRequest');
|
|
55
53
|
searchRequest.setVersion('0.0.1');
|
|
56
54
|
searchRequest.setAsOf(asOf);
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
positionFilter.setVersion('0.0.1');
|
|
61
|
-
|
|
62
|
-
const fieldMapEntry = createFieldMapEntry(fieldProto, fieldValue);
|
|
63
|
-
positionFilter.setFiltersList([fieldMapEntry]);
|
|
64
|
-
|
|
65
|
-
searchRequest.setSearchTransactionInput(positionFilter);
|
|
56
|
+
searchRequest.setSearchTransactionInput(positionFilter.toProto());
|
|
57
|
+
searchRequest.setLimit(maxResults);
|
|
66
58
|
|
|
67
59
|
const tmpClient = this.client;
|
|
68
60
|
|
|
69
|
-
const listTransactions: Transaction[] = [];
|
|
70
|
-
|
|
71
61
|
async function processStreamSynchronously(): Promise<Transaction[]> {
|
|
72
62
|
const stream2 = tmpClient.search(searchRequest);
|
|
63
|
+
var results: Transaction[] = [];
|
|
73
64
|
|
|
74
65
|
return new Promise<Transaction[]>((resolve, reject) => {
|
|
75
|
-
stream2.on('data', (response:QueryTransactionResponseProto) => {
|
|
66
|
+
stream2.on('data', (response: QueryTransactionResponseProto) => {
|
|
76
67
|
response.getTransactionResponseList().forEach((transaction) => {
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
const txn: Transaction = new Transaction(transaction);
|
|
69
|
+
results.push(txn);
|
|
70
|
+
})
|
|
79
71
|
});
|
|
80
72
|
|
|
81
73
|
stream2.on('end', () => {
|
|
82
|
-
|
|
74
|
+
console.log("Stream ended with ", results.length);
|
|
75
|
+
resolve(results);
|
|
83
76
|
});
|
|
84
77
|
|
|
85
78
|
stream2.on('error', (err) => {
|
|
86
79
|
console.error('Error in the stream:', err);
|
|
87
|
-
reject(err);
|
|
80
|
+
reject(err);
|
|
88
81
|
});
|
|
89
82
|
});
|
|
90
83
|
}
|
|
91
84
|
|
|
92
|
-
return
|
|
85
|
+
return processStreamSynchronously();
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
88
|
|
|
@@ -50,13 +50,23 @@ var price_pb_1 = require("../../../fintekkers/models/price/price_pb");
|
|
|
50
50
|
var PortfolioService_1 = require("../portfolio-service/PortfolioService");
|
|
51
51
|
var TransactionService_1 = require("./TransactionService");
|
|
52
52
|
var transaction_1 = require("../../models/transaction/transaction");
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
var assert = require("assert");
|
|
54
|
+
var positionfilter_1 = require("../../models/position/positionfilter");
|
|
55
|
+
test('test creating a transaction against the portfolio service', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var isTrue;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, testTransaction()];
|
|
60
|
+
case 1:
|
|
61
|
+
isTrue = _a.sent();
|
|
62
|
+
expect(isTrue).toBe(true);
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); }, 30000);
|
|
57
67
|
function testTransaction() {
|
|
58
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var id_proto, now, today, securityService, portfolioService, transactionService, fixedIncomeSecurities, security, portfolios, portfolio, transaction, createTransactionResponse,
|
|
69
|
+
var id_proto, now, today, securityService, portfolioService, transactionService, positionFilter, fixedIncomeSecurities, security, portfolios, portfolio, transaction, createTransactionResponse, transactionResponse, transactionID, transactions;
|
|
60
70
|
return __generator(this, function (_a) {
|
|
61
71
|
switch (_a.label) {
|
|
62
72
|
case 0:
|
|
@@ -66,17 +76,23 @@ function testTransaction() {
|
|
|
66
76
|
securityService = new SecurityService_1.SecurityService();
|
|
67
77
|
portfolioService = new PortfolioService_1.PortfolioService();
|
|
68
78
|
transactionService = new TransactionService_1.TransactionService();
|
|
79
|
+
positionFilter = new positionfilter_1.PositionFilter();
|
|
80
|
+
positionFilter.addFilter(field_pb_1.FieldProto.ASSET_CLASS, 'Fixed Income');
|
|
81
|
+
console.time("searchSecurity");
|
|
69
82
|
return [4 /*yield*/, securityService
|
|
70
|
-
.searchSecurity(now.
|
|
83
|
+
.searchSecurity(now.toProto(), positionFilter)
|
|
71
84
|
.then(function (fixedIncomeSecurities) {
|
|
72
85
|
return fixedIncomeSecurities;
|
|
73
86
|
})];
|
|
74
87
|
case 1:
|
|
75
88
|
fixedIncomeSecurities = _a.sent();
|
|
89
|
+
console.timeEnd("searchSecurity");
|
|
76
90
|
security = fixedIncomeSecurities[0];
|
|
77
|
-
|
|
91
|
+
console.time("searchPortfolio");
|
|
92
|
+
return [4 /*yield*/, portfolioService.searchPortfolio(now.toProto(), new positionfilter_1.PositionFilter().addFilter(field_pb_1.FieldProto.PORTFOLIO_NAME, 'TEST PORTFOLIO'))];
|
|
78
93
|
case 2:
|
|
79
94
|
portfolios = _a.sent();
|
|
95
|
+
console.timeEnd("searchPortfolio");
|
|
80
96
|
if (portfolios === undefined) {
|
|
81
97
|
throw new Error('No portfolios found');
|
|
82
98
|
}
|
|
@@ -88,26 +104,43 @@ function testTransaction() {
|
|
|
88
104
|
transaction.setObjectClass('Transaction');
|
|
89
105
|
transaction.setVersion('0.0.1');
|
|
90
106
|
transaction.setUuid(uuid.UUID.random().toUUIDProto());
|
|
91
|
-
transaction.setAsOf(now.
|
|
107
|
+
transaction.setAsOf(now.toProto());
|
|
92
108
|
transaction.setTradeDate(today);
|
|
93
109
|
transaction.setSettlementDate(today); //Same day settlement
|
|
94
110
|
transaction.setTransactionType(transaction_type_pb_1.TransactionTypeProto.BUY);
|
|
95
111
|
transaction.setPrice(new price_pb_1.PriceProto()
|
|
96
112
|
.setObjectClass('Price')
|
|
97
|
-
.setAsOf(now.
|
|
113
|
+
.setAsOf(now.toProto())
|
|
98
114
|
.setVersion('0.0.1')
|
|
99
115
|
.setSecurity(security.proto)
|
|
100
116
|
.setUuid(uuid.UUID.random().toUUIDProto())
|
|
101
117
|
.setPrice(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('100.00')));
|
|
102
118
|
transaction.setQuantity(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('10000.00'));
|
|
103
|
-
transaction.setPortfolio(portfolio);
|
|
119
|
+
transaction.setPortfolio(portfolio.proto);
|
|
104
120
|
transaction.setSecurity(security.proto);
|
|
121
|
+
// var validationSummary = await transactionService.validateCreateTransaction(new Transaction(transaction));
|
|
122
|
+
// assert(validationSummary.getErrorsList().length == 0, "Validation errors found");
|
|
123
|
+
console.time("createTransaction");
|
|
105
124
|
return [4 /*yield*/, transactionService.createTransaction(new transaction_1.default(transaction))];
|
|
106
125
|
case 3:
|
|
107
126
|
createTransactionResponse = _a.sent();
|
|
108
|
-
|
|
127
|
+
transactionResponse = createTransactionResponse.getTransactionResponse();
|
|
128
|
+
assert(transactionResponse, "No transaction response found");
|
|
129
|
+
console.timeEnd("createTransaction");
|
|
130
|
+
console.log("Searching transaction");
|
|
131
|
+
console.time("searchTransaction");
|
|
132
|
+
transactionID = uuid.UUID.fromU8Array(transactionResponse.getUuid().getRawUuid_asU8());
|
|
133
|
+
positionFilter.addFilter(field_pb_1.FieldProto.ID, transactionID);
|
|
134
|
+
return [4 /*yield*/, transactionService.searchTransaction(now.toProto(), positionFilter)];
|
|
109
135
|
case 4:
|
|
110
|
-
|
|
136
|
+
transactions = _a.sent();
|
|
137
|
+
console.timeEnd("searchTransaction");
|
|
138
|
+
if (transactions === undefined) {
|
|
139
|
+
console.log('No transactions found');
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log(transactions.length);
|
|
143
|
+
}
|
|
111
144
|
return [2 /*return*/, true];
|
|
112
145
|
}
|
|
113
146
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,qFAAqF;AACrF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAElD,uEAAsE;AACtE,kGAAkG;AAClG,wFAAyF;AACzF,sEAAuE;AACvE,0EAAyE;AACzE,2DAA0D;AAC1D,oEAA+D;AAG/D,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"transaction.test.js","sourceRoot":"","sources":["transaction.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,qFAAqF;AACrF,+EAA+E;AAE/E,cAAc;AACd,yEAA0E;AAE1E,8CAAgD;AAChD,gDAAkD;AAElD,uEAAsE;AACtE,kGAAkG;AAClG,wFAAyF;AACzF,sEAAuE;AACvE,0EAAyE;AACzE,2DAA0D;AAC1D,oEAA+D;AAG/D,+BAAkC;AAClC,uEAAsE;AAEtE,IAAI,CAAC,2DAA2D,EAAE;;;;oBACjD,qBAAM,eAAe,EAAE,EAAA;;gBAAhC,MAAM,GAAG,SAAuB;gBACtC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC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