Sha256: e126289d99f440f76e806ae618990a5afeaa3bdba4534f685d05f4aacc63dff4

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

# These modules are used to facilitate referencing of most popular IB Contracts.
# For example, suppose you're explicitly creating such Contract in all your scripts:
#    wfc = IB::Contract.new(:symbol => "WFC",
#                           :exchange => "NYSE",
#                           :currency => "USD",
#                           :sec_type => :stock,
#                           :description => "Wells Fargo Stock"),
#
# Instead, you can put this contract definition into 'ib/symbols/stocks' and just reference
# it as IB::Symbols::Stock[:wfc] anywhere you need it.
#
# Note that the :description field is local to ib-ruby, and is NOT part of the standard TWS API.
# It is never transmitted to IB. It's purely used clientside, and you can store any arbitrary
# string that you may find useful there.

module IB
  module Symbols
    def [] symbol
      if contracts[symbol]
        return contracts[symbol]
      else
        # symbol probably has not been predefined, tell user about it
        file = self.to_s.split(/::/).last.downcase
        msg = "Unknown symbol :#{symbol}, please pre-define it in lib/ib/symbols/#{file}.rb"
        error msg, :symbol
      end
    end
  end
end

require 'ib/symbols/forex'
require 'ib/symbols/futures'
require 'ib/symbols/stocks'
require 'ib/symbols/options'
require 'ib/symbols/bonds'

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
my-ib-api-0.0.4 lib/ib/symbols.rb
my-ib-api-0.0.3 lib/ib/symbols.rb
my-ib-api-0.0.2 lib/ib/symbols.rb
my-ib-api-0.0.1 lib/ib/symbols.rb
ib-ruby-0.9.2 lib/ib/symbols.rb
ib-ruby-0.9.1 lib/ib/symbols.rb
ib-ruby-0.9.0 lib/ib/symbols.rb