-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
utils.py
44 lines (37 loc) · 1.02 KB
/
utils.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
import pandas as pd
# Check lenght of Chikou Span
def distance_chikou_price(chikou, data):
distance = 0
for candle in data:
if (candle.Close <= chikou <= candle.Open) or (candle.Open <= chikou <= candle.Close):
break
distance += 1
return distance
# Check lenght of flat Kijun
def kijun_flat_distance(data):
distance = 0
for candle in reversed(data):
if candle.Kijun != data[-1].Kijun:
break
distance += 1
return distance
# Check lenght of flat Senkou B
def senkou_b_flat_distance(data):
distance = 0
for candle in reversed(data):
if candle.SenkouB != data[-1].SenkouB:
break
distance += 1
return distance
# Get HIGH from series
def get_high(candles):
prices = []
for candle in candles:
prices.append(candle.High)
return pd.Series(prices).max()
# Get LOW from series
def get_low(candles):
prices = []
for candle in candles:
prices.append(candle.Low)
return pd.Series(prices).min()