analyser_hj3415 3.2.2__tar.gz → 3.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/PKG-INFO +1 -1
  2. analyser_hj3415-3.3.1/analyser_hj3415/analyser/__init__.py +30 -0
  3. analyser_hj3415-3.3.1/analyser_hj3415/analyser/compile.py +353 -0
  4. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/eval/blue.py +78 -9
  5. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/eval/common.py +72 -110
  6. analyser_hj3415-3.3.1/analyser_hj3415/analyser/eval/growth.py +181 -0
  7. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/eval/mil.py +119 -18
  8. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/eval/red.py +95 -66
  9. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/tsa/__init__.py +1 -1
  10. analyser_hj3415-3.3.1/analyser_hj3415/analyser/tsa/common.py +33 -0
  11. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/tsa/lstm.py +108 -133
  12. analyser_hj3415-3.3.1/analyser_hj3415/analyser/tsa/prophet.py +405 -0
  13. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/cli.py +12 -9
  14. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/pyproject.toml +1 -1
  15. analyser_hj3415-3.2.2/analyser_hj3415/analyser/__init__.py +0 -12
  16. analyser_hj3415-3.2.2/analyser_hj3415/analyser/compile.py +0 -264
  17. analyser_hj3415-3.2.2/analyser_hj3415/analyser/eval/growth.py +0 -110
  18. analyser_hj3415-3.2.2/analyser_hj3415/analyser/tsa/prophet.py +0 -268
  19. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/.gitignore +0 -0
  20. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/README.md +0 -0
  21. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/__init__.py +0 -0
  22. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/analyser/eval/__init__.py +0 -0
  23. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/workroom/__init__.py +0 -0
  24. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/workroom/mysklearn.py +0 -0
  25. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/workroom/mysklearn2.py +0 -0
  26. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/workroom/score.py +0 -0
  27. {analyser_hj3415-3.2.2 → analyser_hj3415-3.3.1}/analyser_hj3415/workroom/trash.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: analyser_hj3415
