Class: TDAmeritrade::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, Error
Defined in:
lib/tdameritrade/client.rb

Instance Attribute Summary

Attributes included from Authentication

#access_token, #access_token_expires_at, #authorization_code, #client_id, #redirect_uri, #refresh_token, #refresh_token_expires_at

Instance Method Summary collapse

Methods included from Error

gem_error

Methods included from Authentication

#get_access_tokens, #get_new_access_token, #update_tokens

Methods included from Util

handle_api_error, parse_json_response, response_success?

Constructor Details

#initialize(**args) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
# File 'lib/tdameritrade/client.rb', line 18

def initialize(**args)
  @access_token = args[:access_token]
  @refresh_token = args[:refresh_token]
  @access_token_expires_at = args[:access_token_expires_at]
  @refresh_token_expires_at = args[:refresh_token_expires_at]
  @client_id = args[:client_id] || Error.gem_error('client_id is required!')
  @redirect_uri = args[:redirect_uri] || Error.gem_error('redirect_uri is required!')
end

Instance Method Details

#create_watchlist(account_id, watchlist_name, symbols) ⇒ Object



39
40
41
# File 'lib/tdameritrade/client.rb', line 39

def create_watchlist(, watchlist_name, symbols)
  Operations::CreateWatchlist.new(self).call(, watchlist_name, symbols)
end

#get_instrument_fundamentals(symbol) ⇒ Object



27
28
29
# File 'lib/tdameritrade/client.rb', line 27

def get_instrument_fundamentals(symbol)
  Operations::GetInstrumentFundamentals.new(self).call(symbol)
end

#get_price_history(symbol, **options) ⇒ Object



31
32
33
# File 'lib/tdameritrade/client.rb', line 31

def get_price_history(symbol, **options)
  Operations::GetPriceHistory.new(self).call(symbol, options)
end

#get_quotes(symbols) ⇒ Object



35
36
37
# File 'lib/tdameritrade/client.rb', line 35

def get_quotes(symbols)
  Operations::GetQuotes.new(self).call(symbols: symbols)
end

#get_watchlists(account_id) ⇒ Object



43
44
45
# File 'lib/tdameritrade/client.rb', line 43

def get_watchlists()
  Operations::GetWatchlists.new(self).call(account_id: )
end

#replace_watchlist(account_id, watchlist_id, watchlist_name, symbols_to_add = []) ⇒ Object



47
48
49
# File 'lib/tdameritrade/client.rb', line 47

def replace_watchlist(, watchlist_id, watchlist_name, symbols_to_add=[])
  Operations::ReplaceWatchlist.new(self).call(, watchlist_id, watchlist_name, symbols_to_add)
end

#update_watchlist(account_id, watchlist_id, watchlist_name, symbols_to_add = []) ⇒ Object



51
52
53
# File 'lib/tdameritrade/client.rb', line 51

def update_watchlist(, watchlist_id, watchlist_name, symbols_to_add=[])
  Operations::UpdateWatchlist.new(self).call(, watchlist_id, watchlist_name, symbols_to_add)
end