-
Notifications
You must be signed in to change notification settings - Fork 2
/
ramin_cmo_for_instant.py
69 lines (63 loc) · 2.68 KB
/
ramin_cmo_for_instant.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
from cgitb import reset
import sys
from unittest import result
from analyzers import cmo
from analyzers import rsi
from analyzers import ema
from test import get_data
import negative_divergant
import positive_divergent
import time
from datetime import datetime
from send_to_channel import send_ramin,send_main
import pytz
rsi = rsi.RSI()
cmo = cmo.CMO()
tz_London = pytz.timezone('Europe/London')
now = datetime.now(tz_London)
current_time = now.strftime("%d/%m/%Y %H:%M:%S")
class bcolors:
OK = '\033[92m' #GREEN
DOWN = '\033[93m' #YELLOW
UP = '\033[91m' #RED
RESET = '\033[0m' #RESET COLOR
def analyze(ohlc,timeframe):
ohlc_50 = ohlc.tail(50)
rsis = rsi.analyze(ohlc,14)
cmos = cmo.analyze(ohlc,period_count=20)
# print(cmos)
# print(rsis)
rsi_count = rsis.shape[0] - 1
cmo_count = cmos.shape[0] - 1
ohlc_count = ohlc.shape[0] - 1
cmo1 = cmos.cmo[cmo_count]
cmo2 = cmos.cmo[cmo_count-1]
cmo3 = cmos.cmo[cmo_count-2]
rsi1 = rsis.rsi[rsi_count]
rsi2 = rsis.rsi[rsi_count-1]
rsi3 = rsis.rsi[rsi_count-2]
close1 = ohlc.close[ohlc_count]
message=""
print(f"rsi1= {rsi1} and rsi2= {rsi2} and cmo1= {cmo1} and cmo2= {cmo2}")
if rsi1<29 and cmo1<-50 and cmo2>-50 :
positive_div_result = positive_divergent.find_pos_rsi_div(pair, timeframe=timeframe,ohlc = ohlc_50)
if positive_div_result.empty == False:
print(bcolors.UP + 'div yes' + bcolors.RESET)
message = "div yes "+"\n"
print(bcolors.UP + "up signal signal with cmo strategy" + bcolors.RESET)
print(bcolors.UP + "price is: " + str(close1) + bcolors.RESET)
message = message + pair + "\n" + "TIME:" + current_time + "\n" + "time frame: " + str(timeframe) + "\n" + "BUY signal for ramin" + "\n" + "price is: " + str(close1) + "\n"
print(message)
# send_ramin(message)
# send_main(message)
elif rsi1>71 and cmo1>50 and cmo2<50 :
negative_div_result = negative_divergant.find_neg_rsi_div(pair, timeframe=timeframe, ohlc = ohlc_50)
if negative_div_result.empty == False:
print(bcolors.DOWN+'div yes'+ bcolors.RESET)
message = "div yes "+"\n"
print(bcolors.DOWN + "down signal with cmo strategy" + bcolors.RESET)
print(bcolors.DOWN + "price is: " + str(close1) + bcolors.RESET)
message = message + pair + "\n" + "TIME:" + current_time + "\n" + "time frame: " + str(timeframe) + "\n" + "SELL signal for ramin" + "\n" + "price is: " + str(close1) + "\n"
print(message)
# send_ramin(message)
# send_main(message)