docasne ulozeni DYNAMICKY REFACTORING _NEW

This commit is contained in:
David Brazda
2023-07-11 19:25:08 +02:00
parent 2551ccf729
commit 2a9b2a1c7c
17 changed files with 1829 additions and 36 deletions

47
testy/pricecrosses.py Normal file
View 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))