def act(self, world=None, market=None):
        """
        Return random order as a dict with keys in (direction, price, quantity).
        """
        if self.stocks > 0:
            direction = random.choice((BUY, SELL))
        else:
            direction = BUY
        if self.avgprice == 0:
            try:
                self.avgprice = market.lastprice
            except __HOLE__:
                self.avgprice = 100
                logger.warning("No market, no avgprice, avgprice set to 100")
        price = random.randint(self.avgprice*(100-self.maxfluct), 
                self.avgprice*(100+self.maxfluct))/100.
        if direction:
            maxq = self.stocks
        else:
            maxq = min(self.maxbuy, int(self.money/price))
        try:
            quantity = random.randint(1, maxq)
        except ValueError:
            quantity = 1
        return {'direction':direction, 'price':price, 'quantity':quantity}
dataset/ETHPy150Open jcbagneris/fms/fms/agents/randomtrader.py/RandomTrader.act