def ticker(sleeptime, lock): while True: lock.acquire() askItBit = itb.get_current_ask('USD') bidItBit = itb.get_current_bid('USD') askBitfinex = bfx.get_current_ask('USD') bidBitfinex = bfx.get_current_bid('USD') print "itBit : Bid %s Ask %s" % (format(Decimal(bid),'.2f'),format(Decimal(ask),'.2f')) print "Bitfinex : Bid %s Ask %s" % (format(Decimal(bid),'.2f'),format(Decimal(ask),'.2f')) print '-'*20 # check for Arb in one direction (buy @ ItBit, sell @ Bitfinex) if askItBit < bidBitfinex: # can we buy for 100 on ItBit and sell for 101 on Bitfinex? arb = bidBitfinex - askItBit print "Arb #1 exists : ITBIT sell price < Bitfinex buy price " print "Amount : %s " % format(Decimal(arb),'.2f') # check for arb in the other direction (buy @ Bitfinex, sell @ ItBit) if bidItBit > askBitfinex: # can we buy for 100 on Bitfinex and sell for 101 on ItBit? arb = askBitfinex - bidItBit print "Arb #2 exists : Bitfinex sell price < itBit buy price " print "Amount : %s " % format(Decimal(arb),'.2f') lock.release() time.sleep(sleeptime)
def test_orders(cls): ''' Method for testing orders ''' orders = itb.get_current_orders(base.CCY_DEFAULT) ok_(len(orders["asks"]) > 0, "Asks array should not be empty") ok_(len(orders["bids"]) > 0, "Bids array should not be empty") ok_(orders["source"] == "ITBIT", "Source should be 'ITBIT'") ok_(float(orders["timestamp"]) > 0, "Timestamp should be > zero")
def test_ticker(cls): ''' Method for testing ticker ''' data = json.loads(itb.get_current_ticker(base.CCY_DEFAULT)) ok_(data["pair"] == base.CCY_DEFAULT, "shd be '%s'" % base.CCY_DEFAULT) ok_(data["ask"] > 0.00, "ask should not be empty") ok_(data["bid"] > 0.00, "bid should not be empty") ok_(data["bid"] <= data["ask"], "bid should be <= ask") ok_(float(data["timestamp"]) > 0, "Timestamp should be > zero")
def test_ask(cls): ''' Method for test ask price ''' ok_(itb.get_current_ask(base.CCY_DEFAULT) > 0.00)
def test_bid(cls): ''' Method for test bid price ''' ok_(itb.get_current_bid(base.CCY_DEFAULT) > 0.00)
def test_price(cls): ''' Method for testing last price ''' ok_(itb.get_current_price(base.CCY_DEFAULT) > 0.00)