Class: Schwab::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, Error
Defined in:
lib/schwab/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, #secret

Instance Method Summary collapse

Methods included from Error

raise_error

Methods included from Authentication

#authorization_header_token, #default_headers, #refresh_access_token, #request_access_token

Methods included from Util

response_success?

Constructor Details

#initialize(**args) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
# File 'lib/schwab/client.rb', line 14

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] || raise_error('client_id is required!')
  @secret = args[:secret] || raise_error('client_id is required!')
  @redirect_uri = args[:redirect_uri] || raise_error('redirect_uri is required!')
end

Instance Method Details

#get_instrument(symbol, projection) ⇒ Object



24
25
26
# File 'lib/schwab/client.rb', line 24

def get_instrument(symbol, projection)
  Operations::GetInstrument.new(self).call(symbol, projection:)
end

#get_price_history(symbol, **options) ⇒ Object



28
29
30
# File 'lib/schwab/client.rb', line 28

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

#get_quotes(symbols, **options) ⇒ Object



32
33
34
# File 'lib/schwab/client.rb', line 32

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