Skip to content

Commit 89c884b

Browse files
committed
Add latest ranker
1 parent 077fd7c commit 89c884b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Trading/algo/ranker/ranker.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def add_history(self, history: History):
4545
else:
4646
self._scores = dict(sorted(self._scores.items(), key=lambda item: item[1])[:self._top_n])
4747

48+
def scores(self):
49+
return self._scores
50+
4851
class RangeScorer(ScoreCalculator):
4952
'''
5053
RangeScorer class is used to score stocks based on their historical data.
@@ -73,9 +76,14 @@ def calculate(self, history: History):
7376
ratio = top_highs / top_lows
7477

7578
# 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
7780

7881
highs_std = calculate_standard_deviation(ordered_highs)
82+
highs_mean = calculate_mean(ordered_highs)
7983
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
8088

8189
return ratio / (highs_std + lows_std)

0 commit comments

Comments
 (0)