示例#1
0
async def get_available_dates(db_manager, ticker):
    ticker = await db_manager.get(Ticker, symbol=ticker)
    dates = await db_manager.execute(
        Price.select(Price.date).where(Price.ticker_id == ticker).order_by(
            Price.date.desc()))
    dates = [date.date for date in dates]

    return dates
示例#2
0
async def get_prices(db_manager, ticker):
    three_month_ago = datetime.today() - timedelta(days=90)

    ticker_db = await db_manager.get(Ticker, symbol=ticker)

    result = await db_manager.execute(Price.select().where(
        Price.ticker == ticker_db,
        Price.date >= three_month_ago).order_by(Price.date.desc()))
    result = [price.as_json() for price in result]

    log.debug(f'Prices for {ticker}: {result}.')
    return result