3
- Version: 3.2.2
3
+ Version: 3.3.1
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,30 @@
1
+ from typing import NamedTuple
2
+
3
+ class MarketIndices(NamedTuple):
4
+ """
5
+ 주요 시장 지수를 나타내는 NamedTuple입니다.
6
+
7
+ 속성:
8
+ WTI (str): 서부 텍사스 중질유(WTI) 선물 지수 (심볼: "CL=F").
9
+ GOLD (str): 금 선물 지수 (심볼: "GC=F").
10
+ SILVER (str): 은 선물 지수 (심볼: "SI=F").
11
+ USD_IDX (str): 미국 달러 인덱스 (심볼: "DX-Y.NYB").
12
+ USD_KRW (str): 달러-원 환율 (심볼: "KRW=X").
13
+ SP500 (str): S&P 500 주가지수 (심볼: "^GSPC").
14
+ KOSPI (str): 코스피 지수 (심볼: "^KS11").
15
+ NIKKEI (str): 닛케이 225 지수 (일본) (심볼: "^N225").
16
+ CHINA (str): 항셍 지수 (홍콩) (심볼: "^HSI").
17
+ IRX (str): 미국 단기 국채 금리 지수 (13주 T-빌 금리) (심볼: "^IRX").
18
+ """
19
+ WTI: str = "CL=F"
20
+ GOLD: str = "GC=F"
21
+ SILVER: str = "SI=F"
22
+ USD_IDX: str = "DX-Y.NYB"
23
+ USD_KRW: str = "KRW=X"
24
+ SP500: str = "^GSPC"
25
+ KOSPI: str = "^KS11"
26
+ NIKKEI: str = "^N225"
27
+ CHINA: str = "^HSI"
28
+ IRX: str = "^IRX"
29
+
30
+ MIs = MarketIndices()
@@ -0,0 +1,353 @@
1
+ import os
2
+ from collections import OrderedDict
3
+ from typing import Union
4
+ from dataclasses import dataclass
5
+
6
+ from db_hj3415 import myredis
7
+ from utils_hj3415 import tools, setup_logger
8
+
9
+ from analyser_hj3415.analyser import tsa, eval, MIs
10
+
11
+ mylogger = setup_logger(__name__,'WARNING')
12
+ expire_time = tools.to_int(os.getenv('DEFAULT_EXPIRE_TIME_H', 48)) * 3600
13
+
14
+ @dataclass
15
+ class MICompileData:
16
+ """
17
+ MI(Market Index) 데이터를 컴파일하여 저장하는 데이터 클래스.
18
+
19
+ 속성:
20
+ mi_type (str): 시장 지수 유형.
21
+ prophet_data (tsa.ProphetData): Prophet 예측 데이터.
22
+ lstm_grade (tsa.LSTMGrade): LSTM 등급 데이터.
23
+ is_lstm_up (bool): LSTM 상승 여부.
24
+ is_prophet_up (bool): Prophet 상승 여부.
25
+ lstm_html (str): LSTM 시각화 HTML.
26
+ prophet_html (str): Prophet 시각화 HTML.
27
+ """
28
+ mi_type: str
29
+
30
+ prophet_data: tsa.ProphetData
31
+ lstm_grade: tsa.LSTMGrade
32
+
33
+ is_lstm_up: bool = False
34
+ is_prophet_up: bool = False
35
+
36
+ lstm_html: str = ''
37
+ prophet_html: str = ''
38
+
39
+
40
+ class MICompile:
41
+ """
42
+ MI(Market Index) 데이터를 컴파일하는 클래스.
43
+
44
+ 메서드:
45
+ get(refresh=False) -> MICompileData:
46
+ MI 데이터를 컴파일하거나 캐시에서 가져옵니다.
47
+
48
+ analyser_lstm_all_mi(refresh: bool):
49
+ 모든 MI에 대해 LSTM 예측 및 초기화 수행.
50
+ """
51
+ def __init__(self, mi_type: str):
52
+ """
53
+ MICompile 객체를 초기화합니다.
54
+
55
+ 매개변수:
56
+ mi_type (str): 시장 지수 유형.
57
+ """
58
+ assert mi_type in MIs._fields, f"Invalid MI type ({MIs._fields})"
59
+ self._mi_type = mi_type
60
+
61
+ @property
62
+ def mi_type(self) -> str:
63
+ """
64
+ MI 유형을 반환합니다.
65
+
66
+ 반환값:
67
+ str: MI 유형.
68
+ """
69
+ return self._mi_type
70
+
71
+ @mi_type.setter
72
+ def mi_type(self, mi_type: str):
73
+ """
74
+ MI 유형을 변경합니다.
75
+
76
+ 매개변수:
77
+ mi_type (str): 새로 설정할 MI 유형.
78
+ """
79
+ assert mi_type in MIs._fields, f"Invalid MI type ({MIs._fields})"
80
+ self._mi_type = mi_type
81
+
82
+ def get(self, refresh=False) -> MICompileData:
83
+ """
84
+ MI 데이터를 컴파일하거나 캐시에서 가져옵니다.
85
+
86
+ 매개변수:
87
+ refresh (bool): 데이터를 새로 가져올지 여부.
88
+
89
+ 반환값:
90
+ MICompileData: 컴파일된 MI 데이터.
91
+ """
92
+ print(f"{self.mi_type}의 compiling을 시작합니다.")
93
+ redis_name = self.mi_type + '_mi_compile'
94
+ print(
95
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time / 3600}h")
96
+
97
+ def fetch_mi_compile_data() -> MICompileData:
98
+ prophet = tsa.MIProphet(self.mi_type)
99
+ lstm = tsa.MILSTM(self.mi_type)
100
+
101
+ data = MICompileData(
102
+ mi_type=self.mi_type,
103
+ prophet_data=prophet.generate_data(refresh=refresh),
104
+ lstm_grade=lstm.get_final_predictions(refresh=refresh)[1],
105
+ )
106
+ data.is_lstm_up = lstm.is_lstm_up()
107
+ data.is_prophet_up = prophet.is_prophet_up(refresh=False)
108
+ data.lstm_html = lstm.export(refresh=False)
109
+ data.prophet_html = prophet.export()
110
+ return data
111
+
112
+ mi_compile_data = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_mi_compile_data, timer=expire_time)
113
+ return mi_compile_data
114
+
115
+ @staticmethod
116
+ def analyser_lstm_all_mi(refresh: bool):
117
+ """
118
+ 모든 MI(Market Index)에 대해 LSTM 예측과 초기화를 수행합니다.
119
+
120
+ 매개변수:
121
+ refresh (bool): 데이터를 새로 가져올지 여부.
122
+ """
123
+ mi_lstm = tsa.MILSTM('WTI')
124
+ print(f"*** LSTM prediction redis cashing Market Index items ***")
125
+ for mi_type in MIs._fields:
126
+ mi_lstm.mi_type = mi_type
127
+ print(f"{mi_lstm.mi_type}")
128
+ mi_lstm.initializing()
129
+ mi_lstm.get_final_predictions(refresh=refresh, num=5)
130
+
131
+ @dataclass
132
+ class CorpCompileData:
133
+ """
134
+ 기업 데이터를 컴파일하여 저장하는 데이터 클래스.
135
+
136
+ 속성:
137
+ code (str): 기업 코드.
138
+ name (str): 기업 이름.
139
+ red_data (eval.RedData): RED 분석 데이터.
140
+ mil_data (eval.MilData): MIL 분석 데이터.
141
+ prophet_data (tsa.ProphetData): Prophet 예측 데이터.
142
+ lstm_grade (tsa.LSTMGrade): LSTM 등급 데이터.
143
+ is_lstm_up (bool): LSTM 상승 여부.
144
+ is_prophet_up (bool): Prophet 상승 여부.
145
+ lstm_html (str): LSTM 시각화 HTML.
146
+ prophet_html (str): Prophet 시각화 HTML.
147
+ """
148
+ code: str
149
+ name: str
150
+
151
+ red_data: eval.RedData
152
+ mil_data: eval.MilData
153
+
154
+ prophet_data: tsa.ProphetData
155
+ lstm_grade: tsa.LSTMGrade
156
+
157
+ is_lstm_up: bool = False
158
+ is_prophet_up: bool = False
159
+
160
+ lstm_html: str = ''
161
+ prophet_html: str = ''
162
+
163
+
164
+ class CorpCompile:
165
+ """
166
+ 기업 데이터를 컴파일하는 클래스.
167
+
168
+ 메서드:
169
+ get(refresh=False) -> CorpCompileData:
170
+ 기업 데이터를 컴파일하거나 캐시에서 가져옵니다.
171
+
172
+ red_ranking(expect_earn: float = 0.06, refresh=False) -> OrderedDict:
173
+ RED 데이터를 기반으로 기업 순위를 계산합니다.
174
+
175
+ prophet_ranking(refresh=False, top: Union[int, str]='all') -> OrderedDict:
176
+ Prophet 데이터를 기반으로 기업 순위를 계산합니다.
177
+
178
+ analyse_lstm_topn(refresh: bool, top=40):
179
+ 상위 N개의 기업에 대해 LSTM 예측 수행.
180
+ """
181
+ def __init__(self, code: str, expect_earn=0.06):
182
+ """
183
+ CorpCompile 객체를 초기화합니다.
184
+
185
+ 매개변수:
186
+ code (str): 기업 코드.
187
+ expect_earn (float, optional): 예상 수익률. 기본값은 0.06.
188
+ """
189
+ assert tools.is_6digit(code), f'Invalid value : {code}'
190
+ self._code = code
191
+ self.expect_earn = expect_earn
192
+
193
+ @property
194
+ def code(self) -> str:
195
+ """
196
+ 기업 코드를 반환합니다.
197
+
198
+ 반환값:
199
+ str: 기업 코드.
200
+ """
201
+ return self._code
202
+
203
+ @code.setter
204
+ def code(self, code: str):
205
+ """
206
+ 기업 코드를 변경합니다.
207
+
208
+ 매개변수:
209
+ code (str): 새로 설정할 기업 코드.
210
+ """
211
+ assert tools.is_6digit(code), f'Invalid value : {code}'
212
+ mylogger.info(f'change code : {self.code} -> {code}')
213
+ self._code = code
214
+
215
+ def get(self, refresh=False) -> CorpCompileData:
216
+ """
217
+ 기업 데이터를 컴파일하거나 캐시에서 가져옵니다.
218
+
219
+ 매개변수:
220
+ refresh (bool): 데이터를 새로 가져올지 여부.
221
+
222
+ 반환값:
223
+ CorpCompileData: 컴파일된 기업 데이터.
224
+ """
225
+ print(f"{self.code}의 compiling을 시작합니다.")
226
+ redis_name = self.code + '_corp_compile'
227
+ print(
228
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time/3600}h")
229
+
230
+ def fetch_corp_compile_data() -> CorpCompileData:
231
+ prophet = tsa.CorpProphet(self.code)
232
+ lstm = tsa.CorpLSTM(self.code)
233
+
234
+ data = CorpCompileData(
235
+ code=self.code,
236
+ name=myredis.Corps(self.code,'c101').get_name(data_from='mongo'),
237
+ red_data=eval.Red(self.code, self.expect_earn).get(refresh=refresh, verbose=False),
238
+ mil_data=eval.Mil(self.code).get(refresh=refresh, verbose=False),
239
+ prophet_data=prophet.generate_data(refresh=refresh),
240
+ lstm_grade=lstm.get_final_predictions(refresh=refresh)[1],
241
+ )
242
+
243
+ data.is_lstm_up = lstm.is_lstm_up()
244
+ data.is_prophet_up = prophet.is_prophet_up(refresh=False)
245
+ data.lstm_html = lstm.export(refresh=False)
246
+ data.prophet_html = prophet.export()
247
+ return data
248
+
249
+ corp_compile_data = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_corp_compile_data, timer=expire_time)
250
+ return corp_compile_data
251
+
252
+ @staticmethod
253
+ def red_ranking(expect_earn: float = 0.06, refresh=False) -> OrderedDict:
254
+ """
255
+ RED 데이터를 기반으로 기업 순위를 계산합니다.
256
+
257
+ 매개변수:
258
+ expect_earn (float, optional): 예상 수익률. 기본값은 0.06.
259
+ refresh (bool): 데이터를 새로 가져올지 여부.
260
+
261
+ 반환값:
262
+ OrderedDict: RED 점수를 기준으로 정렬된 기업 순위.
263
+ """
264
+ redis_name = 'red_ranking_prev_expect_earn'
265
+ pee = tools.to_float(myredis.Base.get_value(redis_name))
266
+ if pee != expect_earn:
267
+ mylogger.warning(
268
+ f"expect earn : {expect_earn} / prev expect earn : {pee} 두 값이 달라 refresh = True"
269
+ )
270
+ myredis.Base.set_value(redis_name, str(expect_earn))
271
+ refresh = True
272
+
273
+ print("**** Start red_ranking... ****")
274
+ redis_name = 'red_ranking'
275
+ print(
276
+ f"redisname: '{redis_name}' / expect_earn: {expect_earn} / refresh : {refresh} / expire_time : {expire_time / 3600}h")
277
+
278
+ def fetch_ranking(refresh_in: bool) -> dict:
279
+ data = {}
280
+ red = eval.Red(code='005930', expect_earn=expect_earn)
281
+ for i, code in enumerate(myredis.Corps.list_all_codes()):
282
+ red.code = code
283
+ red_score = red.get(refresh=refresh_in, verbose=False).score
284
+ if red_score > 0:
285
+ data[code] = red_score
286
+ print(f"{i}: {red} - {red_score}")
287
+ return data
288
+
289
+ data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, refresh, timer=expire_time)
290
+
291
+ return OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
292
+
293
+ @staticmethod
294
+ def prophet_ranking(refresh=False, top: Union[int, str]='all') -> OrderedDict:
295
+ """
296
+ Prophet 데이터를 기반으로 기업 순위를 계산합니다.
297
+
298
+ 매개변수:
299
+ refresh (bool): 데이터를 새로 가져올지 여부.
300
+ top (Union[int, str], optional): 상위 기업 개수. 'all'이면 전체 반환. 기본값은 'all'.
301
+
302
+ 반환값:
303
+ OrderedDict: Prophet 점수를 기준으로 정렬된 기업 순위.
304
+ """
305
+ print("**** Start Compiling scores and sorting... ****")
306
+ redis_name = 'prophet_ranking'
307
+
308
+ print(
309
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time/3600}h")
310
+
311
+ def fetch_prophet_ranking() -> dict:
312
+ data = {}
313
+ c = tsa.CorpProphet('005930')
314
+ for code in myredis.Corps.list_all_codes():
315
+ try:
316
+ c.code = code
317
+ except ValueError:
318
+ mylogger.error(f'prophet ranking error : {code}')
319
+ continue
320
+ score= c.generate_data(refresh=refresh).score
321
+ print(f'{code} compiled : {score}')
322
+ data[code] = score
323
+ return data
324
+
325
+ data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_prophet_ranking, timer=expire_time)
326
+
327
+ ranking = OrderedDict(sorted(data_dict.items(), key=lambda x: x[1], reverse=True))
328
+
329
+ if top == 'all':
330
+ return ranking
331
+ else:
332
+ if isinstance(top, int):
333
+ return OrderedDict(list(ranking.items())[:top])
334
+ else:
335
+ raise ValueError("top 인자는 'all' 이나 int형 이어야 합니다.")
336
+
337
+ @staticmethod
338
+ def analyse_lstm_topn(refresh: bool, top=40):
339
+ """
340
+ 상위 N개의 기업에 대해 LSTM 예측을 수행합니다.
341
+
342
+ 매개변수:
343
+ refresh (bool): 데이터를 새로 가져올지 여부.
344
+ top (int, optional): 상위 기업 개수. 기본값은 40.
345
+ """
346
+ ranking_topn = CorpCompile.prophet_ranking(refresh=False, top=top)
347
+ mylogger.info(ranking_topn)
348
+ corp_lstm = tsa.CorpLSTM('005930')
349
+ print(f"*** LSTM prediction redis cashing top{top} items ***")
350
+ for i, (code, _) in enumerate(ranking_topn.items()):
351
+ corp_lstm.code = code
352
+ print(f"{i + 1}. {corp_lstm.code}/{corp_lstm.name}")
353
+ corp_lstm.get_final_predictions(refresh=refresh, num=5)
@@ -15,6 +15,28 @@ expire_time = tools.to_int(os.getenv('DEFAULT_EXPIRE_TIME_H', 48)) * 3600
15
15
 
