Skip to content

Instantly share code, notes, and snippets.

@ndoo
Created June 9, 2020 16:22
Show Gist options
  • Save ndoo/f16c67fe04c4922edcd8aae1bd35ed8b to your computer and use it in GitHub Desktop.
Save ndoo/f16c67fe04c4922edcd8aae1bd35ed8b to your computer and use it in GitHub Desktop.
Quick and dirty script to compute half-hourly kWh pricing on SP Wholesale
import urllib.request, json, re
with urllib.request.urlopen("https://www.emcsg.com/chartserver/blue/ticker") as url:
data = json.loads(url.read().decode())
for section in data["Sections"]:
if section["Name"] == "Energy":
for sectiondata in section["SectionData"]:
if sectiondata["Label"] == "USEP":
usepkwh = float(re.search("\d+.\d+", sectiondata["Value"]).group()) / 1000
try:
usepkwh
period = int(data["Period"])
except NameError:
exit("Unable to retrieve USEP")
txcharge = 0.0544 if period >= 15 and period <= 46 else 0.0412
kwhrate = usepkwh + 0.0050 + txcharge
print(" ${:.5f}\t(USEP per kWh)".format(usepkwh))
print("+ $0.00380\t(Market Development and Systems Charge)")
print("+ $0.00120\t(Retail Settlement Uplift)")
print("+ ${:.5f}\t(Transmission Charges for Low Tension)".format(txcharge))
print("***********")
print(" ${:.5f}\n".format(kwhrate))
print("kWh rate for period {:d} is ${:.7f} after 7% GST".format(period, kwhrate * 1.07))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment