Esempio n. 1
0
def get_quote_google(*args, **kwargs):
    raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Google Quotes'))
    return GoogleQuotesReader(*args, **kwargs).read()
Esempio n. 2
0
def DataReader(name,
               data_source=None,
               start=None,
               end=None,
               retry_count=3,
               pause=0.001,
               session=None,
               access_key=None):
    """
    Imports data from a number of online sources.

    Currently supports Google Finance, St. Louis FED (FRED),
    and Kenneth French's data library, among others.

    Parameters
    ----------
    name : str or list of strs
        the name of the dataset. Some data sources (google, fred) will
        accept a list of names.
    data_source: {str, None}
        the data source ("google", "fred", "ff")
    start : {datetime, None}
        left boundary for range (defaults to 1/1/2010)
    end : {datetime, None}
        right boundary for range (defaults to today)
    retry_count : {int, 3}
        Number of times to retry query request.
    pause : {numeric, 0.001}
        Time, in seconds, to pause between consecutive queries of chunks. If
        single value given for symbol, represents the pause between retries.
    session : Session, default None
        requests.sessions.Session instance to be used
    access_key : (str, None)
        Optional parameter to specify an API key for certain data sources.

    Examples
    ----------
    # Data from Google Finance
    aapl = DataReader("AAPL", "google")

    # Price and volume data from IEX
    tops = DataReader(["GS", "AAPL"], "iex-tops")
    # Top of book executions from IEX
    gs = DataReader("GS", "iex-last")
    # Real-time depth of book data from IEX
    gs = DataReader("GS", "iex-book")

    # Data from FRED
    vix = DataReader("VIXCLS", "fred")

    # Data from Fama/French
    ff = DataReader("F-F_Research_Data_Factors", "famafrench")
    ff = DataReader("F-F_Research_Data_Factors_weekly", "famafrench")
    ff = DataReader("6_Portfolios_2x3", "famafrench")
    ff = DataReader("F-F_ST_Reversal_Factor", "famafrench")
    """
    if data_source == "yahoo":
        return YahooDailyReader(symbols=name,
                                start=start,
                                end=end,
                                adjust_price=False,
                                chunksize=25,
                                retry_count=retry_count,
                                pause=pause,
                                session=session).read()

    elif data_source == "google":
        return GoogleDailyReader(symbols=name,
                                 start=start,
                                 end=end,
                                 chunksize=25,
                                 retry_count=retry_count,
                                 pause=pause,
                                 session=session).read()

    elif data_source == "iex":
        return IEXDailyReader(symbols=name,
                              start=start,
                              end=end,
                              chunksize=25,
                              retry_count=retry_count,
                              pause=pause,
                              session=session).read()

    elif data_source == "iex-tops":
        return IEXTops(symbols=name,
                       start=start,
                       end=end,
                       retry_count=retry_count,
                       pause=pause,
                       session=session).read()

    elif data_source == "iex-last":
        return IEXLasts(symbols=name,
                        start=start,
                        end=end,
                        retry_count=retry_count,
                        pause=pause,
                        session=session).read()

    elif data_source == "bankofcanada":
        return BankOfCanadaReader(symbols=name,
                                  start=start,
                                  end=end,
                                  retry_count=retry_count,
                                  pause=pause,
                                  session=session).read()
    elif data_source == "stooq":
        return StooqDailyReader(symbols=name,
                                chunksize=25,
                                retry_count=retry_count,
                                pause=pause,
                                session=session).read()

    elif data_source == "iex-book":
        return IEXDeep(symbols=name,
                       service="book",
                       start=start,
                       end=end,
                       retry_count=retry_count,
                       pause=pause,
                       session=session).read()

    elif data_source == "enigma":
        return EnigmaReader(dataset_id=name, api_key=access_key).read()

    elif data_source == "fred":
        return FredReader(symbols=name,
                          start=start,
                          end=end,
                          retry_count=retry_count,
                          pause=pause,
                          session=session).read()

    elif data_source == "famafrench":
        return FamaFrenchReader(symbols=name,
                                start=start,
                                end=end,
                                retry_count=retry_count,
                                pause=pause,
                                session=session).read()

    elif data_source == "oecd":
        return OECDReader(symbols=name,
                          start=start,
                          end=end,
                          retry_count=retry_count,
                          pause=pause,
                          session=session).read()
    elif data_source == "eurostat":
        return EurostatReader(symbols=name,
                              start=start,
                              end=end,
                              retry_count=retry_count,
                              pause=pause,
                              session=session).read()
    elif data_source == "edgar-index":
        raise ImmediateDeprecationError(DEP_ERROR_MSG.format('EDGAR'))
        return EdgarIndexReader(symbols=name,
                                start=start,
                                end=end,
                                retry_count=retry_count,
                                pause=pause,
                                session=session).read()
    elif data_source == 'nasdaq':
        if name != 'symbols':
            raise ValueError("Only the string 'symbols' is supported for "
                             "Nasdaq, not %r" % (name, ))
        return get_nasdaq_symbols(retry_count=retry_count, pause=pause)

    elif data_source == "quandl":
        return QuandlReader(symbols=name,
                            start=start,
                            end=end,
                            retry_count=retry_count,
                            pause=pause,
                            session=session,
                            api_key=access_key).read()
    elif data_source == "moex":
        return MoexReader(symbols=name,
                          start=start,
                          end=end,
                          retry_count=retry_count,
                          pause=pause,
                          session=session).read()
    elif data_source == "morningstar":
        return MorningstarDailyReader(symbols=name,
                                      start=start,
                                      end=end,
                                      retry_count=retry_count,
                                      pause=pause,
                                      session=session,
                                      interval="d").read()
    elif data_source == 'robinhood':
        return RobinhoodHistoricalReader(symbols=name,
                                         start=start,
                                         end=end,
                                         retry_count=retry_count,
                                         pause=pause,
                                         session=session).read()
    elif data_source == 'tiingo':
        return TiingoDailyReader(symbols=name,
                                 start=start,
                                 end=end,
                                 retry_count=retry_count,
                                 pause=pause,
                                 session=session,
                                 api_key=access_key).read()

    elif data_source == "yahoo-actions":
        return YahooActionReader(symbols=name,
                                 start=start,
                                 end=end,
                                 retry_count=retry_count,
                                 pause=pause,
                                 session=session).read()

    elif data_source == "yahoo-dividends":
        return YahooDivReader(symbols=name,
                              start=start,
                              end=end,
                              adjust_price=False,
                              chunksize=25,
                              retry_count=retry_count,
                              pause=pause,
                              session=session,
                              interval='d').read()

    else:
        msg = "data_source=%r is not implemented" % data_source
        raise NotImplementedError(msg)
Esempio n. 3
0
def get_quote_yahoo(*args, **kwargs):
    raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Quotes'))
    return YahooQuotesReader(*args, **kwargs).read()
Esempio n. 4
0
 def __init__(self, symbols=None, start=None, end=None, retry_count=3,
              pause=0.1, session=None, chunksize=25):
     raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Google finance'))
     super(GoogleDailyReader, self).__init__(symbols, start, end,
                                             retry_count, pause, session,
                                             chunksize)
Esempio n. 5
0
def get_data_yahoo_actions(*args, **kwargs):
    raise ImmediateDeprecationError(DEP_ERROR_MSG.format('Yahoo Actions'))