forked from sostrader/thesisbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuctions.py
83 lines (64 loc) · 1.8 KB
/
fuctions.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
from settings import (
iq, ej, gale_multiply,
gale_seq, symbol, symbols,
timeframe, seq_len, contract,
min_balance, min_payout, min_prob,
expire_time
)
import datetime
import time
from model import train_data
import tensorflow as tf
min_contract = contract
win_count = 0
sell_count = 0
buy_count = 0
Tiedtrade = 0
predict_count = 0
gale_count = 0
bid = True
trade = True
profit = 0
# define the countdown func.
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r")
time.sleep(1)
t -= 1
print('Ready for the Nex Trade!!')
#training fuction
def retrain():
while symbol,timeframe) < 60:
import os
import sys
import shutil
# Get directory name
TUNFILE= "TUN/"
MODELFILE = "models/ThesisBrain.h5"
try:
shutil.rmtree(TUNFILE)
os.remove(MODELFILE)
print("Removing old Model..")
except OSError:
pass
iq,symbol,symbols,timeframe)
else:
model = tf.keras.models.load_model('models/ThesisBrain.h5')
return model
def check_stop_time():
hour = datetime.datetime.now().hour
minutes = datetime.datetime.now().minute
# BERLIN 05:00 - 13:00 / LONDON 06:00 - 14:00 / NEW YORK 11:00 - 19:00 / SYDNEY 19:00 - 03:00 / TOKYO 21:00 - 05:00
forex_open_close = ['4','12','5','13','10','18','2','25']
for times_market in forex_open_close:
stoptime = times_market
if str(hour) == stoptime and minutes >= 50:
return True
return False
def percentage(entry1, entry2):
try:
return ( 100 * entry1 /entry2)
except ZeroDivisionError:
return 0