File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ def add_history(self, history: History):
45
45
else :
46
46
self ._scores = dict (sorted (self ._scores .items (), key = lambda item : item [1 ])[:self ._top_n ])
47
47
48
+ def scores (self ):
49
+ return self ._scores
50
+
48
51
class RangeScorer (ScoreCalculator ):
49
52
'''
50
53
RangeScorer class is used to score stocks based on their historical data.
@@ -73,9 +76,14 @@ def calculate(self, history: History):
73
76
ratio = top_highs / top_lows
74
77
75
78
# minimize the standard deviation of highs and lows
76
- from Trading .utils .calculations import calculate_standard_deviation
79
+ from Trading .utils .calculations import calculate_standard_deviation , calculate_mean
77
80
78
81
highs_std = calculate_standard_deviation (ordered_highs )
82
+ highs_mean = calculate_mean (ordered_highs )
79
83
lows_std = calculate_standard_deviation (ordered_lows )
84
+ lows_mean = calculate_mean (ordered_lows )
85
+
86
+ highs_std = highs_std / highs_mean
87
+ lows_std = lows_std / lows_mean
80
88
81
89
return ratio / (highs_std + lows_std )
You can’t perform that action at this time.
0 commit comments