16
16
  @dataclass()
17
17
  class BlueData:
18
+ """
19
+ 기업의 주요 안정성 지표와 관련된 데이터를 저장하는 데이터 클래스.
20
+
21
+ 이 클래스는 기업의 유동성, 부채 비율, 자산 회전율 등을 포함하며,
22
+ 이를 활용하여 기업의 안정성을 평가할 수 있습니다.
23
+
24
+ 속성:
25
+ code (str): 기업의 종목 코드 (6자리 숫자 문자열).
26
+ name (str): 기업명.
27
+ 유동비율 (float): 유동 자산 대비 유동 부채 비율.
28
+ 이자보상배율_r (float): 최근 이자보상배율 값.
29
+ 이자보상배율_dict (dict): 이자보상배율 데이터.
30
+ 순운전자본회전율_r (float): 최근 순운전자본회전율 값.
31
+ 순운전자본회전율_dict (dict): 순운전자본회전율 데이터.
32
+ 재고자산회전율_r (float): 최근 재고자산회전율 값.
33
+ 재고자산회전율_dict (dict): 재고자산회전율 데이터.
34
+ 재고자산회전율_c106 (dict): C106 기준 재고자산회전율 데이터.
35
+ 순부채비율_r (float): 최근 순부채비율 값.
36
+ 순부채비율_dict (dict): 순부채비율 데이터.
37
+ score (list): 평가 점수.
38
+ date (list): 데이터와 관련된 날짜 목록.
39
+ """
18
40
  code: str
