Skip to content

Commit a842e2b

Browse files
committed
Fix issues caught by flake8
1 parent 86056bf commit a842e2b

File tree

4 files changed

+66
-23
lines changed

4 files changed

+66
-23
lines changed

alpaca_trade_api/alpha_vantage/rest.py

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _request(self, method, params=None):
2727
return resp.json()
2828

2929
def get(self, params=None):
30-
''' Customizable endpoint, where you can pass all
30+
''' Customizable endpoint, where you can pass all
3131
keywords/paramters from the documentation:
3232
https://www.alphavantage.co/documentation/#
3333
@@ -36,13 +36,17 @@ def get(self, params=None):
3636
'''
3737
return self._request('GET', params=params)
3838

39-
def historic_quotes(self, symbol, adjusted=False, outputsize='full', cadence='daily', output_format=None):
40-
''' Returns the one of the TIME_SERIES_* endpoints of the Alpha Vantage API.
39+
def historic_quotes(
40+
self, symbol, adjusted=False, outputsize='full',
41+
cadence='daily', output_format=None
42+
):
43+
''' Returns one of the TIME_SERIES_* endpoints
44+
of the Alpha Vantage API.
4145
4246
Params:
4347
symbol: The ticker to return
4448
adjusted: Return the adjusted prices
45-
cadence: Choose between ['daily', 'weekly', 'monthly'], to return the cadence
49+
cadence: Choose between ['daily', 'weekly', 'monthly']
4650
output_format: Choose between['json', 'csv', 'pandas']
4751
4852
Returns:
@@ -52,16 +56,27 @@ def historic_quotes(self, symbol, adjusted=False, outputsize='full', cadence='da
5256
self._timeseries.output_format = output_format
5357
if cadence == 'daily':
5458
data, _ = self._timeseries.get_daily_adjusted(
55-
symbol=symbol, outputsize=outputsize) if adjusted else self._timeseries.get_daily(symbol=symbol, outputsize=outputsize)
59+
symbol=symbol, outputsize=outputsize
60+
) if adjusted else self._timeseries.get_daily(
61+
symbol=symbol, outputsize=outputsize
62+
)
5663
if cadence == 'weekly':
5764
data, _ = self._timeseries.get_weekly_adjusted(
58-
symbol=symbol) if adjusted else self._timeseries.get_weekly(symbol=symbol)
65+
symbol=symbol
66+
) if adjusted else self._timeseries.get_weekly(
67+
symbol=symbol
68+
)
5969
if cadence == 'monthly':
6070
data, _ = self._timeseries.get_monthly_adjusted(
61-
symbol=symbol) if adjusted else self._timeseries.get_monthly(symbol=symbol)
71+
symbol=symbol
72+
) if adjusted else self._timeseries.get_monthly(
73+
symbol=symbol
74+
)
6275
return data
6376

64-
def intraday_quotes(self, symbol, interval='5min', outputsize='full', output_format=None):
77+
def intraday_quotes(
78+
self, symbol, interval='5min', outputsize='full', output_format=None
79+
):
6580
''' Returns the TIME_SERIES_INTRADAY endpoint of the Alpha Vantage API.
6681
6782
Params:
@@ -113,13 +128,16 @@ def search_endpoint(self, keywords, datatype='json'):
113128
'keywords': keywords, 'datatype': datatype}
114129
return self.get(params)
115130

116-
def historic_fx_quotes(self, from_symbol, to_symbol, outputsize='full', cadence='daily', output_format=None):
117-
''' Returns the one of the FX_* endpoints of the Alpha Vantage API.
131+
def historic_fx_quotes(
132+
self, from_symbol, to_symbol, outputsize='full',
133+
cadence='daily', output_format=None
134+
):
135+
''' Returns one of the FX_* endpoints of the Alpha Vantage API.
118136
119137
Params:
120138
from_currency: The symbol to convert
121139
to_currency: The symbol to convert to
122-
cadence: Choose between ['daily', 'weekly', 'monthly'], to return the cadence
140+
cadence: Choose between ['daily', 'weekly', 'monthly']
123141
output_format: Choose between['json', 'csv', 'pandas']
124142
125143
Returns:
@@ -129,16 +147,28 @@ def historic_fx_quotes(self, from_symbol, to_symbol, outputsize='full', cadence=
129147
self._foreignexchange.output_format = output_format
130148
if cadence == 'daily':
131149
data, _ = self._foreignexchange.get_currency_exchange_daily(
132-
from_symbol=from_symbol, to_symbol=to_symbol, outputsize=outputsize)
150+
from_symbol=from_symbol,
151+
to_symbol=to_symbol,
152+
outputsize=outputsize
153+
)
133154
if cadence == 'weekly':
134155
data, _ = self._foreignexchange.get_currency_exchange_weekly(
135-
from_symbol=from_symbol, to_symbol=to_symbol, outputsize=outputsize)
156+
from_symbol=from_symbol,
157+
to_symbol=to_symbol,
158+
outputsize=outputsize
159+
)
136160
if cadence == 'monthly':
137161
data, _ = self._foreignexchange.get_currency_exchange_monthly(
138-
from_symbol=from_symbol, to_symbol=to_symbol, utputsize=outputsize)
162+
from_symbol=from_symbol,
163+
to_symbol=to_symbol,
164+
outputsize=outputsize
165+
)
139166
return data
140167

