Exemplo n.º 1
0
def test_fetcher():
    fetcher = YahooFetcher(logger=logger)
    raw_data = fetcher.fetch('AAPL', datetime.now() - timedelta(days=365),
                             datetime.now(), '1day')

    objects = json.loads(raw_data)

    assert type(objects) == dict
Exemplo n.º 2
0
def fetch(db_uri, symbol, date, granularity: Granularity):
    fetcher = YahooFetcher(logger=log)
    begin_date = datetime.strptime(date, '%Y-%m-%d')
    end_date = YahooFetcher.get_end_datetime(begin_date, granularity)
    raw_data = fetcher.fetch(symbol, begin_date, end_date, granularity)

    parser = YahooStockParser(logger=log)
    parser.load(raw_data)

    session = get_session(get_engine(db_uri))
    importer = YahooImporter(session=session, logger=log)
    importer.import_(parser)