aeso.equilibrium — Market supply/demand equilibrium points

Helper functions to access AESO’s raw ETS pool price report as published by AESO at <http://ets.aeso.ca/ets_web/ip/Market/Reports/HistoricalPoolPriceReportServlet>.

class aeso.equilibrium.QpPoint(t, price, demand)

Represents the market equilibrium price and quantity exchanged at a given point in time.

demand

decimal.Decimal property.

classmethod from_csvline(line)

Extracts a QpPoint object from a sequece object like: [‘08/10/2009 15’, ‘67.36’, ‘39.67’, ‘8623.0’].

price

decimal.Decimal property.

t

datetime.datetime property.

aeso.equilibrium.dump_equilibrium(f_out, start_date=datetime.date(1995, 1, 1), end_date=None, timeout=None)

Downloads market equilibrium data from ETS and writes it to the file object f_out. Unlike urlopen_pool_price there is no restriction on the amount of data that can be requested. Internally an iterator is used to query data in 721 day blocks before it is written to f_out.

Parameters:
  • f – file-like object
  • start_datedatetime.date
  • end_datedatetime.date (default date.today() + timedelta(1))
  • timeout – optional parameter specifying timeout in seconds for blocking operations like the connection attempt. If operation times out urllib2.URLError will be raised. ValueError will be raised in Python 2.4 and 2.5 if this parameter is set to anything but None.

New in version 0.7: timeout parameter.

Usage example:

>>> # Standard Libraries
>>> from datetime import date
>>> from datetime import timedelta
>>> try:
...     # Python 3
...     from io import BytesIO
... except ImportError:
...     # Python 2.x
...     from StringIO import StringIO as BytesIO
>>>
>>> # Import 3rd party libraries
>>> from aeso import equilibrium
>>>
>>> end_date = date.today()
>>> start_date = end_date - timedelta(1)
>>>
>>> f = BytesIO()
>>> try:
...     equilibrium.dump_equilibrium(f, start_date, end_date)
...     assert len(f.getvalue()) > 0
... finally:
...     f.close()
aeso.equilibrium.parse_equilibrium_file(f)

Yields QpPoint objects as extracted from the open CSV file-object f.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>> try:
...     from io import BytesIO
... except ImportError:
...     from StringIO import StringIO as BytesIO
>>>
>>> # 3rd Party Libraries
>>> import aeso
>>> from aeso import equilibrium
>>>
>>> end_date = date.today()
>>> start_date = end_date - timedelta(1)
>>>
>>> f = BytesIO()
>>> try:
...     equilibrium.dump_equilibrium(f, start_date, end_date)
...     ofs = f.seek(0)
...     data = list(equilibrium.parse_equilibrium_file(f))
...     assert len(data) > 0
... finally:
...     f.close()
>>>
>>> # Yesterday's market clearing price/demand points.
>>> for d in data:
...   ab_time = AB_TZ.normalize(d.t.astimezone(aeso.AB_TZ))
...   # print '{0} ${1} {2}MW'.format(ab_time, d.price, d.demand)
aeso.equilibrium.urlopen(start_date, end_date, timeout=None)

Returns a file-like object attached to the ETS pool price report webservice. Note that the webservice limits the number of days that can be queried to 721 days (as of 2009-11-12).

Parameters:
  • start_datedatetime.date
  • end_datedatetime.date
  • timeout – optional parameter specifying timeout in seconds for blocking operations like the connection attempt. If operation times out urllib2.URLError will be raised. ValueError will be raised in Python 2.4 and 2.5 if this parameter is set to anything but None.
Return type:

file-like object.

New in version 0.7: timeout parameter.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>>
>>> # 3rd Party Libraries
>>> from aeso import equilibrium
>>>
>>> end_date = date.today()
>>> start_date = end_date - timedelta(1)
>>>
>>> f = equilibrium.urlopen(start_date, end_date)
... try:
...     bytes = f.read()
...     assert len(bytes) > 0
... finally:
...     f.close()

Previous topic

aeso.csd — Current Supply/Demand (CSD) Report Access

Next topic

aeso.eventlog — Alberta Interconnected Electric System (AIES) Log Access

This Page