def act(self, world=None, market=None):
        """
        Return order as a dict with keys in (direction, price, quantity).
        If SELL, pick price between highest success, next highest bid.
        If BUY, pick price between lowest success, next lowest bid.

        Avoid short selling and levering up (borrowing).
        """
        if self.successes:
            # Average price of successful bids
            stockprice = float(sum(self.successes))/len(self.successes)
        else:
            stockprice = random.randint(1, self.maxprice*100)/100.

        try:
            minp = max(self.successes)
        except ValueError:
            # No successes
            minp = 0.01
        try:
            maxp = min([bid for bid in self.bids if bid > minp])
        except:
            # No higher bids
            maxp = self.maxprice
        sellprice = random.randint(int(minp*100), int(maxp*100))/100.
        sellquant = self.stocks
        try:
            maxp = min(self.successes)
        except ValueError:
            # No successes
            maxp = self.maxprice
        try: 
            minp = max([bid for bid in self.bids if bid < maxp])
        except __HOLE__:
            # No lower bids
            minp = 0.01
        buyprice = random.randint(int(minp*100), int(maxp*100))/100.
        if buyprice <= 0:
            buyprice = 0.01
        buyquant = int(self.money/buyprice)

        # Choose buy or sell, place order
        # Wealth if trader sells all his stock
        sellwealth = self.money + sellquant*sellprice
        # Wealth if trader uses as much money as possible to buy
        buywealth = self.money - buyquant*buyprice + \
                    (self.stocks + buyquant)*stockprice
        if sellwealth > buywealth:
            direction = SELL
            price = sellprice
            quantity = sellquant
        else:
            direction = BUY
            price = buyprice
            quantity = buyquant
        self.bids.append(price)
        return {'direction':direction, 'price':price, 'quantity':quantity}
dataset/ETHPy150Open jcbagneris/fms/fms/contrib/coleman/agents/smartmem5trader.py/SmartMem5Trader.act