Exemple #1
0
def aplicar(e, s, pl, et, m):

    api = IQ_Option(e, s)
    api.connect()

    porcentagem_lucro = float(pl)
    entrada = float(et)
    moeda = m  #  EURUSD
    tipoConta = "PRACTICE"  # PRACTICE / REAL
    operacao = "put"  #put / call
    timeframe = 1

    valor_minimo = round(float(entrada) * (float(porcentagem_lucro / 100)), 2)

    api.subscribe_strike_list(moeda, timeframe)

    status, id = api.buy_digital_spot(moeda, entrada, operacao, timeframe)
    time.sleep(0.3)

    while api.get_async_order(
            id)['position-changed']['msg']['status'] == 'open':
        vpv = round(api.get_digital_spot_profit_after_sale(id), 2)

        time.sleep(0.3)
        os.system('cls' if os.name == 'nt' else 'clear')
        print('Atual: $' + str(vpv) + ' - Minimo para venda: $' +
              str(valor_minimo))

        if vpv > valor_minimo:
            print('Fechando operação')
            api.close_digital_option(id)
            break

        time.sleep(0.3)

    status, valor = api.check_win_digital_v2(id)
    print('Resultado da operação: ' + str('WIN +' if valor > 0 else 'LOSS ') +
          str(round(valor, 2)))
Exemple #2
0
      "limit_price: {},"
      "stop_price: {},"
      "stop_lose_value: {},"
      "take_profit_value: {},"
      "take_profit_kind: {},"
      "use_trail_stop: {},"
      "auto_margin_call: {},"
      "use_token_for_commission: {}".format(
          instrument_type, instrument_id, side, amount, leverage, type,
          limit_price, stop_price, stop_lose_value, stop_lose_kind,
          take_profit_value, take_profit_kind, use_trail_stop,
          auto_margin_call, use_token_for_commission))
check, id = Iq.buy_order(instrument_type=instrument_type,
                         instrument_id=instrument_id,
                         side=side,
                         amount=amount,
                         leverage=leverage,
                         type=type,
                         limit_price=limit_price,
                         stop_price=stop_price,
                         stop_lose_value=stop_lose_value,
                         stop_lose_kind=stop_lose_kind,
                         take_profit_value=take_profit_value,
                         take_profit_kind=take_profit_kind,
                         use_trail_stop=use_trail_stop,
                         auto_margin_call=auto_margin_call,
                         use_token_for_commission=use_token_for_commission)
while Iq.get_async_order(id) == None:
    pass
order_data = Iq.get_async_order(id)
print(Iq.get_async_order(id))
Exemple #3
0
    print(" Erro ao conectar")
    input("\n\n Aperte enter para sair")
    sys.exit()

porcentagem_lucro = 10
entrada = 10.0
par = "EURUSD"
timeframe = 1
valor_minimo = round(float(entrada) * (float(porcentagem_lucro / 100)), 2)

API.subscribe_strike_list(par, timeframe)

status, id = API.buy_digital_spot(par, entrada, "put", timeframe)
time.sleep(2)

while API.get_async_order(id)["position-changed"]["msg"]["status"] == "open":
    vpv = round(API.get_digital_spot_profit_after_sale(id), 2)

    print("Atual: $" + str(vpv) + " - Minimo para venda: $" +
          str(valor_minimo))

    if vpv > valor_minimo:
        print("Fechando operação")
        API.close_digital_option(id)
        break

    time.sleep(0.3)

status, valor = API.check_win_digital_v2(id)
print("Resultado da operação: " + ("WIN - " if valor > 0 else "LOSS - ") +
      str(round(valor, 2)))
Exemple #4
0
    print(' Erro ao conectar')
    input('\n\n Aperte enter para sair')
    sys.exit()

porcentagem_lucro = 10
entrada = 10.0
par = 'EURUSD'
timeframe = 1
valor_minimo = round(float(entrada) * (float(porcentagem_lucro / 100)), 2)

API.subscribe_strike_list(par, timeframe)

status, id = API.buy_digital_spot(par, entrada, 'put', timeframe)
time.sleep(2)

while API.get_async_order(id)['position-changed']['msg']['status'] == 'open':
    vpv = round(API.get_digital_spot_profit_after_sale(id), 2)

    print('Atual: $' + str(vpv) + ' - Minimo para venda: $' +
          str(valor_minimo))

    if vpv > valor_minimo:
        print('Fechando operação')
        API.close_digital_option(id)
        break

    time.sleep(0.3)

status, valor = API.check_win_digital_v2(id)
print('Resultado da operação: ' + ('WIN - ' if valor > 0 else 'LOSS - ') +
      str(round(valor, 2)))
      "stop_price: {},"
      "stop_lose_value: {},"
      "take_profit_value: {},"
      "take_profit_kind: {},"
      "use_trail_stop: {},"
      "auto_margin_call: {},"
      "use_token_for_commission: {}".format(
          instrument_type, instrument_id, side, amount, leverage, type,
          limit_price, stop_price, stop_lose_value, stop_lose_kind,
          take_profit_value, take_profit_kind, use_trail_stop,
          auto_margin_call, use_token_for_commission))
check, id = I_want_money.buy_order(
    instrument_type=instrument_type,
    instrument_id=instrument_id,
    side=side,
    amount=amount,
    leverage=leverage,
    type=type,
    limit_price=limit_price,
    stop_price=stop_price,
    stop_lose_value=stop_lose_value,
    stop_lose_kind=stop_lose_kind,
    take_profit_value=take_profit_value,
    take_profit_kind=take_profit_kind,
    use_trail_stop=use_trail_stop,
    auto_margin_call=auto_margin_call,
    use_token_for_commission=use_token_for_commission)
