aeso.mpp — Marginal pool prices

Access to marginal pool price (MPP) data. The raw report can be accessed at <http://ets.aeso.ca/ets_web/ip/Market/Reports/HistoricalSystemMarginalPriceReportServlet>.

class aeso.mpp.PPoint(dt, price)

A price at a given point in time.

Since PPoint objects will iterate over their properties t, and price, they can be unpacked:

>>> from datetime import datetime
>>> point = PPoint(datetime(2010, 2, 12, 10, 36), '4.56')
>>> t, price = point
dt

Equal to property PPoint.t

price

decimal.Decimal property

t

datetime.datetime property

aeso.mpp.dump_mpp(dst, start_date=datetime.date(1999, 10, 1), end_date=None, timeout=None)

Downloads market marginal pool price data from ETS and writes it to file object dst. Unlike urlopen_marginal_pool_price there is no limit on the amount of data that can be requested. Internally an iterator is used to query data in 31 day blocks before it is written to dst. Output is included for start_date but excludes data for end_date.

Parameters:
  • dst – writeable file object
  • 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.

New in version 0.6.

New in version 0.7: timeout parameter.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>> try:
...     # For Python 3
...     from io import BytesIO
... except ImportError:
...     # For Python 2.x
...     from StringIO import StringIO as BytesIO
>>>
>>> # 3rd Party Libraries
>>> from aeso import mpp
>>>
>>> start_date = date(2010, 1, 1)
>>> end_date = date(2010, 1, 31) + timedelta(1)
>>> # Remember, no data will be returned on end_date itself!
>>>
>>> f = BytesIO()
>>> mpp.dump_mpp(f, start_date, end_date)
>>> text = f.getvalue()
>>> f.close()
aeso.mpp.parse_mpp_file(f)

Yields a PPoint object for each price point in marginal pool price data report file-object f. As always, times are UTC.

New in version 0.6.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>> try:
...     # For Python 3
...     from io import BytesIO
... except ImportError:
...     # For Python 2.x
...     from StringIO import StringIO as BytesIO
>>>
>>> # 3rd Party Libraries
>>> from aeso.mpp import dump_mpp, parse_mpp_file
>>> from aeso import AB_TZ, UTC_TZ
>>>
>>> start_date = date(2010, 1, 1)
>>> end_date = date(2010, 1, 31) + timedelta(1)
>>> # Remember, no data will be returned on end_date itself!
>>>
>>> f = BytesIO()
>>> dump_mpp(f, start_date, end_date)
>>> ofs = f.seek(0)
>>>
>>> points = list(parse_mpp_file(f))
>>>
>>> for pp in points:
...   # PPoint objects are iterable and can be unpacked!
...   utc_dt, price = pp
...   # print '%s, $%f' % (AB_TZ.normalize(utc_dt.astimezone(AB_TZ)), price)
...   # *time* is in UTC, so it must be converted to Alberta
...   # timezone before display.
aeso.mpp.urlopen(start_date, end_date, timeout=None)

Returns a file-like object attached to the ETS marginal pool price report. The report is limited by AESO to returning 31 days of information (2010-02-09). The report will include data for start_date but not for end_date. The earliest date for which marginal price information is available is 1999-10-01 (2010-02-10). start_date must be before end_date.

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 as returned by urlopen.

New in version 0.6.

New in version 0.7: timeout parameter.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>>
>>> # 3rd Party Libraries
>>> from pyaeso.ets import urlopen_marginal_pool_price
>>>
>>> start_date = date(2010, 1, 1)
>>> end_date = date(2010, 1, 31) + timedelta(1)
>>> # If you want to include all days in january, must add 24 hours.
>>> # Remember that there will be no information returned for
>>> # *end_date* itself, only for dates prior to it!
>>>
>>> f = urlopen_marginal_pool_price(start_date, end_date)
>>> text = f.read()
>>> f.close()

Previous topic

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

Next topic

Examples

This Page