Cost calculations

This commit is contained in:
Aart van Halteren
2022-01-09 17:58:12 +01:00
parent 61f4a0ddc0
commit 83364d13cf
7 changed files with 328 additions and 29 deletions

35
app/models/entsoe.rb Normal file
View File

@@ -0,0 +1,35 @@
#
# Obtain energy prices from Entsoe (transparancy platform)
# See https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html
#
require 'open-uri'
require 'nokogiri'
class Entsoe
URL = 'https://transparency.entsoe.eu'
def initialize(api_key)
@api_key = api_key
end
def day_ahead_prices(date)
start_date = date.beginning_of_day
end_date = date.end_of_day
# A44 - Document type => Price Document
# A01 - Process type => Day Ahead
# NL = '10YNL----------L'
domain = '10YNL----------L'
url = URL + "/api?securityToken=%s&documentType=A44&processType=A01&in_Domain=%s&out_Domain=%s&periodStart=%s&periodEnd=%s" % [@api_key, domain, domain, start_date.iso8601, end_date.iso8601]
p url
end
private
def base_request(url)
doc = Nokogiri::XML(URI.open(url))
end
end