while I_want_money.get_async_order(id) == None:
    pass
order_data = I_want_money.get_async_order(id)
print(I_want_money.get_async_order(id))
Exemple #6
0
def testfunc(jobid, email, password, instrumentid_tmp, instrumenttype_tmp,
             direction_tmp, leverage_tmp, starttimehour_tmp,
             starttimeminute_tmp, stoptimehour_tmp, stoptimeminute_tmp,
             day_str, amount_tmp):
    print("{}: JobId executing... current time {}".format(
        jobid, datetime.now()))
    print("{}: JobId parameters "
          "{}: email"
          "{}: password"
          "instrumentId: {} "
          "instrumentType: {} "
          "diection_tmp: {} "
          "leverage_tmp: {}"
          "starttimehour_tmp: {}"
          "starttimeminute_tmp: {}"
          "stoptimehour_tmp: {}"
          "stoptimeminute_tmp: {}"
          "day_str: {}"
          "amount_tmp: {}".format(jobid, email, password, instrumentid_tmp,
                                  instrumenttype_tmp, direction_tmp,
                                  leverage_tmp, starttimehour_tmp,
                                  starttimeminute_tmp, stoptimehour_tmp,
                                  stoptimeminute_tmp, day_str, amount_tmp))
    if instrumenttype_tmp == 'BINARY' or instrumenttype_tmp == 'binary':
        print("In binary")
        Iq = IQ_Option(email=email, password=password)
        # Iq = IQ_Option("*****@*****.**", "aswdkl;123")
        Iq.connect()
        print(Iq.connect())
        # Money = 1
        # ACTIVES = "EURUSD"
        Money = int(amount_tmp)
        ACTIVES = instrumentid_tmp
        if direction_tmp == "BUY":
            ACTION = "call"  # or "put"
        else:
            ACTION = "put"
        expirations_mode = 1
        check, id = Iq.buy(Money, ACTIVES, ACTION, expirations_mode)
        if check:
            print("{}: JobId {} {} at {}".format(jobid, ACTIVES, ACTION,
                                                 datetime.now()))
        else:
            print("buy fail")
    elif instrumenttype_tmp == 'DIGITAL' or instrumenttype_tmp == 'digital':
        print("In digital!")
        Iq = IQ_Option(email=email, password=password)
        # Iq = IQ_Option("*****@*****.**", "aswdkl;123")
        Iq.connect()
        print(Iq.connect())
        # Money = 1
        # ACTIVES = "EURUSD"
        Money = int(amount_tmp)
        ACTIVES = str(instrumentid_tmp)
        if direction_tmp == "BUY":
            ACTION = "call"  # or "put"
        else:
            ACTION = "put"
        DURATION = 1
        print("Money: {} ACTIVES: {} ACTION: {} expiration_mode: {}".format(
            Money, ACTIVES, ACTION, DURATION))
        # print(type(Money))
        # print(type(ACTIVES))
        # print(type(ACTION))
        # print(type(DURATION))
        check, id = Iq.buy_digital_spot(ACTIVES, Money, ACTION, DURATION)
        if check:
            print("{}: JobId {} {} at {}".format(jobid, ACTIVES, ACTION,
                                                 datetime.now()))
        else:
            print("buy fail")
    else:
        Iq = IQ_Option(email=email, password=password)
        # Iq = IQ_Option("*****@*****.**", "aswdkl;123")
        Iq.connect()
        print(Iq.connect())
        print("__For_Forex_Stock_Commodities_Crypto_ETFs")
        instrument_type = instrumenttype_tmp.lower()
        print(instrument_type)
        instrument_id = instrumentid_tmp
        if direction_tmp == "BUY":
            side = "buy"  # or "put"
        else:
            side = "sell"
        amount = int(amount_tmp)
        leverage = int(leverage_tmp)
        type = "market"
        limit_price = None
        stop_price = None
        stop_lose_kind = "percent"
        stop_lose_value = 95
        take_profit_kind = None
        take_profit_value = None
        use_trail_stop = True
        auto_margin_call = False
        use_token_for_commission = False
        print("instrument_type: {},"
              "instrument_id: {},"
              "side: {},"
              "leverage: {},"
              "type: {},"
              "limit_price: {},"
              "stop_price: {},"
              "stop_lose_value: {},"
              "take_profit_value: {},"
              "take_profit_kind: {},"
              "use_trail_stop: {},"
              "auto_margin_call: {},"
              "use_token_for_commission: {}".format(
                  instrument_type, instrument_id, side, amount, leverage, type,
                  limit_price, stop_price, stop_lose_value, stop_lose_kind,
                  take_profit_value, take_profit_kind, use_trail_stop,
                  auto_margin_call, use_token_for_commission))
        check, id = Iq.buy_order(
            instrument_type=instrument_type,
            instrument_id=instrument_id,
            side=side,
            amount=amount,
            leverage=leverage,
            type=type,
            limit_price=limit_price,
            stop_price=stop_price,
            stop_lose_value=stop_lose_value,
            stop_lose_kind=stop_lose_kind,
            take_profit_value=take_profit_value,
            take_profit_kind=take_profit_kind,
            use_trail_stop=use_trail_stop,
            auto_margin_call=auto_margin_call,
            use_token_for_commission=use_token_for_commission)
        # if check:
        #     print(check)
        # else:
        #     print("no check")
        if check:
            print("{}: JobId {} {} at {}".format(jobid, instrument_type,
                                                 instrument_id,
                                                 datetime.now()))
        else:
            print("buy fail")

        while Iq.get_async_order(id) == None:
            pass

        order_data = Iq.get_async_order(id)
        print(Iq.get_async_order(id))