pyaeso.ets — Deprecated

The Energy Trading System (ETS) is a website <http://ets.aeso.ca> made available by the Alberta Electric System Operator (AESO) <http://www.aeso.ca> for energy trading and public information purposes. The ets module makes access to many of the reporting functions easier. This is useful for the contruction of market models and various heuristic “expert” trading systems.

The pyaeso.ets module defines the following functions:

pyaeso.ets.urlopen_pool_price(start_date, end_date)

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:
Return type:

file-like object as returned by urlopen.

Usage example:

>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>> end_date = datetime.date.today()
>>> start_date = end_date - datetime.timedelta(1)
>>>
>>> f = ets.urlopen_pool_price(start_date, end_date)
>>> print f.read()
>>> f.close()

Note

The raw ETS pool price report can be accessed at <http://ets.aeso.ca/ets_web/ip/Market/Reports/HistoricalPoolPriceReportServlet>.

pyaeso.ets.dump_pool_price(f_out, start_date = datetime.date(1995, 1, 1), end_date = datetime.date.today() + datetime.timedelta(1))

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.

Usage example:

>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>> end_date = datetime.date.today()
>>> start_date = end_date - datetime.timedelta(1)
>>>
>>> f = open('pool_price_report.csv', 'w')
>>> ets.dump_pool_price(f, start_date, end_date)
>>> f.close()
pyaeso.ets.parse_pool_price_file(f)

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

Usage example:

>>> # Standard library imports
>>> from StringIO import StringIO
>>> import datetime
>>>
>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>> end_date = datetime.date.today()
>>> start_date = end_date - datetime.timedelta(1)
>>>
>>> f = StringIO()
>>> ets.dump_pool_price(f, start_date, end_date)
>>> f.seek(0)
>>> data = list(ets.parse_pool_price_file(f))
>>> f.close()
>>>
>>> print "Yesterday's market clearing price/demand points."
>>> for d in data:
...   ab_time = d.t.astimezone(ets.ALBERTA_TZ)
...   print '{0} ${1} {2}MW'.format(ab_time, d.price, d.demand)
pyaeso.ets.urlopen_asset_list()

Returns a file-like object containing data returned by the ETS asset list webservice.

Return type:file-like object as returned by urlopen.

New in version 0.2.

Usage example:

>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>> f = ets.urlopen_asset_list()
>>> print f.read()
>>> f.close()

Note

The raw ETS asset list report can be accessed at <http://ets.aeso.ca/ets_web/ip/Market/Reports/AssetListReportServlet>.

pyaeso.ets.dump_asset_list(f_out)

Downloads asset list report and writes it to file-object f.

New in version 0.2.

Usage example:

>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>> f = open('asset_list_report.csv', 'w')
>>> ets.dump_asset_list(f)
>>> f.close()
pyaeso.ets.parse_asset_list_file(f)

Yields Asset objects extracted from the open file-object f.

New in version 0.2.

Usage example:

>>> # 3rd Party Libraries
>>> from pyaeso import ets
>>>
>>>
>>> f = ets.urlopen_asset_list()
>>> assets = list(ets.parse_asset_list_file(f))
>>> f.close()
pyaeso.ets.urlopen_marginal_pool_price(start_date, end_date)

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:
Return type:

file-like object as returned by urlopen.

New in version 0.4.

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 = datetime.date(2010, 1, 1)
>>> end_date = datetime.date(2010, 1, 31) + datetime.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()
pyaeso.ets.dump_marginal_pool_price(dst, start_date = datetime.date(1999, 10, 1), end_date = datetime.date.today() + datetime.timedelta(1))

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:

New in version 0.4.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>> from StringIO import StringIO
>>>
>>> # 3rd Party Libraries
>>> from pyaeso.ets import dump_marginal_pool_price
>>>
>>> start_date = datetime.date(2010, 1, 1)
>>> end_date = datetime.date(2010, 1, 31) + datetime.timedelta(1)
>>> # Remember, no data will be returned on end_date itself!
>>>
>>> f = StringIO()
>>> dump_marginal_pool_price(f)
>>> text = f.getvalue()
pyaeso.ets.parse_marginal_pool_price_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.4.

Usage example:

>>> # Standard library imports
>>> from datetime import date
>>> from datetime import timedelta
>>> from StringIO import StringIO
>>>
>>> # 3rd Party Libraries
>>> from pyaeso.ets import dump_marginal_pool_price, parse_marginal_pool_price_file
>>> from pyaeso import ets
>>>
>>> start_date = datetime.date(2010, 1, 1)
>>> end_date = datetime.date(2010, 1, 31) + datetime.timedelta(1)
>>> # Remember, no data will be returned on end_date itself!
>>>
>>> f = StringIO()
>>> dump_marginal_pool_price(f)
>>> f.seek(0)
>>>
>>> points = list(parse_marginal_pool_price_file(f))
>>>
>>> for pp in points:
...   # PPoint objects are iterable and can be unpacked!
...   time, price = pp
...   print time.astimezone(ets.ALBERTA_TZ), '$' + str(price)
...   # *time* is in UTC, so it must be converted to Alberta
...   # timezone before display.
class pyaeso.ets.QpPoint

Represents the market equilibrium at a given point in time.

t

UTC localized time at which price and demand are valid. Normally this time should be localized to Alberta Mountain Standard Time before being displayed to the user. (@type datetime.datetime)

Usage Example:

# QpPoint object *qp* as yielded by parse_pool_price_file method
qp.t.astimezone(ets.ALBERTA_TZ)`
price

Power price in CDN$/MW (@type Decimal).

demand

Power demand in megawatts (MW) (@type Decimal).

class pyaeso.ets.AssetType

An enumeration of asset types.

New in version 0.2.

SOURCE
SINK
class pyaeso.ets.AssetStatus

An enumeration of asset status’.

New in version 0.2.

ACTIVE
INACTIVE
RETIRED
SUSPENDED
class pyaeso.ets.Asset
__init__(self, asset_name, asset_id, asset_type, status, participant_name, participant_id)
Representation of an asset.

New in version 0.2.

asset_name

(@type str)

asset_id

(@type str)

asset_type

A value from AssetType enumeration.

status

A value from AssetStatus enumeration.

participant_name

(@type str)

participant_id

(@type str)

class pyaeso.ets.PPoint

A price at a given point in time.

Since PPoint objects will iterate over their properties t, and price, they can be unpacked as in the example. Also of note is that the time, t, attribute is normally stored in UTC and is normally converted to Alberta’s timezone before display.

New in version 0.4.

Usage example:

>>> from datetime import datetime
>>> from pyaeso import ets
>>>
>>> point = PPoint(datetime(2010, 2, 12, 10, 36), 4.56)
>>> t, price = point
>>> t.astimezone(ets.ALBERTA_TZ)
time
This is a UTC time and so normally must be converted to Alberta’s timezone before display.

(@type datetime.datetime).

price

(@type Decimal).

Previous topic

aeso.aieslog — Deprecated

This Page