Skip to content

Commit

Permalink
added quote and options chain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgolec committed May 5, 2024
1 parent 309bd14 commit f4e0957
Show file tree
Hide file tree
Showing 2 changed files with 321 additions and 269 deletions.
16 changes: 9 additions & 7 deletions schwab/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ def get_user_preferences(self):
'''Preferences for the logged in account, including all linked
accounts.'''
path = '/trader/v1/userPreference'
return self._get_request(path, ())
return self._get_request(path, {})


##########################################################################
# Quotes

class GetQuote:
class Quote:
class Fields(Enum):
QUOTE = 'quote'
FUNDAMENTAL = 'fundamental'
Expand All @@ -446,9 +446,9 @@ def get_quote(self, symbol, *, fields=None):
:param fields: Fields to request. If unset, return all available data.
i.e. all fields. See :class:`GetQuote.Field` for options.
'''
fields = self.convert_enum_iterable(fields, self.GetQuote.Fields)
fields = self.convert_enum_iterable(fields, self.Quote.Fields)
if fields:
params = {'fields': fields}
params = {'fields': ','.join(fields)}
else:
params = {}

Expand All @@ -470,9 +470,9 @@ def get_quotes(self, symbols, *, fields=None, indicative=None):
'symbols': ','.join(symbols)
}

fields = self.convert_enum_iterable(fields, self.GetQuote.Fields)
fields = self.convert_enum_iterable(fields, self.Quote.Fields)
if fields:
params['fields'] = fields
params['fields'] = ','.join(fields)

if indicative is not None:
if type(indicative) is not bool:
Expand Down Expand Up @@ -603,9 +603,9 @@ def get_option_chain(
strike_range, self.Options.StrikeRange)
option_type = self.convert_enum(option_type, self.Options.Type)
exp_month = self.convert_enum(exp_month, self.Options.ExpirationMonth)
entitlement = self.convert_enum(entitlement, self.Options.Entitlement)

params = {
'apikey': self.api_key,
'symbol': symbol,
}

Expand Down Expand Up @@ -639,6 +639,8 @@ def get_option_chain(
params['expMonth'] = exp_month
if option_type is not None:
params['optionType'] = option_type
if entitlement is not None:
params['entitlement'] = entitlement

path = '/marketdata/v1/chains'
return self._get_request(path, params)
Expand Down
Loading

0 comments on commit f4e0957

Please sign in to comment.