19
41
  name: str
20
42
 
@@ -38,6 +60,20 @@ class BlueData:
38
60
 
39
61
 
40
62
  class Blue:
63
+ """
64
+ 기업의 안정성 지표를 분석하고 계산하는 클래스.
65
+
66
+ 이 클래스는 주어진 기업 코드에 대해 주요 안정성 지표(예: 유동비율, 이자보상배율 등)를 수집하고,
67
+ 이를 기반으로 기업의 안정성을 평가합니다. Redis 캐시를 활용하여 계산된 데이터를 저장하고
68
+ 재사용할 수 있습니다.
69
+
70
+ 속성:
71
+ c101 (myredis.C101): 기업 정보 및 최근 데이터 접근 객체.
72
+ c103 (myredis.C103): 재무 상태표 데이터 접근 객체.
73
+ c104 (myredis.C104): 투자 지표 데이터 접근 객체.
74
+ name (str): 기업명.
75
+ _code (str): 기업 종목 코드.
76
+ """
41
77
  def __init__(self, code: str):
42
78
  assert tools.is_6digit(code), f'Invalid value : {code}'
43
79
  mylogger.debug(f"Blue : 종목코드 ({code})")
@@ -69,10 +105,22 @@ class Blue:
69
105
  self._code = code
70
106
 
