def filter(cls, oid=None, account=None, issue=None, include_private=False): "Look up offers." (all_ids, all_accounts, all_issues) = (False, False, False) if not oid: all_ids = True if account: uid = account.id else: uid = None all_accounts = True if issue: iid = issue.id else: iid = None all_issues = True result = [] with cls.db.conn.cursor() as curs: curs.execute( '''SELECT account, maturity, matures, contract_type, issue, url, title, side, price, quantity, id, created, all_or_nothing FROM offer_overview WHERE (id = %s OR %s) AND (account = %s OR %s) AND (issue = %s OR %s) ''', (oid, all_ids, uid, all_accounts, iid, all_issues)) for row in curs.fetchall(): (uid, mid, matures, cid, iid, url, title, side, price, quantity, oid, created, all_or_nothing) = row account = Account(uid=uid) issue = Issue(url=url, iid=iid, title=title) if (not include_private) and (not issue.is_public): continue maturity = Maturity(matures, mid) ctype = ContractType(issue, maturity, cid) result.append( cls(account, ctype, side, price, quantity, oid, created, all_or_nothing)) return result
def setup(self): Maturity.make_upcoming(self)
def maturities(self): return Maturity.available(self)
def cleanup(self, contract_types=[]): Offer.cleanup(self, contract_types) ContractType.cleanup(contract_types) Maturity.cleanup(self) Issue.cleanup(self)