Cost calculations
This commit is contained in:
35
app/models/entsoe.rb
Normal file
35
app/models/entsoe.rb
Normal 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
|
||||
Reference in New Issue
Block a user