forked from samuelmr/nordpool-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweekly.js
More file actions
27 lines (24 loc) · 724 Bytes
/
Copy pathweekly.js
File metadata and controls
27 lines (24 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {nordpool} from 'nordpool'
import dayjs from 'dayjs'
import dayjsPluginWeekOfYear from 'dayjs/plugin/weekOfYear.js'
dayjs.extend(dayjsPluginWeekOfYear)
const opts = {
currency: 'NOK',
area: 'Bergen',
from: '2019-06-01'
}
const getWeekly = async () => {
const prices = await new nordpool.Prices().weekly(opts)
for (const week of prices.reverse()) {
const weeklyPriceMessage = 'The MWh price on week ' +
dayjs(week.date).week() + '/' + dayjs(week.date).format('YYYY') +
' was ' + priceFormat.format(week.value)
console.log(weeklyPriceMessage)
}
}
getWeekly()
const priceFormat = new Intl.NumberFormat('no-NO', {
style: 'currency',
currency: 'NOK',
minimumFractionDigits: 2
});