@fintekkers/ledger-models 0.4.0 → 0.4.2
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/hierarchy.json +2 -2
- package/node/fintekkers/models/security/bond/agency_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/bond/agency_pb.d.ts +14 -0
- package/node/fintekkers/models/security/bond/agency_pb.js +35 -0
- package/node/fintekkers/models/security/product_type_pb.d.ts +1 -0
- package/node/fintekkers/models/security/product_type_pb.js +1 -0
- package/node/fintekkers/models/security/security_pb.d.ts +69 -0
- package/node/fintekkers/models/security/security_pb.js +572 -1
- package/node/wrappers/models/security/BondSecurity.d.ts +41 -3
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.d.ts +1 -0
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.js +75 -0
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.js.map +1 -0
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.ts +95 -0
- package/node/wrappers/models/security/BondSecurity.js +50 -2
- package/node/wrappers/models/security/BondSecurity.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.ts +65 -3
- package/node/wrappers/models/security/FloatingRateNote.d.ts +30 -0
- package/node/wrappers/models/security/FloatingRateNote.js +80 -0
- package/node/wrappers/models/security/FloatingRateNote.js.map +1 -0
- package/node/wrappers/models/security/FloatingRateNote.ts +67 -0
- package/node/wrappers/models/security/IndexSecurity.d.ts +16 -0
- package/node/wrappers/models/security/IndexSecurity.js +26 -0
- package/node/wrappers/models/security/IndexSecurity.js.map +1 -0
- package/node/wrappers/models/security/IndexSecurity.test.d.ts +1 -0
- package/node/wrappers/models/security/IndexSecurity.test.js +60 -0
- package/node/wrappers/models/security/IndexSecurity.test.js.map +1 -0
- package/node/wrappers/models/security/IndexSecurity.test.ts +60 -0
- package/node/wrappers/models/security/IndexSecurity.ts +24 -0
- package/node/wrappers/models/security/Issuance.d.ts +35 -0
- package/node/wrappers/models/security/Issuance.js +64 -0
- package/node/wrappers/models/security/Issuance.js.map +1 -0
- package/node/wrappers/models/security/Issuance.test.d.ts +1 -0
- package/node/wrappers/models/security/Issuance.test.js +55 -0
- package/node/wrappers/models/security/Issuance.test.js.map +1 -0
- package/node/wrappers/models/security/Issuance.test.ts +52 -0
- package/node/wrappers/models/security/Issuance.ts +74 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.d.ts +48 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.d.ts +1 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js +93 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js.map +1 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.ts +107 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.js +131 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.js.map +1 -0
- package/node/wrappers/models/security/MortgageBackedSecurity.ts +125 -0
- package/node/wrappers/models/security/TIPSBond.d.ts +30 -0
- package/node/wrappers/models/security/TIPSBond.js +83 -0
- package/node/wrappers/models/security/TIPSBond.js.map +1 -0
- package/node/wrappers/models/security/TIPSBond.ts +70 -0
- package/node/wrappers/models/security/security.d.ts +20 -3
- package/node/wrappers/models/security/security.identifiers.test.d.ts +1 -0
- package/node/wrappers/models/security/security.identifiers.test.js +67 -0
- package/node/wrappers/models/security/security.identifiers.test.js.map +1 -0
- package/node/wrappers/models/security/security.identifiers.test.ts +67 -0
- package/node/wrappers/models/security/security.js +72 -22
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +75 -22
- package/node/wrappers/models/transaction/transaction.js +4 -2
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.ts +4 -2
- package/node/wrappers/services/security-service/security.maturityLadder.test.js +3 -2
- package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -1
- package/node/wrappers/services/security-service/security.maturityLadder.test.ts +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const security_1 = __importDefault(require("./security"));
|
|
7
|
+
const BondSecurity_1 = __importDefault(require("./BondSecurity"));
|
|
8
|
+
const TIPSBond_1 = __importDefault(require("./TIPSBond"));
|
|
9
|
+
const FloatingRateNote_1 = __importDefault(require("./FloatingRateNote"));
|
|
10
|
+
const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
|
|
11
|
+
const coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
|
|
12
|
+
const coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
13
|
+
const index_type_pb_1 = require("../../../fintekkers/models/security/index/index_type_pb");
|
|
14
|
+
const date_1 = require("../utils/date");
|
|
15
|
+
const local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
16
|
+
const decimal_js_1 = require("decimal.js");
|
|
17
|
+
function makeDate(y, m, d) {
|
|
18
|
+
return new date_1.LocalDate(new local_date_pb_1.LocalDateProto().setYear(y).setMonth(m).setDay(d));
|
|
19
|
+
}
|
|
20
|
+
const baseInputs = {
|
|
21
|
+
faceValue: new decimal_js_1.Decimal('1000'),
|
|
22
|
+
couponRate: new decimal_js_1.Decimal('0.045'),
|
|
23
|
+
couponType: coupon_type_pb_1.CouponTypeProto.FIXED,
|
|
24
|
+
couponFrequency: coupon_frequency_pb_1.CouponFrequencyProto.SEMIANNUALLY,
|
|
25
|
+
issueDate: makeDate(2024, 1, 15),
|
|
26
|
+
maturityDate: makeDate(2034, 1, 15),
|
|
27
|
+
};
|
|
28
|
+
test('BondSecurity.fromPricerInputs round-trips through Security.create as a BondSecurity', () => {
|
|
29
|
+
const proto = BondSecurity_1.default.fromPricerInputs(baseInputs);
|
|
30
|
+
expect(proto.getProductType()).toBe(product_type_pb_1.ProductTypeProto.TREASURY_NOTE);
|
|
31
|
+
const sec = security_1.default.create(proto);
|
|
32
|
+
expect(sec).toBeInstanceOf(BondSecurity_1.default);
|
|
33
|
+
const bond = sec;
|
|
34
|
+
expect(bond.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
35
|
+
expect(bond.getFaceValue().getArbitraryPrecisionValue()).toBe('1000');
|
|
36
|
+
expect(bond.getCouponType().name()).toBe('FIXED');
|
|
37
|
+
expect(bond.getCouponFrequency().toString()).toBe('SEMIANNUALLY');
|
|
38
|
+
expect(bond.getIssueDate().toDate().getFullYear()).toBe(2024);
|
|
39
|
+
expect(bond.getMaturityDate().toDate().getFullYear()).toBe(2034);
|
|
40
|
+
});
|
|
41
|
+
test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const proto = TIPSBond_1.default.fromPricerInputs(Object.assign(Object.assign({}, baseInputs), { baseCpi: new decimal_js_1.Decimal('301.5'), indexDate: makeDate(2024, 1, 15), inflationIndexType: index_type_pb_1.IndexTypeProto.CPI_U }));
|
|
44
|
+
expect(proto.getProductType()).toBe(product_type_pb_1.ProductTypeProto.TIPS);
|
|
45
|
+
expect(proto.hasTipsExtension()).toBe(true);
|
|
46
|
+
const sec = security_1.default.create(proto);
|
|
47
|
+
expect(sec).toBeInstanceOf(TIPSBond_1.default);
|
|
48
|
+
const tips = sec;
|
|
49
|
+
// Bond-side checks (inherited from BondSecurity)
|
|
50
|
+
expect(tips.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
51
|
+
// TIPS-specific checks
|
|
52
|
+
expect((_a = tips.getBaseCpi()) === null || _a === void 0 ? void 0 : _a.toString()).toBe('301.5');
|
|
53
|
+
expect((_b = tips.getIndexDate()) === null || _b === void 0 ? void 0 : _b.toDate().getFullYear()).toBe(2024);
|
|
54
|
+
expect(tips.getInflationIndexType()).toBe(index_type_pb_1.IndexTypeProto.CPI_U);
|
|
55
|
+
});
|
|
56
|
+
test('FloatingRateNote.fromPricerInputs round-trips with frn_extension populated', () => {
|
|
57
|
+
var _a;
|
|
58
|
+
const proto = FloatingRateNote_1.default.fromPricerInputs(Object.assign(Object.assign({}, baseInputs), { spread: new decimal_js_1.Decimal('0.0015'), referenceRateIndex: index_type_pb_1.IndexTypeProto.SOFR, resetFrequency: coupon_frequency_pb_1.CouponFrequencyProto.QUARTERLY }));
|
|
59
|
+
expect(proto.getProductType()).toBe(product_type_pb_1.ProductTypeProto.TREASURY_FRN);
|
|
60
|
+
expect(proto.hasFrnExtension()).toBe(true);
|
|
61
|
+
const sec = security_1.default.create(proto);
|
|
62
|
+
expect(sec).toBeInstanceOf(FloatingRateNote_1.default);
|
|
63
|
+
const frn = sec;
|
|
64
|
+
expect(frn.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
65
|
+
expect((_a = frn.getSpread()) === null || _a === void 0 ? void 0 : _a.toString()).toBe('0.0015');
|
|
66
|
+
expect(frn.getReferenceRateIndex()).toBe(index_type_pb_1.IndexTypeProto.SOFR);
|
|
67
|
+
expect(frn.getResetFrequency()).toBe(coupon_frequency_pb_1.CouponFrequencyProto.QUARTERLY);
|
|
68
|
+
});
|
|
69
|
+
test('TIPS / FRN wrappers inherit isBond() narrowing', () => {
|
|
70
|
+
const tipsProto = TIPSBond_1.default.fromPricerInputs(Object.assign(Object.assign({}, baseInputs), { baseCpi: new decimal_js_1.Decimal('250'), indexDate: makeDate(2024, 1, 15), inflationIndexType: index_type_pb_1.IndexTypeProto.CPI_U }));
|
|
71
|
+
const frnProto = FloatingRateNote_1.default.fromPricerInputs(Object.assign(Object.assign({}, baseInputs), { spread: new decimal_js_1.Decimal('0.002'), referenceRateIndex: index_type_pb_1.IndexTypeProto.SOFR, resetFrequency: coupon_frequency_pb_1.CouponFrequencyProto.QUARTERLY }));
|
|
72
|
+
expect(security_1.default.create(tipsProto).isBond()).toBe(true);
|
|
73
|
+
expect(security_1.default.create(frnProto).isBond()).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=BondSecurity.fromPricerInputs.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BondSecurity.fromPricerInputs.test.js","sourceRoot":"","sources":["BondSecurity.fromPricerInputs.test.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAClC,kEAA0C;AAC1C,0DAAkC;AAClC,0EAAkD;AAClD,yFAAuF;AACvF,uFAAqF;AACrF,iGAA+F;AAC/F,2FAAyF;AACzF,wCAA0C;AAC1C,iFAA+E;AAC/E,2CAAqC;AAErC,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC/C,OAAO,IAAI,gBAAS,CAAC,IAAI,8BAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,IAAI,oBAAO,CAAC,MAAM,CAAC;IAC9B,UAAU,EAAE,IAAI,oBAAO,CAAC,OAAO,CAAC;IAChC,UAAU,EAAE,gCAAe,CAAC,KAAK;IACjC,eAAe,EAAE,0CAAoB,CAAC,YAAY;IAClD,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;IAChC,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;CACpC,CAAC;AAEF,IAAI,CAAC,qFAAqF,EAAE,GAAG,EAAE;IAC/F,MAAM,KAAK,GAAG,sBAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,kCAAgB,CAAC,aAAa,CAA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C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import Security from './security';
|
|
2
|
+
import BondSecurity from './BondSecurity';
|
|
3
|
+
import TIPSBond from './TIPSBond';
|
|
4
|
+
import FloatingRateNote from './FloatingRateNote';
|
|
5
|
+
import { ProductTypeProto } from '../../../fintekkers/models/security/product_type_pb';
|
|
6
|
+
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
7
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
8
|
+
import { IndexTypeProto } from '../../../fintekkers/models/security/index/index_type_pb';
|
|
9
|
+
import { LocalDate } from '../utils/date';
|
|
10
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
11
|
+
import { Decimal } from 'decimal.js';
|
|
12
|
+
|
|
13
|
+
function makeDate(y: number, m: number, d: number): LocalDate {
|
|
14
|
+
return new LocalDate(new LocalDateProto().setYear(y).setMonth(m).setDay(d));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const baseInputs = {
|
|
18
|
+
faceValue: new Decimal('1000'),
|
|
19
|
+
couponRate: new Decimal('0.045'),
|
|
20
|
+
couponType: CouponTypeProto.FIXED,
|
|
21
|
+
couponFrequency: CouponFrequencyProto.SEMIANNUALLY,
|
|
22
|
+
issueDate: makeDate(2024, 1, 15),
|
|
23
|
+
maturityDate: makeDate(2034, 1, 15),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
test('BondSecurity.fromPricerInputs round-trips through Security.create as a BondSecurity', () => {
|
|
27
|
+
const proto = BondSecurity.fromPricerInputs(baseInputs);
|
|
28
|
+
expect(proto.getProductType()).toBe(ProductTypeProto.TREASURY_NOTE);
|
|
29
|
+
const sec = Security.create(proto);
|
|
30
|
+
expect(sec).toBeInstanceOf(BondSecurity);
|
|
31
|
+
const bond = sec as BondSecurity;
|
|
32
|
+
expect(bond.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
33
|
+
expect(bond.getFaceValue().getArbitraryPrecisionValue()).toBe('1000');
|
|
34
|
+
expect(bond.getCouponType().name()).toBe('FIXED');
|
|
35
|
+
expect(bond.getCouponFrequency().toString()).toBe('SEMIANNUALLY');
|
|
36
|
+
expect(bond.getIssueDate().toDate().getFullYear()).toBe(2024);
|
|
37
|
+
expect(bond.getMaturityDate().toDate().getFullYear()).toBe(2034);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () => {
|
|
41
|
+
const proto = TIPSBond.fromPricerInputs({
|
|
42
|
+
...baseInputs,
|
|
43
|
+
baseCpi: new Decimal('301.5'),
|
|
44
|
+
indexDate: makeDate(2024, 1, 15),
|
|
45
|
+
inflationIndexType: IndexTypeProto.CPI_U,
|
|
46
|
+
});
|
|
47
|
+
expect(proto.getProductType()).toBe(ProductTypeProto.TIPS);
|
|
48
|
+
expect(proto.hasTipsExtension()).toBe(true);
|
|
49
|
+
|
|
50
|
+
const sec = Security.create(proto);
|
|
51
|
+
expect(sec).toBeInstanceOf(TIPSBond);
|
|
52
|
+
const tips = sec as TIPSBond;
|
|
53
|
+
// Bond-side checks (inherited from BondSecurity)
|
|
54
|
+
expect(tips.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
55
|
+
// TIPS-specific checks
|
|
56
|
+
expect(tips.getBaseCpi()?.toString()).toBe('301.5');
|
|
57
|
+
expect(tips.getIndexDate()?.toDate().getFullYear()).toBe(2024);
|
|
58
|
+
expect(tips.getInflationIndexType()).toBe(IndexTypeProto.CPI_U);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('FloatingRateNote.fromPricerInputs round-trips with frn_extension populated', () => {
|
|
62
|
+
const proto = FloatingRateNote.fromPricerInputs({
|
|
63
|
+
...baseInputs,
|
|
64
|
+
spread: new Decimal('0.0015'),
|
|
65
|
+
referenceRateIndex: IndexTypeProto.SOFR,
|
|
66
|
+
resetFrequency: CouponFrequencyProto.QUARTERLY,
|
|
67
|
+
});
|
|
68
|
+
expect(proto.getProductType()).toBe(ProductTypeProto.TREASURY_FRN);
|
|
69
|
+
expect(proto.hasFrnExtension()).toBe(true);
|
|
70
|
+
|
|
71
|
+
const sec = Security.create(proto);
|
|
72
|
+
expect(sec).toBeInstanceOf(FloatingRateNote);
|
|
73
|
+
const frn = sec as FloatingRateNote;
|
|
74
|
+
expect(frn.getCouponRate().getArbitraryPrecisionValue()).toBe('0.045');
|
|
75
|
+
expect(frn.getSpread()?.toString()).toBe('0.0015');
|
|
76
|
+
expect(frn.getReferenceRateIndex()).toBe(IndexTypeProto.SOFR);
|
|
77
|
+
expect(frn.getResetFrequency()).toBe(CouponFrequencyProto.QUARTERLY);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('TIPS / FRN wrappers inherit isBond() narrowing', () => {
|
|
81
|
+
const tipsProto = TIPSBond.fromPricerInputs({
|
|
82
|
+
...baseInputs,
|
|
83
|
+
baseCpi: new Decimal('250'),
|
|
84
|
+
indexDate: makeDate(2024, 1, 15),
|
|
85
|
+
inflationIndexType: IndexTypeProto.CPI_U,
|
|
86
|
+
});
|
|
87
|
+
const frnProto = FloatingRateNote.fromPricerInputs({
|
|
88
|
+
...baseInputs,
|
|
89
|
+
spread: new Decimal('0.002'),
|
|
90
|
+
referenceRateIndex: IndexTypeProto.SOFR,
|
|
91
|
+
resetFrequency: CouponFrequencyProto.QUARTERLY,
|
|
92
|
+
});
|
|
93
|
+
expect(Security.create(tipsProto).isBond()).toBe(true);
|
|
94
|
+
expect(Security.create(frnProto).isBond()).toBe(true);
|
|
95
|
+
});
|
|
@@ -3,8 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildBondDetails = exports.decimalToProto = exports.localDateToProto = void 0;
|
|
6
7
|
const security_1 = __importDefault(require("./security"));
|
|
8
|
+
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
7
9
|
const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
|
|
10
|
+
const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
8
11
|
const date_1 = require("../utils/date");
|
|
9
12
|
const coupon_frequency_1 = require("./coupon_frequency");
|
|
10
13
|
const coupon_type_1 = require("./coupon_type");
|
|
@@ -12,6 +15,35 @@ const term_1 = require("./term");
|
|
|
12
15
|
const tenor_type_pb_1 = require("../../../fintekkers/models/security/tenor_type_pb");
|
|
13
16
|
const decimal_js_1 = require("decimal.js");
|
|
14
17
|
const product_hierarchy_1 = require("./product_hierarchy");
|
|
18
|
+
const Issuance_1 = __importDefault(require("./Issuance"));
|
|
19
|
+
/**
|
|
20
|
+
* Build a LocalDateProto from a LocalDate wrapper. Exported so subclass
|
|
21
|
+
* builders (TIPSBond, FloatingRateNote) can re-use it without poking at
|
|
22
|
+
* LocalDate's proto privately.
|
|
23
|
+
*/
|
|
24
|
+
function localDateToProto(d) {
|
|
25
|
+
return d.toProto();
|
|
26
|
+
}
|
|
27
|
+
exports.localDateToProto = localDateToProto;
|
|
28
|
+
/** Build a DecimalValueProto from a Decimal. */
|
|
29
|
+
function decimalToProto(v) {
|
|
30
|
+
return new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(v.toString());
|
|
31
|
+
}
|
|
32
|
+
exports.decimalToProto = decimalToProto;
|
|
33
|
+
/**
|
|
34
|
+
* Build a populated BondDetailsProto from BondPricerInputs. Shared helper
|
|
35
|
+
* so the three pricer-input builders stay in sync.
|
|
36
|
+
*/
|
|
37
|
+
function buildBondDetails(args) {
|
|
38
|
+
return new security_pb_1.BondDetailsProto()
|
|
39
|
+
.setFaceValue(decimalToProto(args.faceValue))
|
|
40
|
+
.setCouponRate(decimalToProto(args.couponRate))
|
|
41
|
+
.setCouponType(args.couponType)
|
|
42
|
+
.setCouponFrequency(args.couponFrequency)
|
|
43
|
+
.setIssueDate(localDateToProto(args.issueDate))
|
|
44
|
+
.setMaturityDate(localDateToProto(args.maturityDate));
|
|
45
|
+
}
|
|
46
|
+
exports.buildBondDetails = buildBondDetails;
|
|
15
47
|
class BondSecurity extends security_1.default {
|
|
16
48
|
constructor(proto) {
|
|
17
49
|
super(proto);
|
|
@@ -99,9 +131,25 @@ class BondSecurity extends security_1.default {
|
|
|
99
131
|
const datedDate = bond ? bond.getDatedDate() : undefined;
|
|
100
132
|
return datedDate ? new date_1.LocalDate(datedDate) : undefined;
|
|
101
133
|
}
|
|
102
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Returns every auction/reopening record on this bond as typed Issuance
|
|
136
|
+
* wrappers. Empty list if bond_details is unset or has no issuances.
|
|
137
|
+
*/
|
|
138
|
+
getIssuances() {
|
|
103
139
|
const bond = this.getBondLikeDetails();
|
|
104
|
-
|
|
140
|
+
const list = bond ? bond.getIssuanceInfoList() : [];
|
|
141
|
+
return list.map(p => new Issuance_1.default(p));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Build a fresh SecurityProto for a vanilla treasury note from pricer
|
|
145
|
+
* inputs. Use TIPSBond.fromPricerInputs / FloatingRateNote.fromPricerInputs
|
|
146
|
+
* for the inflation-linked / floating variants.
|
|
147
|
+
*/
|
|
148
|
+
static fromPricerInputs(args) {
|
|
149
|
+
const bond = buildBondDetails(args);
|
|
150
|
+
return new security_pb_1.SecurityProto()
|
|
151
|
+
.setProductType(product_type_pb_1.ProductTypeProto.TREASURY_NOTE)
|
|
152
|
+
.setBondDetails(bond);
|
|
105
153
|
}
|
|
106
154
|
/**
|
|
107
155
|
* Returns the price scale factor for bonds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.ts"],"names":[],"m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,kCAAkC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc;QACZ,6CAA6C;QAC7C,8DAA8D;QAC9D,IAAI,OAAQ,IAAY,CAAC,QAAQ,KAAK,UAAU,EAAE;YAChD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,MAAM,KAAK,GAAI,IAAY,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;YAC9C,OAAO,MAAM,CAAC;SACf;aAAM,IAAI,KAAK,GAAG,EAAE,EAAE;YACrB,OAAO,MAAM,CAAC;SACf;aAAM;YACL,OAAO,MAAM,CAAC;SACf;IACH,CAAC;CACF;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,15 +1,60 @@
|
|
|
1
1
|
import Security from './security';
|
|
2
|
-
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
2
|
+
import { SecurityProto, BondDetailsProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
3
|
import { ProductTypeProto } from "../../../fintekkers/models/security/product_type_pb";
|
|
4
4
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
5
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
5
6
|
import { LocalDate } from '../utils/date';
|
|
6
7
|
import { IssuanceProto } from '../../../fintekkers/models/security/bond/issuance_pb';
|
|
7
8
|
import { CouponFrequency } from './coupon_frequency';
|
|
8
9
|
import { CouponType } from './coupon_type';
|
|
9
10
|
import { Tenor, Period } from './term';
|
|
10
11
|
import { TenorTypeProto } from '../../../fintekkers/models/security/tenor_type_pb';
|
|
12
|
+
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
13
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
11
14
|
import { Decimal } from 'decimal.js';
|
|
12
15
|
import { isDescendantOf } from './product_hierarchy';
|
|
16
|
+
import Issuance from './Issuance';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Inputs required to mint a SecurityProto for the bond pricer. Shared by
|
|
20
|
+
* BondSecurity / TIPSBond / FloatingRateNote builders.
|
|
21
|
+
*/
|
|
22
|
+
export interface BondPricerInputs {
|
|
23
|
+
faceValue: Decimal;
|
|
24
|
+
couponRate: Decimal;
|
|
25
|
+
couponType: CouponTypeProto;
|
|
26
|
+
couponFrequency: CouponFrequencyProto;
|
|
27
|
+
issueDate: LocalDate;
|
|
28
|
+
maturityDate: LocalDate;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Build a LocalDateProto from a LocalDate wrapper. Exported so subclass
|
|
33
|
+
* builders (TIPSBond, FloatingRateNote) can re-use it without poking at
|
|
34
|
+
* LocalDate's proto privately.
|
|
35
|
+
*/
|
|
36
|
+
export function localDateToProto(d: LocalDate): LocalDateProto {
|
|
37
|
+
return d.toProto();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Build a DecimalValueProto from a Decimal. */
|
|
41
|
+
export function decimalToProto(v: Decimal): DecimalValueProto {
|
|
42
|
+
return new DecimalValueProto().setArbitraryPrecisionValue(v.toString());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build a populated BondDetailsProto from BondPricerInputs. Shared helper
|
|
47
|
+
* so the three pricer-input builders stay in sync.
|
|
48
|
+
*/
|
|
49
|
+
export function buildBondDetails(args: BondPricerInputs): BondDetailsProto {
|
|
50
|
+
return new BondDetailsProto()
|
|
51
|
+
.setFaceValue(decimalToProto(args.faceValue))
|
|
52
|
+
.setCouponRate(decimalToProto(args.couponRate))
|
|
53
|
+
.setCouponType(args.couponType)
|
|
54
|
+
.setCouponFrequency(args.couponFrequency)
|
|
55
|
+
.setIssueDate(localDateToProto(args.issueDate))
|
|
56
|
+
.setMaturityDate(localDateToProto(args.maturityDate));
|
|
57
|
+
}
|
|
13
58
|
|
|
14
59
|
class BondSecurity extends Security {
|
|
15
60
|
constructor(proto: SecurityProto) {
|
|
@@ -109,9 +154,26 @@ class BondSecurity extends Security {
|
|
|
109
154
|
return datedDate ? new LocalDate(datedDate) : undefined;
|
|
110
155
|
}
|
|
111
156
|
|
|
112
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Returns every auction/reopening record on this bond as typed Issuance
|
|
159
|
+
* wrappers. Empty list if bond_details is unset or has no issuances.
|
|
160
|
+
*/
|
|
161
|
+
getIssuances(): Issuance[] {
|
|
113
162
|
const bond = this.getBondLikeDetails();
|
|
114
|
-
|
|
163
|
+
const list: IssuanceProto[] = bond ? bond.getIssuanceInfoList() : [];
|
|
164
|
+
return list.map(p => new Issuance(p));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Build a fresh SecurityProto for a vanilla treasury note from pricer
|
|
169
|
+
* inputs. Use TIPSBond.fromPricerInputs / FloatingRateNote.fromPricerInputs
|
|
170
|
+
* for the inflation-linked / floating variants.
|
|
171
|
+
*/
|
|
172
|
+
static fromPricerInputs(args: BondPricerInputs): SecurityProto {
|
|
173
|
+
const bond = buildBondDetails(args);
|
|
174
|
+
return new SecurityProto()
|
|
175
|
+
.setProductType(ProductTypeProto.TREASURY_NOTE)
|
|
176
|
+
.setBondDetails(bond);
|
|
115
177
|
}
|
|
116
178
|
|
|
117
179
|
/**
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import BondSecurity, { BondPricerInputs } from './BondSecurity';
|
|
2
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
|
+
import { IndexTypeProto } from '../../../fintekkers/models/security/index/index_type_pb';
|
|
4
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
5
|
+
import { Decimal } from 'decimal.js';
|
|
6
|
+
/**
|
|
7
|
+
* FRN-specific accessors layered on top of BondSecurity. The floating-rate
|
|
8
|
+
* fields live in the parallel frn_extension sub-message; bond_details
|
|
9
|
+
* still carries face value / dates / etc.
|
|
10
|
+
*/
|
|
11
|
+
declare class FloatingRateNote extends BondSecurity {
|
|
12
|
+
constructor(proto: SecurityProto);
|
|
13
|
+
private getFrnExtension;
|
|
14
|
+
/** Spread added on top of the reference rate at each reset. */
|
|
15
|
+
getSpread(): Decimal | null;
|
|
16
|
+
/** Which index the coupon resets off (SOFR on a US TREASURY_FRN). */
|
|
17
|
+
getReferenceRateIndex(): IndexTypeProto;
|
|
18
|
+
/** Reset cadence (e.g. QUARTERLY). */
|
|
19
|
+
getResetFrequency(): CouponFrequencyProto;
|
|
20
|
+
/**
|
|
21
|
+
* Build a fresh SecurityProto for a floating-rate note. product_type is
|
|
22
|
+
* set to TREASURY_FRN so Security.create routes back to this wrapper.
|
|
23
|
+
*/
|
|
24
|
+
static fromPricerInputs(args: BondPricerInputs & {
|
|
25
|
+
spread: Decimal;
|
|
26
|
+
referenceRateIndex: IndexTypeProto;
|
|
27
|
+
resetFrequency: CouponFrequencyProto;
|
|
28
|
+
}): SecurityProto;
|
|
29
|
+
}
|
|
30
|
+
export default FloatingRateNote;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const BondSecurity_1 = __importStar(require("./BondSecurity"));
|
|
27
|
+
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
28
|
+
const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
|
|
29
|
+
const index_type_pb_1 = require("../../../fintekkers/models/security/index/index_type_pb");
|
|
30
|
+
const coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
31
|
+
const decimal_js_1 = require("decimal.js");
|
|
32
|
+
/**
|
|
33
|
+
* FRN-specific accessors layered on top of BondSecurity. The floating-rate
|
|
34
|
+
* fields live in the parallel frn_extension sub-message; bond_details
|
|
35
|
+
* still carries face value / dates / etc.
|
|
36
|
+
*/
|
|
37
|
+
class FloatingRateNote extends BondSecurity_1.default {
|
|
38
|
+
constructor(proto) {
|
|
39
|
+
super(proto);
|
|
40
|
+
}
|
|
41
|
+
getFrnExtension() {
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = this.proto.getFrnExtension()) !== null && _a !== void 0 ? _a : undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Spread added on top of the reference rate at each reset. */
|
|
46
|
+
getSpread() {
|
|
47
|
+
const ext = this.getFrnExtension();
|
|
48
|
+
const v = ext ? ext.getSpread() : undefined;
|
|
49
|
+
if (!v)
|
|
50
|
+
return null;
|
|
51
|
+
return new decimal_js_1.Decimal(v.getArbitraryPrecisionValue());
|
|
52
|
+
}
|
|
53
|
+
/** Which index the coupon resets off (SOFR on a US TREASURY_FRN). */
|
|
54
|
+
getReferenceRateIndex() {
|
|
55
|
+
const ext = this.getFrnExtension();
|
|
56
|
+
return ext ? ext.getReferenceRateIndex() : index_type_pb_1.IndexTypeProto.UNKNOWN_INDEX_TYPE;
|
|
57
|
+
}
|
|
58
|
+
/** Reset cadence (e.g. QUARTERLY). */
|
|
59
|
+
getResetFrequency() {
|
|
60
|
+
const ext = this.getFrnExtension();
|
|
61
|
+
return ext ? ext.getResetFrequency() : coupon_frequency_pb_1.CouponFrequencyProto.UNKNOWN_COUPON_FREQUENCY;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Build a fresh SecurityProto for a floating-rate note. product_type is
|
|
65
|
+
* set to TREASURY_FRN so Security.create routes back to this wrapper.
|
|
66
|
+
*/
|
|
67
|
+
static fromPricerInputs(args) {
|
|
68
|
+
const bond = (0, BondSecurity_1.buildBondDetails)(args);
|
|
69
|
+
const frn = new security_pb_1.FrnExtensionProto()
|
|
70
|
+
.setSpread((0, BondSecurity_1.decimalToProto)(args.spread))
|
|
71
|
+
.setReferenceRateIndex(args.referenceRateIndex)
|
|
72
|
+
.setResetFrequency(args.resetFrequency);
|
|
73
|
+
return new security_pb_1.SecurityProto()
|
|
74
|
+
.setProductType(product_type_pb_1.ProductTypeProto.TREASURY_FRN)
|
|
75
|
+
.setBondDetails(bond)
|
|
76
|
+
.setFrnExtension(frn);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = FloatingRateNote;
|
|
80
|
+
//# sourceMappingURL=FloatingRateNote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloatingRateNote.js","sourceRoot":"","sources":["FloatingRateNote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAIwB;AACxB,iFAAmG;AACnG,yFAAuF;AACvF,2FAAyF;AACzF,iGAA+F;AAC/F,2CAAqC;AAErC;;;;GAIG;AACH,MAAM,gBAAiB,SAAQ,sBAAY;IACzC,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEO,eAAe;;QACrB,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,mCAAI,SAAS,CAAC;IACnD,CAAC;IAED,+DAA+D;IAC/D,SAAS;QACP,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpB,OAAO,IAAI,oBAAO,CAAC,CAAC,CAAC,0BAA0B,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,qEAAqE;IACrE,qBAAqB;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACnC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,8BAAc,CAAC,kBAAkB,CAAC;IAC/E,CAAC;IAED,sCAAsC;IACtC,iBAAiB;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACnC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,0CAAoB,CAAC,wBAAwB,CAAC;IACvF,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAIvB;QACC,MAAM,IAAI,GAAG,IAAA,+BAAgB,EAAC,IAAI,CAAC,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,+BAAiB,EAAE;aAChC,SAAS,CAAC,IAAA,6BAAc,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtC,qBAAqB,CAAC,IAAI,CAAC,kBAAkB,CAAC;aAC9C,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,OAAO,IAAI,2BAAa,EAAE;aACvB,cAAc,CAAC,kCAAgB,CAAC,YAAY,CAAC;aAC7C,cAAc,CAAC,IAAI,CAAC;aACpB,eAAe,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import BondSecurity, {
|
|
2
|
+
BondPricerInputs,
|
|
3
|
+
buildBondDetails,
|
|
4
|
+
decimalToProto,
|
|
5
|
+
} from './BondSecurity';
|
|
6
|
+
import { SecurityProto, FrnExtensionProto } from '../../../fintekkers/models/security/security_pb';
|
|
7
|
+
import { ProductTypeProto } from '../../../fintekkers/models/security/product_type_pb';
|
|
8
|
+
import { IndexTypeProto } from '../../../fintekkers/models/security/index/index_type_pb';
|
|
9
|
+
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
10
|
+
import { Decimal } from 'decimal.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* FRN-specific accessors layered on top of BondSecurity. The floating-rate
|
|
14
|
+
* fields live in the parallel frn_extension sub-message; bond_details
|
|
15
|
+
* still carries face value / dates / etc.
|
|
16
|
+
*/
|
|
17
|
+
class FloatingRateNote extends BondSecurity {
|
|
18
|
+
constructor(proto: SecurityProto) {
|
|
19
|
+
super(proto);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private getFrnExtension(): FrnExtensionProto | undefined {
|
|
23
|
+
return this.proto.getFrnExtension() ?? undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Spread added on top of the reference rate at each reset. */
|
|
27
|
+
getSpread(): Decimal | null {
|
|
28
|
+
const ext = this.getFrnExtension();
|
|
29
|
+
const v = ext ? ext.getSpread() : undefined;
|
|
30
|
+
if (!v) return null;
|
|
31
|
+
return new Decimal(v.getArbitraryPrecisionValue());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Which index the coupon resets off (SOFR on a US TREASURY_FRN). */
|
|
35
|
+
getReferenceRateIndex(): IndexTypeProto {
|
|
36
|
+
const ext = this.getFrnExtension();
|
|
37
|
+
return ext ? ext.getReferenceRateIndex() : IndexTypeProto.UNKNOWN_INDEX_TYPE;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Reset cadence (e.g. QUARTERLY). */
|
|
41
|
+
getResetFrequency(): CouponFrequencyProto {
|
|
42
|
+
const ext = this.getFrnExtension();
|
|
43
|
+
return ext ? ext.getResetFrequency() : CouponFrequencyProto.UNKNOWN_COUPON_FREQUENCY;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Build a fresh SecurityProto for a floating-rate note. product_type is
|
|
48
|
+
* set to TREASURY_FRN so Security.create routes back to this wrapper.
|
|
49
|
+
*/
|
|
50
|
+
static fromPricerInputs(args: BondPricerInputs & {
|
|
51
|
+
spread: Decimal;
|
|
52
|
+
referenceRateIndex: IndexTypeProto;
|
|
53
|
+
resetFrequency: CouponFrequencyProto;
|
|
54
|
+
}): SecurityProto {
|
|
55
|
+
const bond = buildBondDetails(args);
|
|
56
|
+
const frn = new FrnExtensionProto()
|
|
57
|
+
.setSpread(decimalToProto(args.spread))
|
|
58
|
+
.setReferenceRateIndex(args.referenceRateIndex)
|
|
59
|
+
.setResetFrequency(args.resetFrequency);
|
|
60
|
+
return new SecurityProto()
|
|
61
|
+
.setProductType(ProductTypeProto.TREASURY_FRN)
|
|
62
|
+
.setBondDetails(bond)
|
|
63
|
+
.setFrnExtension(frn);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default FloatingRateNote;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Security from './security';
|
|
2
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
|
+
import { IndexTypeProto } from '../../../fintekkers/models/security/index/index_type_pb';
|
|
4
|
+
/**
|
|
5
|
+
* Wrapper for Security messages whose product_type is a descendant of
|
|
6
|
+
* INDEX in hierarchy.json (CPI_SERIES, SOFR_SERIES, EQUITY_INDEX, etc.).
|
|
7
|
+
* The index-specific fields live in the index_details sub-message (one of
|
|
8
|
+
* the non_bond_details oneof variants).
|
|
9
|
+
*/
|
|
10
|
+
declare class IndexSecurity extends Security {
|
|
11
|
+
constructor(proto: SecurityProto);
|
|
12
|
+
/** Which index family this security represents. Defaults to
|
|
13
|
+
* UNKNOWN_INDEX_TYPE when index_details is not populated. */
|
|
14
|
+
getIndexType(): IndexTypeProto;
|
|
15
|
+
}
|
|
16
|
+
export default IndexSecurity;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const security_1 = __importDefault(require("./security"));
|
|
7
|
+
const index_type_pb_1 = require("../../../fintekkers/models/security/index/index_type_pb");
|
|
8
|
+
/**
|
|
9
|
+
* Wrapper for Security messages whose product_type is a descendant of
|
|
10
|
+
* INDEX in hierarchy.json (CPI_SERIES, SOFR_SERIES, EQUITY_INDEX, etc.).
|
|
11
|
+
* The index-specific fields live in the index_details sub-message (one of
|
|
12
|
+
* the non_bond_details oneof variants).
|
|
13
|
+
*/
|
|
14
|
+
class IndexSecurity extends security_1.default {
|
|
15
|
+
constructor(proto) {
|
|
16
|
+
super(proto);
|
|
17
|
+
}
|
|
18
|
+
/** Which index family this security represents. Defaults to
|
|
19
|
+
* UNKNOWN_INDEX_TYPE when index_details is not populated. */
|
|
20
|
+
getIndexType() {
|
|
21
|
+
const details = this.proto.getIndexDetails();
|
|
22
|
+
return details ? details.getIndexType() : index_type_pb_1.IndexTypeProto.UNKNOWN_INDEX_TYPE;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = IndexSecurity;
|
|
26
|
+
//# sourceMappingURL=IndexSecurity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexSecurity.js","sourceRoot":"","sources":["IndexSecurity.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,2FAAyF;AAEzF;;;;;GAKG;AACH,MAAM,aAAc,SAAQ,kBAAQ;IAClC,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED;iEAC6D;IAC7D,YAAY;QACV,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,8BAAc,CAAC,kBAAkB,CAAC;IAC9E,CAAC;CACF;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|