Module: AEMO::Market Abstract

Includes:
HTTParty
Defined in:
lib/aemo/market.rb,
lib/aemo/market/node.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, Node

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



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

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

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

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

Description of method

Parameters:

Returns:

Since:

  • 0.1.0



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

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

  response = get "/mms.GRAPHS/GRAPHS/GRAPH_30#{region}1.csv"
  parse_response(response)
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 from AEMO

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



65
66
67
68
69
70
71
72
73
74
# File 'lib/aemo/market.rb', line 65

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

  month = Kernel.format('%02d', month)
  url = 'https://aemo.com.au/aemo/data/nem/priceanddemand/' \
        "PRICE_AND_DEMAND_#{year}#{month}_#{region}1.csv"

  response = HTTParty.get(url)
  parse_response(response)
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 (Time)

    this is inclusive not exclusive

  • finish (Time)

    this is inclusive not exclusive

Returns:

Since:

  • 0.1.0



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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 do |values|
    values.datetime >= start && values.datetime <= finish
  end
end