Пример #1
0
    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)
Пример #2
0
def main():
        """main function, called at the start of the program"""

        print '-'*20
        askBitfinex = bfx.get_current_ask('USD')
        bidBitfinex = bfx.get_current_bid('USD')
        print "Bitfinex : Bid %s Ask %s" % (format(Decimal(bid),'.2f'),format(Decimal(ask),'.2f'))
        print '-'*20
Пример #3
0
 def test_orders(cls):
     ''' Method for testing orders '''
     orders = bfx.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"] == "Bitfinex", "Source should be 'Bitfinex'")
     ok_(float(orders["timestamp"]) > 0, "Timestamp should be > zero")
Пример #4
0
 def test_ticker(cls):
     ''' Method for testing ticker '''
     data = json.loads(bfx.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")
Пример #5
0
 def test_ask(cls):
     ''' Method for testing ask price '''
     ok_(bfx.get_current_ask(base.CCY_DEFAULT) > 0.00)
Пример #6
0
 def test_bid(cls):
     ''' Method for testing bid price '''
     ok_(bfx.get_current_bid(base.CCY_DEFAULT) > 0.00)
Пример #7
0
 def test_price(cls):
     ''' Method for testing last price '''
     ok_(bfx.get_current_price(base.CCY_DEFAULT) > 0.00)