parent
dbc12adb3d
commit
5ab9d93484
3 changed files with 32 additions and 6 deletions
10
agenda/fx.py
10
agenda/fx.py
|
|
@ -44,11 +44,11 @@ async def get_gbpusd(config: flask.config.Config) -> Decimal:
|
|||
return typing.cast(Decimal, 1 / data["quotes"]["USDGBP"])
|
||||
|
||||
|
||||
def get_exchange_rates(config) -> dict[str, Decimal]:
|
||||
def get_rates(config: flask.config.Config) -> dict[str, Decimal]:
|
||||
"""Get current values of exchange rates for a list of currencies against GBP."""
|
||||
currencies = config.CURRENCIES
|
||||
access_key = config.EXCHANGERATE_ACCESS_KEY
|
||||
data_dir = config.DATA_DIR
|
||||
currencies = config["CURRENCIES"]
|
||||
access_key = config["EXCHANGERATE_ACCESS_KEY"]
|
||||
data_dir = config["DATA_DIR"]
|
||||
|
||||
now = datetime.now()
|
||||
now_str = now.strftime("%Y-%m-%d_%H:%M")
|
||||
|
|
@ -65,7 +65,7 @@ def get_exchange_rates(config) -> dict[str, Decimal]:
|
|||
recent = datetime.strptime(recent_filename[:16], "%Y-%m-%d_%H:%M")
|
||||
delta = now - recent
|
||||
|
||||
if delta < timedelta(hours=6):
|
||||
if delta < timedelta(hours=12):
|
||||
full_path = os.path.join(fx_dir, recent_filename)
|
||||
with open(full_path) as file:
|
||||
data = json.load(file, parse_float=Decimal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue