forked from vlex05/SMC-Algo-Trading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Candle.py
42 lines (36 loc) · 1.01 KB
/
Candle.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
class Candle():
def __init__(self,data):
if data is not None:
self.O = data["open"]
self.H = data["high"]
self.L = data["low"]
self.C = data["close"]
self.date = data["date"]
try:
self.dnert = data["trend"]
except:
self.dnert = None
pass
self.trend()
else:
self.O = None
self.H = None
self.L = None
self.C = None
self.date = None
self.dnert = None
def __repr__(self):
a = [self.O,self.H,self.L,self.C,self.date,self.dnert]
b = str(a)
return b
def trend(self):
if self.O is None or self.C is None:
return self.dnert()
elif self.O > self.C:
self.dnert = "bear"
return self.dnert
elif self.O < self.C:
self.dnert = "bull"
return self.dnert
else:
return None