Exemple #1
0
    def do_confirm(self):
        while True:
            confirmedstr = str(raw_input("ok [y/N]? \n"))

            confirmed = confirmedstr
            if "#" in confirmed:
                confirmed = confirmed[: confirmed.index("#")]
            confirmed = confirmed.strip().lower()
            try:
                if confirmed == "y":
                    return True
                elif confirmed == "n":
                    return False
            except:
                pass

            continue
Exemple #2
0
    def dummy_price(self):
        def rand(dir=None):
            if dir is None:
                dir = self.dummy_loop_dir

            if dir == 0:
                self.price *= 1 + (random.randint(-20, 20) / 1000.0)
            elif dir > 0:
                self.price *= 1 + (random.randint(0, 20) / 1000.0)
            elif dir < 0:
                self.price *= 1 + (random.randint(-20, 0) / 1000.0)

            return self.price

        try:
            while True:
                self.price = float(self.price)
                if self.dummy_loop > 0:
                    self.dummy_loop -= 1
                    rand()
                    break

                laststr = str(raw_input("New price? \n"))
                last = laststr
                if "#" in last:
                    last = last[: last.index("#")]
                last = last.strip()

                print "[%s] -> [%s]" % (laststr, last)

                try:
                    if last == "":
                        rand(dir=0)
                        break
                    elif last == "up":
                        rand(dir=1)
                        break
                    elif last == "down":
                        rand(dir=-1)
                        break
                    elif last.startswith("loopup"):
                        self.dummy_loop_dir = 1
                        self.dummy_loop = int(last[6:])
                        rand()
                        break
                    elif last.startswith("loopdown"):
                        self.dummy_loop_dir = -1
                        self.dummy_loop = int(last[8:])
                        rand()
                        break
                    elif last.startswith("loop"):
                        self.dummy_loop_dir = 0
                        self.dummy_loop = int(last[4:])
                        rand()
                        break
                    elif last.startswith("*"):
                        self.price = self.price * float(last[1:])
                        break
                    elif last.startswith("/"):
                        self.price = self.price / float(last[1:])
                        break
                    elif last.startswith("+"):
                        self.price = self.price + float(last[1:])
                        break
                    elif last.startswith("-"):
                        self.price = self.price - float(last[1:])
                        break
                    elif isnumber(last):
                        self.price = float(last)
                        break
                except:
                    pass

                continue
        finally:
            self.ticknonce()
            self.price = BTC.VALUE(self.price)
            print "new price: ", self.price
            self.process()