Class: RTicker::Option

Inherits:
Entry
  • Object
show all
Defined in:
lib/rticker/option.rb

Overview

Represents option contracts which are derivatives of either equities or futures.

Instance Attribute Summary collapse

Attributes inherited from Entry

#bold, #curr_value, #description, #last_changed, #purchase_count, #purchase_price, #symbol

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, description = nil, purchase_count = nil, purchase_price = nil, bold = false) ⇒ Option

Returns a new instance of Option.



19
20
21
22
# File 'lib/rticker/option.rb', line 19

def initialize (symbol, description=nil, purchase_count=nil, purchase_price=nil, bold=false)
  super(symbol, description, purchase_count, purchase_price, bold)
  @bid = @ask = nil
end

Instance Attribute Details

#askObject

Because option contracts are not traded as much as their underlying, the bid/ask spread can be pretty high and there might be quite a bit of time since a trade has occurred for a given contract. Therefore it is sometimes more meaningful to represent the value of an option by showing both the current bid and ask prices rather than the last trade price.



17
18
19
# File 'lib/rticker/option.rb', line 17

def ask
  @ask
end

#bidObject

Because option contracts are not traded as much as their underlying, the bid/ask spread can be pretty high and there might be quite a bit of time since a trade has occurred for a given contract. Therefore it is sometimes more meaningful to represent the value of an option by showing both the current bid and ask prices rather than the last trade price.



17
18
19
# File 'lib/rticker/option.rb', line 17

def bid
  @bid
end

Class Method Details

.update(entries) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rticker/option.rb', line 24

def Option.update (entries)
  go = Proc.new do |entry|
    Thread.new { Option.run_update entry }
  end

  threads = []
  for entry in entries
    # Can only grab one option contract at a time, so request each one in
    # a separate thread.
    threads << go.call(entry)
  end
  threads.each {|t| t.join}
end