Module: Tradier::API::Watchlists

Includes:
Utils
Included in:
Client
Defined in:
lib/tradier/api/watchlists.rb

Instance Method Summary collapse

Instance Method Details

#add_watchlist_item(id, options = {}) ⇒ Tradier::Watchlist Also known as: create_watchlist_item, create_watchlist_symbol, add_watchlist_symbol

Update a watchlist symbol.

Parameters:

  • id (String)

    The watchlist id.

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

Options Hash (options):

  • :symbols (String)

    A comma delimited list of symbols.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



94
95
96
# File 'lib/tradier/api/watchlists.rb', line 94

def add_watchlist_item(id, options={})
  object_from_response(Tradier::WatchlistItem, :post, "/watchlists/#{id}/symbols", options)
end

#create_watchlist(options = {}) ⇒ Tradier::Watchlist

Create a new watchlist.

Parameters:

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

Options Hash (options):

  • :name (String)

    The watchlist name.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



51
52
53
# File 'lib/tradier/api/watchlists.rb', line 51

def create_watchlist(options={})
  object_from_response(Tradier::Watchlist, :post, '/watchlists', options)
end

#delete_watchlist(id, options = {}) ⇒ Boolean

Delete a watchlist.

Parameters:

  • id (String)

    The watchlist id.

Returns:

  • (Boolean)

    Result of watchlist removal.

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



38
39
40
# File 'lib/tradier/api/watchlists.rb', line 38

def delete_watchlist(id, options={})
  send(:delete, "/watchlists/#{id}", options)[:status] == 200
end

#remove_watchlist_item(id, symbol, options = {}) ⇒ Tradier::Watchlist Also known as: delete_watchlist_item, remove_watchlist_symbol, delete_watchlist_symbol

Remove a watchlist symbol.

Parameters:

  • id (String)

    The watchlist id.

  • symbol (String)

    The watchlist symbol.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



111
112
113
# File 'lib/tradier/api/watchlists.rb', line 111

def remove_watchlist_item(id, symbol, options={})
  send(:delete, "/watchlists/#{id}/symbols/#{symbol}", options)[:status] == 200
end

#update_watchlist(id, options = {}) ⇒ Tradier::Watchlist

Update a watchlist.

Parameters:

  • id (String)

    The watchlist id.

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

Options Hash (options):

  • :name (String)

    The watchlist name.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



65
66
67
# File 'lib/tradier/api/watchlists.rb', line 65

def update_watchlist(id, options={})
  object_from_response(Tradier::Watchlist, :put, "/watchlists/#{id}", options)
end

#update_watchlist_item(id, symbol, options = {}) ⇒ Tradier::WatchlistItem Also known as: update_watchlist_symbol

Update a watchlist symbol.

Parameters:

  • id (String)

    The watchlist id.

  • symbol (String)

    The watchlist symbol.

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

Options Hash (options):

  • :shares (String)

    The number of shares.

  • :purchase_date (String)

    The purchase date.

  • :purchase_price (String)

    The purchase price.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



132
133
134
# File 'lib/tradier/api/watchlists.rb', line 132

def update_watchlist_item(id, symbol, options={})
  object_from_response(Tradier::WatchlistItem, :put, "/watchlists/#{id}/symbols/#{symbol}", options)
end

#watchlist(id, options = {}) ⇒ Tradier::Watchlist

Get a watchlist.

Parameters:

  • id (String)

    The watchlist id.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



26
27
28
# File 'lib/tradier/api/watchlists.rb', line 26

def watchlist(id, options={})
  object_from_response(Tradier::Watchlist, :get, "/watchlists/#{id}", options)
end

#watchlist_item(id, symbol, options = {}) ⇒ Tradier::WatchlistItem Also known as: watchlist_symbol

Retrieve a watchlist symbol.

Parameters:

  • id (String)

    The watchlist id.

  • symbol (String)

    The watchlist symbol.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



78
79
80
# File 'lib/tradier/api/watchlists.rb', line 78

def watchlist_item(id, symbol, options={})
  object_from_response(Tradier::WatchlistItem, :get, "/watchlists/#{id}/symbols/#{symbol}", options)
end

#watchlists(options = {}) ⇒ Array<Tradier::Watchlist>

Get all watchlists.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



14
15
16
# File 'lib/tradier/api/watchlists.rb', line 14

def watchlists(options={})
  response = object_from_response(Tradier::API::Utils::Watchlist, :get, '/watchlists', options).body
end