Example #1
0
def getportfolio(chatid):
    portfolio = list()
    for call in Calls.select().where((Calls.chatid == chatid)
                                     & (Calls.type == PORTFOLIO_TYPE)
                                     & (Calls.qty > 0)):
        portfolio.append(call)
    return portfolio
Example #2
0
def getwatchlist(chatid):
    watchlist = list()
    for call in Calls.select().where((Calls.chatid == chatid)
                                     & (Calls.type == WATCH_TYPE)
                                     & (Calls.sym.is_null(False))):
        watchlist.append(call)
    return watchlist
Example #3
0
def lastupdatedportfolio(chatid):
    try:
        call=Calls.select()\
                .where((Calls.chatid==chatid) & (Calls.type==PORTFOLIO_TYPE) & (Calls.misc==str(PORTFOLIO_STATE_PENDING)))\
                .order_by(Calls.time.desc()).get()
    except DoesNotExist as de:
        return None
    return call
Example #4
0
def getcalls(chatid, symbol=None):
    clauses = [(Calls.chatid == chatid),
               (Calls.type.not_in([WATCH_TYPE, PORTFOLIO_TYPE]))]
    if symbol:
        clauses.append((Calls.sym == symbol))

    callstxt = ''
    for call in Calls.select().where(reduce(operator.and_, clauses)):
        callstxt += call.user + " : " + call.type + " " + call.sym + "@" + call.callrange + \
                    " " +(call.desc if call.desc else " ")+ \
                    " on <i>" + call.time.strftime('%b %d %H:%M') + "</i>\n"
    return callstxt
Example #5
0
def deleteoldwatchlist():
    calls = Calls.select(Calls.time).where(Calls.type == WATCH_TYPE).order_by(
        Calls.time.desc()).limit(LIMIT)
    Calls.delete().where((Calls.type == WATCH_TYPE)
                         & (Calls.time.not_in(calls))).execute()
Example #6
0
def deleteoldcalls():
    calls = Calls.select(Calls.time).where(
        (Calls.type.not_in([WATCH_TYPE, PORTFOLIO_TYPE
                            ]))).order_by(Calls.time.desc()).limit(LIMIT)
    Calls.delete().where((Calls.type.not_in([WATCH_TYPE, PORTFOLIO_TYPE]))
                         & (Calls.time.not_in(calls))).execute()