This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script to track Day Ahead prices for electricity on the ENTSOE-E Platform
#3
1. prices must be a table where key is hour (0..23) and value is price. The resulting minhour variable is the first hour of the 4 hour period with the lowest prices.
Code:
minsum = math.huge
minhour = 0

step = 4

for hour = 0, 24 - step do
  sum = 0

  for i = hour, hour + step - 1 do
    sum = sum + prices[ i ]
  end

  if sum < minsum then
    minsum = sum
    minhour = hour
  end
end

log(minhour)

2. For night prices use this, adjust night hours as needed (22 to 5 inclusive in this example).
Code:
for hour = 0, 23 do
  if hour >= 22 or hour <= 5 then
    nightprices[ #nightprices + 1 ] = {
      hour = hour,
      price = prices[ hour ]
    }
  end
end

table.sort(nightprices, function(a, b)
  return a.price < b.price
end)

for i = 1, 4 do
  item = nightprices[ i ]
  log(item.hour, item.price)
end
Reply


Messages In This Thread
RE: Script to track Day Ahead prices for electricity on the ENTSOE-E Platform - by admin - 11.04.2023, 06:12

Forum Jump: