docasne ulozeni DYNAMICKY REFACTORING _NEW
This commit is contained in:
47
testy/pricecrosses.py
Normal file
47
testy/pricecrosses.py
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
test1_threshold = 28.905
|
||||
bacma = []
|
||||
bacma.append([28.91])
|
||||
bacma.append([28.91,28.90])
|
||||
bacma.append([28.91,28.90,28.89])
|
||||
bacma.append([28.91,28.90,28.89,28.88])
|
||||
bacma.append([28.91,28.90,28.89,28.88,28.87])
|
||||
bacma.append([28.91,28.90,28.89,28.88,28.87,28.86])
|
||||
|
||||
|
||||
def crossed_up(threshold, list):
|
||||
"""check if threshold has crossed up last thresholdue in list"""
|
||||
try:
|
||||
if threshold < list[-1] and threshold >= list[-2]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
def crossed_down(threshold, list):
|
||||
"""check if threshold has crossed down last thresholdue in list"""
|
||||
try:
|
||||
if threshold > list[-1] and threshold <= list[-2]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
def crossed(threshold, list):
|
||||
"""check if threshold has crossed last thresholdue in list"""
|
||||
if crossed_down(threshold, list) or crossed_up(threshold, list):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
for i in bacma:
|
||||
print(i)
|
||||
print(f"threshold crossed down {i}", threshold_crossed_down(test1_threshold, i))
|
||||
print(f"threshold crossed up {i}", threshold_crossed_up(test1_threshold, i))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user