Ejemplo n.º 1
0
def updateOrderbookCache():
    while True:
        time.sleep(20)
        printmsg("Checking for orderbook updates")
        try:
            lasttrade = rGet("omniwallet:omnidex:lasttrade")
            if lasttrade == None:
                lasttrade = 0

            lastpending = rGet("omniwallet:omnidex:lastpending")
            if lastpending == None:
                lastpending = 0

            ret = getOrderbook(lasttrade, lastpending)
            if ret['updated']:
                printmsg("Orderbook cache updated. Lasttrade: " +
                         str(lasttrade) + " Lastpending: " + str(lastpending))
                rSet("omniwallet:omnidex:lasttrade", ret['lasttrade'])
                rSet("omniwallet:omnidex:lastpending", ret['lastpending'])
                rSet("omniwallet:omnidex:book", json.dumps(ret['book']))
            #dbCommit()
        except Exception as e:
            printmsg("Error updating orderbook cache " + str(e))
            #abort any previous txs and close connection so it can be reopened
            dbRollback()
Ejemplo n.º 2
0
def update_orderbook():
    global orderbook, lasttrade, lastpending
    try:
        while True:
            time.sleep(10)
            printmsg("updating orderbook")
            book = rGet("omniwallet:omnidex:book")
            if book != None:
                lasttrade = rGet("omniwallet:omnidex:lasttrade")
                lastpending = rGet("omniwallet:omnidex:lastpending")
                printmsg("Loading orderbook from redis.")
                orderbook = json.loads(book)
                printmsg("Orderbook Lasttrade: " + str(lasttrade) +
                         " Book length is: " + str(len(orderbook)))
            else:
                ret = getOrderbook(lasttrade, lastpending)
                printmsg("Checking for new orderbook updates, last: " +
                         str(lasttrade))
                if ret['updated']:
                    orderbook = ret['book']
                    printmsg("Orderbook updated. Lasttrade: " +
                             str(lasttrade) + " Newtrade: " +
                             str(ret['lasttrade']) + " Book length is: " +
                             str(len(orderbook)))
                    lasttrade = ret['lasttrade']
                    lastpending = ret['lastpending']
    except Exception as e:
        printmsg("error updating orderbook: " + str(e))
Ejemplo n.º 3
0
def update_orderbook():
    printmsg("updating orderbook")
    global orderbook, lasttrade, lastpending
    ret = getOrderbook(lasttrade, lastpending)
    printmsg("Checking for new orderbook updates, last: " + str(lasttrade))
    if ret['updated']:
        orderbook = ret['book']
        printmsg("Orderbook updated. Lasttrade: " + str(lasttrade) +
                 " Newtrade: " + str(ret['lasttrade']) + " Book length is: " +
                 str(len(orderbook)))
        lasttrade = ret['lasttrade']
        lastpending = ret['lastpending']
Ejemplo n.º 4
0
def update_orderbook():
  global orderbook, lasttrade, lastpending

  try:
    while True:
      time.sleep(10)
      print_debug(("updating orderbook"),4)
      ret=getOrderbook(lasttrade, lastpending)
      print_debug(("Checking for new orderbook updates, last:",str(lasttrade)),4)
      if ret['updated']:
        orderbook=ret['book']
        print_debug(("Orderbook updated. Lasttrade:",str(lasttrade),"Newtrade:",str(ret['lasttrade']),"Book length is:",str(len(orderbook))),4)
        lasttrade=ret['lasttrade']
        lastpending=ret['lastpending']
  except Exception as e:
    print_debug(("error updating orderbook:",str(e)),4)
Ejemplo n.º 5
0
def updateOrderbookCache():
    while True:
        time.sleep(20)
        printmsg("Checking for orderbook updates")
        try:
            lasttrade = rGet("omniwallet:omnidex:lasttrade")
            if lasttrade == None:
                lasttrade = 0

            lastpending = rGet("omniwallet:omnidex:lastpending")
            if lastpending == None:
                lastpending = 0

            ret = getOrderbook(lasttrade, lastpending)
            if ret['updated']:
                printmsg("Orderbook cache updated. Lasttrade: " +
                         str(lasttrade) + " Lastpending: " + str(lastpending))
                rSet("omniwallet:omnidex:lasttrade", ret['lasttrade'])
                rSet("omniwallet:omnidex:lastpending", ret['lastpending'])
                rSet("omniwallet:omnidex:book", json.dumps(ret['book']))
        except Exception as e:
            printmsg("Error updating orderbook cache " + str(e))
Ejemplo n.º 6
0
def updateOrderbookCache():
  while True:
    time.sleep(20)
    printmsg("Checking for orderbook updates")
    try:
      lasttrade = rGet("omniwallet:omnidex:lasttrade")
      if lasttrade == None:
        lasttrade=0

      lastpending = rGet("omniwallet:omnidex:lastpending")
      if lastpending == None:
        lastpending = 0

      ret = getOrderbook(lasttrade,lastpending)
      if ret['updated']:
        printmsg("Orderbook cache updated. Lasttrade: "+str(lasttrade)+" Lastpending: "+str(lastpending))
        rSet("omniwallet:omnidex:lasttrade",ret['lasttrade'])
        rSet("omniwallet:omnidex:lastpending",ret['lastpending'])
        rSet("omniwallet:omnidex:book",json.dumps(ret['book']))
    except Exception as e:
      printmsg("Error updating orderbook cache "+str(e))
    dbCommit()
Ejemplo n.º 7
0
def update_orderbook():
  global orderbook, lasttrade, lastpending
  try:
    while True:
      time.sleep(10)
      printmsg("updating orderbook")
      book=rGet("omniwallet:omnidex:book")
      if book != None:
        lasttrade = rGet("omniwallet:omnidex:lasttrade")
        lastpending = rGet("omniwallet:omnidex:lastpending")
        printmsg("Loading orderbook from redis.")
        orderbook=json.loads(book)
        printmsg("Orderbook Lasttrade: "+str(lasttrade)+" Book length is: "+str(len(orderbook)))
      else:
        ret=getOrderbook(lasttrade, lastpending)
        printmsg("Checking for new orderbook updates, last: "+str(lasttrade))
        if ret['updated']:
          orderbook=ret['book']
          printmsg("Orderbook updated. Lasttrade: "+str(lasttrade)+" Newtrade: "+str(ret['lasttrade'])+" Book length is: "+str(len(orderbook)))
          lasttrade=ret['lasttrade']
          lastpending=ret['lastpending']
  except Exception as e:
    printmsg("error updating orderbook: "+str(e))