class AEMO::Market::Interval

AEMO::Market::Interval

@author Joel Courtney @abstract @since 0.1.0

Constants

INTERVALS

Attributes

datetime[W]
period_type[RW]
region[RW]
rrp[RW]
total_demand[RW]

Public Class Methods

new(datetime, options = {}) click to toggle source

Create a new instance of an Interval

@param [Time] datetime @param [Hash] options Hash of optional data values @return [AEMO::Market::Interval]

# File lib/aemo/market/interval.rb, line 24
def initialize(datetime, options = {})
  @datetime     = Time.parse("#{datetime} +1000")
  @region       = options['REGION']
  @total_demand = options['TOTALDEMAND']
  @rrp          = options['RRP']
  @period_type  = options['PERIODTYPE']
end

Public Instance Methods

datetime(trailing_edge = true) click to toggle source

All AEMO Data operates in Australian Eastern Standard Time All AEMO Data aggregates to the trailing edge of the period (this makes it difficult to do daily aggregations :( ) @param [Boolean] trailing_edge selection of either the trailing edge of the period or the rising edge of the period for the date time @return [Time] a time object of the trailing edge of the interval

# File lib/aemo/market/interval.rb, line 38
def datetime(trailing_edge = true)
  t = @datetime
  # If the datetime requested is the trailing edge, offset as per interval requirement
  unless trailing_edge
    # This is for dispatch intervals of five minutes
    if dispatch?
      t -= 5 * 60
    elsif trading?
      t -= 30 * 60
    end
  end
  t
end
dispatch?() click to toggle source

@return [Boolean] returns true if the interval type is dispatch

# File lib/aemo/market/interval.rb, line 63
def dispatch?
  @period_type.nil? || @period_type.empty?
end
interval_length() click to toggle source

@return [Time] the time of the

# File lib/aemo/market/interval.rb, line 53
def interval_length
  Time.at(300)
end
interval_type() click to toggle source

@return [Symbol] :dispatch or :trading

# File lib/aemo/market/interval.rb, line 58
def interval_type
  dispatch? ? :dispatch : :trading
end
trading?() click to toggle source

@return [Boolean] returns true if the interval type is trading

# File lib/aemo/market/interval.rb, line 68
def trading?
  !dispatch?
end
value() click to toggle source

@return [Float] the value of the interval in Australian Dollars

# File lib/aemo/market/interval.rb, line 73
def value
  @value ||= Float::NAN
  @value = (@total_demand * @rrp).round(2) if @total_demand.class == Float && @rrp.class == Float
  @value
end