@fintekkers/ledger-models 0.4.2 → 0.4.4
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/node/fintekkers/requests/position/query_position_request.packed_enum_v4.test.d.ts +1 -0
- package/node/fintekkers/requests/position/query_position_request.packed_enum_v4.test.js +61 -0
- package/node/fintekkers/requests/position/query_position_request.packed_enum_v4.test.js.map +1 -0
- package/node/fintekkers/requests/position/query_position_request.packed_enum_v4.test.ts +65 -0
- package/node/fintekkers/requests/position/query_position_request_pb.js +2 -2
- package/node/fintekkers/requests/security/get_fields_response_pb.js +1 -1
- package/node/fintekkers/requests/valuation/curve_request_pb.js +1 -1
- package/node/fintekkers/requests/valuation/valuation_request_pb.js +1 -1
- package/node/wrappers/models/security/BondSecurity.d.ts +5 -21
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.js +17 -11
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.fromPricerInputs.test.ts +17 -11
- package/node/wrappers/models/security/BondSecurity.js +15 -32
- package/node/wrappers/models/security/BondSecurity.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.ts +18 -37
- package/node/wrappers/models/security/Issuance.d.ts +3 -5
- package/node/wrappers/models/security/Issuance.js +3 -8
- package/node/wrappers/models/security/Issuance.js.map +1 -1
- package/node/wrappers/models/security/Issuance.test.js +16 -8
- package/node/wrappers/models/security/Issuance.test.js.map +1 -1
- package/node/wrappers/models/security/Issuance.test.ts +10 -2
- package/node/wrappers/models/security/Issuance.ts +6 -12
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js +11 -7
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.js.map +1 -1
- package/node/wrappers/models/security/MortgageBackedSecurity.fromPricerInputs.test.ts +12 -8
- package/node/wrappers/models/security/TIPSBond.d.ts +2 -3
- package/node/wrappers/models/security/TIPSBond.js +2 -4
- package/node/wrappers/models/security/TIPSBond.js.map +1 -1
- package/node/wrappers/models/security/TIPSBond.ts +5 -7
- package/node/wrappers/models/security/security.d.ts +38 -12
- package/node/wrappers/models/security/security.js +58 -15
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.test.js +91 -10
- package/node/wrappers/models/security/security.test.js.map +1 -1
- package/node/wrappers/models/security/security.test.ts +106 -11
- package/node/wrappers/models/security/security.ts +64 -16
- package/node/wrappers/models/transaction/transaction.d.ts +2 -3
- package/node/wrappers/models/transaction/transaction.js +23 -21
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.ts +22 -21
- package/node/wrappers/models/transaction/transaction_constructor.test.js +4 -2
- package/node/wrappers/models/transaction/transaction_constructor.test.js.map +1 -1
- package/node/wrappers/models/transaction/transaction_constructor.test.ts +10 -8
- package/node/wrappers/models/utils/date.d.ts +13 -1
- package/node/wrappers/models/utils/date.js +26 -1
- package/node/wrappers/models/utils/date.js.map +1 -1
- package/node/wrappers/models/utils/date.ts +25 -1
- package/node/wrappers/services/security-service/security.maturityLadder.test.js +4 -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Regression guard for the v4-runtime decode path on packed-enum fields.
|
|
3
|
+
//
|
|
4
|
+
// google-protobuf v4 removed `BinaryReader.prototype.readPackedEnum`. The
|
|
5
|
+
// bundled protoc 3.19.1 generator emits decode code that calls it on every
|
|
6
|
+
// `repeated <enum>` field. compile.sh substitutes the call with the v4
|
|
7
|
+
// `readPackableEnumInto(arr)` equivalent. This test exercises that path
|
|
8
|
+
// end-to-end so a regen-without-patch (or a sed-rule drift) trips CI before
|
|
9
|
+
// shipping.
|
|
10
|
+
//
|
|
11
|
+
// Repro: positions UI hit "reader.readPackedEnum is not a function" on every
|
|
12
|
+
// `/data/positions` request because the QueryPositionRequestProto encode/decode
|
|
13
|
+
// round-trip needed the packed-enum decoder. (second-brain#292)
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const google_protobuf_1 = require("google-protobuf");
|
|
16
|
+
const query_position_request_pb_1 = require("../../../fintekkers/requests/position/query_position_request_pb");
|
|
17
|
+
const field_pb_1 = require("../../../fintekkers/models/position/field_pb");
|
|
18
|
+
const measure_pb_1 = require("../../../fintekkers/models/position/measure_pb");
|
|
19
|
+
describe("packed-enum decode under google-protobuf v4 (second-brain#292)", () => {
|
|
20
|
+
test("v4 BinaryReader does NOT expose readPackedEnum (sentinel for the bug)", () => {
|
|
21
|
+
// If a future google-protobuf release re-adds readPackedEnum, this
|
|
22
|
+
// assertion flips and the regen can drop the post-process patch.
|
|
23
|
+
expect(typeof google_protobuf_1.BinaryReader.prototype.readPackedEnum).toBe("undefined");
|
|
24
|
+
});
|
|
25
|
+
test("v4 BinaryReader exposes readPackableEnumInto (the replacement target)", () => {
|
|
26
|
+
expect(typeof google_protobuf_1.BinaryReader.prototype.readPackableEnumInto).toBe("function");
|
|
27
|
+
});
|
|
28
|
+
test("QueryPositionRequestProto round-trips packed repeated FieldProto + MeasureProto", () => {
|
|
29
|
+
const req = new query_position_request_pb_1.QueryPositionRequestProto();
|
|
30
|
+
req.setFieldsList([
|
|
31
|
+
field_pb_1.FieldProto.SECURITY,
|
|
32
|
+
field_pb_1.FieldProto.PORTFOLIO,
|
|
33
|
+
field_pb_1.FieldProto.AS_OF,
|
|
34
|
+
]);
|
|
35
|
+
req.setMeasuresList([
|
|
36
|
+
measure_pb_1.MeasureProto.MARKET_VALUE,
|
|
37
|
+
measure_pb_1.MeasureProto.DIRECTED_QUANTITY,
|
|
38
|
+
]);
|
|
39
|
+
// Encode → bytes → decode. Without the v4-compat substitution this
|
|
40
|
+
// throws `reader.readPackedEnum is not a function`.
|
|
41
|
+
const bytes = req.serializeBinary();
|
|
42
|
+
const decoded = query_position_request_pb_1.QueryPositionRequestProto.deserializeBinary(bytes);
|
|
43
|
+
expect(decoded.getFieldsList()).toEqual([
|
|
44
|
+
field_pb_1.FieldProto.SECURITY,
|
|
45
|
+
field_pb_1.FieldProto.PORTFOLIO,
|
|
46
|
+
field_pb_1.FieldProto.AS_OF,
|
|
47
|
+
]);
|
|
48
|
+
expect(decoded.getMeasuresList()).toEqual([
|
|
49
|
+
measure_pb_1.MeasureProto.MARKET_VALUE,
|
|
50
|
+
measure_pb_1.MeasureProto.DIRECTED_QUANTITY,
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
test("empty repeated enum lists round-trip cleanly", () => {
|
|
54
|
+
const req = new query_position_request_pb_1.QueryPositionRequestProto();
|
|
55
|
+
const bytes = req.serializeBinary();
|
|
56
|
+
const decoded = query_position_request_pb_1.QueryPositionRequestProto.deserializeBinary(bytes);
|
|
57
|
+
expect(decoded.getFieldsList()).toEqual([]);
|
|
58
|
+
expect(decoded.getMeasuresList()).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=query_position_request.packed_enum_v4.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query_position_request.packed_enum_v4.test.js","sourceRoot":"","sources":["query_position_request.packed_enum_v4.test.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,YAAY;AACZ,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,gEAAgE;;AAEhE,qDAA+C;AAC/C,+GAA4G;AAC5G,2EAA0E;AAC1E,+EAA8E;AAE9E,QAAQ,CAAC,gEAAgE,EAAE,GAAG,EAAE;IAC5E,IAAI,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,mEAAmE;QACnE,iEA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e,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,qDAAyB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACnE,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Regression guard for the v4-runtime decode path on packed-enum fields.
|
|
2
|
+
//
|
|
3
|
+
// google-protobuf v4 removed `BinaryReader.prototype.readPackedEnum`. The
|
|
4
|
+
// bundled protoc 3.19.1 generator emits decode code that calls it on every
|
|
5
|
+
// `repeated <enum>` field. compile.sh substitutes the call with the v4
|
|
6
|
+
// `readPackableEnumInto(arr)` equivalent. This test exercises that path
|
|
7
|
+
// end-to-end so a regen-without-patch (or a sed-rule drift) trips CI before
|
|
8
|
+
// shipping.
|
|
9
|
+
//
|
|
10
|
+
// Repro: positions UI hit "reader.readPackedEnum is not a function" on every
|
|
11
|
+
// `/data/positions` request because the QueryPositionRequestProto encode/decode
|
|
12
|
+
// round-trip needed the packed-enum decoder. (second-brain#292)
|
|
13
|
+
|
|
14
|
+
import { BinaryReader } from "google-protobuf";
|
|
15
|
+
import { QueryPositionRequestProto } from "../../../fintekkers/requests/position/query_position_request_pb";
|
|
16
|
+
import { FieldProto } from "../../../fintekkers/models/position/field_pb";
|
|
17
|
+
import { MeasureProto } from "../../../fintekkers/models/position/measure_pb";
|
|
18
|
+
|
|
19
|
+
describe("packed-enum decode under google-protobuf v4 (second-brain#292)", () => {
|
|
20
|
+
test("v4 BinaryReader does NOT expose readPackedEnum (sentinel for the bug)", () => {
|
|
21
|
+
// If a future google-protobuf release re-adds readPackedEnum, this
|
|
22
|
+
// assertion flips and the regen can drop the post-process patch.
|
|
23
|
+
expect(typeof (BinaryReader.prototype as any).readPackedEnum).toBe("undefined");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("v4 BinaryReader exposes readPackableEnumInto (the replacement target)", () => {
|
|
27
|
+
expect(typeof (BinaryReader.prototype as any).readPackableEnumInto).toBe("function");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("QueryPositionRequestProto round-trips packed repeated FieldProto + MeasureProto", () => {
|
|
31
|
+
const req = new QueryPositionRequestProto();
|
|
32
|
+
req.setFieldsList([
|
|
33
|
+
FieldProto.SECURITY,
|
|
34
|
+
FieldProto.PORTFOLIO,
|
|
35
|
+
FieldProto.AS_OF,
|
|
36
|
+
]);
|
|
37
|
+
req.setMeasuresList([
|
|
38
|
+
MeasureProto.MARKET_VALUE,
|
|
39
|
+
MeasureProto.DIRECTED_QUANTITY,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
// Encode → bytes → decode. Without the v4-compat substitution this
|
|
43
|
+
// throws `reader.readPackedEnum is not a function`.
|
|
44
|
+
const bytes = req.serializeBinary();
|
|
45
|
+
const decoded = QueryPositionRequestProto.deserializeBinary(bytes);
|
|
46
|
+
|
|
47
|
+
expect(decoded.getFieldsList()).toEqual([
|
|
48
|
+
FieldProto.SECURITY,
|
|
49
|
+
FieldProto.PORTFOLIO,
|
|
50
|
+
FieldProto.AS_OF,
|
|
51
|
+
]);
|
|
52
|
+
expect(decoded.getMeasuresList()).toEqual([
|
|
53
|
+
MeasureProto.MARKET_VALUE,
|
|
54
|
+
MeasureProto.DIRECTED_QUANTITY,
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("empty repeated enum lists round-trip cleanly", () => {
|
|
59
|
+
const req = new QueryPositionRequestProto();
|
|
60
|
+
const bytes = req.serializeBinary();
|
|
61
|
+
const decoded = QueryPositionRequestProto.deserializeBinary(bytes);
|
|
62
|
+
expect(decoded.getFieldsList()).toEqual([]);
|
|
63
|
+
expect(decoded.getMeasuresList()).toEqual([]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -160,13 +160,13 @@ proto.fintekkers.requests.position.QueryPositionRequestProto.deserializeBinaryFr
|
|
|
160
160
|
msg.setPositionView(value);
|
|
161
161
|
break;
|
|
162
162
|
case 30:
|
|
163
|
-
var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? reader.
|
|
163
|
+
var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
|
|
164
164
|
for (var i = 0; i < values.length; i++) {
|
|
165
165
|
msg.addFields(values[i]);
|
|
166
166
|
}
|
|
167
167
|
break;
|
|
168
168
|
case 31:
|
|
169
|
-
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.
|
|
169
|
+
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
|
|
170
170
|
for (var i = 0; i < values.length; i++) {
|
|
171
171
|
msg.addMeasures(values[i]);
|
|
172
172
|
}
|
|
@@ -132,7 +132,7 @@ proto.fintekkers.requests.security.GetFieldsResponseProto.deserializeBinaryFromR
|
|
|
132
132
|
msg.setVersion(value);
|
|
133
133
|
break;
|
|
134
134
|
case 10:
|
|
135
|
-
var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? reader.
|
|
135
|
+
var values = /** @type {!Array<!proto.fintekkers.models.position.FieldProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
|
|
136
136
|
for (var i = 0; i < values.length; i++) {
|
|
137
137
|
msg.addFields(values[i]);
|
|
138
138
|
}
|
|
@@ -477,7 +477,7 @@ proto.fintekkers.requests.valuation.CurveRequestProto.deserializeBinaryFromReade
|
|
|
477
477
|
msg.setAsofDatetime(value);
|
|
478
478
|
break;
|
|
479
479
|
case 20:
|
|
480
|
-
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.
|
|
480
|
+
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
|
|
481
481
|
for (var i = 0; i < values.length; i++) {
|
|
482
482
|
msg.addCurveTypes(values[i]);
|
|
483
483
|
}
|
|
@@ -156,7 +156,7 @@ proto.fintekkers.requests.valuation.ValuationRequestProto.deserializeBinaryFromR
|
|
|
156
156
|
msg.setOperationType(value);
|
|
157
157
|
break;
|
|
158
158
|
case 30:
|
|
159
|
-
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? reader.
|
|
159
|
+
var values = /** @type {!Array<!proto.fintekkers.models.position.MeasureProto>} */ (reader.isDelimited() ? (function(){var arr=[];reader.readPackableEnumInto(arr);return arr;})() : [reader.readEnum()]);
|
|
160
160
|
for (var i = 0; i < values.length; i++) {
|
|
161
161
|
msg.addMeasures(values[i]);
|
|
162
162
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import Security from './security';
|
|
2
2
|
import { SecurityProto, BondDetailsProto } from '../../../fintekkers/models/security/security_pb';
|
|
3
3
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
4
|
-
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
5
|
-
import { LocalDate } from '../utils/date';
|
|
6
4
|
import { CouponFrequency } from './coupon_frequency';
|
|
7
5
|
import { CouponType } from './coupon_type';
|
|
8
6
|
import { Tenor } from './term';
|
|
@@ -19,15 +17,9 @@ export interface BondPricerInputs {
|
|
|
19
17
|
couponRate: Decimal;
|
|
20
18
|
couponType: CouponTypeProto;
|
|
21
19
|
couponFrequency: CouponFrequencyProto;
|
|
22
|
-
issueDate:
|
|
23
|
-
maturityDate:
|
|
20
|
+
issueDate: Date;
|
|
21
|
+
maturityDate: Date;
|
|
24
22
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Build a LocalDateProto from a LocalDate wrapper. Exported so subclass
|
|
27
|
-
* builders (TIPSBond, FloatingRateNote) can re-use it without poking at
|
|
28
|
-
* LocalDate's proto privately.
|
|
29
|
-
*/
|
|
30
|
-
export declare function localDateToProto(d: LocalDate): LocalDateProto;
|
|
31
23
|
/** Build a DecimalValueProto from a Decimal. */
|
|
32
24
|
export declare function decimalToProto(v: Decimal): DecimalValueProto;
|
|
33
25
|
/**
|
|
@@ -50,11 +42,11 @@ declare class BondSecurity extends Security {
|
|
|
50
42
|
* This method handles month and year boundaries correctly.
|
|
51
43
|
*/
|
|
52
44
|
private calculatePeriod;
|
|
53
|
-
getCouponRate():
|
|
54
|
-
getFaceValue():
|
|
45
|
+
getCouponRate(): Decimal | null;
|
|
46
|
+
getFaceValue(): Decimal | null;
|
|
55
47
|
getCouponType(): CouponType;
|
|
56
48
|
getCouponFrequency(): CouponFrequency;
|
|
57
|
-
getDatedDate():
|
|
49
|
+
getDatedDate(): Date | null;
|
|
58
50
|
/**
|
|
59
51
|
* Returns every auction/reopening record on this bond as typed Issuance
|
|
60
52
|
* wrappers. Empty list if bond_details is unset or has no issuances.
|
|
@@ -73,14 +65,6 @@ declare class BondSecurity extends Security {
|
|
|
73
65
|
* @returns The price scale factor as a Decimal (0.01)
|
|
74
66
|
*/
|
|
75
67
|
getPriceScaleFactor(): Decimal;
|
|
76
|
-
/**
|
|
77
|
-
* Bond issue date is the auction date and is required for bonds.
|
|
78
|
-
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
79
|
-
* base) with a non-nullable return type — for a properly-formed bond,
|
|
80
|
-
* issue date is always present, and TS callers narrowed via isBond()
|
|
81
|
-
* shouldn't have to null-check.
|
|
82
|
-
*/
|
|
83
|
-
getIssueDate(): LocalDate;
|
|
84
68
|
getProductType(): string;
|
|
85
69
|
}
|
|
86
70
|
export default BondSecurity;
|
|
@@ -11,11 +11,11 @@ const product_type_pb_1 = require("../../../fintekkers/models/security/product_t
|
|
|
11
11
|
const coupon_type_pb_1 = require("../../../fintekkers/models/security/coupon_type_pb");
|
|
12
12
|
const coupon_frequency_pb_1 = require("../../../fintekkers/models/security/coupon_frequency_pb");
|
|
13
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
14
|
const decimal_js_1 = require("decimal.js");
|
|
17
15
|
function makeDate(y, m, d) {
|
|
18
|
-
|
|
16
|
+
const date = new Date(y, m - 1, d);
|
|
17
|
+
date.setHours(0, 0, 0, 0);
|
|
18
|
+
return date;
|
|
19
19
|
}
|
|
20
20
|
const baseInputs = {
|
|
21
21
|
faceValue: new decimal_js_1.Decimal('1000'),
|
|
@@ -31,15 +31,19 @@ test('BondSecurity.fromPricerInputs round-trips through Security.create as a Bon
|
|
|
31
31
|
const sec = security_1.default.create(proto);
|
|
32
32
|
expect(sec).toBeInstanceOf(BondSecurity_1.default);
|
|
33
33
|
const bond = sec;
|
|
34
|
-
expect(bond.getCouponRate().
|
|
35
|
-
expect(bond.getFaceValue().
|
|
34
|
+
expect(bond.getCouponRate().equals(new decimal_js_1.Decimal('0.045'))).toBe(true);
|
|
35
|
+
expect(bond.getFaceValue().equals(new decimal_js_1.Decimal('1000'))).toBe(true);
|
|
36
36
|
expect(bond.getCouponType().name()).toBe('FIXED');
|
|
37
37
|
expect(bond.getCouponFrequency().toString()).toBe('SEMIANNUALLY');
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const issueDate = bond.getIssueDate();
|
|
39
|
+
const maturityDate = bond.getMaturityDate();
|
|
40
|
+
expect(issueDate).toBeInstanceOf(Date);
|
|
41
|
+
expect(maturityDate).toBeInstanceOf(Date);
|
|
42
|
+
expect(issueDate.getFullYear()).toBe(2024);
|
|
43
|
+
expect(maturityDate.getFullYear()).toBe(2034);
|
|
40
44
|
});
|
|
41
45
|
test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () => {
|
|
42
|
-
var _a
|
|
46
|
+
var _a;
|
|
43
47
|
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
48
|
expect(proto.getProductType()).toBe(product_type_pb_1.ProductTypeProto.TIPS);
|
|
45
49
|
expect(proto.hasTipsExtension()).toBe(true);
|
|
@@ -47,10 +51,12 @@ test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () =
|
|
|
47
51
|
expect(sec).toBeInstanceOf(TIPSBond_1.default);
|
|
48
52
|
const tips = sec;
|
|
49
53
|
// Bond-side checks (inherited from BondSecurity)
|
|
50
|
-
expect(tips.getCouponRate().
|
|
54
|
+
expect(tips.getCouponRate().equals(new decimal_js_1.Decimal('0.045'))).toBe(true);
|
|
51
55
|
// TIPS-specific checks
|
|
52
56
|
expect((_a = tips.getBaseCpi()) === null || _a === void 0 ? void 0 : _a.toString()).toBe('301.5');
|
|
53
|
-
|
|
57
|
+
const indexDate = tips.getIndexDate();
|
|
58
|
+
expect(indexDate).toBeInstanceOf(Date);
|
|
59
|
+
expect(indexDate.getFullYear()).toBe(2024);
|
|
54
60
|
expect(tips.getInflationIndexType()).toBe(index_type_pb_1.IndexTypeProto.CPI_U);
|
|
55
61
|
});
|
|
56
62
|
test('FloatingRateNote.fromPricerInputs round-trips with frn_extension populated', () => {
|
|
@@ -61,7 +67,7 @@ test('FloatingRateNote.fromPricerInputs round-trips with frn_extension populated
|
|
|
61
67
|
const sec = security_1.default.create(proto);
|
|
62
68
|
expect(sec).toBeInstanceOf(FloatingRateNote_1.default);
|
|
63
69
|
const frn = sec;
|
|
64
|
-
expect(frn.getCouponRate().
|
|
70
|
+
expect(frn.getCouponRate().equals(new decimal_js_1.Decimal('0.045'))).toBe(true);
|
|
65
71
|
expect((_a = frn.getSpread()) === null || _a === void 0 ? void 0 : _a.toString()).toBe('0.0015');
|
|
66
72
|
expect(frn.getReferenceRateIndex()).toBe(index_type_pb_1.IndexTypeProto.SOFR);
|
|
67
73
|
expect(frn.getResetFrequency()).toBe(coupon_frequency_pb_1.CouponFrequencyProto.QUARTERLY);
|
|
@@ -1 +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,
|
|
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,2CAAqC;AAErC,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC/C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,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,0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AAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,0CAAoB,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC1D,MAAM,SAAS,GAAG,kBAAQ,CAAC,gBAAgB,iCACtC,UAAU,KACb,OAAO,EAAE,IAAI,oBAAO,CAAC,KAAK,CAAC,EAC3B,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,EAChC,kBAAkB,EAAE,8BAAc,CAAC,KAAK,IACxC,CAAC;IACH,MAAM,QAAQ,GAAG,0BAAgB,CAAC,gBAAgB,iCAC7C,UAAU,KACb,MAAM,EAAE,IAAI,oBAAO,CAAC,OAAO,CAAC,EAC5B,kBAAkB,EAAE,8BAAc,CAAC,IAAI,EACvC,cAAc,EAAE,0CAAoB,CAAC,SAAS,IAC9C,CAAC;IACH,MAAM,CAAC,kBAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC,CAAC"}
|
|
@@ -6,12 +6,12 @@ import { ProductTypeProto } from '../../../fintekkers/models/security/product_ty
|
|
|
6
6
|
import { CouponTypeProto } from '../../../fintekkers/models/security/coupon_type_pb';
|
|
7
7
|
import { CouponFrequencyProto } from '../../../fintekkers/models/security/coupon_frequency_pb';
|
|
8
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
9
|
import { Decimal } from 'decimal.js';
|
|
12
10
|
|
|
13
|
-
function makeDate(y: number, m: number, d: number):
|
|
14
|
-
|
|
11
|
+
function makeDate(y: number, m: number, d: number): Date {
|
|
12
|
+
const date = new Date(y, m - 1, d);
|
|
13
|
+
date.setHours(0, 0, 0, 0);
|
|
14
|
+
return date;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const baseInputs = {
|
|
@@ -29,12 +29,16 @@ test('BondSecurity.fromPricerInputs round-trips through Security.create as a Bon
|
|
|
29
29
|
const sec = Security.create(proto);
|
|
30
30
|
expect(sec).toBeInstanceOf(BondSecurity);
|
|
31
31
|
const bond = sec as BondSecurity;
|
|
32
|
-
expect(bond.getCouponRate()
|
|
33
|
-
expect(bond.getFaceValue()
|
|
32
|
+
expect(bond.getCouponRate()!.equals(new Decimal('0.045'))).toBe(true);
|
|
33
|
+
expect(bond.getFaceValue()!.equals(new Decimal('1000'))).toBe(true);
|
|
34
34
|
expect(bond.getCouponType().name()).toBe('FIXED');
|
|
35
35
|
expect(bond.getCouponFrequency().toString()).toBe('SEMIANNUALLY');
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const issueDate = bond.getIssueDate();
|
|
37
|
+
const maturityDate = bond.getMaturityDate();
|
|
38
|
+
expect(issueDate).toBeInstanceOf(Date);
|
|
39
|
+
expect(maturityDate).toBeInstanceOf(Date);
|
|
40
|
+
expect(issueDate!.getFullYear()).toBe(2024);
|
|
41
|
+
expect(maturityDate!.getFullYear()).toBe(2034);
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () => {
|
|
@@ -51,10 +55,12 @@ test('TIPSBond.fromPricerInputs round-trips with tips_extension populated', () =
|
|
|
51
55
|
expect(sec).toBeInstanceOf(TIPSBond);
|
|
52
56
|
const tips = sec as TIPSBond;
|
|
53
57
|
// Bond-side checks (inherited from BondSecurity)
|
|
54
|
-
expect(tips.getCouponRate()
|
|
58
|
+
expect(tips.getCouponRate()!.equals(new Decimal('0.045'))).toBe(true);
|
|
55
59
|
// TIPS-specific checks
|
|
56
60
|
expect(tips.getBaseCpi()?.toString()).toBe('301.5');
|
|
57
|
-
|
|
61
|
+
const indexDate = tips.getIndexDate();
|
|
62
|
+
expect(indexDate).toBeInstanceOf(Date);
|
|
63
|
+
expect(indexDate!.getFullYear()).toBe(2024);
|
|
58
64
|
expect(tips.getInflationIndexType()).toBe(IndexTypeProto.CPI_U);
|
|
59
65
|
});
|
|
60
66
|
|
|
@@ -71,7 +77,7 @@ test('FloatingRateNote.fromPricerInputs round-trips with frn_extension populated
|
|
|
71
77
|
const sec = Security.create(proto);
|
|
72
78
|
expect(sec).toBeInstanceOf(FloatingRateNote);
|
|
73
79
|
const frn = sec as FloatingRateNote;
|
|
74
|
-
expect(frn.getCouponRate()
|
|
80
|
+
expect(frn.getCouponRate()!.equals(new Decimal('0.045'))).toBe(true);
|
|
75
81
|
expect(frn.getSpread()?.toString()).toBe('0.0015');
|
|
76
82
|
expect(frn.getReferenceRateIndex()).toBe(IndexTypeProto.SOFR);
|
|
77
83
|
expect(frn.getResetFrequency()).toBe(CouponFrequencyProto.QUARTERLY);
|
|
@@ -3,7 +3,7 @@ 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 =
|
|
6
|
+
exports.buildBondDetails = exports.decimalToProto = void 0;
|
|
7
7
|
const security_1 = __importDefault(require("./security"));
|
|
8
8
|
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
9
9
|
const product_type_pb_1 = require("../../../fintekkers/models/security/product_type_pb");
|
|
@@ -16,15 +16,6 @@ const tenor_type_pb_1 = require("../../../fintekkers/models/security/tenor_type_
|
|
|
16
16
|
const decimal_js_1 = require("decimal.js");
|
|
17
17
|
const product_hierarchy_1 = require("./product_hierarchy");
|
|
18
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
19
|
/** Build a DecimalValueProto from a Decimal. */
|
|
29
20
|
function decimalToProto(v) {
|
|
30
21
|
return new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue(v.toString());
|
|
@@ -40,8 +31,8 @@ function buildBondDetails(args) {
|
|
|
40
31
|
.setCouponRate(decimalToProto(args.couponRate))
|
|
41
32
|
.setCouponType(args.couponType)
|
|
42
33
|
.setCouponFrequency(args.couponFrequency)
|
|
43
|
-
.setIssueDate(
|
|
44
|
-
.setMaturityDate(
|
|
34
|
+
.setIssueDate((0, date_1.dateToLocalDateProto)(args.issueDate))
|
|
35
|
+
.setMaturityDate((0, date_1.dateToLocalDateProto)(args.maturityDate));
|
|
45
36
|
}
|
|
46
37
|
exports.buildBondDetails = buildBondDetails;
|
|
47
38
|
class BondSecurity extends security_1.default {
|
|
@@ -66,8 +57,13 @@ class BondSecurity extends security_1.default {
|
|
|
66
57
|
* @returns The tenor (term) of the bond as a Tenor object.
|
|
67
58
|
*/
|
|
68
59
|
getTenor(asOfDate) {
|
|
69
|
-
const
|
|
70
|
-
const maturityDate = this.getMaturityDate()
|
|
60
|
+
const issueDate = this.getIssueDate();
|
|
61
|
+
const maturityDate = this.getMaturityDate();
|
|
62
|
+
if (!issueDate)
|
|
63
|
+
throw new Error("Issue date is required for getTenor");
|
|
64
|
+
if (!maturityDate)
|
|
65
|
+
throw new Error("Maturity date is required for getTenor");
|
|
66
|
+
const startDate = asOfDate ? asOfDate : issueDate;
|
|
71
67
|
// Calculate the period between issue date and maturity date
|
|
72
68
|
const period = this.calculatePeriod(startDate, maturityDate);
|
|
73
69
|
return new term_1.Tenor(tenor_type_pb_1.TenorTypeProto.TERM, period);
|
|
@@ -102,15 +98,15 @@ class BondSecurity extends security_1.default {
|
|
|
102
98
|
const bond = this.getBondLikeDetails();
|
|
103
99
|
const rate = bond ? bond.getCouponRate() : undefined;
|
|
104
100
|
if (!rate)
|
|
105
|
-
|
|
106
|
-
return rate;
|
|
101
|
+
return null;
|
|
102
|
+
return new decimal_js_1.Decimal(rate.getArbitraryPrecisionValue());
|
|
107
103
|
}
|
|
108
104
|
getFaceValue() {
|
|
109
105
|
const bond = this.getBondLikeDetails();
|
|
110
106
|
const faceValue = bond ? bond.getFaceValue() : undefined;
|
|
111
107
|
if (!faceValue)
|
|
112
|
-
|
|
113
|
-
return faceValue;
|
|
108
|
+
return null;
|
|
109
|
+
return new decimal_js_1.Decimal(faceValue.getArbitraryPrecisionValue());
|
|
114
110
|
}
|
|
115
111
|
getCouponType() {
|
|
116
112
|
const bond = this.getBondLikeDetails();
|
|
@@ -129,7 +125,7 @@ class BondSecurity extends security_1.default {
|
|
|
129
125
|
getDatedDate() {
|
|
130
126
|
const bond = this.getBondLikeDetails();
|
|
131
127
|
const datedDate = bond ? bond.getDatedDate() : undefined;
|
|
132
|
-
return
|
|
128
|
+
return (0, date_1.localDateProtoToDate)(datedDate);
|
|
133
129
|
}
|
|
134
130
|
/**
|
|
135
131
|
* Returns every auction/reopening record on this bond as typed Issuance
|
|
@@ -160,19 +156,6 @@ class BondSecurity extends security_1.default {
|
|
|
160
156
|
getPriceScaleFactor() {
|
|
161
157
|
return new decimal_js_1.Decimal('0.01');
|
|
162
158
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Bond issue date is the auction date and is required for bonds.
|
|
165
|
-
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
166
|
-
* base) with a non-nullable return type — for a properly-formed bond,
|
|
167
|
-
* issue date is always present, and TS callers narrowed via isBond()
|
|
168
|
-
* shouldn't have to null-check.
|
|
169
|
-
*/
|
|
170
|
-
getIssueDate() {
|
|
171
|
-
const date = super.getIssueDate();
|
|
172
|
-
if (!date)
|
|
173
|
-
throw new Error("Issue date is required for bonds");
|
|
174
|
-
return date;
|
|
175
|
-
}
|
|
176
159
|
getProductType() {
|
|
177
160
|
// Only BondSecurity has getTenor implemented
|
|
178
161
|
// Check if getTenor method exists (it's only in BondSecurity)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAClC,iFAAkG;AAClG,yFAAuF;AACvF,uFAAqF;AAErF,
|
|
1
|
+
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAClC,iFAAkG;AAClG,yFAAuF;AACvF,uFAAqF;AAErF,wCAA2E;AAE3E,yDAAqD;AACrD,+CAA2C;AAC3C,iCAAuC;AACvC,qFAAmF;AAGnF,2CAAqC;AACrC,2DAAqD;AACrD,0DAAkC;AAelC,gDAAgD;AAChD,SAAgB,cAAc,CAAC,CAAU;IACvC,OAAO,IAAI,oCAAiB,EAAE,CAAC,0BAA0B,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,wCAEC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,IAAsB;IACrD,OAAO,IAAI,8BAAgB,EAAE;SAC1B,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC5C,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC9C,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC;SAC9B,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC;SACxC,YAAY,CAAC,IAAA,2BAAoB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAClD,eAAe,CAAC,IAAA,2BAAoB,EAAC,IAAI,C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M,CAAC,gBAAgB,CAAC,IAAsB;QAC5C,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,IAAI,2BAAa,EAAE;aACvB,cAAc,CAAC,kCAAgB,CAAC,aAAa,CAAC;aAC9C,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,mBAAmB;QACjB,OAAO,IAAI,oBAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,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"}
|
|
@@ -3,7 +3,7 @@ import { SecurityProto, BondDetailsProto } from '../../../fintekkers/models/secu
|
|
|
3
3
|
import { ProductTypeProto } from "../../../fintekkers/models/security/product_type_pb";
|
|
4
4
|
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
5
5
|
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
6
|
-
import {
|
|
6
|
+
import { dateToLocalDateProto, localDateProtoToDate } from '../utils/date';
|
|
7
7
|
import { IssuanceProto } from '../../../fintekkers/models/security/bond/issuance_pb';
|
|
8
8
|
import { CouponFrequency } from './coupon_frequency';
|
|
9
9
|
import { CouponType } from './coupon_type';
|
|
@@ -24,17 +24,8 @@ export interface BondPricerInputs {
|
|
|
24
24
|
couponRate: Decimal;
|
|
25
25
|
couponType: CouponTypeProto;
|
|
26
26
|
couponFrequency: CouponFrequencyProto;
|
|
27
|
-
issueDate:
|
|
28
|
-
maturityDate:
|
|
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();
|
|
27
|
+
issueDate: Date;
|
|
28
|
+
maturityDate: Date;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
31
|
/** Build a DecimalValueProto from a Decimal. */
|
|
@@ -52,8 +43,8 @@ export function buildBondDetails(args: BondPricerInputs): BondDetailsProto {
|
|
|
52
43
|
.setCouponRate(decimalToProto(args.couponRate))
|
|
53
44
|
.setCouponType(args.couponType)
|
|
54
45
|
.setCouponFrequency(args.couponFrequency)
|
|
55
|
-
.setIssueDate(
|
|
56
|
-
.setMaturityDate(
|
|
46
|
+
.setIssueDate(dateToLocalDateProto(args.issueDate))
|
|
47
|
+
.setMaturityDate(dateToLocalDateProto(args.maturityDate));
|
|
57
48
|
}
|
|
58
49
|
|
|
59
50
|
class BondSecurity extends Security {
|
|
@@ -81,8 +72,11 @@ class BondSecurity extends Security {
|
|
|
81
72
|
* @returns The tenor (term) of the bond as a Tenor object.
|
|
82
73
|
*/
|
|
83
74
|
getTenor(asOfDate?: Date): Tenor {
|
|
84
|
-
const
|
|
85
|
-
const maturityDate = this.getMaturityDate()
|
|
75
|
+
const issueDate = this.getIssueDate();
|
|
76
|
+
const maturityDate = this.getMaturityDate();
|
|
77
|
+
if (!issueDate) throw new Error("Issue date is required for getTenor");
|
|
78
|
+
if (!maturityDate) throw new Error("Maturity date is required for getTenor");
|
|
79
|
+
const startDate = asOfDate ? asOfDate : issueDate;
|
|
86
80
|
|
|
87
81
|
// Calculate the period between issue date and maturity date
|
|
88
82
|
const period = this.calculatePeriod(startDate, maturityDate);
|
|
@@ -120,18 +114,18 @@ class BondSecurity extends Security {
|
|
|
120
114
|
};
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
getCouponRate():
|
|
117
|
+
getCouponRate(): Decimal | null {
|
|
124
118
|
const bond = this.getBondLikeDetails();
|
|
125
119
|
const rate = bond ? bond.getCouponRate() : undefined;
|
|
126
|
-
if (!rate)
|
|
127
|
-
return rate;
|
|
120
|
+
if (!rate) return null;
|
|
121
|
+
return new Decimal(rate.getArbitraryPrecisionValue());
|
|
128
122
|
}
|
|
129
123
|
|
|
130
|
-
getFaceValue():
|
|
124
|
+
getFaceValue(): Decimal | null {
|
|
131
125
|
const bond = this.getBondLikeDetails();
|
|
132
126
|
const faceValue = bond ? bond.getFaceValue() : undefined;
|
|
133
|
-
if (!faceValue)
|
|
134
|
-
return faceValue;
|
|
127
|
+
if (!faceValue) return null;
|
|
128
|
+
return new Decimal(faceValue.getArbitraryPrecisionValue());
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
getCouponType(): CouponType {
|
|
@@ -148,10 +142,10 @@ class BondSecurity extends Security {
|
|
|
148
142
|
return new CouponFrequency(couponFrequency);
|
|
149
143
|
}
|
|
150
144
|
|
|
151
|
-
getDatedDate():
|
|
145
|
+
getDatedDate(): Date | null {
|
|
152
146
|
const bond = this.getBondLikeDetails();
|
|
153
147
|
const datedDate = bond ? bond.getDatedDate() : undefined;
|
|
154
|
-
return
|
|
148
|
+
return localDateProtoToDate(datedDate);
|
|
155
149
|
}
|
|
156
150
|
|
|
157
151
|
/**
|
|
@@ -186,19 +180,6 @@ class BondSecurity extends Security {
|
|
|
186
180
|
return new Decimal('0.01');
|
|
187
181
|
}
|
|
188
182
|
|
|
189
|
-
/**
|
|
190
|
-
* Bond issue date is the auction date and is required for bonds.
|
|
191
|
-
* Overrides Security.getIssueDate (which returns LocalDate | null on the
|
|
192
|
-
* base) with a non-nullable return type — for a properly-formed bond,
|
|
193
|
-
* issue date is always present, and TS callers narrowed via isBond()
|
|
194
|
-
* shouldn't have to null-check.
|
|
195
|
-
*/
|
|
196
|
-
getIssueDate(): LocalDate {
|
|
197
|
-
const date = super.getIssueDate();
|
|
198
|
-
if (!date) throw new Error("Issue date is required for bonds");
|
|
199
|
-
return date;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
183
|
getProductType(): string {
|
|
203
184
|
// Only BondSecurity has getTenor implemented
|
|
204
185
|
// Check if getTenor method exists (it's only in BondSecurity)
|