Module: QuestradeClient::Symbol

Included in:
Client
Defined in:
lib/questrade_client/symbol.rb

Instance Method Summary collapse

Instance Method Details

#symboloptions(symbolid) ⇒ Array[Hash]

Retrieves an option chain for a particular underlying symbol.

Docs: www.questrade.com/api/documentation/rest-operations/market-calls/symbols-id-options

Examples:

client.symboloptions(9292)

Parameters:

  • Symbol (Integer)

    id to find options for

Returns:

  • (Array[Hash])

    List of option chain data for symbol



47
48
49
# File 'lib/questrade_client/symbol.rb', line 47

def symboloptions(symbolid)
    get("/symbols/#{symbolid}/options")['optionChain']
end

#symbols(args) ⇒ Array[Hash]

Retrieves the accounts associated with the user on behalf of which the API client is authorized.

Docs: www.questrade.com/api/documentation/rest-operations/account-calls/accounts

Examples:

client.symbols(9292)
client.symbols(['BMO', 'SHOP', 'VTI'])
client.symbols([9292, 8089])

Parameters:

  • args (Int|Array[Int|String])

    The ID of the symbol, or a list of symbol ids or names

Returns:

  • (Array[Hash])

    List of symbol data



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/questrade_client/symbol.rb', line 14

def symbols(args)
  if args.is_a?(Integer)
    get("/symbols/#{args}")['symbols']
  elsif args.length > 1 && args.first.is_a?(String)
    get("/symbols?names=#{args.join(',')}")['symbols']
  elsif args.length > 1 && args.first.is_a?(Integer)
    get("/symbols?ids=#{args.join(',')}")['symbols']
  else
    fail "Malformed argument: #{args}"
  end
end

#symbolsearch(prefix, offset = nil) ⇒ Array[Hash]

Retrieves symbol(s) using several search criteria.

Docs: www.questrade.com/api/documentation/rest-operations/market-calls/symbols-search

FIXME: add offset

Examples:

client.symbolsearch('BMO')

Parameters:

  • prefix (String)

    Prefix to use in search

Returns:

  • (Array[Hash])

    List of symbol data



35
36
37
# File 'lib/questrade_client/symbol.rb', line 35

def symbolsearch(prefix, offset=nil)
    get("/symbols/search?prefix=#{prefix}")['symbols']
end