Added option to cache prices

This commit is contained in:
2023-05-19 19:24:49 +02:00
parent 6958357296
commit 6a2a2c1da9
2 changed files with 36 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ from EngieApi.EngieAPI import EngieAPI
class Dynamic:
def __init__(self, btw=1.21):
def __init__(self, btw=1.21, cache: bool = False):
self.btw = btw
self.vast = 100.7 # EUR / jaar
@@ -22,6 +22,7 @@ class Dynamic:
# 20000 < kwh < 50000: 1.22748 cent / kWh
# 50000 < kwh < 100000: 1.15540 cent / kWh
self.federale_accijns = 0.0144160 # EUR / kWh
self.cache = cache
def calculate_price_per_kwh(self, date, peak: float):
"""calculate_price_per_kwh
@@ -29,7 +30,7 @@ class Dynamic:
:param date: date to calculate for
:type date: date
"""
api = EngieAPI()
api = EngieAPI(cache=self.cache)
epex_spot = np.array(api.get_epex_spot(date))
prijs = 0.2040 + 0.1 * (epex_spot) # zonder BTW per Cent/kWh