Esempio n. 1
0
def get_stocks_in_day(stock_name, day):
    out = []
    markets = Market.all(keys_only=False).filter("date =", day).filter("ref =", stock_name.market_ref).order('time').fetch(100)
    for market in markets:
        stock = Stock.all().filter("market =", market.key()).filter('name = ', stock_name.key()).get()
        if not stock is None:
            dt = datetime.combine(market.date, market.time)
            out.append((dt, stock, market.exchange_rate))
    return out
Esempio n. 2
0
def get_stocks_days(stock_name, num_days=10):
    days = last_weekdays(num_days)
    out = []
    for day in days:
        market = Market.all(keys_only=False).filter("date =", day.date()).filter("ref =", stock_name.market_ref).order('-time').get()
        if not market is None:
            stock = Stock.all().filter("market =", market.key()).filter('name = ', stock_name.key()).get()
            if not stock is None:
                out.append((day, stock, market.exchange_rate))
    return out
Esempio n. 3
0
def get_market(ref, date=None, keys_only=False):
    if date is None:
        return Market.all(keys_only=keys_only).filter("ref =", ref).order('-date').order('-time').get()
    else:
        return Market.all(keys_only=keys_only).filter("date =", date.date()).filter("time =", date.time()).filter("ref =", ref).get()
Esempio n. 4
0
def get_last_date(market_ref):
    return Market.all().filter("ref = ", market_ref).order('-date').get().date