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.

Options Hash (options):

  • :symbols (String)

    A comma delimited list of symbols.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Options Hash (options):

  • :name (String)

    The watchlist name.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Options Hash (options):

  • :name (String)

    The watchlist name.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Options Hash (options):

  • :shares (String)

    The number of shares.

  • :purchase_date (String)

    The purchase date.

  • :purchase_price (String)

    The purchase price.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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.

Raises:

See Also:

Authentication:

  • Requires user context

Rate Limited?:

  • Yes



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