Skip to content

Commit

Permalink
chore: files were formated, got pass code style action
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Dec 3, 2023
1 parent 24b2274 commit fa8db90
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 46 deletions.
101 changes: 61 additions & 40 deletions example/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

CONST_ASSET = "AUDCAD"

#vars global parameters
# vars global parameters
last_action = None
count_sequence_loss = 1
#countSequenceLossTrend = 0
# countSequenceLossTrend = 0

#management risk
valor_entrada_em_operacao = 2 #dollars
# management risk
valor_entrada_em_operacao = 2 # dollars
valor_entrada_inicial = valor_entrada_em_operacao
limite_wins_sequencias = 2
limite_tentativas_recuperacao_loss_gale = 2
Expand All @@ -35,6 +35,7 @@
valor_total_credito_win = 0
##--end management risk--##


def __x__(y):
z = asyncio.get_event_loop().run_until_complete(y)
return z
Expand All @@ -43,6 +44,7 @@ def __x__(y):
client = Quotex(email="your@mail.com", password="yourPassword")
client.debug_ws_enable = False


async def login(attempts=5):
check, reason = await client.connect()
print(colored("[INFO]: ", "blue"), "Start your robot")
Expand All @@ -66,6 +68,7 @@ async def login(attempts=5):
await asyncio.sleep(0.5)
return check, reason


def check_asset(asset):
asset_query = asset_parse(asset)
asset_open = client.check_asset_open(asset_query)
Expand All @@ -77,6 +80,7 @@ def check_asset(asset):
asset_open = client.check_asset_open(asset_query)
return asset, asset_open


async def get_balance():
check_connect, message = await login()
if check_connect:
Expand Down Expand Up @@ -115,6 +119,7 @@ async def trade():
print(colored("[INFO]: ", "blue"), "Exiting...")
client.close()


async def trade_and_check():
check_connect, message = await login()
if check_connect:
Expand All @@ -126,7 +131,7 @@ async def trade_and_check():
while balance >= 1:
amount = 1
if count_sequence_loss > 0:
#amount = countSequenceLoss + countSequenceLoss #martigale
# amount = countSequenceLoss + countSequenceLoss #martigale
amount = 2

if last_action is None:
Expand All @@ -141,11 +146,11 @@ async def trade_and_check():
if asset_open[2]:
print(colored("[INFO]: "), "OK: Asset is open")
status, trade_info = await client.trade(action, amount, asset, DurationTime.ONE_MINUTE)
#print(status, trade_info, "\n")
# print(status, trade_info, "\n")
if status:
print(colored("[INFO]: ", "blue"), "Waiting for result...")
print(colored("[INFO]: ", "blue"), f"Side: {action}, countSequenceLoss: {count_sequence_loss}")
#print(f"id checking {trade_info[asset]['id']}")
# print(f"id checking {trade_info[asset]['id']}")

if await client.check_win(asset, trade_info[asset]["id"]):
print(colored("[INFO]: ", "green"), f"Win -> Profit: {client.get_profit()}")
Expand All @@ -160,12 +165,12 @@ async def trade_and_check():
else:
last_action = OperationType.CALL_GREEN
count_sequence_loss = 0
#else:
#else: #error
# else:
# else: #error
# print(colored("[ERROR]: ", "red"), "Check Win/Loss failed!!!")
# lastAction = None
else:
print(colored("[ERROR]: ", "red"), "Operation failed!!!")
print(colored("[ERROR]: ", "red"), "Operation failed!!!")
return
else:
print(colored("[WARN]: ", "light_red"), "Asset is closed.")
Expand All @@ -177,8 +182,8 @@ async def trade_and_check():
print(colored("[WARN]: ", "light_red"), "No balance available :(")
client.close()

async def management_risk(result_trade):

async def management_risk(result_trade):
global valor_entrada_em_operacao
global valor_entrada_inicial
global limite_wins_sequencias
Expand All @@ -192,43 +197,50 @@ async def management_risk(result_trade):
global valor_total_debito_loss
global count_gale

if result_trade: #win
if result_trade: # win
valor_total_credito_win = valor_total_credito_win + valor_entrada_em_operacao
count_win = count_win + 1
count_win_print = count_win_print + 1

