Prices 2023 added
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -12,3 +12,4 @@ gem 'ruby-gr'
|
|||||||
gem 'gr-plot'
|
gem 'gr-plot'
|
||||||
gem 'histogram'
|
gem 'histogram'
|
||||||
gem 'numo-narray'
|
gem 'numo-narray'
|
||||||
|
gem 'gruff'
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ GEM
|
|||||||
raabro (~> 1.4)
|
raabro (~> 1.4)
|
||||||
gr-plot (0.0.1)
|
gr-plot (0.0.1)
|
||||||
ruby-gr
|
ruby-gr
|
||||||
|
gruff (0.19.0)
|
||||||
|
histogram
|
||||||
|
rmagick (>= 4.2)
|
||||||
histogram (0.2.4.1)
|
histogram (0.2.4.1)
|
||||||
i18n (1.8.11)
|
i18n (1.8.11)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
@@ -37,6 +40,7 @@ GEM
|
|||||||
pkg-config (1.4.9)
|
pkg-config (1.4.9)
|
||||||
raabro (1.4.0)
|
raabro (1.4.0)
|
||||||
racc (1.6.0)
|
racc (1.6.0)
|
||||||
|
rmagick (5.0.0)
|
||||||
ruby-gr (0.66.0.0)
|
ruby-gr (0.66.0.0)
|
||||||
fiddle
|
fiddle
|
||||||
numo-narray
|
numo-narray
|
||||||
@@ -55,6 +59,7 @@ DEPENDENCIES
|
|||||||
activerecord
|
activerecord
|
||||||
daemons
|
daemons
|
||||||
gr-plot
|
gr-plot
|
||||||
|
gruff
|
||||||
histogram
|
histogram
|
||||||
mail
|
mail
|
||||||
mysql2
|
mysql2
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ EASY_ENERGY_TARIFFS = {}
|
|||||||
|
|
||||||
# See https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/zakelijk/overige_belastingen/belastingen_op_milieugrondslag/tarieven_milieubelastingen/tabellen_tarieven_milieubelastingen
|
# See https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/zakelijk/overige_belastingen/belastingen_op_milieugrondslag/tarieven_milieubelastingen/tabellen_tarieven_milieubelastingen
|
||||||
# Without VAT
|
# Without VAT
|
||||||
ENERGY_TAX_KWH = { 2020 => 0.09770, 2021 => 0.09428, 2022 => 0.03679}
|
ENERGY_TAX_KWH = { 2020 => 0.09770, 2021 => 0.09428, 2022 => 0.03679, 2023 => 0.12599 }
|
||||||
ODE_KWH = { 2020 => 0.0273, 2021 => 0.0300, 2022 => 0.0305}
|
ODE_KWH = { 2020 => 0.0273, 2021 => 0.0300, 2022 => 0.0305, 2023 => 0.0}
|
||||||
# merge by adding values
|
# merge by adding values
|
||||||
TAX_KWH = ENERGY_TAX_KWH.merge(ODE_KWH){|key, energy_tax, ode| energy_tax + ode}
|
TAX_KWH = ENERGY_TAX_KWH.merge(ODE_KWH){|key, energy_tax, ode| energy_tax + ode}
|
||||||
|
|
||||||
@@ -151,6 +151,9 @@ class Cost
|
|||||||
high_tariff ? 0.06782 : 0.05259
|
high_tariff ? 0.06782 : 0.05259
|
||||||
when 2022
|
when 2022
|
||||||
high_tariff ? 0.23665 : 0.19408
|
high_tariff ? 0.23665 : 0.19408
|
||||||
|
when 2023
|
||||||
|
# rate excl. VAT
|
||||||
|
high_tariff ? 0.47758 : 0.34165
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -175,10 +178,15 @@ class Cost
|
|||||||
# normaal_kwh * (0.23665 + 0.04452 + 0.03691) + dal_kwh * (0.19408 + 0.04452 + 0.03691)
|
# normaal_kwh * (0.23665 + 0.04452 + 0.03691) + dal_kwh * (0.19408 + 0.04452 + 0.03691)
|
||||||
normaal_kwh_cost = 0.23665
|
normaal_kwh_cost = 0.23665
|
||||||
dal_kwh_cost = 0.19408
|
dal_kwh_cost = 0.19408
|
||||||
# From 8 Sept 2022 until 31 December 2025 (may need to extend this)
|
# From 8 Sept 2022 until 31 December 2022
|
||||||
when 1662595200..1767139200
|
when 1662595200..1672527599
|
||||||
normaal_kwh_cost = 0.60824
|
normaal_kwh_cost = 0.60824
|
||||||
dal_kwh_cost = 0.43701
|
dal_kwh_cost = 0.43701
|
||||||
|
# From 1 Jan 2023 until 31 December 2023
|
||||||
|
when 1672527600..1704063599
|
||||||
|
vat = 1 + vat_at(Date.parse(formatted_hour))
|
||||||
|
normaal_kwh_cost = 0.47758*vat
|
||||||
|
dal_kwh_cost = 0.34165*vat
|
||||||
else
|
else
|
||||||
# catch-all, incase 'formated_hour' is outside any of the cases
|
# catch-all, incase 'formated_hour' is outside any of the cases
|
||||||
normaal_kwh_cost = 0.0
|
normaal_kwh_cost = 0.0
|
||||||
|
|||||||
46
frankenergy.py
Normal file
46
frankenergy.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import requests
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import csv
|
||||||
|
|
||||||
|
def FrankEnergy():
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
yesterday = datetime.now() + timedelta(days=-1)
|
||||||
|
startdate = yesterday.strftime("%Y-%m-%d")
|
||||||
|
enddate = now.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
if int(now.strftime("%H")) > 15:
|
||||||
|
tomorrow = datetime.now() + timedelta(days=2)
|
||||||
|
startdate = now.strftime("%Y-%m-%d")
|
||||||
|
enddate = tomorrow.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
headers = { "content-type":"application/json" }
|
||||||
|
|
||||||
|
query = f"""query MarketPrices {{
|
||||||
|
marketPricesGas(startDate: "{startdate}", endDate: "{enddate}") {{
|
||||||
|
from
|
||||||
|
till
|
||||||
|
marketPrice
|
||||||
|
priceIncludingMarkup
|
||||||
|
}}
|
||||||
|
}}"""
|
||||||
|
|
||||||
|
response = requests.post('https://graphcdn.frankenergie.nl', json={'query': query}, headers=headers)
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
frank_gas_file = "frank_gas.csv"
|
||||||
|
|
||||||
|
frank_headers = ['till', 'from', 'marketPrice', 'priceIncludingMarkup']
|
||||||
|
|
||||||
|
with open(frank_gas_file, 'w') as csvfile:
|
||||||
|
writer = csv.DictWriter(csvfile, fieldnames = frank_headers)
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerows(data['data']['marketPricesGas'])
|
||||||
|
|
||||||
|
for gas in data['data']['marketPricesGas']:
|
||||||
|
print(gas['till'], gas['from'],gas['marketPrice'], gas['priceIncludingMarkup'])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
FrankEnergy()
|
||||||
|
|
||||||
BIN
stacked_bar.png
Normal file
BIN
stacked_bar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
Reference in New Issue
Block a user