Commit 58ec879a authored by Johannes Blaschke's avatar Johannes Blaschke

tweaked ForexDay data model

parent a5ba1047
Pipeline #1 failed with stages
......@@ -30,8 +30,9 @@ class CurrencyPair(CurrencyRates):
Pair of currencies, allowing their exchange rate to be calculated. The pair is directional:
exchange rates are calculated from the "in" currency in units of the "out" currency.
def __init__(self, c_in: str = "EUR", c_out: str = "USD", quant: float = 10000) -> None:
def __init__(self, c_in: str = "EUR", c_out: str = "USD", quant: float = 10000,
force_decimal: bool = False) -> None:
self.currency_in: str = c_in
self.currency_out: str = c_out
......@@ -57,7 +58,9 @@ class ForexDay(object):
n_list: int = int(timedelta(days=1) / resolution)
t_list: List[datetime] = [as_datetime(c_date) + self.resolution * n for n in range(n_list)] List[Tuple[datetime, float]] = [(t, cp.get_pair_rate(t)) for t in t_list] Dict[datetime, float] = dict()
for current_t in t_list:[current_t] = cp.get_pair_rate(current_t)
def __repr__(self) -> str:
......@@ -68,14 +71,14 @@ class ForexDay(object):
Returns a list of times for which the exchange rates where determined.
return [elem[0] for elem in]
return sorted(
def get_rates(self) -> List[float]:
Returns a list of exchange rates corresponding to the times returned by `get_times`.
return [elem[1] for elem in]
return sorted([elem for _, elem in zip(,])
def mean_rate(self) -> float:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment