sec_id 5.1.0 → 6.0.0

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/CHANGELOG.md +38 -0
  4. data/MIGRATION.md +101 -0
  5. data/README.md +262 -15
  6. data/lib/sec_id/active_model.rb +144 -0
  7. data/lib/sec_id/base.rb +41 -1
  8. data/lib/sec_id/bic/country_codes.rb +46 -0
  9. data/lib/sec_id/bic.rb +123 -0
  10. data/lib/sec_id/cei.rb +19 -7
  11. data/lib/sec_id/cfi/attribute_set.rb +49 -0
  12. data/lib/sec_id/cfi/classification.rb +107 -0
  13. data/lib/sec_id/cfi/field.rb +56 -0
  14. data/lib/sec_id/cfi/tables.rb +1033 -0
  15. data/lib/sec_id/cfi.rb +153 -208
  16. data/lib/sec_id/cik.rb +13 -0
  17. data/lib/sec_id/concerns/checkable.rb +2 -2
  18. data/lib/sec_id/concerns/generatable.rb +71 -0
  19. data/lib/sec_id/concerns/normalizable.rb +1 -0
  20. data/lib/sec_id/concerns/validatable.rb +14 -3
  21. data/lib/sec_id/cusip.rb +18 -7
  22. data/lib/sec_id/deep_freeze.rb +18 -0
  23. data/lib/sec_id/detector.rb +28 -7
  24. data/lib/sec_id/dti.rb +104 -0
  25. data/lib/sec_id/errors.rb +7 -0
  26. data/lib/sec_id/figi.rb +18 -0
  27. data/lib/sec_id/fisn.rb +31 -0
  28. data/lib/sec_id/iban/country_rules.rb +7 -6
  29. data/lib/sec_id/iban.rb +26 -1
  30. data/lib/sec_id/isin.rb +20 -15
  31. data/lib/sec_id/lei.rb +13 -0
  32. data/lib/sec_id/occ.rb +21 -0
  33. data/lib/sec_id/railtie.rb +14 -0
  34. data/lib/sec_id/scanner.rb +140 -0
  35. data/lib/sec_id/sedol.rb +16 -0
  36. data/lib/sec_id/valoren.rb +13 -0
  37. data/lib/sec_id/version.rb +2 -1
  38. data/lib/sec_id/wkn.rb +16 -0
  39. data/lib/sec_id.rb +112 -32
  40. data/sec_id.gemspec +11 -5
  41. data/sig/manifest.yaml +8 -0
  42. data/sig/sec_id/base.rbs +72 -0
  43. data/sig/sec_id/bic/country_codes.rbs +5 -0
  44. data/sig/sec_id/bic.rbs +30 -0
  45. data/sig/sec_id/cei.rbs +26 -0
  46. data/sig/sec_id/cfi/attribute_set.rbs +68 -0
  47. data/sig/sec_id/cfi/classification.rbs +23 -0
  48. data/sig/sec_id/cfi/field.rbs +337 -0
  49. data/sig/sec_id/cfi/tables.rbs +68 -0
  50. data/sig/sec_id/cfi.rbs +56 -0
  51. data/sig/sec_id/cik.rbs +19 -0
  52. data/sig/sec_id/concerns/checkable.rbs +41 -0
  53. data/sig/sec_id/concerns/generatable.rbs +26 -0
  54. data/sig/sec_id/concerns/normalizable.rbs +34 -0
  55. data/sig/sec_id/concerns/validatable.rbs +42 -0
  56. data/sig/sec_id/cusip.rbs +29 -0
  57. data/sig/sec_id/deep_freeze.rbs +6 -0
  58. data/sig/sec_id/detector.rbs +35 -0
  59. data/sig/sec_id/dti.rbs +27 -0
  60. data/sig/sec_id/errors.rbs +28 -0
  61. data/sig/sec_id/figi.rbs +31 -0
  62. data/sig/sec_id/fisn.rbs +24 -0
  63. data/sig/sec_id/iban/country_rules.rbs +10 -0
  64. data/sig/sec_id/iban.rbs +54 -0
  65. data/sig/sec_id/isin.rbs +40 -0
  66. data/sig/sec_id/lei.rbs +33 -0
  67. data/sig/sec_id/occ.rbs +45 -0
  68. data/sig/sec_id/scanner.rbs +46 -0
  69. data/sig/sec_id/sedol.rbs +34 -0
  70. data/sig/sec_id/valoren.rbs +29 -0
  71. data/sig/sec_id/version.rbs +3 -0
  72. data/sig/sec_id/wkn.rbs +15 -0
  73. data/sig/sec_id.rbs +58 -0
  74. metadata +57 -7
  75. data/lib/sec_id/concerns/identifier_metadata.rb +0 -56