141-
def intraday_fx_quotes(self, from_symbol, to_symbol, interval='5min', outputsize='full', output_format=None):
168+
def intraday_fx_quotes(
169+
self, from_symbol, to_symbol, interval='5min',
170+
outputsize='full', output_format=None
171+
):
142172
''' Returns the FX_INTRADAY endpoint of the Alpha Vantage API.
143173
144174
Params:
@@ -153,7 +183,11 @@ def intraday_fx_quotes(self, from_symbol, to_symbol, interval='5min', outputsize
153183
if output_format:
154184
self._foreignexchange.output_format = output_format
155185
data, _ = self._foreignexchange.get_currency_exchange_intraday(
156-
from_symbol=from_symbol, to_symbol=to_symbol, interval=interval, outputsize=outputsize)
186+
from_symbol=from_symbol,
187+
to_symbol=to_symbol,
188+
interval=interval,
189+
outputsize=outputsize
190+
)
157191
return data
158192

159193
def exchange_rate(self, from_currency, to_currency):
@@ -172,13 +206,16 @@ def exchange_rate(self, from_currency, to_currency):
172206
data = self.get(params)
173207
return data
174208

175-
def historic_cryptocurrency_quotes(self, symbol, market, cadence='daily', output_format=None):
176-
''' Returns the one of the DIGITAL_CURRENCY_* endpoints of the Alpha Vantage API.
209+
def historic_cryptocurrency_quotes(
210+
self, symbol, market, cadence='daily', output_format=None
211+
):
212+
''' Returns one of the DIGITAL_CURRENCY_* endpoints of the
213+
Alpha Vantage API.
177214
178215
Params:
179216
symbol: The cryptocurrency to return
180217
market: The market it's being sold on
181-
cadence: Choose between ['daily', 'weekly', 'monthly'], to return the cadence
218+
cadence: Choose between ['daily', 'weekly', 'monthly']
182219
output_format: Choose between['json', 'csv', 'pandas']
183220
184221
Returns:
@@ -197,8 +234,11 @@ def historic_cryptocurrency_quotes(self, symbol, market, cadence='daily', output
197234
symbol=symbol, market=market)
198235
return data
199236

200-
def techindicators(self, techindicator='SMA', output_format='json', **kwargs):
201-
''' Returns the one of the technical indicator endpoints of the Alpha Vantage API.
237+
def techindicators(
238+
self, techindicator='SMA', output_format='json', **kwargs
239+
):
240+
''' Returns one of the technical indicator endpoints of the
241+
Alpha Vantage API.
202242
203243
Params:
204244
techindicator: The technical indicator of choice

alpaca_trade_api/entity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@ def __getattr__(self, key):
152152
return val
153153
return super().__getattr__(key)
154154

155+
155156
class Watchlist(Entity):
156157
pass

alpaca_trade_api/polygon/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def last_quote(self, symbol):
151151
raw = self.get(path)
152152
# TODO status check
153153
return Quote(raw['last'])
154-
154+
155155
def previous_day_bar(self, symbol):
156156
path = '/aggs/ticker/{}/prev'.format(symbol)
157157
raw = self.get(path, version='v2')

alpaca_trade_api/rest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ def add_watchlist(self, watchlist_name):
416416
return [Watchlist(o) for o in resp]
417417

418418
def add_to_watchlist(self, watchlist_id, symbol):
419-
resp = self.post('/watchlists/{}'.format(watchlist_id), data=dict(symbol=symbol))
419+
resp = self.post(
420+
'/watchlists/{}'.format(watchlist_id), data=dict(symbol=symbol)
421+
)
420422
return Watchlist(resp)
421423

422424
def update_watchlist(self, watchlist_id, name=None, symbols=None):

0 commit comments

Comments
 (0)