@fintekkers/ledger-models 0.1.118 → 0.1.128
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/.npmrc.example +4 -0
- package/catalog/fields.json +275 -0
- package/catalog/measures.json +259 -0
- package/node/fintekkers/models/portfolio/portfolio_pb.js +13 -19
- package/node/fintekkers/models/position/field_pb.js +1 -7
- package/node/fintekkers/models/position/measure_pb.d.ts +18 -0
- package/node/fintekkers/models/position/measure_pb.js +20 -8
- package/node/fintekkers/models/position/position_filter_pb.js +7 -13
- package/node/fintekkers/models/position/position_pb.d.ts +7 -0
- package/node/fintekkers/models/position/position_pb.js +64 -17
- package/node/fintekkers/models/position/position_status_pb.js +1 -7
- package/node/fintekkers/models/position/position_util_pb.js +11 -17
- package/node/fintekkers/models/price/price_pb.d.ts +4 -0
- package/node/fintekkers/models/price/price_pb.js +45 -19
- package/node/fintekkers/models/price/price_type_grpc_pb.js +1 -0
- package/node/fintekkers/models/price/price_type_pb.d.ts +15 -0
- package/node/fintekkers/models/price/price_type_pb.js +30 -0
- package/node/fintekkers/models/security/bond/auction_type_pb.js +1 -7
- package/node/fintekkers/models/security/bond/issuance_pb.js +17 -23
- package/node/fintekkers/models/security/coupon_frequency_pb.js +1 -7
- package/node/fintekkers/models/security/coupon_type_pb.js +1 -7
- package/node/fintekkers/models/security/identifier/identifier_pb.js +9 -15
- package/node/fintekkers/models/security/identifier/identifier_type_pb.d.ts +1 -0
- package/node/fintekkers/models/security/identifier/identifier_type_pb.js +2 -7
- package/node/fintekkers/models/security/index/index_type_grpc_pb.js +1 -0
- package/node/fintekkers/models/security/index/index_type_pb.d.ts +22 -0
- package/node/fintekkers/models/security/index/index_type_pb.js +37 -0
- package/node/fintekkers/models/security/index_composition_pb.d.ts +126 -0
- package/node/fintekkers/models/security/index_composition_pb.js +992 -0
- package/node/fintekkers/models/security/security_pb.d.ts +382 -0
- package/node/fintekkers/models/security/security_pb.js +3183 -57
- package/node/fintekkers/models/security/security_quantity_type_pb.js +1 -7
- package/node/fintekkers/models/security/security_type_pb.d.ts +3 -0
- package/node/fintekkers/models/security/security_type_pb.js +5 -8
- package/node/fintekkers/models/security/tenor_pb.js +9 -15
- package/node/fintekkers/models/security/tenor_type_pb.js +1 -7
- package/node/fintekkers/models/strategy/strategy_allocation_pb.js +13 -19
- package/node/fintekkers/models/strategy/strategy_pb.js +14 -20
- package/node/fintekkers/models/transaction/transaction_pb.js +24 -30
- package/node/fintekkers/models/transaction/transaction_type_pb.js +1 -7
- package/node/fintekkers/models/util/api/api_key_pb.js +10 -16
- package/node/fintekkers/models/util/currency_pb.d.ts +27 -0
- package/node/fintekkers/models/util/currency_pb.js +170 -0
- package/node/fintekkers/models/util/date_range_pb.js +8 -14
- package/node/fintekkers/models/util/decimal_value_pb.js +4 -10
- package/node/fintekkers/models/util/endpoint_pb.js +7 -13
- package/node/fintekkers/models/util/local_date_pb.js +5 -11
- package/node/fintekkers/models/util/local_timestamp_pb.js +5 -11
- package/node/fintekkers/models/util/lock/node_partition_pb.js +9 -15
- package/node/fintekkers/models/util/lock/node_state_pb.js +10 -16
- package/node/fintekkers/models/util/uuid_pb.js +3 -9
- package/node/fintekkers/models/valuation/cashflow_pb.d.ts +57 -0
- package/node/fintekkers/models/valuation/cashflow_pb.js +401 -0
- package/node/fintekkers/requests/index_composition/create_index_composition_request_pb.d.ts +79 -0
- package/node/fintekkers/requests/index_composition/create_index_composition_request_pb.js +599 -0
- package/node/fintekkers/requests/index_composition/get_index_composition_request_pb.d.ts +84 -0
- package/node/fintekkers/requests/index_composition/get_index_composition_request_pb.js +624 -0
- package/node/fintekkers/requests/portfolio/create_portfolio_request_pb.js +7 -13
- package/node/fintekkers/requests/portfolio/create_portfolio_response_pb.js +8 -14
- package/node/fintekkers/requests/portfolio/query_portfolio_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/portfolio/query_portfolio_request_pb.js +39 -15
- package/node/fintekkers/requests/portfolio/query_portfolio_response_pb.js +8 -14
- package/node/fintekkers/requests/position/query_position_request_pb.js +15 -27
- package/node/fintekkers/requests/position/query_position_response_pb.js +10 -16
- package/node/fintekkers/requests/price/create_price_request_pb.js +7 -13
- package/node/fintekkers/requests/price/create_price_response_pb.js +8 -14
- package/node/fintekkers/requests/price/query_price_request_pb.js +12 -18
- package/node/fintekkers/requests/price/query_price_response_pb.js +8 -14
- package/node/fintekkers/requests/security/create_security_request_pb.js +7 -13
- package/node/fintekkers/requests/security/create_security_response_pb.js +9 -15
- package/node/fintekkers/requests/security/get_field_values_request_pb.js +7 -13
- package/node/fintekkers/requests/security/get_field_values_response_pb.js +7 -13
- package/node/fintekkers/requests/security/get_fields_response_pb.js +8 -17
- package/node/fintekkers/requests/security/query_security_request_pb.d.ts +3 -0
- package/node/fintekkers/requests/security/query_security_request_pb.js +39 -15
- package/node/fintekkers/requests/security/query_security_response_pb.js +9 -15
- package/node/fintekkers/requests/transaction/create_transaction_request_pb.js +7 -13
- package/node/fintekkers/requests/transaction/create_transaction_response_pb.js +8 -14
- package/node/fintekkers/requests/transaction/query_transaction_request_pb.js +10 -16
- package/node/fintekkers/requests/transaction/query_transaction_response_pb.js +9 -15
- package/node/fintekkers/requests/util/delete_request_pb.d.ts +135 -0
- package/node/fintekkers/requests/util/delete_request_pb.js +1051 -0
- package/node/fintekkers/requests/util/errors/error_pb.js +7 -13
- package/node/fintekkers/requests/util/errors/message_pb.js +6 -12
- package/node/fintekkers/requests/util/errors/summary_pb.js +4 -10
- package/node/fintekkers/requests/util/lock/lock_request_pb.js +8 -14
- package/node/fintekkers/requests/util/lock/lock_response_pb.js +9 -15
- package/node/fintekkers/requests/util/operation_pb.js +1 -7
- package/node/fintekkers/requests/valuation/curve_request_pb.d.ts +85 -0
- package/node/fintekkers/requests/valuation/curve_request_pb.js +646 -0
- package/node/fintekkers/requests/valuation/curve_response_pb.d.ts +105 -0
- package/node/fintekkers/requests/valuation/curve_response_pb.js +806 -0
- package/node/fintekkers/requests/valuation/product_inputs.test.ts +172 -0
- package/node/fintekkers/requests/valuation/product_inputs_pb.d.ts +137 -0
- package/node/fintekkers/requests/valuation/product_inputs_pb.js +987 -0
- package/node/fintekkers/requests/valuation/valuation_request_pb.d.ts +19 -0
- package/node/fintekkers/requests/valuation/valuation_request_pb.js +168 -22
- package/node/fintekkers/requests/valuation/valuation_response_pb.d.ts +13 -0
- package/node/fintekkers/requests/valuation/valuation_response_pb.js +118 -16
- package/node/fintekkers/services/index-composition-service/index_composition_service_grpc_pb.d.ts +60 -0
- package/node/fintekkers/services/index-composition-service/index_composition_service_grpc_pb.js +87 -0
- package/node/fintekkers/services/index-composition-service/index_composition_service_pb.d.ts +9 -0
- package/node/fintekkers/services/index-composition-service/index_composition_service_pb.js +21 -0
- package/node/fintekkers/services/lock-service/lock_service_grpc_pb.js +22 -22
- package/node/fintekkers/services/lock-service/lock_service_pb.js +15 -21
- package/node/fintekkers/services/portfolio-service/portfolio_service_grpc_pb.d.ts +18 -0
- package/node/fintekkers/services/portfolio-service/portfolio_service_grpc_pb.js +39 -5
- package/node/fintekkers/services/portfolio-service/portfolio_service_pb.d.ts +1 -0
- package/node/fintekkers/services/portfolio-service/portfolio_service_pb.js +3 -7
- package/node/fintekkers/services/position-service/position_service_grpc_pb.d.ts +37 -0
- package/node/fintekkers/services/position-service/position_service_grpc_pb.js +64 -6
- package/node/fintekkers/services/position-service/position_service_pb.d.ts +3 -0
- package/node/fintekkers/services/position-service/position_service_pb.js +7 -7
- package/node/fintekkers/services/price-service/price_service_grpc_pb.js +5 -5
- package/node/fintekkers/services/price-service/price_service_pb.js +1 -7
- package/node/fintekkers/services/security-service/security_service_grpc_pb.d.ts +18 -0
- package/node/fintekkers/services/security-service/security_service_grpc_pb.js +43 -9
- package/node/fintekkers/services/security-service/security_service_pb.d.ts +1 -0
- package/node/fintekkers/services/security-service/security_service_pb.js +3 -7
- package/node/fintekkers/services/transaction-service/transaction_service_grpc_pb.d.ts +55 -0
- package/node/fintekkers/services/transaction-service/transaction_service_grpc_pb.js +97 -5
- package/node/fintekkers/services/transaction-service/transaction_service_pb.d.ts +4 -0
- package/node/fintekkers/services/transaction-service/transaction_service_pb.js +9 -7
- package/node/fintekkers/services/valuation-service/valuation_service_grpc_pb.d.ts +19 -0
- package/node/fintekkers/services/valuation-service/valuation_service_grpc_pb.js +37 -2
- package/node/fintekkers/services/valuation-service/valuation_service_pb.d.ts +2 -0
- package/node/fintekkers/services/valuation-service/valuation_service_pb.js +5 -7
- package/node/wrappers/models/portfolio/portfolio.js.map +1 -1
- package/node/wrappers/models/portfolio/portfolio.test.d.ts +2 -0
- package/node/wrappers/models/portfolio/portfolio.test.js +29 -0
- package/node/wrappers/models/portfolio/portfolio.test.js.map +1 -0
- package/node/wrappers/models/portfolio/portfolio.test.ts +28 -0
- package/node/wrappers/models/position/position.js +25 -13
- package/node/wrappers/models/position/position.js.map +1 -1
- package/node/wrappers/models/position/position.test.js +20 -0
- package/node/wrappers/models/position/position.test.js.map +1 -1
- package/node/wrappers/models/position/position.test.ts +23 -0
- package/node/wrappers/models/position/position.ts +27 -13
- package/node/wrappers/models/position/positionfilter.js +1 -1
- package/node/wrappers/models/position/positionfilter.js.map +1 -1
- package/node/wrappers/models/position/positionfilter.test.js.map +1 -1
- package/node/wrappers/models/price/Price.cash.test.d.ts +1 -0
- package/node/wrappers/models/price/Price.cash.test.js +42 -0
- package/node/wrappers/models/price/Price.cash.test.js.map +1 -0
- package/node/wrappers/models/price/Price.cash.test.ts +43 -0
- package/node/wrappers/models/price/Price.d.ts +38 -0
- package/node/wrappers/models/price/Price.js +111 -0
- package/node/wrappers/models/price/Price.js.map +1 -0
- package/node/wrappers/models/price/Price.test.d.ts +1 -0
- package/node/wrappers/models/price/Price.test.js +55 -0
- package/node/wrappers/models/price/Price.test.js.map +1 -0
- package/node/wrappers/models/price/Price.test.ts +63 -0
- package/node/wrappers/models/price/Price.ts +123 -0
- package/node/wrappers/models/security/BondSecurity.d.ts +17 -2
- package/node/wrappers/models/security/BondSecurity.js +59 -11
- package/node/wrappers/models/security/BondSecurity.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.priceScale.test.d.ts +1 -0
- package/node/wrappers/models/security/BondSecurity.priceScale.test.js +36 -0
- package/node/wrappers/models/security/BondSecurity.priceScale.test.js.map +1 -0
- package/node/wrappers/models/security/BondSecurity.priceScale.test.ts +36 -0
- package/node/wrappers/models/security/BondSecurity.test.js +34 -1
- package/node/wrappers/models/security/BondSecurity.test.js.map +1 -1
- package/node/wrappers/models/security/BondSecurity.test.ts +42 -1
- package/node/wrappers/models/security/BondSecurity.ts +63 -11
- package/node/wrappers/models/security/security-roundtrip.test.d.ts +1 -0
- package/node/wrappers/models/security/security-roundtrip.test.js +173 -0
- package/node/wrappers/models/security/security-roundtrip.test.js.map +1 -0
- package/node/wrappers/models/security/security-roundtrip.test.ts +192 -0
- package/node/wrappers/models/security/security.d.ts +8 -0
- package/node/wrappers/models/security/security.js +24 -2
- package/node/wrappers/models/security/security.js.map +1 -1
- package/node/wrappers/models/security/security.ts +26 -2
- package/node/wrappers/models/security/term.js +31 -6
- package/node/wrappers/models/security/term.js.map +1 -1
- package/node/wrappers/models/security/term.test.js +21 -2
- package/node/wrappers/models/security/term.test.js.map +1 -1
- package/node/wrappers/models/security/term.test.ts +28 -2
- package/node/wrappers/models/security/term.ts +34 -6
- package/node/wrappers/models/transaction/transaction.d.ts +59 -1
- package/node/wrappers/models/transaction/transaction.derived.test.d.ts +1 -0
- package/node/wrappers/models/transaction/transaction.derived.test.js +199 -0
- package/node/wrappers/models/transaction/transaction.derived.test.js.map +1 -0
- package/node/wrappers/models/transaction/transaction.derived.test.ts +251 -0
- package/node/wrappers/models/transaction/transaction.js +350 -2
- package/node/wrappers/models/transaction/transaction.js.map +1 -1
- package/node/wrappers/models/transaction/transaction.ts +416 -2
- package/node/wrappers/models/transaction/transaction_constructor.test.d.ts +1 -0
- package/node/wrappers/models/transaction/transaction_constructor.test.js +100 -0
- package/node/wrappers/models/transaction/transaction_constructor.test.js.map +1 -0
- package/node/wrappers/models/transaction/transaction_constructor.test.ts +111 -0
- package/node/wrappers/models/transaction/transaction_type.js.map +1 -1
- package/node/wrappers/models/utils/datetime.d.ts +6 -0
- package/node/wrappers/models/utils/datetime.js +14 -6
- package/node/wrappers/models/utils/datetime.js.map +1 -1
- package/node/wrappers/models/utils/datetime.ts +15 -6
- package/node/wrappers/models/utils/protoEnum.js.map +1 -1
- package/node/wrappers/models/utils/requestcontext.d.ts +17 -3
- package/node/wrappers/models/utils/requestcontext.js +39 -7
- package/node/wrappers/models/utils/requestcontext.js.map +1 -1
- package/node/wrappers/models/utils/requestcontext.test.d.ts +1 -0
- package/node/wrappers/models/utils/requestcontext.test.js +108 -0
- package/node/wrappers/models/utils/requestcontext.test.js.map +1 -0
- package/node/wrappers/models/utils/requestcontext.test.ts +85 -0
- package/node/wrappers/models/utils/requestcontext.ts +49 -9
- package/node/wrappers/models/utils/serialization.d.ts +2 -1
- package/node/wrappers/models/utils/serialization.js +4 -0
- package/node/wrappers/models/utils/serialization.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.js +15 -0
- package/node/wrappers/models/utils/serialization.test.js.map +1 -1
- package/node/wrappers/models/utils/serialization.test.ts +19 -1
- package/node/wrappers/models/utils/serialization.ts +5 -4
- package/node/wrappers/models/utils/serialization.util.js.map +1 -1
- package/node/wrappers/models/utils/uuid.js +9 -1
- package/node/wrappers/models/utils/uuid.js.map +1 -1
- package/node/wrappers/models/utils/uuid.test.js +22 -4
- package/node/wrappers/models/utils/uuid.test.js.map +1 -1
- package/node/wrappers/models/utils/uuid.test.ts +26 -5
- package/node/wrappers/models/utils/uuid.ts +7 -1
- package/node/wrappers/services/apikey.test.d.ts +7 -0
- package/node/wrappers/services/apikey.test.js +56 -0
- package/node/wrappers/services/apikey.test.js.map +1 -0
- package/node/wrappers/services/apikey.test.ts +65 -0
- package/node/wrappers/services/portfolio-service/PortfolioService.d.ts +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.js +8 -2
- package/node/wrappers/services/portfolio-service/PortfolioService.js.map +1 -1
- package/node/wrappers/services/portfolio-service/PortfolioService.ts +7 -2
- package/node/wrappers/services/position-service/PositionService.d.ts +1 -1
- package/node/wrappers/services/position-service/PositionService.js +8 -2
- package/node/wrappers/services/position-service/PositionService.js.map +1 -1
- package/node/wrappers/services/position-service/PositionService.ts +7 -2
- package/node/wrappers/services/position-service/position.test.js.map +1 -1
- package/node/wrappers/services/price-service/PriceService.d.ts +29 -0
- package/node/wrappers/services/price-service/PriceService.js +151 -0
- package/node/wrappers/services/price-service/PriceService.js.map +1 -0
- package/node/wrappers/services/price-service/PriceService.ts +127 -0
- package/node/wrappers/services/price-service/price-wrapper.test.d.ts +1 -0
- package/node/wrappers/services/price-service/price-wrapper.test.js +132 -0
- package/node/wrappers/services/price-service/price-wrapper.test.js.map +1 -0
- package/node/wrappers/services/price-service/price-wrapper.test.ts +120 -0
- package/node/wrappers/services/price-service/price.test.d.ts +1 -0
- package/node/wrappers/services/price-service/price.test.js +198 -0
- package/node/wrappers/services/price-service/price.test.js.map +1 -0
- package/node/wrappers/services/price-service/price.test.ts +205 -0
- package/node/wrappers/services/security-service/SecurityService.d.ts +1 -1
- package/node/wrappers/services/security-service/SecurityService.js +8 -2
- package/node/wrappers/services/security-service/SecurityService.js.map +1 -1
- package/node/wrappers/services/security-service/SecurityService.searchByUuid.test.d.ts +1 -0
- package/node/wrappers/services/security-service/SecurityService.searchByUuid.test.js +38 -0
- package/node/wrappers/services/security-service/SecurityService.searchByUuid.test.js.map +1 -0
- package/node/wrappers/services/security-service/SecurityService.searchByUuid.test.ts +32 -0
- package/node/wrappers/services/security-service/SecurityService.ts +7 -2
- package/node/wrappers/services/security-service/security.maturityLadder.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.d.ts +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.js +8 -2
- package/node/wrappers/services/transaction-service/TransactionService.js.map +1 -1
- package/node/wrappers/services/transaction-service/TransactionService.ts +7 -2
- package/node/wrappers/services/transaction-service/transaction.search.test.js.map +1 -1
- package/node/wrappers/services/transaction-service/transaction.test.js.map +1 -1
- package/package.json +3 -2
- package/.env +0 -3
|
@@ -0,0 +1,111 @@
|
|
|
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 price_pb_1 = require("../../../fintekkers/models/price/price_pb");
|
|
7
|
+
const price_type_pb_1 = require("../../../fintekkers/models/price/price_type_pb");
|
|
8
|
+
const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
9
|
+
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
10
|
+
const security_1 = __importDefault(require("../security/security"));
|
|
11
|
+
const datetime_1 = require("../utils/datetime");
|
|
12
|
+
const uuid_1 = require("../utils/uuid");
|
|
13
|
+
const decimal_js_1 = require("decimal.js");
|
|
14
|
+
class Price {
|
|
15
|
+
constructor(proto) {
|
|
16
|
+
this.proto = proto;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Simple factory: create a Price from a security UUID string, a numeric price, and a Date.
|
|
20
|
+
* This is the primary entry point for callers who just want:
|
|
21
|
+
* new Price(uuid, 99.5, date)
|
|
22
|
+
*
|
|
23
|
+
* @param securityId - UUID string of the security (e.g. "18e8c4e6-3da0-47c9-...")
|
|
24
|
+
* @param price - The price as a number (e.g. 99.5)
|
|
25
|
+
* @param date - A JavaScript Date for when this price is effective
|
|
26
|
+
* @param priceType - Optional price type, defaults to PERCENTAGE
|
|
27
|
+
*/
|
|
28
|
+
static fromSimple(securityId, price, date, priceType = price_type_pb_1.PriceTypeProto.PERCENTAGE) {
|
|
29
|
+
const decimalValueProto = new decimal_value_pb_1.DecimalValueProto();
|
|
30
|
+
decimalValueProto.setArbitraryPrecisionValue(price.toString());
|
|
31
|
+
const securityProto = new security_pb_1.SecurityProto();
|
|
32
|
+
securityProto.setUuid(new uuid_1.UUID(uuid_1.UUID.fromString(securityId)).toUUIDProto());
|
|
33
|
+
securityProto.setIsLink(true);
|
|
34
|
+
const priceProto = new price_pb_1.PriceProto();
|
|
35
|
+
priceProto.setObjectClass('Price');
|
|
36
|
+
priceProto.setVersion('0.0.1');
|
|
37
|
+
priceProto.setUuid(uuid_1.UUID.random().toUUIDProto());
|
|
38
|
+
priceProto.setAsOf(datetime_1.ZonedDateTime.from(date).toProto());
|
|
39
|
+
priceProto.setPrice(decimalValueProto);
|
|
40
|
+
priceProto.setSecurity(securityProto);
|
|
41
|
+
priceProto.setPriceType(priceType);
|
|
42
|
+
return new Price(priceProto);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Factory method to create a Price from a Decimal value, Security, and ZonedDateTime
|
|
46
|
+
*/
|
|
47
|
+
static create(price, security, asOf) {
|
|
48
|
+
const decimalValueProto = new decimal_value_pb_1.DecimalValueProto();
|
|
49
|
+
decimalValueProto.setArbitraryPrecisionValue(price.toString());
|
|
50
|
+
const priceProto = new price_pb_1.PriceProto();
|
|
51
|
+
priceProto.setPrice(decimalValueProto);
|
|
52
|
+
priceProto.setObjectClass('Price');
|
|
53
|
+
priceProto.setVersion('0.0.1');
|
|
54
|
+
priceProto.setAsOf(asOf.toProto());
|
|
55
|
+
priceProto.setUuid(uuid_1.UUID.random().toUUIDProto());
|
|
56
|
+
priceProto.setSecurity(security.proto);
|
|
57
|
+
return new Price(priceProto);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a cash price (always 1.0) for a cash security
|
|
61
|
+
*/
|
|
62
|
+
static getCashPrice(cashSecurity, asOf) {
|
|
63
|
+
return Price.create(new decimal_js_1.Decimal('1.0'), cashSecurity, asOf);
|
|
64
|
+
}
|
|
65
|
+
getID() {
|
|
66
|
+
const uuid = this.proto.getUuid();
|
|
67
|
+
if (!uuid)
|
|
68
|
+
throw new Error("UUID is required");
|
|
69
|
+
return uuid_1.UUID.fromU8Array(uuid.getRawUuid_asU8());
|
|
70
|
+
}
|
|
71
|
+
getPrice() {
|
|
72
|
+
const priceValue = this.proto.getPrice();
|
|
73
|
+
if (!priceValue)
|
|
74
|
+
throw new Error("Price value is required");
|
|
75
|
+
return new decimal_js_1.Decimal(priceValue.getArbitraryPrecisionValue());
|
|
76
|
+
}
|
|
77
|
+
getPriceType() {
|
|
78
|
+
return this.proto.getPriceType();
|
|
79
|
+
}
|
|
80
|
+
getSecurity() {
|
|
81
|
+
const securityProto = this.proto.getSecurity();
|
|
82
|
+
if (!securityProto)
|
|
83
|
+
throw new Error("Security is required");
|
|
84
|
+
return security_1.default.create(securityProto);
|
|
85
|
+
}
|
|
86
|
+
getSecurityID() {
|
|
87
|
+
const securityProto = this.proto.getSecurity();
|
|
88
|
+
if (!securityProto)
|
|
89
|
+
throw new Error("Security is required");
|
|
90
|
+
const uuid = securityProto.getUuid();
|
|
91
|
+
if (!uuid)
|
|
92
|
+
throw new Error("Security UUID is required");
|
|
93
|
+
return uuid_1.UUID.fromU8Array(uuid.getRawUuid_asU8());
|
|
94
|
+
}
|
|
95
|
+
getAsOf() {
|
|
96
|
+
const asOf = this.proto.getAsOf();
|
|
97
|
+
if (!asOf)
|
|
98
|
+
throw new Error("AsOf is required");
|
|
99
|
+
return new datetime_1.ZonedDateTime(asOf);
|
|
100
|
+
}
|
|
101
|
+
toString() {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
const priceStr = (_b = (_a = this.proto.getPrice()) === null || _a === void 0 ? void 0 : _a.getArbitraryPrecisionValue()) !== null && _b !== void 0 ? _b : 'N/A';
|
|
104
|
+
return `Price[${priceStr}, securityId=${this.getSecurityID().toString()}]`;
|
|
105
|
+
}
|
|
106
|
+
equals(other) {
|
|
107
|
+
return this.getID().equals(other.getID());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.default = Price;
|
|
111
|
+
//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Aa,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC;IAC/E,CAAC;IAED,MAAM,CAAC,KAAY;QACf,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;CACJ;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 Price_1 = __importDefault(require("./Price"));
|
|
7
|
+
const price_type_pb_1 = require("../../../fintekkers/models/price/price_type_pb");
|
|
8
|
+
const decimal_js_1 = require("decimal.js");
|
|
9
|
+
const TEST_UUID = '18e8c4e6-3da0-47c9-b26d-c5ea8b8dce95';
|
|
10
|
+
test('Price.fromSimple creates a Price with correct values', () => {
|
|
11
|
+
const date = new Date('2026-03-15T12:00:00Z');
|
|
12
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 99.5, date);
|
|
13
|
+
expect(price.getPrice().equals(new decimal_js_1.Decimal('99.5'))).toBe(true);
|
|
14
|
+
expect(price.getSecurityID().toString()).toBe(TEST_UUID);
|
|
15
|
+
expect(price.getAsOf()).toBeTruthy();
|
|
16
|
+
expect(price.getID()).toBeTruthy();
|
|
17
|
+
expect(price.getPriceType()).toBe(price_type_pb_1.PriceTypeProto.PERCENTAGE);
|
|
18
|
+
});
|
|
19
|
+
test('Price.fromSimple accepts a custom price type', () => {
|
|
20
|
+
const date = new Date();
|
|
21
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 250, date, price_type_pb_1.PriceTypeProto.INDEX_LEVEL);
|
|
22
|
+
expect(price.getPriceType()).toBe(price_type_pb_1.PriceTypeProto.INDEX_LEVEL);
|
|
23
|
+
expect(price.getPrice().equals(new decimal_js_1.Decimal('250'))).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
test('Price.fromSimple sets security as link reference', () => {
|
|
26
|
+
var _a;
|
|
27
|
+
const date = new Date();
|
|
28
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 100.25, date);
|
|
29
|
+
expect((_a = price.proto.getSecurity()) === null || _a === void 0 ? void 0 : _a.getIsLink()).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
test('Price.toString returns a readable string', () => {
|
|
32
|
+
const date = new Date();
|
|
33
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 99.875, date);
|
|
34
|
+
const str = price.toString();
|
|
35
|
+
expect(str).toContain('99.875');
|
|
36
|
+
expect(str).toContain(TEST_UUID);
|
|
37
|
+
});
|
|
38
|
+
test('Price.getID returns a valid UUID', () => {
|
|
39
|
+
const date = new Date();
|
|
40
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 99.5, date);
|
|
41
|
+
const id = price.getID();
|
|
42
|
+
// UUID toString should return a valid UUID string (8-4-4-4-12 format)
|
|
43
|
+
expect(id.toString()).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
|
|
44
|
+
});
|
|
45
|
+
test('Price proto has all required fields set', () => {
|
|
46
|
+
const date = new Date();
|
|
47
|
+
const price = Price_1.default.fromSimple(TEST_UUID, 50.0, date);
|
|
48
|
+
expect(price.proto.getObjectClass()).toBe('Price');
|
|
49
|
+
expect(price.proto.getVersion()).toBe('0.0.1');
|
|
50
|
+
expect(price.proto.getUuid()).toBeTruthy();
|
|
51
|
+
expect(price.proto.getAsOf()).toBeTruthy();
|
|
52
|
+
expect(price.proto.getPrice()).toBeTruthy();
|
|
53
|
+
expect(price.proto.getSecurity()).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=Price.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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E;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG,eAAK,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAEtD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;IAC3C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;IAC3C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Price from './Price';
|
|
2
|
+
import { PriceTypeProto } from '../../../fintekkers/models/price/price_type_pb';
|
|
3
|
+
import { Decimal } from 'decimal.js';
|
|
4
|
+
|
|
5
|
+
const TEST_UUID = '18e8c4e6-3da0-47c9-b26d-c5ea8b8dce95';
|
|
6
|
+
|
|
7
|
+
test('Price.fromSimple creates a Price with correct values', () => {
|
|
8
|
+
const date = new Date('2026-03-15T12:00:00Z');
|
|
9
|
+
const price = Price.fromSimple(TEST_UUID, 99.5, date);
|
|
10
|
+
|
|
11
|
+
expect(price.getPrice().equals(new Decimal('99.5'))).toBe(true);
|
|
12
|
+
expect(price.getSecurityID().toString()).toBe(TEST_UUID);
|
|
13
|
+
expect(price.getAsOf()).toBeTruthy();
|
|
14
|
+
expect(price.getID()).toBeTruthy();
|
|
15
|
+
expect(price.getPriceType()).toBe(PriceTypeProto.PERCENTAGE);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('Price.fromSimple accepts a custom price type', () => {
|
|
19
|
+
const date = new Date();
|
|
20
|
+
const price = Price.fromSimple(TEST_UUID, 250, date, PriceTypeProto.INDEX_LEVEL);
|
|
21
|
+
|
|
22
|
+
expect(price.getPriceType()).toBe(PriceTypeProto.INDEX_LEVEL);
|
|
23
|
+
expect(price.getPrice().equals(new Decimal('250'))).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('Price.fromSimple sets security as link reference', () => {
|
|
27
|
+
const date = new Date();
|
|
28
|
+
const price = Price.fromSimple(TEST_UUID, 100.25, date);
|
|
29
|
+
|
|
30
|
+
expect(price.proto.getSecurity()?.getIsLink()).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('Price.toString returns a readable string', () => {
|
|
34
|
+
const date = new Date();
|
|
35
|
+
const price = Price.fromSimple(TEST_UUID, 99.875, date);
|
|
36
|
+
|
|
37
|
+
const str = price.toString();
|
|
38
|
+
expect(str).toContain('99.875');
|
|
39
|
+
expect(str).toContain(TEST_UUID);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('Price.getID returns a valid UUID', () => {
|
|
43
|
+
const date = new Date();
|
|
44
|
+
const price = Price.fromSimple(TEST_UUID, 99.5, date);
|
|
45
|
+
|
|
46
|
+
const id = price.getID();
|
|
47
|
+
// UUID toString should return a valid UUID string (8-4-4-4-12 format)
|
|
48
|
+
expect(id.toString()).toMatch(
|
|
49
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('Price proto has all required fields set', () => {
|
|
54
|
+
const date = new Date();
|
|
55
|
+
const price = Price.fromSimple(TEST_UUID, 50.0, date);
|
|
56
|
+
|
|
57
|
+
expect(price.proto.getObjectClass()).toBe('Price');
|
|
58
|
+
expect(price.proto.getVersion()).toBe('0.0.1');
|
|
59
|
+
expect(price.proto.getUuid()).toBeTruthy();
|
|
60
|
+
expect(price.proto.getAsOf()).toBeTruthy();
|
|
61
|
+
expect(price.proto.getPrice()).toBeTruthy();
|
|
62
|
+
expect(price.proto.getSecurity()).toBeTruthy();
|
|
63
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { PriceProto } from "../../../fintekkers/models/price/price_pb";
|
|
2
|
+
import { PriceTypeProto } from "../../../fintekkers/models/price/price_type_pb";
|
|
3
|
+
import { DecimalValueProto } from "../../../fintekkers/models/util/decimal_value_pb";
|
|
4
|
+
import { SecurityProto } from "../../../fintekkers/models/security/security_pb";
|
|
5
|
+
import Security from "../security/security";
|
|
6
|
+
import { ZonedDateTime } from "../utils/datetime";
|
|
7
|
+
import { UUID } from "../utils/uuid";
|
|
8
|
+
import { Decimal } from "decimal.js";
|
|
9
|
+
|
|
10
|
+
class Price {
|
|
11
|
+
proto: PriceProto;
|
|
12
|
+
|
|
13
|
+
constructor(proto: PriceProto) {
|
|
14
|
+
this.proto = proto;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Simple factory: create a Price from a security UUID string, a numeric price, and a Date.
|
|
19
|
+
* This is the primary entry point for callers who just want:
|
|
20
|
+
* new Price(uuid, 99.5, date)
|
|
21
|
+
*
|
|
22
|
+
* @param securityId - UUID string of the security (e.g. "18e8c4e6-3da0-47c9-...")
|
|
23
|
+
* @param price - The price as a number (e.g. 99.5)
|
|
24
|
+
* @param date - A JavaScript Date for when this price is effective
|
|
25
|
+
* @param priceType - Optional price type, defaults to PERCENTAGE
|
|
26
|
+
*/
|
|
27
|
+
static fromSimple(
|
|
28
|
+
securityId: string,
|
|
29
|
+
price: number,
|
|
30
|
+
date: Date,
|
|
31
|
+
priceType: PriceTypeProto = PriceTypeProto.PERCENTAGE
|
|
32
|
+
): Price {
|
|
33
|
+
const decimalValueProto = new DecimalValueProto();
|
|
34
|
+
decimalValueProto.setArbitraryPrecisionValue(price.toString());
|
|
35
|
+
|
|
36
|
+
const securityProto = new SecurityProto();
|
|
37
|
+
securityProto.setUuid(new UUID(UUID.fromString(securityId)).toUUIDProto());
|
|
38
|
+
securityProto.setIsLink(true);
|
|
39
|
+
|
|
40
|
+
const priceProto = new PriceProto();
|
|
41
|
+
priceProto.setObjectClass('Price');
|
|
42
|
+
priceProto.setVersion('0.0.1');
|
|
43
|
+
priceProto.setUuid(UUID.random().toUUIDProto());
|
|
44
|
+
priceProto.setAsOf(ZonedDateTime.from(date).toProto());
|
|
45
|
+
priceProto.setPrice(decimalValueProto);
|
|
46
|
+
priceProto.setSecurity(securityProto);
|
|
47
|
+
priceProto.setPriceType(priceType);
|
|
48
|
+
|
|
49
|
+
return new Price(priceProto);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Factory method to create a Price from a Decimal value, Security, and ZonedDateTime
|
|
54
|
+
*/
|
|
55
|
+
static create(price: Decimal, security: Security, asOf: ZonedDateTime): Price {
|
|
56
|
+
const decimalValueProto = new DecimalValueProto();
|
|
57
|
+
decimalValueProto.setArbitraryPrecisionValue(price.toString());
|
|
58
|
+
|
|
59
|
+
const priceProto = new PriceProto();
|
|
60
|
+
priceProto.setPrice(decimalValueProto);
|
|
61
|
+
priceProto.setObjectClass('Price');
|
|
62
|
+
priceProto.setVersion('0.0.1');
|
|
63
|
+
priceProto.setAsOf(asOf.toProto());
|
|
64
|
+
priceProto.setUuid(UUID.random().toUUIDProto());
|
|
65
|
+
priceProto.setSecurity(security.proto);
|
|
66
|
+
|
|
67
|
+
return new Price(priceProto);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Creates a cash price (always 1.0) for a cash security
|
|
72
|
+
*/
|
|
73
|
+
static getCashPrice(cashSecurity: Security, asOf: ZonedDateTime): Price {
|
|
74
|
+
return Price.create(new Decimal('1.0'), cashSecurity, asOf);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getID(): UUID {
|
|
78
|
+
const uuid = this.proto.getUuid();
|
|
79
|
+
if (!uuid) throw new Error("UUID is required");
|
|
80
|
+
return UUID.fromU8Array(uuid.getRawUuid_asU8());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getPrice(): Decimal {
|
|
84
|
+
const priceValue = this.proto.getPrice();
|
|
85
|
+
if (!priceValue) throw new Error("Price value is required");
|
|
86
|
+
return new Decimal(priceValue.getArbitraryPrecisionValue());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getPriceType(): PriceTypeProto {
|
|
90
|
+
return this.proto.getPriceType();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getSecurity(): Security {
|
|
94
|
+
const securityProto = this.proto.getSecurity();
|
|
95
|
+
if (!securityProto) throw new Error("Security is required");
|
|
96
|
+
return Security.create(securityProto);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getSecurityID(): UUID {
|
|
100
|
+
const securityProto = this.proto.getSecurity();
|
|
101
|
+
if (!securityProto) throw new Error("Security is required");
|
|
102
|
+
const uuid = securityProto.getUuid();
|
|
103
|
+
if (!uuid) throw new Error("Security UUID is required");
|
|
104
|
+
return UUID.fromU8Array(uuid.getRawUuid_asU8());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getAsOf(): ZonedDateTime {
|
|
108
|
+
const asOf = this.proto.getAsOf();
|
|
109
|
+
if (!asOf) throw new Error("AsOf is required");
|
|
110
|
+
return new ZonedDateTime(asOf);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
toString(): string {
|
|
114
|
+
const priceStr = this.proto.getPrice()?.getArbitraryPrecisionValue() ?? 'N/A';
|
|
115
|
+
return `Price[${priceStr}, securityId=${this.getSecurityID().toString()}]`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
equals(other: Price): boolean {
|
|
119
|
+
return this.getID().equals(other.getID());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default Price;
|
|
@@ -6,10 +6,17 @@ import { IssuanceProto } from '../../../fintekkers/models/security/bond/issuance
|
|
|
6
6
|
import { CouponFrequency } from './coupon_frequency';
|
|
7
7
|
import { CouponType } from './coupon_type';
|
|
8
8
|
import { Tenor } from './term';
|
|
9
|
+
import { Decimal } from 'decimal.js';
|
|
9
10
|
declare class BondSecurity extends Security {
|
|
10
11
|
constructor(proto: SecurityProto);
|
|
11
|
-
/** Returns the tenor (term) of the bond as a Tenor object
|
|
12
|
-
|
|
12
|
+
/** Returns the tenor (term) of the bond as a Tenor object.
|
|
13
|
+
*
|
|
14
|
+
* If an 'as of date' is provided the term will be based on
|
|
15
|
+
* maturity date - as of date, instead of maturity date - issue date.
|
|
16
|
+
* @param asOfDate - [Optional]The 'as of date' to use for the tenor calculation.
|
|
17
|
+
* @returns The tenor (term) of the bond as a Tenor object.
|
|
18
|
+
*/
|
|
19
|
+
getTenor(asOfDate?: Date): Tenor;
|
|
13
20
|
/**
|
|
14
21
|
* Calculates the period between two dates in years, months, and days.
|
|
15
22
|
* This method handles month and year boundaries correctly.
|
|
@@ -21,5 +28,13 @@ declare class BondSecurity extends Security {
|
|
|
21
28
|
getCouponFrequency(): CouponFrequency;
|
|
22
29
|
getDatedDate(): LocalDate | undefined;
|
|
23
30
|
getIssuanceInfo(): IssuanceProto[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns the price scale factor for bonds.
|
|
33
|
+
* Bonds are typically priced as percentages (e.g., 99.5 means 99.5%),
|
|
34
|
+
* so the price scale factor converts percentage to decimal (0.01).
|
|
35
|
+
* @returns The price scale factor as a Decimal (0.01)
|
|
36
|
+
*/
|
|
37
|
+
getPriceScaleFactor(): Decimal;
|
|
38
|
+
getProductType(): string;
|
|
24
39
|
}
|
|
25
40
|
export default BondSecurity;
|
|
@@ -10,19 +10,26 @@ const coupon_frequency_1 = require("./coupon_frequency");
|
|
|
10
10
|
const coupon_type_1 = require("./coupon_type");
|
|
11
11
|
const term_1 = require("./term");
|
|
12
12
|
const tenor_type_pb_1 = require("../../../fintekkers/models/security/tenor_type_pb");
|
|
13
|
+
const decimal_js_1 = require("decimal.js");
|
|
13
14
|
class BondSecurity extends security_1.default {
|
|
14
15
|
constructor(proto) {
|
|
15
16
|
super(proto);
|
|
16
|
-
if (proto.getSecurityType() !== security_type_pb_1.SecurityTypeProto.BOND_SECURITY) {
|
|
17
|
+
if (proto.getSecurityType() !== security_type_pb_1.SecurityTypeProto.BOND_SECURITY && proto.getSecurityType() !== security_type_pb_1.SecurityTypeProto.TIPS && proto.getSecurityType() !== security_type_pb_1.SecurityTypeProto.FRN) {
|
|
17
18
|
throw new Error(`BondSecurity requires BOND_SECURITY type, got ${security_type_pb_1.SecurityTypeProto[proto.getSecurityType()]}`);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
/** Returns the tenor (term) of the bond as a Tenor object
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/** Returns the tenor (term) of the bond as a Tenor object.
|
|
22
|
+
*
|
|
23
|
+
* If an 'as of date' is provided the term will be based on
|
|
24
|
+
* maturity date - as of date, instead of maturity date - issue date.
|
|
25
|
+
* @param asOfDate - [Optional]The 'as of date' to use for the tenor calculation.
|
|
26
|
+
* @returns The tenor (term) of the bond as a Tenor object.
|
|
27
|
+
*/
|
|
28
|
+
getTenor(asOfDate) {
|
|
29
|
+
const startDate = asOfDate ? asOfDate : this.getIssueDate().toDate();
|
|
23
30
|
const maturityDate = this.getMaturityDate().toDate();
|
|
24
31
|
// Calculate the period between issue date and maturity date
|
|
25
|
-
const period = this.calculatePeriod(
|
|
32
|
+
const period = this.calculatePeriod(startDate, maturityDate);
|
|
26
33
|
return new term_1.Tenor(tenor_type_pb_1.TenorTypeProto.TERM, period);
|
|
27
34
|
}
|
|
28
35
|
/**
|
|
@@ -52,35 +59,76 @@ class BondSecurity extends security_1.default {
|
|
|
52
59
|
};
|
|
53
60
|
}
|
|
54
61
|
getCouponRate() {
|
|
55
|
-
const
|
|
62
|
+
const bond = this.getBondLikeDetails();
|
|
63
|
+
const rate = bond ? bond.getCouponRate() : this.proto.getCouponRate();
|
|
56
64
|
if (!rate)
|
|
57
65
|
throw new Error("Coupon rate is required for bonds");
|
|
58
66
|
return rate;
|
|
59
67
|
}
|
|
60
68
|
getFaceValue() {
|
|
61
|
-
const
|
|
69
|
+
const bond = this.getBondLikeDetails();
|
|
70
|
+
const faceValue = bond ? bond.getFaceValue() : this.proto.getFaceValue();
|
|
62
71
|
if (!faceValue)
|
|
63
72
|
throw new Error("Face value is required for bonds");
|
|
64
73
|
return faceValue;
|
|
65
74
|
}
|
|
66
75
|
getCouponType() {
|
|
67
|
-
const
|
|
76
|
+
const bond = this.getBondLikeDetails();
|
|
77
|
+
const couponType = bond ? bond.getCouponType() : this.proto.getCouponType();
|
|
68
78
|
if (!couponType)
|
|
69
79
|
throw new Error("Coupon Type is required for bonds");
|
|
70
80
|
return new coupon_type_1.CouponType(couponType);
|
|
71
81
|
}
|
|
72
82
|
getCouponFrequency() {
|
|
73
|
-
const
|
|
83
|
+
const bond = this.getBondLikeDetails();
|
|
84
|
+
const couponFrequency = bond ? bond.getCouponFrequency() : this.proto.getCouponFrequency();
|
|
74
85
|
if (!couponFrequency)
|
|
75
86
|
throw new Error("Coupon Frequency is required for bonds");
|
|
76
87
|
return new coupon_frequency_1.CouponFrequency(couponFrequency);
|
|
77
88
|
}
|
|
78
89
|
getDatedDate() {
|
|
79
|
-
const
|
|
90
|
+
const bond = this.getBondLikeDetails();
|
|
91
|
+
const datedDate = bond ? bond.getDatedDate() : this.proto.getDatedDate();
|
|
80
92
|
return datedDate ? new date_1.LocalDate(datedDate) : undefined;
|
|
81
93
|
}
|
|
82
94
|
getIssuanceInfo() {
|
|
83
|
-
|
|
95
|
+
const bond = this.getBondLikeDetails();
|
|
96
|
+
return bond ? bond.getIssuanceInfoList() : this.proto.getIssuanceInfoList();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the price scale factor for bonds.
|
|
100
|
+
* Bonds are typically priced as percentages (e.g., 99.5 means 99.5%),
|
|
101
|
+
* so the price scale factor converts percentage to decimal (0.01).
|
|
102
|
+
* @returns The price scale factor as a Decimal (0.01)
|
|
103
|
+
*/
|
|
104
|
+
getPriceScaleFactor() {
|
|
105
|
+
return new decimal_js_1.Decimal('0.01');
|
|
106
|
+
}
|
|
107
|
+
getProductType() {
|
|
108
|
+
// Only BondSecurity has getTenor implemented
|
|
109
|
+
// Check if getTenor method exists (it's only in BondSecurity)
|
|
110
|
+
if (typeof this.getTenor !== 'function') {
|
|
111
|
+
throw new Error('getProductType() is only supported for BondSecurity');
|
|
112
|
+
}
|
|
113
|
+
const tenor = this.getTenor();
|
|
114
|
+
if (!tenor) {
|
|
115
|
+
throw new Error('Tenor is required to determine product type');
|
|
116
|
+
}
|
|
117
|
+
const period = tenor.getTenor();
|
|
118
|
+
if (!period) {
|
|
119
|
+
throw new Error('Period is required to determine product type');
|
|
120
|
+
}
|
|
121
|
+
const years = period.years;
|
|
122
|
+
const months = period.months;
|
|
123
|
+
if (years < 1 || (years === 1 && months === 0)) {
|
|
124
|
+
return 'BILL';
|
|
125
|
+
}
|
|
126
|
+
else if (years > 19) {
|
|
127
|
+
return 'BOND';
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return 'NOTE';
|
|
131
|
+
}
|
|
84
132
|
}
|
|
85
133
|
}
|
|
86
134
|
exports.default = BondSecurity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,2FAAyF;AAEzF,wCAA0C;AAE1C,yDAAqD;AACrD,+CAA2C;AAC3C,iCAAuC;AACvC,qFAAmF;
|
|
1
|
+
{"version":3,"file":"BondSecurity.js","sourceRoot":"","sources":["BondSecurity.ts"],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AChD,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 assert = require("assert");
|
|
7
|
+
const BondSecurity_1 = __importDefault(require("./BondSecurity"));
|
|
8
|
+
const security_pb_1 = require("../../../fintekkers/models/security/security_pb");
|
|
9
|
+
const security_type_pb_1 = require("../../../fintekkers/models/security/security_type_pb");
|
|
10
|
+
const decimal_value_pb_1 = require("../../../fintekkers/models/util/decimal_value_pb");
|
|
11
|
+
const local_date_pb_1 = require("../../../fintekkers/models/util/local_date_pb");
|
|
12
|
+
const uuid_1 = require("../utils/uuid");
|
|
13
|
+
const datetime_1 = require("../utils/datetime");
|
|
14
|
+
const decimal_js_1 = require("decimal.js");
|
|
15
|
+
test('test BondSecurity getPriceScaleFactor', () => {
|
|
16
|
+
testGetPriceScaleFactor();
|
|
17
|
+
});
|
|
18
|
+
function testGetPriceScaleFactor() {
|
|
19
|
+
const bondSecurity = createDummyBondSecurity();
|
|
20
|
+
const priceScaleFactor = bondSecurity.getPriceScaleFactor();
|
|
21
|
+
// Price scale factor should be 0.01 for bonds
|
|
22
|
+
assert(priceScaleFactor.equals(new decimal_js_1.Decimal('0.01')), `Expected price scale factor 0.01, got ${priceScaleFactor.toString()}`);
|
|
23
|
+
}
|
|
24
|
+
function createDummyBondSecurity() {
|
|
25
|
+
const securityProto = new security_pb_1.SecurityProto();
|
|
26
|
+
securityProto.setObjectClass('Security');
|
|
27
|
+
securityProto.setVersion('0.0.1');
|
|
28
|
+
securityProto.setUuid(uuid_1.UUID.random().toUUIDProto());
|
|
29
|
+
securityProto.setSecurityType(security_type_pb_1.SecurityTypeProto.BOND_SECURITY);
|
|
30
|
+
securityProto.setAsOf(datetime_1.ZonedDateTime.now().toProto());
|
|
31
|
+
securityProto.setFaceValue(new decimal_value_pb_1.DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
32
|
+
securityProto.setIssueDate(new local_date_pb_1.LocalDateProto().setYear(2021).setMonth(1).setDay(1));
|
|
33
|
+
securityProto.setMaturityDate(new local_date_pb_1.LocalDateProto().setYear(2031).setMonth(1).setDay(1));
|
|
34
|
+
return new BondSecurity_1.default(securityProto);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=BondSecurity.priceScale.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BondSecurity.priceScale.test.js","sourceRoot":"","sources":["BondSecurity.priceScale.test.ts"],"names":[],"mappings":";;;;;AAAA,iCAAkC;AAClC,kEAA0C;AAC1C,iFAAgF;AAChF,2FAAyF;AACzF,uFAA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AAC,CAAC,CAAC,CAAC,CAAC;IAExF,OAAO,IAAI,sBAAY,CAAC,aAAa,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import assert = require('assert');
|
|
2
|
+
import BondSecurity from './BondSecurity';
|
|
3
|
+
import { SecurityProto } from '../../../fintekkers/models/security/security_pb';
|
|
4
|
+
import { SecurityTypeProto } from '../../../fintekkers/models/security/security_type_pb';
|
|
5
|
+
import { DecimalValueProto } from '../../../fintekkers/models/util/decimal_value_pb';
|
|
6
|
+
import { LocalDateProto } from '../../../fintekkers/models/util/local_date_pb';
|
|
7
|
+
import { UUID } from '../utils/uuid';
|
|
8
|
+
import { ZonedDateTime } from '../utils/datetime';
|
|
9
|
+
import { Decimal } from 'decimal.js';
|
|
10
|
+
|
|
11
|
+
test('test BondSecurity getPriceScaleFactor', () => {
|
|
12
|
+
testGetPriceScaleFactor();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function testGetPriceScaleFactor(): void {
|
|
16
|
+
const bondSecurity = createDummyBondSecurity();
|
|
17
|
+
const priceScaleFactor = bondSecurity.getPriceScaleFactor();
|
|
18
|
+
|
|
19
|
+
// Price scale factor should be 0.01 for bonds
|
|
20
|
+
assert(priceScaleFactor.equals(new Decimal('0.01')),
|
|
21
|
+
`Expected price scale factor 0.01, got ${priceScaleFactor.toString()}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function createDummyBondSecurity(): BondSecurity {
|
|
25
|
+
const securityProto = new SecurityProto();
|
|
26
|
+
securityProto.setObjectClass('Security');
|
|
27
|
+
securityProto.setVersion('0.0.1');
|
|
28
|
+
securityProto.setUuid(UUID.random().toUUIDProto());
|
|
29
|
+
securityProto.setSecurityType(SecurityTypeProto.BOND_SECURITY);
|
|
30
|
+
securityProto.setAsOf(ZonedDateTime.now().toProto());
|
|
31
|
+
securityProto.setFaceValue(new DecimalValueProto().setArbitraryPrecisionValue('1000.00'));
|
|
32
|
+
securityProto.setIssueDate(new LocalDateProto().setYear(2021).setMonth(1).setDay(1));
|
|
33
|
+
securityProto.setMaturityDate(new LocalDateProto().setYear(2031).setMonth(1).setDay(1));
|
|
34
|
+
|
|
35
|
+
return new BondSecurity(securityProto);
|
|
36
|
+
}
|