From eecc765cb7f492489b6338bc4046c6f17a2eb425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Lipt=C3=A1k?= Date: Sun, 9 Jul 2017 15:27:59 -0400 Subject: [PATCH] Removed Oanda as it became subscription only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gábor Lipták --- docs/source/remote_data.rst | 37 ----------------- docs/source/whatsnew/v0.5.0.txt | 7 ++++ pandas_datareader/data.py | 7 ---- pandas_datareader/oanda.py | 58 --------------------------- pandas_datareader/tests/test_oanda.py | 41 ------------------- 5 files changed, 7 insertions(+), 143 deletions(-) delete mode 100644 pandas_datareader/oanda.py delete mode 100644 pandas_datareader/tests/test_oanda.py diff --git a/docs/source/remote_data.rst b/docs/source/remote_data.rst index 2f1efa80..02470e3f 100644 --- a/docs/source/remote_data.rst +++ b/docs/source/remote_data.rst @@ -33,7 +33,6 @@ Currently the following sources are supported: - :ref:`OECD` - :ref:`Eurostat` - :ref:`Thrift Savings Plan` - - :ref:`Oanda currency historical rate` - :ref:`Nasdaq Trader symbol definitions` It should be noted, that various sources support different kinds of data, so not all sources implement the same methods and the data elements returned might also differ. @@ -537,42 +536,6 @@ Download mutual fund index prices for the TSP. tspreader.read() -.. _remote_data.oanda_curr_hist: - -Oanda currency historical rate -============================== - -Download currency historical rate from `Oanda `__. - -.. code-block:: python - - In [1]: from pandas_datareader.oanda import get_oanda_currency_historical_rates - In [2]: start, end = "2016-01-01", "2016-06-01" - In [3]: quote_currency = "USD" - In [4]: base_currency = ["EUR", "GBP", "JPY"] - In [5]: df_rates = get_oanda_currency_historical_rates( - start, end, - quote_currency=quote_currency, - base_currency=base_currency - ) - In [6]: print(df_rates) - - EUR/USD GBP/USD JPY/USD - Date - 2016-01-01 1.087090 1.473989 0.008320 - 2016-01-02 1.087090 1.473989 0.008320 - 2016-01-03 1.087090 1.473989 0.008320 - 2016-01-04 1.086730 1.473481 0.008370 - 2016-01-05 1.078760 1.469430 0.008388 - ... ... ... ... - 2016-05-28 1.111669 1.462630 0.009072 - 2016-05-29 1.111669 1.462630 0.009072 - 2016-05-30 1.112479 1.461999 0.009006 - 2016-05-31 1.114269 1.461021 0.009010 - 2016-06-01 1.115170 1.445410 0.009095 - - [153 rows x 3 columns] - .. _remote_data.nasdaq_symbols: Nasdaq Trader Symbol Definitions diff --git a/docs/source/whatsnew/v0.5.0.txt b/docs/source/whatsnew/v0.5.0.txt index 8b0df437..0ee1482a 100644 --- a/docs/source/whatsnew/v0.5.0.txt +++ b/docs/source/whatsnew/v0.5.0.txt @@ -20,6 +20,13 @@ Enhancements - ``DataReader`` now supports Quandl, see :ref:`here` (:issue:`361`). +.. _whatsnew_050.api_breaking: + +Backwards incompatible API changes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Removed Oanda as it became subscription only (:issue:`296`). + .. _whatsnew_050.bug_fixes: Bug Fixes diff --git a/pandas_datareader/data.py b/pandas_datareader/data.py index 9798dc1f..3d013a25 100644 --- a/pandas_datareader/data.py +++ b/pandas_datareader/data.py @@ -20,7 +20,6 @@ from pandas_datareader.oecd import OECDReader from pandas_datareader.edgar import EdgarIndexReader from pandas_datareader.enigma import EnigmaReader -from pandas_datareader.oanda import get_oanda_currency_historical_rates from pandas_datareader.nasdaq_trader import get_nasdaq_symbols from pandas_datareader.quandl import QuandlReader @@ -162,12 +161,6 @@ def DataReader(name, data_source=None, start=None, end=None, return EdgarIndexReader(symbols=name, start=start, end=end, retry_count=retry_count, pause=pause, session=session).read() - elif data_source == "oanda": - return get_oanda_currency_historical_rates( - start, end, - quote_currency="USD", base_currency=name, - reversed=True, session=session - ) elif data_source == 'nasdaq': if name != 'symbols': raise ValueError("Only the string 'symbols' is supported for " diff --git a/pandas_datareader/oanda.py b/pandas_datareader/oanda.py deleted file mode 100644 index a8606010..00000000 --- a/pandas_datareader/oanda.py +++ /dev/null @@ -1,58 +0,0 @@ -import pandas as pd -from pandas.compat import StringIO, string_types -from ._utils import _init_session, _sanitize_dates - - -def reverse_pair(s, sep="/"): - lst = s.split(sep) - return sep.join([lst[1], lst[0]]) - - -def get_oanda_currency_historical_rates(start, end, quote_currency="USD", - base_currency=None, reversed=True, - session=None): - session = _init_session(session) - start, end = _sanitize_dates(start, end) - - url = "http://www.oanda.com/currency/historical-rates/download" - bam = "bid" # "ask", "mid" - - if base_currency is None: - base_currency = ["EUR", "GBP", "AUD", "NZD", "CAD", "CHF"] - elif isinstance(base_currency, string_types): - base_currency = [base_currency] - - params = { - "quote_currency": quote_currency, - "start_date": start.strftime("%Y-%m-%d"), - "end_date": end.strftime("%Y-%m-%d"), - "period": "daily", - "display": "absolute", - "rate": 0, - "data_range": "c", - "price": bam, - "view": "table", - "download": "csv" - } - for i, _base_currency in enumerate(base_currency): - params["base_currency_%d" % i] = _base_currency - - response = session.get(url, params=params) - skiprows = 4 - skipfooter = 4 - usecols = range(len(base_currency) + 1) - df = pd.read_csv(StringIO(response.text), parse_dates=[0], - skiprows=skiprows, skipfooter=skipfooter, - usecols=usecols, engine='python') - df = df.rename(columns={ - "End Date": "Date", - }) - df = df.set_index("Date") - df = df[::-1] - if reversed: - df.columns = pd.Index(df.columns.map(reverse_pair)) - df = 1 / df - if len(base_currency) == 1: - return df.iloc[:, 0] - else: - return df diff --git a/pandas_datareader/tests/test_oanda.py b/pandas_datareader/tests/test_oanda.py deleted file mode 100644 index 8fde6d4e..00000000 --- a/pandas_datareader/tests/test_oanda.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest - -import pandas as pd -import pandas_datareader.data as web - -from pandas_datareader.oanda import get_oanda_currency_historical_rates - - -class TestOandaCurrencyHistoricalRate(object): - - @classmethod - def setup_class(cls): - # TODO: Investigate the data returned. - pytest.skip("Data returned from 3rd party is invalid, " - "as it cannot be parsed by our CSV reader.") - - def test_oanda_currency_historical_rate(self): - start = "2016-01-01" - end = "2016-06-01" - - quote_currency = "USD" - base_currency = None - reversed = True - - df_rates = get_oanda_currency_historical_rates( - start, end, - quote_currency=quote_currency, - base_currency=base_currency, reversed=reversed - ) - - assert df_rates.index[0] == pd.to_datetime("2016-01-01") - assert df_rates.index[-1] == pd.to_datetime("2016-06-01") - - def test_oanda_currency_historical_rate_datareader(self): - start = "2016-01-01" - end = "2016-06-01" - - df_rates = web.DataReader(["EUR", "GBP", "JPY"], "oanda", start, end) - - assert df_rates.index[0] == pd.to_datetime("2016-01-01") - assert df_rates.index[-1] == pd.to_datetime("2016-06-01")