Skip to content

Commit 26a6bec

Browse files
committed
Remove crypto and FX endpoints for Alpha Vantage
1 parent 18b784e commit 26a6bec

File tree

2 files changed

+0
-158
lines changed

2 files changed

+0
-158
lines changed

alpaca_trade_api/alpha_vantage/rest.py

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -128,112 +128,6 @@ def search_endpoint(self, keywords, datatype='json'):
128128
'keywords': keywords, 'datatype': datatype}
129129
return self.get(params)
130130

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.
136-
137-
Params:
138-
from_currency: The symbol to convert
139-
to_currency: The symbol to convert to
140-
cadence: Choose between ['daily', 'weekly', 'monthly']
141-
output_format: Choose between['json', 'csv', 'pandas']
142-
143-
Returns:
144-
pandas, csv, or json
145-
'''
146-
if output_format:
147-
self._foreignexchange.output_format = output_format
148-
if cadence == 'daily':
149-
data, _ = self._foreignexchange.get_currency_exchange_daily(
150-
from_symbol=from_symbol,
151-
to_symbol=to_symbol,
152-
outputsize=outputsize
153-
)
154-
if cadence == 'weekly':
155-
data, _ = self._foreignexchange.get_currency_exchange_weekly(
156-
from_symbol=from_symbol,
157-
to_symbol=to_symbol,
158-
outputsize=outputsize
159-
)
160-
if cadence == 'monthly':
161-
data, _ = self._foreignexchange.get_currency_exchange_monthly(
162-
from_symbol=from_symbol,
163-
to_symbol=to_symbol,
164-
outputsize=outputsize
165-
)
166-
return data
167-
168-
def intraday_fx_quotes(
169-
self, from_symbol, to_symbol, interval='5min',
170-
outputsize='full', output_format=None
171-
):
172-
''' Returns the FX_INTRADAY endpoint of the Alpha Vantage API.
173-
174-
Params:
175-
from_currency: The symbol to convert
176-
to_currency: The symbol to convert to
177-
interval: Choose between['1min', '5min', '15min', '30min', '60min']
178-
output_format: Choose between['json', 'csv', 'pandas']
179-
180-
Returns:
181-
pandas, csv, or json
182-
'''
183-
if output_format:
184-
self._foreignexchange.output_format = output_format
185-
data, _ = self._foreignexchange.get_currency_exchange_intraday(
186-
from_symbol=from_symbol,
187-
to_symbol=to_symbol,
188-
interval=interval,
189-
outputsize=outputsize
190-
)
191-
return data
192-
193-
def exchange_rate(self, from_currency, to_currency):
194-
''' Returns the exchange rate of two currencies, digital or physical.
195-
CURRENCY_EXCHANGE_RATE endpoint of the Alpha Vantage API
196-
197-
Params:
198-
from_currency: The symbol to convert
199-
to_currency: The symbol to convert to
200-
201-
Returns:
202-
json
203-
'''
204-
params = {'function': "CURRENCY_EXCHANGE_RATE",
205-
'from_currency': from_currency, 'to_currency': to_currency}
206-
data = self.get(params)
207-
return data
208-
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.
214-
215-
Params:
216-
symbol: The cryptocurrency to return
217-
market: The market it's being sold on
218-
cadence: Choose between ['daily', 'weekly', 'monthly']
219-
output_format: Choose between['json', 'csv', 'pandas']
220-
221-
Returns:
222-
pandas, csv, or json
223-
'''
224-
if output_format:
225-
self._cryptocurrencies.output_format = output_format
226-
if cadence == 'daily':
227-
data, _ = self._cryptocurrencies.get_digital_currency_daily(
228-
symbol=symbol, market=market)
229-
if cadence == 'weekly':
230-
data, _ = self._cryptocurrencies.get_digital_currency_weekly(
231-
symbol=symbol, market=market)
232-
if cadence == 'monthly':
233-
data, _ = self._cryptocurrencies.get_digital_currency_monthly(
234-
symbol=symbol, market=market)
235-
return data
236-
237131
def techindicators(
238132
self, techindicator='SMA', output_format='json', **kwargs
239133
):

tests/test_alpha_vantage/test_rest.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -272,58 +272,6 @@ def test_search_endpoint(self, mock_request):
272272
self.assertIsInstance(
273273
data, dict, 'Result Data must be a dict')
274274

275-
@requests_mock.Mocker()
276-
def test_historic_fx_quotes(self, mock_request):
277-
""" Test that api call returns a json file as requested
278-
"""
279-
cli = REST(TestAlphaVantage._API_KEY_TEST)
280-
url = "https://www.alphavantage.co/query?function=FX_DAILY&from_symbol=USD&to_symbol=EUR&outputsize=full&apikey=test"
281-
path_file = self.get_file_from_url("mock_foreign_exchange_historical")
282-
with open(path_file) as f:
283-
mock_request.get(url, text=f.read())
284-
data = cli.historic_fx_quotes('USD', 'EUR')
285-
self.assertIsInstance(
286-
data, dict, 'Result Data must be a dict')
287-
288-
@requests_mock.Mocker()
289-
def test_intraday_fx_quotes(self, mock_request):
290-
""" Test that api call returns a json file as requested
291-
"""
292-
cli = REST(TestAlphaVantage._API_KEY_TEST)
293-
url = "https://www.alphavantage.co/query?function=FX_INTRADAY&from_symbol=USD&to_symbol=EUR&outputsize=full&apikey=test"
294-
path_file = self.get_file_from_url("mock_intraday_fx")
295-
with open(path_file) as f:
296-
mock_request.get(url, text=f.read())
297-
data = cli.intraday_fx_quotes('USD', 'EUR')
298-
self.assertIsInstance(
299-
data, dict, 'Result Data must be a dict')
300-
301-
@requests_mock.Mocker()
302-
def test_exchange_rate(self, mock_request):
303-
""" Test that api call returns a json file as requested
304-
"""
305-
cli = REST(TestAlphaVantage._API_KEY_TEST)
306-
url = "https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=EUR&apikey=test"
307-
path_file = self.get_file_from_url("mock_foreign_exchange")
308-
with open(path_file) as f:
309-
mock_request.get(url, text=f.read())
310-
data = cli.exchange_rate('USD', 'EUR')
311-
self.assertIsInstance(
312-
data, dict, 'Result Data must be a dict')
313-
314-
@requests_mock.Mocker()
315-
def test_historic_cryptocurrency_quotes(self, mock_request):
316-
""" Test that api call returns a json file as requested
317-
"""
318-
cli = REST(TestAlphaVantage._API_KEY_TEST)
319-
url = "https://www.alphavantage.co/query?function=DIGITAL_CURRENCY_DAILY&symbol=BTC&market=CNY&apikey=test&datatype=json"
320-
path_file = self.get_file_from_url("mock_crypto_currencies")
321-
with open(path_file) as f:
322-
mock_request.get(url, text=f.read())
323-
data = cli.historic_cryptocurrency_quotes('BTC', 'CNY')
324-
self.assertIsInstance(
325-
data, dict, 'Result Data must be a dict')
326-
327275
@requests_mock.Mocker()
328276
def test_techindicators(self, mock_request):
329277
""" Test that api call returns a json file as requested

0 commit comments

Comments
 (0)