Skip to content

Commit ef9d7b8

Browse files
committed
autoconvert string args to get_instruments to a list
1 parent 324e58f commit ef9d7b8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

schwab/client/base.py

+3
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,9 @@ def get_instruments(self, symbols, projection):
11191119
- String, or array of strings
11201120
- Symbols for which to return fundamentals. Exact match.
11211121
'''
1122+
if isinstance(symbols, str):
1123+
symbols = [symbols]
1124+
11221125
projection = self.convert_enum(projection, self.Instrument.Projection)
11231126

11241127
params = {

tests/client_test.py

+9
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,15 @@ def test_get_instruments(self):
21782178
'projection': 'fundamental'})
21792179

21802180

2181+
def test_get_instruments_string_args(self):
2182+
self.client.get_instruments(
2183+
'AAPL', self.client_class.Instrument.Projection.FUNDAMENTAL)
2184+
self.mock_session.get.assert_called_once_with(
2185+
self.make_url('/marketdata/v1/instruments'), params={
2186+
'symbol': 'AAPL',
2187+
'projection': 'fundamental'})
2188+
2189+
21812190
def test_get_instruments_projection_unchecked(self):
21822191
self.client.set_enforce_enums(False)
21832192
self.client.get_instruments(

0 commit comments

Comments
 (0)