Module: AEMO::Market Abstract

Includes:
HTTParty
Defined in:
lib/aemo/market.rb,
lib/aemo/market/interval.rb

Overview

This module is abstract.

AEMO::Market

Author:

  • Joel Courtney

Since:

  • 0.1.0

Defined Under Namespace

Classes: Interval

Class Method Summary collapse

Class Method Details

.current_dispatch(region) ⇒ Array<AEMO::Market::Interval>

Return the current dispatch dataset for a region

Parameters:

Returns:

Since:

  • 0.1.0



17
18
19
20
21
22
23
# File 'lib/aemo/market.rb', line 17

def current_dispatch(region)
  region = AEMO::Region.new(region) if region.is_a?(String)

  response = get "/mms.GRAPHS/GRAPHS/GRAPH_5#{region}1.csv"
  values = parse_response(response)
  values
end

.current_trading(region) ⇒ Array<AEMO::Market::Interval>

Description of method

Parameters:

Returns:

Since:

  • 0.1.0



29
30
31
32
33
34
35
# File 'lib/aemo/market.rb', line 29

def current_trading(region)
  region = AEMO::Region.new(region) if region.is_a?(String)

  response = get "/mms.GRAPHS/GRAPHS/GRAPH_30#{region}1.csv"
  values = parse_response(response)
  values
end

.historic_trading(region, year, month) ⇒ Array<AEMO::Market::Interval>

Return an array of historic trading values for a Year, Month and Region

As per the historical data at
http://www.aemo.com.au/Electricity/Data/Price-and-Demand/Aggregated-Price-and-Demand-Data-Files/Aggregated-Price-and-Demand-2011-to-2016

Parameters:

  • region (String, AEMO::Region)

    AEMO::Region

  • year (Integer)

    The year for the report from AEMO

  • month (Integer)

    The month for the report from AEMO

Returns:

Since:

  • 0.1.0



62
63
64
65
66
67
68
69
70
# File 'lib/aemo/market.rb', line 62

def historic_trading(region, year, month)
  region = AEMO::Region.new(region) if region.is_a?(String)

  month = sprintf('%02d', month)

  response = get "/mms.GRAPHS/data/DATA#{year}#{month}_#{region}1.csv"
  values = parse_response(response)
  values
end

.historic_trading_by_range(region, start, finish) ⇒ Array<AEMO::Market::Interval>

Return an array of historic trading values based on a start and finish

Parameters:

  • region (String, AEMO::Region)

    AEMO::Region

  • start (DateTime)

    this is inclusive not exclusive

  • finish (DateTime)

    this is inclusive not exclusive

Returns:

Since:

  • 0.1.0



43
44
45
46
47
48
49
50
51
52
# File 'lib/aemo/market.rb', line 43

def historic_trading_by_range(region, start, finish)
  region = AEMO::Region.new(region) if region.is_a?(String)

  required_data = []
  (start..finish).map { |d| { year: d.year, month: d.month } }.uniq.each do |period|
    required_data += historic_trading(region, period[:year], period[:month])
  end

  required_data.select { |values| values.datetime >= start && values.datetime <= finish }
end