Ejemplo n.º 1
0
    def __call__(self, price, active, direction, duration):
        """Method to send message to buyv2 websocket chanel.

        :param price: The buying price.
        :param active: The buying active.
        :param direction: The buying direction.
        """
        # thank Darth-Carrotpie's code
        #https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6

        exp, idx = get_expiration_time(int(self.api.timesync.server_timestamp),
                                       duration)

        if idx < 5:
            option = "turbo"
        else:
            option = "binary"

        data = {
            "price": price,
            "act": active,
            "exp": int(exp),
            "type": option,
            "direction": direction.lower(),
            "user_balance_id": int(global_value.balance_id),
            "time": self.api.timesync.server_timestamp
        }

        self.send_websocket_request(self.name, data)
Ejemplo n.º 2
0
    def __call__(self, price, active, direction, duration):
        """Method to send message to buyv2 websocket chanel.
        :param price: The buying price.
        :param active: The buying active.
        :param direction: The buying direction.
        """

        exp, idx = get_expiration_time(
            int(self.api.timesync.server_timestamp), duration)

        if idx < 5:
            option = 3  # turbo
        else:
            option = 1  # non-turbo / binary

        data = {
            "price": price,
            "act": active,
            "exp": int(exp),
            "type": option,
            "direction": direction.lower(),
            "user_balance_id": int(global_value.balance_id),
            "time": self.api.timesync.server_timestamp
        }

        self.send_websocket_request(self.name, data)
Ejemplo n.º 3
0
    def __call__(self, price, active, direction, duration):
        """Method to send message to buyv2 websocket chanel.

        :param price: The buying price.
        :param active: The buying active.
        :param direction: The buying direction.
        """

        exp, idx = get_expiration_time(int(self.api.timesync.server_timestamp),
                                       duration)

        if idx < 5:
            option = 3  # turbo
        else:
            option = 1  # non-turbo / binary

        data = {
            "name": "binary-options.open-option",
            "version": "1.0",
            "body": {
                "user_balance_id": int(self.api.profile.balance_id),
                "active_id": active,
                "option_type_id": option,
                "direction": direction.lower(),
                "expired": int(exp),
                "refund_value": 0,
                "price": price,
                "value":
                0,  # Preset to 0, don't worry won't affect the actual buy contract
                "profit_percent":
                0  # IQOption accept any value lower than the actual percent, don't worry it won't affect actual earning
            }
        }

        self.send_websocket_request(self.name, data)
Ejemplo n.º 4
0
    def buy_digital_spot(self, active,amount, action, duration):
        #Expiration time need to be formatted like this: YYYYMMDDHHII
        #And need to be on GMT time
       
        #Type - P or C
        if action == 'put':
            action = 'P'
        elif action=='call':
            action = 'C'
        else:
            logging.error('buy_digital_spot active error')
            return -1
        #doEURUSD201907191250PT5MPSPT
        timestamp=int(self.api.timesync.server_timestamp)
        if duration==1:
            exp,_=get_expiration_time(timestamp,duration) 
        else:
            now_date = datetime.fromtimestamp(timestamp)+timedelta(minutes=1,seconds=30)
            while True:
                if now_date.minute%duration==0 and time.mktime(now_date.timetuple())-timestamp>30:
                    break
                now_date = now_date+timedelta(minutes=1)
            exp=time.mktime(now_date.timetuple())
       
        dateFormated = str(datetime.utcfromtimestamp(exp).strftime("%Y%m%d%H%M"))
        instrument_id = "do" + active + dateFormated + "PT" + str(duration) + "M" + action + "SPT" 
        self.api.digital_option_placed_id=None
         
        self.api.place_digital_option(instrument_id,amount)
        while self.api.digital_option_placed_id==None:
            pass

        return  self.api.digital_option_placed_id
Ejemplo n.º 5
0
    def buy_digital_spot(self, active, amount, action, duration):
        #Expiration time need to be formatted like this: YYYYMMDDHHII
        #And need to be on GMT time

        #Type - P or C
        if action == 'put':
            action = 'P'
        elif action == 'call':
            action = 'C'
        else:
            logging.error('buy_digital_spot active error')
            return -1
        #doEURUSD201907191250PT5MPSPT

        exp, idx = get_expiration_time(int(self.api.timesync.server_timestamp),
                                       duration)

        dateFormated = str(
            datetime.utcfromtimestamp(exp).strftime("%Y%m%d%H%M"))
        instrument_id = "do" + active + dateFormated + "PT" + str(
            duration) + "M" + action + "SPT"
        self.api.digital_option_placed_id = None

        self.api.place_digital_option(instrument_id, amount)
        while self.api.digital_option_placed_id == None:
            pass

        return self.api.digital_option_placed_id
Ejemplo n.º 6
0
    def __call__(self, price, active, direction, duration, request_id):

        # thank Darth-Carrotpie's code
        # https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6
        exp, idx = get_expiration_time(int(self.api.timesync.server_timestamp),
                                       duration)
        if idx <= 5:
            option = 3  #"turbo"
        else:
            option = 1  #"binary"
        data = {
            "body": {
                "price": price,
                "active_id": active,
                "expired": int(exp),
                "direction": direction.lower(),
                "option_type_id": option,
            },
            "name": "binary-options.open-option",
            "version": "1.0"
        }
        self.send_websocket_request(self.name, data, str(request_id))
Ejemplo n.º 7
0
    def processar_ordem(_iqOption, _ativo, _direcao, _valor, _tipo_opcao, expiracao_ordem, exp_bin):
        expiracao_ordem = expiracao_ordem.replace("PT", "").replace("M","")
        expiracao_ordem = int(expiracao_ordem)
        id_number = None
        if _tipo_opcao != 'B':
            id_number = trade_digital(_iqOption, _valor, expiracao_ordem, _ativo, _direcao)
        if _tipo_opcao == 'B':
            id_number = trade_binaria(_iqOption, _valor, exp_bin, _ativo, _direcao)
        if id_number == None:
            logger.error(u'ERRO: N\xe3o pode fazer o trade, problema a corretora. 001')
            return
        #logger.info(' | ---> Nro. ordem: {} - Valor: {} <===='.format(id_number, _valor))
        _expiracao_ordem, _ = get_expiration_time(time.time(), expiracao_ordem)
        
        if _tipo_opcao != 'B':
            win_loss = check_trade_digital(_iqOption, id_number, _valor, _expiracao_ordem)
        else:
            win_loss = check_trade_binaria_v2(_iqOption, id_number, _valor, _expiracao_ordem)

        if win_loss == None:
            logger.error(u'ERRO: N\xe3o pode fazer a checagem, problema na corretora. 002')

        return win_loss