示例#1
0
def import_tickers(db_uri, filename):
    """Import tickers from a JSON file."""
    session = get_session(get_engine(db_uri))
    parser = YahooStockParser()
    parser.load(filename)
    importer = YahooImporter(session)
    importer.import_(parser)
示例#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)