======
pyaeso
======

pyaeso  is a python package that makes access to the Alberta Electric System
Operator's (AESO) Energy Trading System (ETS) easier.

The Alberta Electric Systems Operator (AESO) <http://en.wikipedia.org/wiki/AESO>
operates the Canadian province of Alberta's deregulated electricity
market.  AESO provides price, demand, and other valuable information
through the publically accessible Energy Trading System (ETS) website
[http://ets.aeso.ca].  This information is useful for economic analysis,
power trading, electric system study, and electric system forecasting.
The first step in using such information is to download it and parse it
into useful data structures - a task performed by this library.
Typically the data will feed statistical methods, heuristics, and system
models to provide useful analysis of the Alberta electric system.


Requirements
============
* *Python 2.4 or better* - Available at <http://python.org/download>
  (2009-11-25).

* *pytz* - "World timezone definitions, modern and historical".
  Available at <http://pypi.python.org/pypi/pytz> (2009-11-14).


Installation
============

Extracting the archive, enter the recovered directory and type:

``python setup.py install``


Usage
=====

Some code samples that use pyaeso are availble in the ``examples``
directory.  One sample is listed here::

    '''Print yesterday's market clearing price/demand points and exit.'''

    # Standard library imports
    import sys
    from StringIO import StringIO
    import datetime
    from pprint import pprint

    # 3rd Party Libraries
    from pyaeso import ets

    def  main():
        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)
        #print f.getvalue()
        data = list(ets.parse_pool_price_file(f))
        f.close()

        pprint('''Yesterday's market clearing price/demand points.''')
        for d in data:
            # Time calculations are easier when done in UTC so that no timezone
            # conversions or daylist-savings time conversions need to be made.  For
            # this reason all times yielded by pyaeso are UTC.
            #
            # UTC times are converted to local times when they are displayed to the
            # user.
            print '{0} ${1} {2}MW'.format(d.t.astimezone(ets.ALBERTA_TZ), d.price, d.demand)

        return(0)


    if __name__ == '__main__':
        sys.exit(main())



Known Incompatibilities
=======================
* *Python < 2.4* - untested on these versions of python.  There does not
  appear to be a technical reason why Python 2.3 will not work, but use
  at your own risk.  Pyaeso makes extensive use of the Decimal class
  which was distributed beginning with Python 2.3.  The underlying pytz
  library supports Python 2.3 and above.  Trying to use pyaeso with
  Python 2.2 or below will definately fail out-of-the box.

* *Python 3* - pyaeso uses the pytz package which has no Python 3 version
  (2009-11-14).


