Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add currency attributes to ibetStraightBond #552

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Conversation

YoshihitoAso
Copy link
Member

close #546

Comment on lines +397 to +404
face_value_currency: str
interest_rate: float
interest_payment_date: List[str]
interest_payment_currency: str
redemption_date: str
redemption_value: int
redemption_value_currency: str
base_fx_rate: float
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added four new items to the Bond contract.

  • face_value_currency
  • interest_payment_currency
  • redemption_value_currency
  • base_fx_rate

Comment on lines +502 to +504
self.face_value_currency = ContractUtils.call_function(
contract, "faceValueCurrency", (), ""
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of face_value_currency is "".

Comment on lines +509 to +511
self.interest_payment_currency = ContractUtils.call_function(
contract, "interestPaymentCurrency", (), ""
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of interest_payment_currency is "".

Comment on lines +518 to +520
self.redemption_value_currency = ContractUtils.call_function(
contract, "redemptionValueCurrency", (), ""
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of redemption_value_currency is "".

Comment on lines +525 to +534
try:
_raw_base_fx_rate = ContractUtils.call_function(
contract, "baseFXRate", (), ""
)
if _raw_base_fx_rate is not None and _raw_base_fx_rate != "":
self.base_fx_rate = float(_raw_base_fx_rate)
else:
self.base_fx_rate = 0.0
except ValueError:
self.base_fx_rate = 0.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value of base_fx_rate is 0.0.
Error handling is performed when invalid data that cannot be converted to float is set.


if data.base_fx_rate is not None:
tx = contract.functions.setBaseFXRate(
str(data.base_fx_rate)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert the input value to str and set it.

@@ -132,6 +132,7 @@ class RetrieveLedgerHistoryResponse(BaseModel):

created: str
token_name: str
currency: str
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value is "".
Although the item itself does not exist in the data created with the old version, the default value (i.e. "") is returned as the API return value.

Comment on lines +70 to +80
@field_validator("base_fx_rate")
@classmethod
def base_fx_rate_6_decimal_places(cls, v):
if v is not None:
float_data = float(v * 10**6)
int_data = int(v * 10**6)
if not math.isclose(int_data, float_data):
raise ValueError(
"base_fx_rate must be less than or equal to six decimal places"
)
return v
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of digits after the decimal point is 6.

Comment on lines +20 to +22
def upgrade():
# Delete all `token_cache` data
op.get_bind().execute(delete(TokenCache))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If valid token cache data exists, the old format data will be returned, so I decided to delete it all at once.

@YoshihitoAso YoshihitoAso marked this pull request as ready for review October 30, 2023 14:00
Copy link
Member

@purplesmoke05 purplesmoke05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YoshihitoAso YoshihitoAso merged commit baa0f3c into dev-23.12 Oct 31, 2023
4 checks passed
@YoshihitoAso YoshihitoAso deleted the feature/#546 branch October 31, 2023 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Supports multiple currency-denominated tokens
2 participants