@@ -0,0 +1,337 @@
1
+ # Generated by `rake sig:cfi` from SecID::CFI::Tables. Do not edit by hand.
2
+ module SecID
3
+ class CFI < Base
4
+ # A single decoded CFI position (category, group, or one attribute).
5
+ class Field
6
+ attr_reader code: String
7
+ attr_reader name: Symbol
8
+ attr_reader label: String
9
+ attr_reader meaning: Symbol?
10
+
11
+ def initialize: (String code, Symbol name, String label, Array[Symbol] domain, ?meaning: Symbol?) -> void
12
+ def to_s: () -> String
13
+ def to_h: () -> Hash[Symbol, untyped]
14
+ def as_json: (*untyped) -> Hash[Symbol, untyped]
15
+
16
+ # Per-domain predicates — the union of every symbol a Field may hold. Each
17
+ # instance only answers the symbols in its own domain; an out-of-domain call
18
+ # raises NoMethodError at runtime (RBS can't express per-instance domains).
19
+ def accreting?: () -> bool
20
+ def accumulation_funds?: () -> bool
21
+ def adjustable_rate?: () -> bool
22
+ def agriculture?: () -> bool
23
+ def allotment_rights?: () -> bool
24
+ def american?: () -> bool
25
+ def american_call?: () -> bool
26
+ def american_chooser?: () -> bool
27
+ def american_put?: () -> bool
28
+ def amortization_plan?: () -> bool
29
+ def amortization_with_call?: () -> bool
30
+ def amortization_with_put?: () -> bool
31
+ def amortization_with_put_and_call?: () -> bool
32
+ def amortizing?: () -> bool
33
+ def annually?: () -> bool
34
+ def arbitrage?: () -> bool
35
+ def asian?: () -> bool
36
+ def asset_backed?: () -> bool
37
+ def asset_backed_securities?: () -> bool
38
+ def asset_based_lending?: () -> bool
39
+ def auction?: () -> bool
40
+ def auction_rate?: () -> bool
41
+ def balanced_conservative?: () -> bool
42
+ def bank_loan?: () -> bool
43
+ def barrier?: () -> bool
44
+ def barrier_capital_protection?: () -> bool
45
+ def barrier_discount_certificate?: () -> bool
46
+ def barrier_instrument_based?: () -> bool
47
+ def barrier_reverse_convertible?: () -> bool
48
+ def barrier_underlying_based?: () -> bool
49
+ def basis_swap?: () -> bool
50
+ def basket?: () -> bool
51
+ def baskets?: () -> bool
52
+ def bearer?: () -> bool
53
+ def bearer_registered?: () -> bool
54
+ def bermudan?: () -> bool
55
+ def bermudan_call?: () -> bool
56
+ def bermudan_chooser?: () -> bool
57
+ def bermudan_put?: () -> bool
58
+ def bonds?: () -> bool
59
+ def bonds_with_warrants?: () -> bool
60
+ def bonus_certificate?: () -> bool
61
+ def bullion_coins?: () -> bool
62
+ def call?: () -> bool
63
+ def call_and_put?: () -> bool
64
+ def call_options?: () -> bool
65
+ def capital_protection_convertible?: () -> bool
66
+ def capital_protection_with_coupons?: () -> bool
67
+ def capital_protection_with_participation?: () -> bool
68
+ def capitalization_weighted?: () -> bool
69
+ def carbon_credit?: () -> bool
70
+ def cash?: () -> bool
71
+ def cash_collateral?: () -> bool
72
+ def cash_payment?: () -> bool
73
+ def cash_repayment?: () -> bool
74
+ def cds_basket?: () -> bool
75
+ def cds_index?: () -> bool
76
+ def cds_index_tranche?: () -> bool
77
+ def cds_single_name?: () -> bool
78
+ def certificate_of_deposit?: () -> bool
79
+ def closed_end?: () -> bool
80
+ def collective_investment_vehicles?: () -> bool
81
+ def combination_of_bonds?: () -> bool
82
+ def combination_of_shares?: () -> bool
83
+ def combined_instruments?: () -> bool
84
+ def commercial_property?: () -> bool
85
+ def commodities?: () -> bool
86
+ def commodities_futures?: () -> bool
87
+ def common_shares?: () -> bool
88
+ def constant?: () -> bool
89
+ def contract_for_difference?: () -> bool
90
+ def convertible?: () -> bool
91
+ def convertible_bonds?: () -> bool
92
+ def convertible_common_shares?: () -> bool
93
+ def convertible_preferred_shares?: () -> bool
94
+ def convertible_redeemable?: () -> bool
95
+ def convertible_securities?: () -> bool
96
+ def corporate?: () -> bool
97
+ def corporate_bonds?: () -> bool
98
+ def covered?: () -> bool
99
+ def credit?: () -> bool
100
+ def credit_default?: () -> bool
101
+ def credits?: () -> bool
102
+ def cross_currency?: () -> bool
103
+ def cumulative_fixed_rate?: () -> bool
104
+ def cumulative_participating?: () -> bool
105
+ def currencies?: () -> bool
106
+ def custom?: () -> bool
107
+ def daily?: () -> bool
108
+ def debt?: () -> bool
109
+ def debt_instruments?: () -> bool
110
+ def defined_benefit?: () -> bool
111
+ def defined_contribution?: () -> bool
112
+ def delivery_versus_payment?: () -> bool
113
+ def depositary_receipts?: () -> bool
114
+ def derivatives?: () -> bool
115
+ def digital?: () -> bool
116
+ def digital_barrier?: () -> bool
117
+ def directional?: () -> bool
118
+ def discount_certificate?: () -> bool
119
+ def dividend?: () -> bool
120
+ def dividend_payments?: () -> bool
121
+ def dividends?: () -> bool
122
+ def elect_at_exercise?: () -> bool
123
+ def elect_at_settlement?: () -> bool
124
+ def energy?: () -> bool
125
+ def enhanced_voting?: () -> bool
126
+ def entitlements?: () -> bool
127
+ def environmental?: () -> bool
128
+ def equal_weighted?: () -> bool
129
+ def equities?: () -> bool
130
+ def equity?: () -> bool
131
+ def escrow_receipts?: () -> bool
132
+ def etf?: () -> bool
133
+ def european?: () -> bool
134
+ def european_call?: () -> bool
135
+ def european_chooser?: () -> bool
136
+ def european_put?: () -> bool
137
+ def event_driven?: () -> bool
138
+ def exchange_traded_funds?: () -> bool
139
+ def exchangeable?: () -> bool
140
+ def express_certificate?: () -> bool
141
+ def extendible?: () -> bool
142
+ def extraction_resources?: () -> bool
143
+ def fertilizer?: () -> bool
144
+ def financial_futures?: () -> bool
145
+ def financing?: () -> bool
146
+ def fixed?: () -> bool
147
+ def fixed_cash_repayment?: () -> bool
148
+ def fixed_fixed?: () -> bool
149
+ def fixed_floating?: () -> bool
150
+ def fixed_interest?: () -> bool
151
+ def fixed_maturity?: () -> bool
152
+ def fixed_maturity_with_call?: () -> bool
153
+ def fixed_maturity_with_put?: () -> bool
154
+ def fixed_maturity_with_put_and_call?: () -> bool
155
+ def fixed_rate?: () -> bool
156
+ def flexible?: () -> bool
157
+ def foreign_exchange?: () -> bool
158
+ def forward?: () -> bool
159
+ def forward_forward_swap?: () -> bool
160
+ def forward_price?: () -> bool
161
+ def forwards?: () -> bool
162
+ def free_of_payment?: () -> bool
163
+ def free_of_restrictions?: () -> bool
164
+ def freight?: () -> bool
165
+ def fully_paid?: () -> bool
166
+ def fund_unit_and_other?: () -> bool
167
+ def funds_of_funds?: () -> bool
168
+ def futures?: () -> bool
169
+ def general_collateral?: () -> bool
170
+ def generated_resources?: () -> bool
171
+ def government_bonds?: () -> bool
172
+ def government_guarantee?: () -> bool
173
+ def gross_total_return?: () -> bool
174
+ def growth?: () -> bool
175
+ def hedge_funds?: () -> bool
176
+ def hold_in_custody?: () -> bool
177
+ def income_funds?: () -> bool
178
+ def index?: () -> bool
179
+ def index_tranche?: () -> bool
180
+ def indices?: () -> bool
181
+ def industrial_products?: () -> bool
182
+ def inflation_rate_index?: () -> bool
183
+ def insurance_policies?: () -> bool
184
+ def interest_rate_index?: () -> bool
185
+ def interest_rates?: () -> bool
186
+ def joint_guarantee?: () -> bool
187
+ def junior?: () -> bool
188
+ def junior_subordinated?: () -> bool
189
+ def legacy_currency?: () -> bool
190
+ def letter_of_credit?: () -> bool
191
+ def life_style?: () -> bool
192
+ def limited_partnership_units?: () -> bool
193
+ def listed_options?: () -> bool
194
+ def loan_lease?: () -> bool
195
+ def local?: () -> bool
196
+ def long?: () -> bool
197
+ def lookback?: () -> bool
198
+ def medium_term_notes?: () -> bool
199
+ def metals?: () -> bool
200
+ def mini_future_certificates?: () -> bool
201
+ def miscellaneous?: () -> bool
202
+ def mixed?: () -> bool
203
+ def mixed_funds?: () -> bool
204
+ def modified_market_cap_weighted?: () -> bool
205
+ def money_market?: () -> bool
206
+ def money_market_instruments?: () -> bool
207
+ def monthly?: () -> bool
208
+ def mortgage_backed?: () -> bool
209
+ def mortgage_backed_securities?: () -> bool
210
+ def multi_commodity?: () -> bool
211
+ def multi_strategy?: () -> bool
212
+ def municipal_bonds?: () -> bool
213
+ def naked?: () -> bool
214
+ def national_currency?: () -> bool
215
+ def negative_pledge?: () -> bool
216
+ def net_total_return?: () -> bool
217
+ def nil_paid?: () -> bool
218
+ def no_payments?: () -> bool
219
+ def nominal?: () -> bool
220
+ def non_deliverable?: () -> bool
221
+ def non_listed_options?: () -> bool
222
+ def non_standardized?: () -> bool
223
+ def non_voting?: () -> bool
224
+ def normal_rate?: () -> bool
225
+ def not_applicable?: () -> bool
226
+ def open?: () -> bool
227
+ def open_end?: () -> bool
228
+ def options?: () -> bool
229
+ def other_assets?: () -> bool
230
+ def other_otc_derivatives?: () -> bool
231
+ def other_path_dependent?: () -> bool
232
+ def others?: () -> bool
233
+ def outperformance_bonus_certificate?: () -> bool
234
+ def outperforming_certificate?: () -> bool
235
+ def overnight?: () -> bool
236
+ def overnight_index_swap?: () -> bool
237
+ def paper?: () -> bool
238
+ def participating?: () -> bool
239
+ def partly_paid?: () -> bool
240
+ def payment_in_kind?: () -> bool
241
+ def pension_funds?: () -> bool
242
+ def perpetual?: () -> bool
243
+ def perpetual_with_call?: () -> bool
244
+ def perpetual_with_put?: () -> bool
245
+ def physical?: () -> bool
246
+ def physical_repayment?: () -> bool
247
+ def polypropylene_products?: () -> bool
248
+ def precious_metal_receipts?: () -> bool
249
+ def preferred_shares?: () -> bool
250
+ def price?: () -> bool
251
+ def price_return?: () -> bool
252
+ def price_weighted?: () -> bool
253
+ def private_equity?: () -> bool
254
+ def private_equity_funds?: () -> bool
255
+ def promissory_note?: () -> bool
256
+ def purchase_rights?: () -> bool
257
+ def put?: () -> bool
258
+ def put_options?: () -> bool
259
+ def quarterly?: () -> bool
260
+ def rates?: () -> bool
261
+ def real?: () -> bool
262
+ def real_estate?: () -> bool
263
+ def real_estate_deeds?: () -> bool
264
+ def real_estate_investment_trusts?: () -> bool
265
+ def redeemable?: () -> bool
266
+ def redeemable_exchangeable?: () -> bool
267
+ def redeemable_exchangeable_extendible?: () -> bool
268
+ def redeemable_extendible?: () -> bool
269
+ def referential_instruments?: () -> bool
270
+ def registered?: () -> bool
271
+ def reit?: () -> bool
272
+ def relative_value?: () -> bool
273
+ def repayment_in_assets?: () -> bool
274
+ def repayment_in_assets_and_cash?: () -> bool
275
+ def repayment_in_assets_or_cash?: () -> bool
276
+ def repayment_in_cash?: () -> bool
277
+ def repurchase_agreements?: () -> bool
278
+ def restricted_voting?: () -> bool
279
+ def restrictions?: () -> bool
280
+ def reverse_convertible?: () -> bool
281
+ def secured?: () -> bool
282
+ def securities_lending?: () -> bool
283
+ def security_selection?: () -> bool
284
+ def semi_annually?: () -> bool
285
+ def senior?: () -> bool
286
+ def senior_subordinated?: () -> bool
287
+ def services?: () -> bool
288
+ def share_and_bond?: () -> bool
289
+ def share_and_warrant?: () -> bool
290
+ def shares?: () -> bool
291
+ def shares_for_qualified_investors?: () -> bool
292
+ def short?: () -> bool
293
+ def single_currency?: () -> bool
294
+ def single_name?: () -> bool
295
+ def single_stock?: () -> bool
296
+ def sovereign?: () -> bool
297
+ def specific_security_collateral?: () -> bool
298
+ def spot?: () -> bool
299
+ def spot_forward_swap?: () -> bool
300
+ def spread_bet?: () -> bool
301
+ def standard_funds?: () -> bool
302
+ def standard_investment_funds?: () -> bool
303
+ def standardized?: () -> bool
304
+ def stock_dividend?: () -> bool
305
+ def stock_dividends?: () -> bool
306
+ def strategies?: () -> bool
307
+ def structured_instruments?: () -> bool
308
+ def structured_products_with_protection?: () -> bool
309
+ def structured_products_without_protection?: () -> bool
310
+ def subscription_rights?: () -> bool
311
+ def supranational?: () -> bool
312
+ def swaps?: () -> bool
313
+ def term?: () -> bool
314
+ def total_return?: () -> bool
315
+ def tracker_certificate?: () -> bool
316
+ def trade_finance_instruments?: () -> bool
317
+ def traditional?: () -> bool
318
+ def tri_party?: () -> bool
319
+ def twin_win_certificate?: () -> bool
320
+ def units?: () -> bool
321
+ def units_for_qualified_investors?: () -> bool
322
+ def unsecured?: () -> bool
323
+ def vanilla?: () -> bool
324
+ def variable?: () -> bool
325
+ def variable_cash_repayment?: () -> bool
326
+ def variable_interest?: () -> bool
327
+ def variance?: () -> bool
328
+ def volatility?: () -> bool
329
+ def voting?: () -> bool
330
+ def warrant_and_warrant?: () -> bool
331
+ def warrants?: () -> bool
332
+ def weekly?: () -> bool
333
+ def zero_coupon?: () -> bool
334
+ def zero_rate?: () -> bool
335
+ end
336
+ end
337
+ end
@@ -0,0 +1,68 @@
1
+ module SecID
2
+ class CFI < Base
3
+ # ISO 10962:2021 CFI code tables.
4
+ #
5
+ # @api private
6
+ module Tables
7
+ # `{ letter => [value_symbol, value_label] }` for one attribute position.
8
+ # Values are typed loosely: the `[symbol, label]` tuple literals widen to
9
+ # `Array[Symbol | String]` under `Hash#freeze`, and `map(&:first)` on them feeds
10
+ # Field domains (Array[Symbol]) — untyped keeps both sides consistent.
11
+ type value_map = Hash[String, untyped]
12
+
13
+ # A group definition and the (loosely-typed, deeply-nested) group table.
14
+ type group_def = Hash[Symbol, untyped]
15
+
16
+ NA: nil
17
+
18
+ FORM: value_map
19
+ VOTING: value_map
20
+ OWNERSHIP: value_map
21
+ PAYMENT: value_map
22
+ PREF_REDEMPTION: value_map
23
+ PREF_INCOME: value_map
24
+ DEBT_GUARANTEE: value_map
25
+ DEBT_REDEMPTION: value_map
26
+ DEBT_INTEREST_FZVK: value_map
27
+ DEBT_INTEREST_FZV: value_map
28
+ STRUCTURED_DISTRIBUTION: value_map
29
+ STRUCTURED_UNDERLYING: value_map
30
+ WARRANT_UNDERLYING: value_map
31
+ EXERCISE_STYLE: value_map
32
+ CIV_CLOSED_OPEN: value_map
33
+ CIV_DISTRIBUTION: value_map
34
+ CIV_ASSETS: value_map
35
+ CIV_SECURITY_FULL: value_map
36
+ CIV_SECURITY_SHORT: value_map
37
+ OPTION_STYLE: value_map
38
+ OPTION_UNDERLYING: value_map
39
+ STANDARDIZED: value_map
40
+ COMMODITY_ASSETS: value_map
41
+ RETURN_TRIGGER: value_map
42
+ H_OPTION_STYLE: value_map
43
+ H_VALUATION: value_map
44
+ DELIVERY_CP: value_map
45
+ DELIVERY_PN: value_map
46
+ DELIVERY_PCN: value_map
47
+ DELIVERY_CPE: value_map
48
+ H_DELIVERY: value_map
49
+ H_DELIVERY_N: value_map
50
+ H_DELIVERY_NA: value_map
51
+ FWD_TRIGGER_CSF: value_map
52
+ FWD_TRIGGER_SF: value_map
53
+ FWD_TRIGGER_CF: value_map
54
+
55
+ # `{ letter => [category_symbol, category_label] }`. Typed loosely (widening tuple
56
+ # values; generation also indexes with nilable `.keys.sample` results).
57
+ CATEGORIES: Hash[untyped, untyped]
58
+
59
+ # `{ cat_letter => { grp_letter => group_def } }` (typed loosely, as above).
60
+ GROUPS: Hash[untyped, untyped]
61
+
62
+ ED_REDEMPTION_RULE: Hash[Symbol, untyped]
63
+
64
+ def self.ed_rule_applies?: (untyped category_code, untyped group_code, untyped letters) -> bool
65
+ def self.group: (untyped category_code, untyped group_code) -> untyped
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,56 @@
1
+ module SecID
2
+ # Classification of Financial Instruments (CFI) — ISO 10962:2021.
3
+ class CFI < Base
4
+ FULL_NAME: String
5
+ ID_LENGTH: Integer
6
+ EXAMPLE: String
7
+ VALID_CHARS_REGEX: ::Regexp
8
+ ID_REGEX: ::Regexp
9
+
10
+ # Derived semantic maps (letter => symbol).
11
+ CATEGORIES: Hash[String, Symbol]
12
+ GROUPS: Hash[String, Hash[String, Symbol]]
13
+
14
+ def self.categories: () -> Hash[String, Symbol]
15
+ def self.groups_for: (String category_code) -> Hash[String, Symbol]?
16
+
17
+ # Used unguarded as non-nil after validation (indexed into the tables); typed loosely
18
+ # so static Steep and runtime RBS::Test (which sees nil for invalid) agree.
19
+ attr_reader category_code: untyped
20
+ attr_reader group_code: untyped
21
+ attr_reader attr1: untyped
22
+ attr_reader attr2: untyped
23
+ attr_reader attr3: untyped
24
+ attr_reader attr4: untyped
25
+
26
+ def initialize: (SecID::input cfi) -> void
27
+ def category: () -> Symbol?
28
+ def group: () -> Symbol?
29
+ def decode: () -> Classification?
30
+ def to_s: () -> String
31
+
32
+ private def self.generate_body: (Random random) -> String
33
+ private def self.sample_attribute: (untyped position, Random random) -> String
34
+ private def self.enforce_ed_rule: (untyped category_code, untyped group_code, untyped letters, Random random) -> void
35
+
36
+ private
37
+
38
+ def components: () -> Hash[Symbol, untyped]
39
+ def valid_format?: () -> bool
40
+ def detect_errors: () -> Array[Symbol]
41
+ def validation_message: (Symbol code) -> String?
42
+ def valid_category?: () -> bool
43
+ def valid_group?: () -> bool
44
+ def valid_attributes?: () -> bool
45
+ # `[position, letter]` pairs; typed loosely since the tuple literals widen.
46
+ def attribute_violations: () -> Array[untyped]
47
+ def compute_attribute_violations: () -> Array[untyped]
48
+ def permitted_attribute?: (untyped position, String letter) -> bool
49
+ def ed_rule_violations: () -> Array[untyped]
50
+ def ed_rule_applies?: () -> bool
51
+ def attribute_letters: () -> Array[String]
52
+ def attribute_error_message: () -> String
53
+
54
+ @attribute_violations: Array[untyped]
55
+ end
56
+ end
@@ -0,0 +1,19 @@
1
+ module SecID
2
+ # Central Index Key (CIK).
3
+ class CIK < Base
4
+ FULL_NAME: String
5
+ # Typed loosely: `#normalized` does `ID_LENGTH.max` and Range#max is nilable in RBS.
6
+ ID_LENGTH: untyped
7
+ EXAMPLE: String
8
+ VALID_CHARS_REGEX: ::Regexp
9
+ ID_REGEX: ::Regexp
10
+
11
+ attr_reader padding: String?
12
+
13
+ def initialize: (SecID::input cik) -> void
14
+ def normalized: () -> String
15
+ def normalize!: () -> self
16
+ def to_s: () -> String
17
+ private def self.generate_body: (Random random) -> String
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ module SecID
2
+ # Provides check-digit validation and calculation for identifiers with a check digit.
3
+ module Checkable : SecID::Base
4
+ CHAR_TO_DIGITS: Hash[String, Integer | Array[Integer]]
5
+ CHAR_TO_DIGIT: Hash[String, Integer]
6
+
7
+ def self.included: (Module base) -> void
8
+
9
+ attr_reader check_digit: (Integer | String)?
10
+
11
+ # Class methods added when Checkable is included.
12
+ module ClassMethods : SecID::_IdentifierClass
13
+ def restore: (SecID::input id_without_check_digit) -> String
14
+ def restore!: (SecID::input id_without_check_digit) -> Base
15
+ def check_digit: (SecID::input id) -> (Integer | String)
16
+ end
17
+
18
+ def valid?: () -> bool
19
+ def restore: () -> String
20
+ def restore!: () -> self
21
+ def calculate_check_digit: () -> (Integer | String)
22
+ def to_s: () -> String
23
+
24
+ private
25
+
26
+ def luhn_sum_double_add_double: (Array[Integer] digits) -> Integer
27
+ def luhn_sum_indexed: (Array[Integer] digits) -> Integer
28
+ def luhn_sum_standard: (Array[Integer] digits) -> Integer
29
+ def reversed_digits_single: (untyped id) -> Array[Integer]
30
+ def reversed_digits_multi: (untyped id) -> Array[Integer]
31
+ def error_codes: () -> Array[Symbol]
32
+ def check_digit_width: () -> Integer
33
+ def validation_message: (Symbol code) -> String?
34
+ def validate_format_for_calculation!: () -> void
35
+ def mod10: (Integer sum) -> Integer
36
+ def div10mod10: (Integer number) -> Integer
37
+ def mod97: (String numeric_string) -> Integer
38
+
39
+ @check_digit: (Integer | String)?
40
+ end
41
+ end
@@ -0,0 +1,26 @@
1
+ module SecID
2
+ # Provides generation of new, format-valid identifiers for use as test fixtures.
3
+ module Generatable
4
+ ALPHA: Array[String]
5
+ DIGITS: Array[String]
6
+ ALPHANUMERIC: Array[String]
7
+
8
+ def self.included: (Module base) -> void
9
+
10
+ # The class-object surface Generatable's methods call once extended.
11
+ interface _GeneratableClass
12
+ def new: (SecID::input) -> Base
13
+ def has_check_digit?: () -> bool
14
+ end
15
+
16
+ # Class methods added when Generatable is included.
17
+ module ClassMethods : SecID::Generatable::_GeneratableClass
18
+ def generate: (?random: Random) -> Base
19
+
20
+ private
21
+
22
+ def generate_body: (Random _random) -> String
23
+ def random_string: (Array[String] charset, Integer length, random: Random) -> String
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,34 @@
1
+ module SecID
2
+ # Host surface Normalizable's instance methods call through `self`.
3
+ interface _NormalizableHost
4
+ def identifier: () -> String?
5
+ def valid?: () -> bool
6
+ def validate!: () -> void
7
+ end
8
+
9
+ # Provides normalization and display-formatting methods for identifier types.
10
+ #
11
+ # `ClassMethods#normalize`/`#to_pretty_s` read `self::SEPARATORS` (polymorphic
12
+ # constant dispatch); the extend-module `self` can't be typed as `singleton(Base)`,
13
+ # so that access resolves via the relaxed UnknownConstant diagnostic (see Steepfile).
14
+ module Normalizable : SecID::_NormalizableHost
15
+ SEPARATORS: ::Regexp
16
+
17
+ def self.included: (Module base) -> void
18
+
19
+ # Class methods added when Normalizable is included.
20
+ module ClassMethods : SecID::_IdentifierClass
21
+ def normalize: (_ToS id) -> String
22
+ def to_pretty_s: (_ToS id) -> String?
23
+ end
24
+
25
+ def normalized: () -> String
26
+ alias normalize normalized
27
+ def normalize!: () -> self
28
+ def to_pretty_s: () -> String?
29
+ def to_s: () -> String
30
+ def to_str: () -> String
31
+
32
+ @full_id: String
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ module SecID
2
+ # Host surface Validatable's instance methods call through `self`. The refined
3
+ # `class` return lets `self.class::ID_LENGTH` and the class metadata resolve.
4
+ interface _ValidatableHost
5
+ def identifier: () -> String?
6
+ def full_id: () -> String
7
+ def class: () -> singleton(SecID::Base)
8
+ end
9
+
10
+ # Provides validation methods for identifier types.
11
+ module Validatable : SecID::_ValidatableHost
12
+ ERROR_MAP: Hash[Symbol, singleton(SecID::Error)]
13
+
14
+ def self.included: (Module base) -> void
15
+
16
+ # Class methods added when Validatable is included.
17
+ module ClassMethods : SecID::_IdentifierClass
18
+ def valid?: (SecID::input id) -> bool
19
+ def validate: (SecID::input id) -> Base
20
+ def validate!: (SecID::input id) -> Base
21
+ def error_class_for: (Symbol code) -> singleton(SecID::Error)
22
+ end
23
+
24
+ def valid?: () -> bool
25
+ def validate: () -> self
26
+ def errors: () -> Errors
27
+ def validate!: () -> self
28
+
29
+ private
30
+
31
+ def valid_format?: () -> bool
32
+ def error_codes: () -> Array[Symbol]
33
+ def detect_errors: () -> Array[Symbol]
34
+ def valid_length?: () -> bool
35
+ def valid_characters?: () -> bool
36
+ def check_digit_width: () -> Integer
37
+ def validation_message: (Symbol code) -> String?
38
+ def build_error: (Symbol code, String? message) -> Errors::detail
39
+
40
+ @errors: Errors
41
+ end
42
+ end
@@ -0,0 +1,29 @@
1
+ module SecID
2
+ # Committee on Uniform Securities Identification Procedures (CUSIP).
3
+ class CUSIP < Base
4
+ include Checkable
5
+ extend Checkable::ClassMethods
6
+
7
+ FULL_NAME: String
8
+ ID_LENGTH: Integer
9
+ EXAMPLE: String
10
+ VALID_CHARS_REGEX: ::Regexp
11
+ ID_REGEX: ::Regexp
12
+
13
+ # `#cins?` indexes `cusip6[0]` (nilable even for a non-nil String); typed loosely.
14
+ attr_reader cusip6: untyped
15
+ attr_reader issue: String?
16
+
17
+ def initialize: (SecID::input cusip) -> void
18
+ def to_pretty_s: () -> String?
19
+ def calculate_check_digit: () -> Integer
20
+ def self.check_digit: (SecID::input id) -> Integer
21
+ private def self.generate_body: (Random random) -> String
22
+ def to_isin: (String country_code) -> ISIN
23
+ def cins?: () -> bool
24
+
25
+ private
26
+
27
+ def components: () -> Hash[Symbol, untyped]
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ module SecID
2
+ # Recursively freezes a nested structure of Hashes and Arrays and returns it.
3
+ module DeepFreeze
4
+ def self.call: (untyped object) -> untyped
5
+ end
6
+ end