-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
183 lines (156 loc) · 5.09 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import os
import time
from quotexapi.stable_api import Quotex
# browser=True enable playwright
client = Quotex(email="[email protected]", password="senha", browser=False)
client.debug_ws_enable = False
def login(attempts=2):
check, reason = client.connect()
print("Start your robot")
attempt = 1
while attempt < attempts:
if not client.check_connect():
print(f"Tentando reconectar, tentativa {attempt} de {attempts}")
check, reason = client.connect()
if check:
print("Reconectado com sucesso!!!")
break
else:
print("Erro ao reconectar.")
attempt += 1
if os.path.isfile("session.json"):
os.remove("session.json")
elif not check:
attempt += 1
else:
break
time.sleep(0.5)
return check, reason
def get_balance():
check_connect, message = login()
print(check_connect, message)
if check_connect:
client.change_account("practice")
print("Saldo corrente: ", client.get_balance())
print("Saindo...")
client.close()
def balance_refill():
check_connect, message = login()
print(check_connect, message)
if check_connect:
result = client.edit_practice_balance(50000)
print(result)
client.close()
def buy():
check_connect, message = login()
print(check_connect, message)
if check_connect:
client.change_account("PRACTICE")
amount = 30
asset = "EURUSD_otc" # "EURUSD_otc"
direction = "call"
duration = 10 # in seconds
status, buy_info = client.buy(amount, asset, direction, duration)
print(status, buy_info)
print("Saldo corrente: ", client.get_balance())
print("Saindo...")
client.close()
def buy_and_check_win():
check_connect, message = login()
print(check_connect, message)
if check_connect:
client.change_account("PRACTICE")
print("Saldo corrente: ", client.get_balance())
amount = 1500
asset = "AUDCAD_otc" # "EURUSD_otc"
direction = "call"
duration = 30 # in seconds
status, buy_info = client.buy(amount, asset, direction, duration)
# print(status, buy_info)
if status:
print("Aguardando resultado...")
if client.check_win(buy_info["id"]):
print(f"\nWin!!! \nVencemos moleque!!!\nLucro: R$ {client.get_profit()}")
else:
print(f"\nLoss!!! \nPerdemos moleque!!!\nPrejuízo: R$ {client.get_profit()}")
else:
print("Falha na operação!!!")
print("Saldo Atual: ", client.get_balance())
print("Saindo...")
client.close()
def sell_option():
check_connect, message = login()
print(check_connect, message)
if check_connect:
client.change_account("PRACTICE")
amount = 30
asset = "EURUSD_otc" # "EURUSD_otc"
direction = "put"
duration = 1000 # in seconds
status, buy_info = client.buy(amount, asset, direction, duration)
print(status, buy_info)
client.sell_option(buy_info["id"])
print("Saldo corrente: ", client.get_balance())
print("Saindo...")
client.close()
def asset_open():
check_connect, message = login()
print(check_connect, message)
if check_connect:
print("Check Asset Open")
for i in client.get_all_asset_name():
print(i, client.check_asset_open(i))
client.close()
def get_candle():
check_connect, message = login()
print(check_connect, message)
if check_connect:
asset = "AUDCAD_otc"
offset = 180 # in seconds
period = 3600 # in seconds / opcional
candles = client.get_candles(asset, offset, period)
for candle in candles["data"]:
print(candle)
client.close()
def get_payment():
check_connect, message = login()
print(check_connect, message)
if check_connect:
all_data = client.get_payment()
for asset_name in all_data:
asset_data = all_data[asset_name]
print(asset_name, asset_data["payment"], asset_data["open"])
client.close()
def get_candle_v2():
check_connect, message = login()
print(check_connect, message)
if check_connect:
a = client.get_candle_v2("USDJPY_otc", 10)
print(a)
client.close()
def get_realtime_candle():
check_connect, message = login()
if check_connect:
list_size = 10
client.start_candles_stream("USDJPY_otc", list_size)
while True:
if len(client.get_realtime_candles("USDJPY_otc")) == list_size:
break
print(client.get_realtime_candles("USDJPY_otc"))
client.close()
def get_signal_data():
check_connect, message = login()
if check_connect:
while True:
print(client.get_signal_data())
time.sleep(1)
client.close()
# get_signal_data()
get_balance()
# get_payment()
# get_candle()
# get_candle_v2()
# get_realtime_candle()
# asset_open()
# buy_and_check_win()
# balance_refill()