-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
126 lines (84 loc) · 2.75 KB
/
Copy pathMain.py
File metadata and controls
126 lines (84 loc) · 2.75 KB
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
from iqoptionapi.stable_api import IQ_Option
import time
from configparser import ConfigParser
config = ConfigParser()
config.read('config.ini')
trader = IQ_Option(config['account']['email'], config['account']['password'])
trader.connect()
def SMA():
candles = trader.get_candles(ACTIVES, 15, 28, time.time())
sma7vals = []
for candle in candles:
sma7vals.append(candle['close'])
candles = trader.get_candles(ACTIVES, 15, 56, time.time())
sma14vals = []
for candle in candles:
sma14vals.append(candle['close'])
if sum(sma7vals)/len(sma7vals) > sum(sma14vals)/len(sma14vals):
pass
print("SMA: Call")
return(True)
else:
print("SMA: Put")
return(False)
def Result(id):
if trader.check_win_v3(id) >= 0:
print(f"Profit: {trader.check_win_v3(id)} {trader.get_currency()}")
return(True)
else:
print(f"Loss: {trader.check_win_v3(id)} {trader.get_currency()}")
return(False)
def ChangedAction(ACTION):
if ACTION == "call":
return("put")
elif ACTION == "put":
return("call")
def IsOpen(ACTIVES):
Isopen = (((trader.get_all_open_time())['binary'])[ACTIVES])['open']
if Isopen == {} or Isopen == False or ((trader.get_all_profit())[ACTIVES])['turbo'] == {}:
return(False)
else:
return(True)
def Incremental(ACTIVES):
profit_percent = ((trader.get_all_profit())[ACTIVES])['turbo']
print('profit percent: ', profit_percent, "\n")
Increment = (1-profit_percent) + 2.05
return(Increment)
def ChangeACTIVES():
openACTIVES = trader.get_all_profit()
open_list = {}
for openACTIVE in openACTIVES:
ACTIVE = (openACTIVES[openACTIVE])['turbo']
if not ACTIVE == {}:
open_list[openACTIVE] = ACTIVE
print(open_list)
max_key = max(open_list, key=open_list.get)
return(max_key)
try:
while True:
Money=1
ACTIVES="EURGBP"
ACTION="call"#or "put"
expirations_mode=1
currency = trader.get_currency()
while True:
if not IsOpen(ACTIVES):
ACTIVES = ChangeACTIVES()
if SMA():
ACTION = "call"
else:
ACTION = "put"
check, id = trader.buy(Money, ACTIVES, ACTION, expirations_mode)
if check: print(f"{ACTION} order succcessful")
else:
print(f"{ACTION} order failed")
result = Result(id)
if result:
break
else:
Increment = Incremental(ACTIVES)
print('Increment is', Increment)
Money = round(Money*Increment)
except KeyboardInterrupt:
print("Exiting...")
exit()