(self)
return enough_liquidity
Returns true if there is enough liquidity on each side of the order book
Returns true if there is enough liquidity on each side of the order book
Returns true if there is enough liquidity on each side of the order book
def enough_liquidity(self):
        "Returns true if there is enough liquidity on each side of the order book"
        enough_liquidity = False
        ticker = self.exchange.get_ticker()
        order_book = self.exchange.market_depth()
        highest_buy = self.exchange.get_highest_buy()
        lowest_sell = self.exchange.get_lowest_sell()

        bid_depth = sum([x["bidSize"] for x in filter(lambda x: x["bidSize"]!=None, order_book)])
        ask_depth = sum([x["askSize"] for x in filter(lambda x: x["askSize"]!=None, order_book)])

        bid_liquid = bid_depth - highest_buy["orderQty"]
        logger.info("Bid Liquidity: "+str(bid_liquid)+" Contracts")
        ask_liquid = ask_depth - lowest_sell["orderQty"]
        logger.info("Ask Liquidity: "+str(ask_liquid)+" Contracts")
        enough_ask_liquidity = ask_liquid >= settings.MIN_CONTRACTS
        enough_bid_liquidity = bid_liquid >= settings.MIN_CONTRACTS
        enough_liquidity = (enough_ask_liquidity and enough_bid_liquidity)
        if not enough_liquidity:
            if (not enough_bid_liquidity) and (not enough_ask_liquidity):
                logger.info("Neither side has enough liquidity")
            elif not enough_bid_liquidity:
                logger.info("Bid side is not liquid enough")
            else:
                logger.info("Ask side is not liquid enough")
        return enough_liquidity
def enough_liquidity ( self ) : enough_liquidity = False ticker = self . exchange . get_ticker ( ) order_book = self . exchange . market_depth ( ) highest_buy = self . exchange . get_highest_buy ( ) lowest_sell = self . exchange . get_lowest_sell ( ) bid_depth = sum ( [ x [ "bidSize" ] for x in filter ( lambda x : x [ "bidSize" ] != None , order_book ) ] ) ask_depth = sum ( [ x [ "askSize" ] for x in filter ( lambda x : x [ "askSize" ] != None , order_book ) ] ) bid_liquid = bid_depth - highest_buy [ "orderQty" ] logger . info ( "Bid Liquidity: " + str ( bid_liquid ) + " Contracts" ) ask_liquid = ask_depth - lowest_sell [ "orderQty" ] logger . info ( "Ask Liquidity: " + str ( ask_liquid ) + " Contracts" ) enough_ask_liquidity = ask_liquid >= settings . MIN_CONTRACTS enough_bid_liquidity = bid_liquid >= settings . MIN_CONTRACTS enough_liquidity = ( enough_ask_liquidity and enough_bid_liquidity ) if not enough_liquidity : if ( not enough_bid_liquidity ) and ( not enough_ask_liquidity ) : logger . info ( "Neither side has enough liquidity" ) elif not enough_bid_liquidity : logger . info ( "Bid side is not liquid enough" ) else : logger . info ( "Ask side is not liquid enough" ) return enough_liquidity