add currency pair class

This commit is contained in:
Pablo Martin 2025-05-26 14:50:21 +02:00
parent 048d6833b4
commit 132d51777a
2 changed files with 54 additions and 0 deletions

19
xexe/currency_pair.py Normal file
View file

@ -0,0 +1,19 @@
from money.currency import Currency
class CurrencyPair:
"""Two currencies with directionality (from->to)."""
def __init__(
self, from_currency: Currency, to_currency: Currency
) -> "CurrencyPair":
self.from_currency = from_currency
self.to_currency = to_currency
def __str__(self):
return str(self.from_currency) + str(self.to_currency)
def get_reverse_pair(self) -> "CurrencyPair":
return CurrencyPair(
from_currency=self.to_currency, to_currency=self.from_currency
)