71
107
  def _calc유동비율(self, pop_count: int, refresh: bool) -> Tuple[str, float]:
72
- """유동비율계산 - Blue에서 사용
108
+ """
109
+ 기업의 유동비율을 계산합니다.
110
+
111
+ 유동비율 데이터가 유효하지 않거나 100 이하일 경우,
112
+ 유동자산과 유동부채를 기반으로 계산을 수행합니다.
113
+
114
+ 매개변수:
115
+ pop_count (int): 데이터 검색 시 사용할 값의 개수.
116
+ refresh (bool): 데이터를 새로고침할지 여부.
117
+
118
+ 반환값:
119
+ Tuple[str, float]: 날짜와 계산된 유동비율.
73
120
 
74
- c104q에서 최근유동비율 찾아보고 유효하지 않거나 \n
75
- 100이하인 경우에는수동으로 계산해서 다시 한번 평가해 본다.\n
121
+ 로그:
122
+ - 유동비율 계산 과정과 결과를 출력합니다.
123
+ - 계산 중 유효하지 않은 데이터가 있으면 경고를 출력합니다.
76
124
  """
77
125
  mylogger.info(f'In the calc유동비율... refresh : {refresh}')
78
126
  self.c104.page = 'c104q'
@@ -111,6 +159,17 @@ class Blue:
111
159
  return [0 ,]
112
160
 
113
161
  def _generate_data(self, refresh: bool) -> BlueData:
162
+ """
163
+ BlueData 형식의 데이터를 생성합니다.
164
+
165
+ 각종 안정성 지표를 계산하고 데이터를 정리하여 BlueData 객체로 반환합니다.
166
+
167
+ 매개변수:
168
+ refresh (bool): 데이터를 새로고침할지 여부.
169
+
170
+ 반환값:
171
+ BlueData: 계산된 안정성 지표 데이터.
172
+ """
114
173
  d1, 유동비율 = self._calc유동비율(pop_count=3, refresh=refresh)
115
174
  mylogger.info(f'유동비율 {유동비율} / [{d1}]')
116
175
 
@@ -171,9 +230,20 @@ class Blue:
171
230
 
172
231
  def get(self, refresh = False, verbose = True) -> BlueData:
173
232
  """
