Class: AEMO::Market::Interval Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/aemo/market/interval.rb

Overview

This class is abstract.

AEMO::Market::Interval

Author:

  • Joel Courtney

Since:

  • 0.1.0

Constant Summary collapse

INTERVALS =

Since:

  • 0.1.0

{
  trading: 'Trading',
  dispatch: 'Dispatch'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datetime, options = {}) ⇒ AEMO::Market::Interval

Parameters:

  • datetime (Time)
  • options (Hash) (defaults to: {})

    Hash of optional data values

Since:

  • 0.1.0



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

def initialize(datetime, options = {})
  @datetime     = Time.parse("#{datetime} +1000")
  @region       = options['REGION']
  @total_demand = options['TOTALDEMAND']
  @rrp          = options['RRP']
  @period_type  = options['PERIODTYPE']
end

Instance Attribute Details

#datetime(trailing_edge = true) ⇒ Time

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 :( )

Parameters:

  • trailing_edge (Boolean) (defaults to: true)

    selection of either the trailing edge of the period or the rising edge of the period for the date time

Returns:

  • (Time)

    a time object of the trailing edge of the interval

Since:

  • 0.1.0



33
34
35
# File 'lib/aemo/market/interval.rb', line 33

def datetime
  @datetime
end

#period_typeObject

Since:

  • 0.1.0



14
15
16
# File 'lib/aemo/market/interval.rb', line 14

def period_type
  @period_type
end

#regionObject

Since:

  • 0.1.0



14
15
16
# File 'lib/aemo/market/interval.rb', line 14

def region
  @region
end

#rrpObject

Since:

  • 0.1.0



14
15
16
# File 'lib/aemo/market/interval.rb', line 14

def rrp
  @rrp
end

#total_demandObject

Since:

  • 0.1.0



14
15
16
# File 'lib/aemo/market/interval.rb', line 14

def total_demand
  @total_demand
end

Instance Method Details

#dispatch?Boolean

Returns true if the interval type is dispatch

Returns:

  • (Boolean)

    returns true if the interval type is dispatch

Since:

  • 0.1.0



58
59
60
# File 'lib/aemo/market/interval.rb', line 58

def dispatch?
  @period_type.nil? || @period_type.empty?
end

#interval_lengthTime

Returns the time of the.

Returns:

  • (Time)

    the time of the

Since:

  • 0.1.0



48
49
50
# File 'lib/aemo/market/interval.rb', line 48

def interval_length
  Time.at(300)
end

#interval_typeSymbol

Returns :dispatch or :trading.

Returns:

  • (Symbol)

    :dispatch or :trading

Since:

  • 0.1.0



53
54
55
# File 'lib/aemo/market/interval.rb', line 53

def interval_type
  dispatch? ? :dispatch : :trading
end

#trading?Boolean

Returns true if the interval type is trading

Returns:

  • (Boolean)

    returns true if the interval type is trading

Since:

  • 0.1.0



63
64
65
# File 'lib/aemo/market/interval.rb', line 63

def trading?
  !dispatch?
end

#valueFloat

Returns the value of the interval in Australian Dollars.

Returns:

  • (Float)

    the value of the interval in Australian Dollars

Since:

  • 0.1.0



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

def value
  @value ||= Float::NAN
  if @total_demand.class == Float && @rrp.class == Float
    @value = (@total_demand * @rrp).round(2)
  end
  @value
end