analyser_hj3415 2.10.6__py3-none-any.whl → 3.0.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- analyser_hj3415/__init__.py +13 -0
- analyser_hj3415/analyser/__init__.py +0 -0
- analyser_hj3415/analyser/eval/__init__.py +4 -0
- analyser_hj3415/analyser/eval/blue.py +187 -0
- analyser_hj3415/analyser/eval/common.py +267 -0
- analyser_hj3415/analyser/eval/growth.py +110 -0
- analyser_hj3415/analyser/eval/mil.py +274 -0
- analyser_hj3415/analyser/eval/red.py +295 -0
- analyser_hj3415/{score.py → analyser/score.py} +24 -23
- analyser_hj3415/analyser/tsa/__init__.py +2 -0
- analyser_hj3415/analyser/tsa/lstm.py +670 -0
- analyser_hj3415/analyser/tsa/prophet.py +207 -0
- analyser_hj3415/cli.py +11 -88
- {analyser_hj3415-2.10.6.dist-info → analyser_hj3415-3.0.0.dist-info}/METADATA +3 -3
- analyser_hj3415-3.0.0.dist-info/RECORD +22 -0
- analyser_hj3415/eval.py +0 -960
- analyser_hj3415/tsa.py +0 -708
- analyser_hj3415-2.10.6.dist-info/RECORD +0 -14
- {analyser_hj3415-2.10.6.dist-info → analyser_hj3415-3.0.0.dist-info}/WHEEL +0 -0
- {analyser_hj3415-2.10.6.dist-info → analyser_hj3415-3.0.0.dist-info}/entry_points.txt +0 -0
@@ -1,12 +1,15 @@
|
|
1
|
-
|
2
|
-
from utils_hj3415 import utils, helpers
|
1
|
+
import os
|
3
2
|
import datetime
|
4
3
|
from collections import OrderedDict
|
5
|
-
from . import eval, tsa
|
6
4
|
|
7
|
-
import
|
5
|
+
from db_hj3415 import myredis
|
6
|
+
from utils_hj3415 import tools, setup_logger
|
7
|
+
|
8
|
+
from analyser_hj3415.analyser import tsa
|
9
|
+
from analyser_hj3415.analyser import eval
|
8
10
|
|
9
|
-
|
11
|
+
mylogger = setup_logger(__name__,'WARNING')
|
12
|
+
expire_time = tools.to_int(os.getenv('DEFAULT_EXPIRE_TIME_H', 48)) * 3600
|
10
13
|
|
11
14
|
|
12
15
|
def is_within_last_three_days(date_to_check: datetime.datetime.date) -> bool:
|
@@ -34,8 +37,8 @@ class Score:
|
|
34
37
|
|
35
38
|
@code.setter
|
36
39
|
def code(self, code: str):
|
37
|
-
assert
|
38
|
-
|
40
|
+
assert tools.is_6digit(code), f'Invalid value : {code}'
|
41
|
+
mylogger.info(f'change code : {self.code} -> {code}')
|
39
42
|
self._code = code
|
40
43
|
self.c101.code = code
|
41
44
|
self.name = self.c101.get_name()
|
@@ -46,7 +49,7 @@ class Score:
|
|
46
49
|
self.lstm.code = code
|
47
50
|
self.prophet.code = code
|
48
51
|
|
49
|
-
def get(self, refresh=False
|
52
|
+
def get(self, refresh=False) -> dict:
|
50
53
|
"""
|
51
54
|
한 종목의 각분야 평가를 모아서 딕셔너리 형태로 반환함.
|
52
55
|
redis_name = self.code + '_score'
|
@@ -65,13 +68,13 @@ class Score:
|
|
65
68
|
print(f"{self.code}/{self.name}의 scoring을 시작합니다.")
|
66
69
|
redis_name = self.code + '_score'
|
67
70
|
print(
|
68
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
71
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time/3600}h")
|
69
72
|
|
70
73
|
def fetch_score() -> dict:
|
71
|
-
|
72
|
-
시가총액 =
|
74
|
+
mylogger.info("시가총액 데이터 추출중..")
|
75
|
+
시가총액 = tools.format_large_number(int(self.c101.get_recent()['시가총액']))
|
73
76
|
|
74
|
-
|
77
|
+
mylogger.info("C108 최근 데이터 추출중..")
|
75
78
|
# c108이 최근에 업데이트 되었는지...
|
76
79
|
c108_recent_date = self.c108.get_recent_date()
|
77
80
|
# print('code - ', code, ' | c108 recent date - ', c108_recent_date.date())
|
@@ -80,19 +83,19 @@ class Score:
|
|
80
83
|
else:
|
81
84
|
is_update_c108 = is_within_last_three_days(c108_recent_date.date())
|
82
85
|
|
83
|
-
|
86
|
+
mylogger.info("Red score 계산중..")
|
84
87
|
red_score = self.red.get(verbose=False).score
|
85
88
|
|
86
|
-
|
89
|
+
mylogger.info("Mil data 계산중..")
|
87
90
|
mil_data = self.mil.get(verbose=False)
|
88
91
|
|
89
|
-
|
92
|
+
mylogger.info("Lstm 최근 데이터 조회중..")
|
90
93
|
if myredis.Base.exists(f'{self.code}_mylstm_predictions'):
|
91
94
|
is_lstm_up = self.lstm.is_up()
|
92
95
|
else:
|
93
96
|
is_lstm_up = None
|
94
97
|
|
95
|
-
|
98
|
+
mylogger.info("\tProphet 최근 데이터 조회중..")
|
96
99
|
prophet_score = self.prophet.scoring()
|
97
100
|
|
98
101
|
return {
|
@@ -105,19 +108,17 @@ class Score:
|
|
105
108
|
'is_lstm_up': is_lstm_up,
|
106
109
|
'prophet_score': prophet_score,
|
107
110
|
}
|
108
|
-
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_score, timer=
|
111
|
+
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_score, timer=expire_time)
|
109
112
|
return data_dict
|
110
113
|
|
111
114
|
@classmethod
|
112
|
-
def ranking(self, refresh=False,
|
115
|
+
def ranking(self, refresh=False, top='all') -> OrderedDict:
|
113
116
|
"""
|
114
117
|
prophet score 기준으로 정렬하여 ordered dict로 반환함
|
115
118
|
|
116
119
|
Parameters:
|
117
120
|
refresh (bool): Specifies whether to refresh the ranking data. Defaults
|
118
121
|
to `False`.
|
119
|
-
expire_time_h (int): Time in hours after which the cached data should
|
120
|
-
expire. Defaults to `24` hours.
|
121
122
|
top (Union[str, int]): Determines how many top rankings to return.
|
122
123
|
Defaults to `'all'`. If an integer is provided, it limits the
|
123
124
|
ranking to the specified count.
|
@@ -134,7 +135,7 @@ class Score:
|
|
134
135
|
redis_name = 'score_ranking'
|
135
136
|
|
136
137
|
print(
|
137
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
138
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time/3600}h")
|
138
139
|
|
139
140
|
def fetch_ranking() -> dict:
|
140
141
|
data = {}
|
@@ -143,13 +144,13 @@ class Score:
|
|
143
144
|
try:
|
144
145
|
s.code = code
|
145
146
|
except ValueError:
|
146
|
-
|
147
|
+
mylogger.error(f'score ranking error : {code}')
|
147
148
|
continue
|
148
149
|
score = s.get(refresh=refresh)
|
149
150
|
data[code] = score
|
150
151
|
return data
|
151
152
|
|
152
|
-
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=
|
153
|
+
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=expire_time)
|
153
154
|
|
154
155
|
# prophet_score를 기준으로 정렬
|
155
156
|
ranking = OrderedDict(sorted(data_dict.items(), key=lambda x: x[1]['prophet_score'], reverse=True))
|