174
- BlueData 형식의 데이터를 계산하여 리턴하고 레디스 캐시에 저장한다.
175
- :param refresh:
176
- :return:
233
+ BlueData 객체를 Redis 캐시에서 가져오거나 새로 생성하여 반환합니다.
234
+
235
+ 캐시에서 데이터를 검색하고, 없을 경우 `_generate_data`를 호출하여 데이터를 생성합니다.
236
+ 생성된 데이터는 Redis 캐시에 저장되어 재사용됩니다.
237
+
238
+ 매개변수:
239
+ refresh (bool): 캐시를 무시하고 새로 데이터를 계산할지 여부. 기본값은 False.
240
+ verbose (bool): 실행 중 상세 정보를 출력할지 여부. 기본값은 True.
241
+
242
+ 반환값:
243
+ BlueData: Redis 캐시에서 가져오거나 새로 생성된 BlueData 객체.
244
+
245
+ 로그:
246
+ - 캐시 검색 상태와 새로 생성된 데이터를 출력합니다.
177
247
  """
178
248
  redis_name = f"{self.code}_blue"
179
249
  mylogger.info(f"{self} BlueData를 레디스캐시에서 가져오거나 새로 생성합니다.. refresh : {refresh}")
@@ -181,7 +251,6 @@ class Blue:
181
251
  print(f"{self} redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time /3600}h")
182
252
 
183
253
  def fetch_generate_data(refresh_in: bool) -> dict:
184
- return asdict(self._generate_data(refresh_in))
254
+ return self._generate_data(refresh_in) # type: ignore
185
255
 
186
- return BlueData \
187
- (**myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_generate_data, refresh, timer=expire_time))
256
+ return myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_generate_data, refresh, timer=expire_time)