def fetch_transaction(date_start, date_end=''): if date_end == '': date_end = date_start try: trans_list = [] sql = sqls.get_sql('trans_by_day', date_start, date_end) # print sql rows = query(sql) # print rows for row in rows: trans = transaction() trans.date = str(row[0]) trans.code = row[1] trans.operation = row[2] trans.portfolio = row[3] trans.sec_type = row[4] trans.quantity = float(row[5]) trans.price = float(row[6]) trans.tax = float(row[7]) trans.other_charges = float(row[8]) trans.amount = float(row[9]) trans_list.append(trans) #print trans_list[0] return trans_list except Exception, e: print "Error occured" traceback.print_exc()
def fetch_holding(date_start, date_end=''): if date_end == '': date_end = date_start try: hlds = [] sql = sqls.get_sql('hld_by_day', date_start, date_end) # print sql rows = query(sql) # print rows for row in rows: hld = holding() hld.date = row[0] hld.portfolio = row[1] hld.code = row[2] hld.sec_type = row[3] hld.quantity = float(row[4]) hld.amount = float(row[5]) hlds.append(hld) # print hlds return hlds except Exception, e: print "Error occured" traceback.print_exc()
def delete_hld(date_start, date_end): try: sql = sqls.get_sql('delete_hld_by_day', date_start, date_end) update(sql) except Exception, e: traceback.print_exc()
def delete_ast(date_str): try: sql = sqls.get_sql('delete_ast_by_day', date_str) update(sql) except Exception, e: traceback.print_exc()