def save_order_into_pg(order, pg_conn, table_name="arbitrage_orders"): cur = pg_conn.cursor PG_INSERT_QUERY = "insert into {table_name}(arbitrage_id, exchange_id, trade_type, pair_id, price, volume, " \ "executed_volume, order_id, trade_id, order_book_time, create_time, execute_time, execute_time_date) " \ "values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);".format(table_name=table_name) args_list = ( order.arbitrage_id, order.exchange_id, order.trade_type, order.pair_id, order.price, order.volume, order.executed_volume, order.order_id, order.trade_id, order.order_book_time, order.create_time, order.execute_time, get_date_time_from_epoch(order.execute_time) ) try: cur.execute(PG_INSERT_QUERY, args_list) except Exception, e: log_error_query_failed(PG_INSERT_QUERY, args_list, e)
def get_pg_arg_list(self): return (self.pair_id, self.exchange_id, self.deal_type, self.price, self.amount, self.total, self.timest, get_date_time_from_epoch(self.timest) )
def get_pg_arg_list(self): return (self.pair_id, self.exchange_id, self.open, self.close, self.high, self.low, self.timest, get_date_time_from_epoch(self.timest) )
def save_alarm_into_pg(src_ticker, dst_ticker, pg_conn): cur = pg_conn.cursor PG_INSERT_QUERY = "insert into alarms(src_exchange_id, dst_exchange_id, src_pair_id, dst_pair_id, src_ask_price, " \ "dst_bid_price, timest, date_time) values(%s, %s, %s, %s, %s, %s, %s, %s);" args_list = ( src_ticker.exchange_id, dst_ticker.exchange_id, src_ticker.pair_id, dst_ticker.pair_id, src_ticker.ask, dst_ticker.bid, src_ticker.timest, get_date_time_from_epoch(src_ticker.timest) ) try: cur.execute(PG_INSERT_QUERY, args_list) except Exception, e: log_error_query_failed(PG_INSERT_QUERY, args_list, e)
def tsv(self): return ("{}\t{}\t{}\t{}\t{}\t{}\t{}\t'{}'".format( self.pair_id, self.exchange_id, self.deal_type, self.price, self.amount, self.total, self.timest, get_date_time_from_epoch(self.timest)).decode('utf8'))
def get_pg_arg_list(self): return (self.pair_id, self.exchange_id, self.timest, get_date_time_from_epoch(self.timest))
def tsv(self): return ("{}\t{}\t{}\t{}\t{}\t'{}'".format( self.pair_id, self.exchange_id, self.ask, self.bid, self.timest, get_date_time_from_epoch(self.timest)).decode('utf8'))
def tsv(self): return ("{}\t{}\t{}\t{}\t{}\t{}\t{}\t'{}'".format( self.pair_id, self.exchange_id, self.open, self.close, self.high, self.low, self.timest, get_date_time_from_epoch(self.timest)).decode('utf8'))