#Se tiver 2 wins seguidos
# Se tiver 2 wins seguidos
if count_win == limite_wins_sequencias:
valor_entrada_em_operacao = valor_entrada_inicial
print(f'\nLimite de Wins atual: {count_win} atingido. reinicia a e contador de gales entrada atual: {valor_entrada_em_operacao}!')
print(
f"\nLimite de Wins atual: {count_win} atingido. reinicia a e contador de gales entrada atual: {valor_entrada_em_operacao}!"
)
count_gale = 0
count_win = 0
lucro = round (valor_total_debito_loss + valor_total_credito_win,2)
print(f'\nPróxima entrada: {valor_entrada_em_operacao}\nLucro atual: {lucro}\nWins: {count_win_print}\nLoss: {count_loss_print}\n')
lucro = round(valor_total_debito_loss + valor_total_credito_win, 2)
print(
f"\nPróxima entrada: {valor_entrada_em_operacao}\nLucro atual: {lucro}\nWins: {count_win_print}\nLoss: {count_loss_print}\n"
)
else:
count_gale += 1
#Qndo der win * 2
# Qndo der win * 2
valor_entrada_em_operacao = valor_entrada_em_operacao * 2
print(f'\nWins, gale nro : {count_gale} subindo a entrada para: {valor_entrada_em_operacao}.')
print(f"\nWins, gale nro : {count_gale} subindo a entrada para: {valor_entrada_em_operacao}.")

#Verifica se o valor da entrada é menor que o valor inicial
# Verifica se o valor da entrada é menor que o valor inicial
if valor_entrada_em_operacao < valor_entrada_inicial:
valor_entrada_em_operacao = valor_entrada_inicial
print(f'\nEntrada em operação atual: {valor_entrada_em_operacao} menor que o valor inicial. resetado valor')
print(f"\nEntrada em operação atual: {valor_entrada_em_operacao} menor que o valor inicial. resetado valor")

#Qndo der loss mantém o valor
#Próxima entrada = entrada inicial
if not result_trade: #loss
# Qndo der loss mantém o valor
# Próxima entrada = entrada inicial
if not result_trade: # loss
valor_total_debito_loss = valor_total_debito_loss - valor_entrada_em_operacao
count_loss = count_loss + 1
count_loss_print = count_loss_print + 1
valor_entrada_em_operacao = valor_entrada_inicial
count_gale = 0
count_win = 0
#Painel de resultados
#entrada_em_operacao = round(entrada_em_operacao,2)
lucro = round (valor_total_debito_loss + valor_total_credito_win,2)
print(f'\nPróxima entrada: {valor_entrada_em_operacao}\nLucro atual: {lucro}\nWins: {count_win_print}\nLoss: {count_loss_print}')
# Painel de resultados
# entrada_em_operacao = round(entrada_em_operacao,2)
lucro = round(valor_total_debito_loss + valor_total_credito_win, 2)
print(
f"\nPróxima entrada: {valor_entrada_em_operacao}\nLucro atual: {lucro}\nWins: {count_win_print}\nLoss: {count_loss_print}"
)


async def wait_for_input_exceeding_30_seconds_limit():
while True:
Expand All @@ -237,6 +249,7 @@ async def wait_for_input_exceeding_30_seconds_limit():
return # Returns when it's the right time to proceed
await asyncio.sleep(0.5)


async def strategy_random():
check_connect, message = await login()
if check_connect:
Expand All @@ -262,7 +275,9 @@ async def strategy_random():

if asset_open[2]:
print(colored("[INFO]: "), "OK: Asset is open")
status, trade_info = await client.trade(action, valor_entrada_em_operacao, asset, DurationTime.ONE_MINUTE)
status, trade_info = await client.trade(
action, valor_entrada_em_operacao, asset, DurationTime.ONE_MINUTE
)
print(status, trade_info, "\n")
if status:
print(colored("[INFO]: ", "blue"), "Waiting for result...")
Expand Down Expand Up @@ -296,6 +311,7 @@ async def strategy_random():
print(colored("[WARN]: ", "light_red"), "No balance available :(")
client.close()


async def sell_option():
check_connect, message = await login()
print(check_connect, message)
Expand Down Expand Up @@ -335,6 +351,7 @@ async def get_candle():
print(candle)
client.close()


