Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def last_traded_price_model(market_,flag,eth_price_usd,usd_ring_price):
- db = db_connection_mysql()
- cursor = db.cursor()
- ret_data =[]
- if flag == 0:
- sql = """select Price from order_book where Market = "%s" and currency = 'eth' and EpochTime = (select askOrderTimeStamp from match_table where Market = "%s" order by EpochTime Desc limit 0,1)"""%(market_,market_)
- res = cursor.execute(sql)
- res = cursor.fetchall()
- a= res[0]
- temp = float(a[0])
- print temp
- ret_data.append(temp*eth_price_usd*usd_ring_price)
- return ret_data
- else:
- sql1 = """select Price from order_book where Market = "%s" and EpochTime = (select askOrderTimeStamp from match_table where Market = "%s" and currency = 'btc' order by EpochTime Desc limit 0,1)"""%(market_,market_)
- sql2 = """select Price from order_book where Market = "%s" and EpochTime = (select askOrderTimeStamp from match_table where Market = "%s" and currency = 'eth' order by EpochTime Desc limit 0,1)"""%(market_,market_)
- res1 = cursor.execute(sql1)
- res1 = cursor.fetchall()
- a= res1[0]
- temp = float(a[0])
- ret_data.append(temp)
- res2 = cursor.execute(sql2)
- res2 = cursor.fetchall()
- a= res2[0]
- temp = float(a[0])
- ret_data.append(temp)
- return ret_data
Add Comment
Please, Sign In to add comment