Class: AEMO::Market::Interval Abstract
- Inherits:
-
Object
- Object
- AEMO::Market::Interval
- Defined in:
- lib/aemo/market/interval.rb
Overview
AEMO::Market::Interval
Constant Summary collapse
- INTERVALS =
{ trading: 'Trading', dispatch: 'Dispatch' }.freeze
Instance Attribute Summary collapse
-
#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 :( ).
- #period_type ⇒ Object
- #region ⇒ Object
- #rrp ⇒ Object
- #total_demand ⇒ Object
Instance Method Summary collapse
-
#dispatch? ⇒ Boolean
Returns true if the interval type is dispatch.
-
#initialize(datetime, options = {}) ⇒ AEMO::Market::Interval
constructor
Create a new instance of an Interval.
-
#interval_length ⇒ Time
The time of the.
-
#interval_type ⇒ Symbol
:dispatch or :trading.
-
#trading? ⇒ Boolean
Returns true if the interval type is trading.
-
#value ⇒ Float
The value of the interval in Australian Dollars.
Constructor Details
#initialize(datetime, options = {}) ⇒ AEMO::Market::Interval
Create a new instance of an Interval
24 25 26 27 28 29 30 |
# File 'lib/aemo/market/interval.rb', line 24 def initialize(datetime, = {}) @datetime = ::Time.parse("#{datetime} +1000") @region = ['REGION'] @total_demand = ['TOTALDEMAND'] @rrp = ['RRP'] @period_type = ['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 :( )
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 |
#period_type ⇒ Object
16 17 18 |
# File 'lib/aemo/market/interval.rb', line 16 def period_type @period_type end |
#region ⇒ Object
16 17 18 |
# File 'lib/aemo/market/interval.rb', line 16 def region @region end |
#rrp ⇒ Object
16 17 18 |
# File 'lib/aemo/market/interval.rb', line 16 def rrp @rrp end |
#total_demand ⇒ Object
16 17 18 |
# File 'lib/aemo/market/interval.rb', line 16 def total_demand @total_demand end |
Instance Method Details
#dispatch? ⇒ Boolean
Returns true if the interval type is dispatch
63 64 65 |
# File 'lib/aemo/market/interval.rb', line 63 def dispatch? @period_type.nil? || @period_type.empty? end |
#interval_length ⇒ Time
Returns the time of the.
53 54 55 |
# File 'lib/aemo/market/interval.rb', line 53 def interval_length ::Time.at(300) end |
#interval_type ⇒ Symbol
Returns :dispatch or :trading.
58 59 60 |
# File 'lib/aemo/market/interval.rb', line 58 def interval_type dispatch? ? :dispatch : :trading end |
#trading? ⇒ Boolean
Returns true if the interval type is trading
68 69 70 |
# File 'lib/aemo/market/interval.rb', line 68 def trading? !dispatch? end |
#value ⇒ Float
Returns the value of the interval in Australian Dollars.
73 74 75 76 77 |
# File 'lib/aemo/market/interval.rb', line 73 def value @value ||= Float::NAN @value = (@total_demand * @rrp).round(2) if @total_demand.instance_of?(Float) && @rrp.instance_of?(Float) @value end |