parishilan

last_traded_price_model

Feb 7th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. def last_traded_price_model(market_,flag,eth_price_usd,usd_ring_price):
  2.     db = db_connection_mysql()
  3.     cursor = db.cursor()
  4.     ret_data =[]
  5.     if flag == 0:
  6.         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_)
  7.         res = cursor.execute(sql)
  8.         res = cursor.fetchall()
  9.         a= res[0]
  10.         temp = float(a[0])
  11.         print temp
  12.         ret_data.append(temp*eth_price_usd*usd_ring_price)
  13.         return ret_data
  14.     else:
  15.         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_)
  16.         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_)
  17.         res1 = cursor.execute(sql1)
  18.         res1 = cursor.fetchall()
  19.         a= res1[0]
  20.         temp = float(a[0])
  21.         ret_data.append(temp)
  22.         res2 = cursor.execute(sql2)
  23.         res2 = cursor.fetchall()
  24.         a= res2[0]
  25.         temp = float(a[0])
  26.         ret_data.append(temp)
  27.         return ret_data
Add Comment
Please, Sign In to add comment