async def get_payment():
check_connect, message = await login()
if check_connect:
Expand All @@ -344,8 +361,11 @@ async def get_payment():
print(asset_name, asset_data["payment"], asset_data["open"])
client.close()


import datetime
#import numpy as np


# import numpy as np
async def get_candle_v2():
check_connect, message = await login()
print(check_connect, message)
Expand All @@ -355,17 +375,17 @@ async def get_candle_v2():
global CONST_ASSET
asset, asset_open = check_asset(CONST_ASSET)
candles = await client.get_candle_v2(asset, period, size)
#data = np.array(candles)
# data = np.array(candles)
## Adiciona uma nova coluna com os valores convertidos em data
#timestamps = data[:, 0]
#datas = [datetime.datetime.fromtimestamp(ts).strftime('%d/%m/%Y %H:%M:%S') for ts in timestamps]
#new_column = np.array(datas).reshape(-1, 1)
#data_with_dates = np.hstack((data, new_column))
# timestamps = data[:, 0]
# datas = [datetime.datetime.fromtimestamp(ts).strftime('%d/%m/%Y %H:%M:%S') for ts in timestamps]
# new_column = np.array(datas).reshape(-1, 1)
# data_with_dates = np.hstack((data, new_column))

for candle in candles:
print(candle)
timestamp = candle[0]
data = datetime.datetime.fromtimestamp(timestamp).strftime('%d/%m/%Y %H:%M:%S')
data = datetime.datetime.fromtimestamp(timestamp).strftime("%d/%m/%Y %H:%M:%S")
print(data)
client.close()

Expand Down Expand Up @@ -406,11 +426,11 @@ async def main():
# await get_balance()
# await get_signal_data()
# await get_payment()
#await get_candle()
#await get_candle_v2()
#await get_realtime_candle()
# await get_candle()
# await get_candle_v2()
# await get_realtime_candle()
# await assets_open()
#await trade_and_check()
# await trade_and_check()
await strategy_random()
# await balance_refill()
# await get_moving_average()
Expand All @@ -419,7 +439,8 @@ async def main():
def run_main():
__x__(main())

#Agendamentos:

# Agendamentos:
schedule.every(30).seconds.do(run_main)

while True:
Expand Down
6 changes: 4 additions & 2 deletions quotexpy/expiration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import pytz
from datetime import datetime, timedelta

TIME_ZONE = 'Etc/GMT+3'
TIME_ZONE = "Etc/GMT+3"


#def get_timestamp() -> int:
# def get_timestamp() -> int:
# return calendar.timegm(time.gmtime())


def get_timestamp() -> int:
global TIME_ZONE
# Obter o objeto de fuso horário para UTC-3
Expand All @@ -21,6 +22,7 @@ def get_timestamp() -> int:

return timestamp


def date_to_timestamp(dt):
return time.mktime(dt.timetuple())

Expand Down
5 changes: 4 additions & 1 deletion quotexpy/stable_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
from quotexpy.api import QuotexAPI
from quotexpy.constants import codes_asset


def nested_dict(n, type):
if n == 1:
return defaultdict(type)
return defaultdict(lambda: nested_dict(n - 1, type))


def truncate(f, n):
return math.floor(f * 10**n) / 10**n


class Quotex(object):
__version__ = "1.40.0"

Expand Down Expand Up @@ -251,7 +254,7 @@ async def check_win(self, asset, id_number):
"""Check win based id"""
self.logger.debug(f"begin check wind {id_number}")
await self.start_remaing_time()
while True: #await self.start_remaing_time():
while True: # await self.start_remaing_time():
try:
listinfodata_dict = self.api.listinfodata.get(asset)
if listinfodata_dict and listinfodata_dict["game_state"] == 1:
Expand Down
1 change: 0 additions & 1 deletion quotexpy/utils/account_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class AccountType:
REAL = "REAL"
PRACTICE = "PRACTICE"

1 change: 0 additions & 1 deletion quotexpy/utils/duration_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ class DurationTime:
FIFTEEN_MINUTES = 900
THIRTY_MINUTES = 1800
ONE_HOUR = 3600

1 change: 0 additions & 1 deletion quotexpy/utils/operation_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class OperationType:
CALL_GREEN = "call"
PUT_RED = "put"

0 comments on commit fa8db90

Please sign in to comment.