moexapi 1.7.20__tar.gz → 1.7.21__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.7.20
3
+ Version: 1.7.21
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -139,12 +139,22 @@ class Bond:
139
139
  if abs(amortization_sum - self.initial_face_value) > 1e-9 and len(original_values) > 1:
140
140
  values = [value / amortization_sum * self.initial_face_value for value in original_values]
141
141
  rounded_values = [round(value + 1e-9, 2) for value in values]
142
- for original_value, rounded_value in zip(original_values, rounded_values):
143
- if abs(original_value - rounded_value) > 1e-9:
144
- logger.error(f"Original value {original_value} is not equal to rounded value {rounded_value}")
145
- raise ValueError(f"Amortization sum {amortization_sum} is greater than initial face value {self.initial_face_value}")
146
- for amortization_item, value in zip(self.amortization, values):
147
- amortization_item.value = value
142
+ if all(abs(original - rounded) <= 1e-9
143
+ for original, rounded in zip(original_values, rounded_values)):
144
+ # Correct only differences attributable to payment rounding.
145
+ for amortization_item, value in zip(self.amortization, values):
146
+ amortization_item.value = value
147
+ elif amortization_sum > self.initial_face_value:
148
+ raise ValueError(
149
+ f"Amortization sum {amortization_sum} is greater than initial face value {self.initial_face_value}"
150
+ )
151
+ else:
152
+ # Incomplete or discounted repayment schedules must retain
153
+ # their published cash flows rather than inventing principal.
154
+ logger.warning(
155
+ "%s: Amortization sum %s is less than initial face value %s; keeping published payments",
156
+ self.secid, amortization_sum, self.initial_face_value,
157
+ )
148
158
  except Exception as e:
149
159
  logger.error(f"{ticker.secid} ({ticker.shortname}): {e}")
150
160
  raise e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.7.20
3
+ Version: 1.7.21
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "moexapi"
7
- version = "1.7.20"
7
+ version = "1.7.21"
8
8
  description = "Python API for MOEX ISS"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Aliaksei Rak", email = "kventinel@gmail.com" }]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes