analyser_hj3415 2.9.6__py3-none-any.whl → 2.9.8__py3-none-any.whl
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.
- analyser_hj3415/cli.py +14 -6
- analyser_hj3415/tsa.py +12 -8
- {analyser_hj3415-2.9.6.dist-info → analyser_hj3415-2.9.8.dist-info}/METADATA +1 -1
- {analyser_hj3415-2.9.6.dist-info → analyser_hj3415-2.9.8.dist-info}/RECORD +6 -6
- {analyser_hj3415-2.9.6.dist-info → analyser_hj3415-2.9.8.dist-info}/WHEEL +0 -0
- {analyser_hj3415-2.9.6.dist-info → analyser_hj3415-2.9.8.dist-info}/entry_points.txt +0 -0
analyser_hj3415/cli.py
CHANGED
@@ -55,6 +55,7 @@ def analyser_manager():
|
|
55
55
|
# caching 파서
|
56
56
|
caching_parser = lstm_subparser.add_parser('caching', help='lstm 랭킹 책정 및 레디스 저장')
|
57
57
|
caching_parser.add_argument('-r', '--refresh', action='store_true', help='래디스 캐시를 사용하지 않고 강제로 재계산 할지')
|
58
|
+
caching_parser.add_argument('-t', '--top', type=int, help='prophet ranking 몇위까지 작업을 할지')
|
58
59
|
caching_parser.add_argument('-n', '--noti', action='store_true', help='작업 완료 후 메시지 전송 여부')
|
59
60
|
# red - get 파서
|
60
61
|
lstm_get_parser = lstm_subparser.add_parser('get', help='lstm get 책정 및 레디스 저장')
|
@@ -218,20 +219,27 @@ def analyser_manager():
|
|
218
219
|
noti.telegram_to('manager', f"오늘의 Growth({args.code})를 레디스 캐시에 저장했습니다.(유효 12시간)")
|
219
220
|
elif args.type == 'prophet':
|
220
221
|
if args.command == 'ranking':
|
221
|
-
|
222
|
+
myprophet = tsa.MyProphet
|
223
|
+
myprophet.expire_time_h = 72
|
224
|
+
result = myprophet.ranking(refresh=args.refresh)
|
222
225
|
print(result)
|
223
226
|
if args.noti:
|
224
|
-
noti.telegram_to('manager', "오늘의 prophet ranking을 레디스캐시에 저장했습니다.(유효
|
227
|
+
noti.telegram_to('manager', f"오늘의 prophet ranking을 레디스캐시에 저장했습니다.(유효 {myprophet.expire_time_h}시간)")
|
225
228
|
elif args.type == 'lstm':
|
229
|
+
mylstm = tsa.MyLSTM
|
230
|
+
mylstm.expire_time_h = 72
|
226
231
|
if args.command == 'caching':
|
227
|
-
|
232
|
+
if args.top:
|
233
|
+
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, top=args.top)
|
234
|
+
else:
|
235
|
+
mylstm.caching_based_on_prophet_ranking(refresh=args.refresh)
|
228
236
|
if args.noti:
|
229
|
-
noti.telegram_to('manager', "오늘의 lstm caching을 레디스캐시에 저장했습니다.(유효
|
237
|
+
noti.telegram_to('manager', f"오늘의 lstm caching(top={args.top if args.top else 20})을 레디스캐시에 저장했습니다.(유효 {mylstm.expire_time_h}시간)")
|
230
238
|
elif args.command == 'get':
|
231
239
|
assert utils.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
|
232
|
-
result =
|
240
|
+
result = mylstm(args.code).get_final_predictions(refresh=args.refresh)
|
233
241
|
if args.noti:
|
234
|
-
noti.telegram_to('manager', f"LSTM 분석을({args.code})를 레디스 캐시에 저장했습니다.(유효
|
242
|
+
noti.telegram_to('manager', f"LSTM 분석을({args.code})를 레디스 캐시에 저장했습니다.(유효 {mylstm.expire_time_h}시간)")
|
235
243
|
elif args.type == 'setting':
|
236
244
|
if args.command == 'set':
|
237
245
|
settings_manager.set_value(args.title, args.value)
|
analyser_hj3415/tsa.py
CHANGED
@@ -33,6 +33,7 @@ tsa_logger = helpers.setup_logger('tsa_logger', logging.WARNING)
|
|
33
33
|
expire_time = 3600 * 24
|
34
34
|
|
35
35
|
class MyProphet:
|
36
|
+
expire_time_h = 24
|
36
37
|
def __init__(self, code: str):
|
37
38
|
assert utils.is_6digit(code), f'Invalid value : {code}'
|
38
39
|
self.scaler = StandardScaler()
|
@@ -204,7 +205,7 @@ class MyProphet:
|
|
204
205
|
redis_name = 'myprophet_ranking'
|
205
206
|
|
206
207
|
print(
|
207
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
208
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {MyProphet.expire_time_h}h")
|
208
209
|
|
209
210
|
def fetch_ranking() -> dict:
|
210
211
|
data = {}
|
@@ -223,7 +224,7 @@ class MyProphet:
|
|
223
224
|
print(f"{i}.{p.code}/{p.name} date: {recent_date} 가격:{recent_price} 기대하한값:{yhat_lower} 편차:{deviation}")
|
224
225
|
return data
|
225
226
|
|
226
|
-
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=
|
227
|
+
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=MyProphet.expire_time_h * 3600)
|
227
228
|
|
228
229
|
return OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
|
229
230
|
|
@@ -264,6 +265,7 @@ class MyLSTM:
|
|
264
265
|
"""
|
265
266
|
# 미래 몇일을 예측할 것인가?
|
266
267
|
future_days = 30
|
268
|
+
expire_time_h = 24
|
267
269
|
|
268
270
|
def __init__(self, code: str):
|
269
271
|
assert utils.is_6digit(code), f'Invalid value : {code}'
|
@@ -498,7 +500,7 @@ class MyLSTM:
|
|
498
500
|
redis_name = f'{self.code}_mylstm_predictions'
|
499
501
|
|
500
502
|
print(
|
501
|
-
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {
|
503
|
+
f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {MyLSTM.expire_time_h}h")
|
502
504
|
|
503
505
|
def fetch_final_predictions(num_in) -> tuple:
|
504
506
|
"""
|
@@ -529,7 +531,7 @@ class MyLSTM:
|
|
529
531
|
|
530
532
|
return future_dates_str, final_future_predictions.tolist()
|
531
533
|
|
532
|
-
future_dates_str, final_future_predictions = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_final_predictions, num, timer=
|
534
|
+
future_dates_str, final_future_predictions = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_final_predictions, num, timer=MyLSTM.expire_time_h * 3600)
|
533
535
|
|
534
536
|
# 문자열을 날짜 형식으로 변환
|
535
537
|
future_dates = [datetime.strptime(date, '%Y-%m-%d') for date in future_dates_str]
|
@@ -661,14 +663,16 @@ class MyLSTM:
|
|
661
663
|
plt.title('Stock Price Prediction with LSTM Ensemble')
|
662
664
|
plt.show()"""
|
663
665
|
|
664
|
-
|
666
|
+
@staticmethod
|
667
|
+
def caching_based_on_prophet_ranking(refresh: bool, top=20):
|
665
668
|
ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking().items(), top))
|
666
669
|
tsa_logger.info(ranking_topn)
|
670
|
+
mylstm = MyLSTM('005930')
|
667
671
|
print(f"*** LSTM prediction redis cashing top{top} items ***")
|
668
672
|
for i, (code, _) in enumerate(ranking_topn.items()):
|
669
|
-
|
670
|
-
|
671
|
-
|
673
|
+
mylstm.code = code
|
674
|
+
print(f"{i+1}. {mylstm.code}/{mylstm.name}")
|
675
|
+
mylstm.get_final_predictions(refresh=refresh, num=5)
|
672
676
|
|
673
677
|
|
674
678
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
analyser_hj3415/.DS_Store,sha256=S5yjTP1issWmV5kF2CFjGHm5OJHgkuTaZHuxjIwSkfc,6148
|
2
2
|
analyser_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
analyser_hj3415/cli.py,sha256=
|
3
|
+
analyser_hj3415/cli.py,sha256=ZxrpF0BOduFp30JPM6SfPxm5yhun1LoYRBYLFhj7BGM,14178
|
4
4
|
analyser_hj3415/eval.py,sha256=WWIvB4BebjW9GNGcF8rMd-MLL-lPXUBOH01_FpSq95I,38811
|
5
|
-
analyser_hj3415/tsa.py,sha256=
|
5
|
+
analyser_hj3415/tsa.py,sha256=XEVYDjOTj8LXr0_wk0DzK9QQXZj2HU0FNhncAfaGy00,26916
|
6
6
|
analyser_hj3415/workroom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
analyser_hj3415/workroom/mysklearn.py,sha256=wJXKz5MqqTzADdG2mqRMMzc_G9RzwYjj5_j4gyOopxQ,2030
|
8
8
|
analyser_hj3415/workroom/mysklearn2.py,sha256=1lIy6EWEQHkOzDS-av8U0zQH6DuCLKWMI73dnJx5KRs,1495
|
9
9
|
analyser_hj3415/workroom/score.py,sha256=P6nHBJYmyhigGtT4qna4BmNtvt4B93b7SKyzdstJK24,17376
|
10
10
|
analyser_hj3415/workroom/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
|
11
|
-
analyser_hj3415-2.9.
|
12
|
-
analyser_hj3415-2.9.
|
13
|
-
analyser_hj3415-2.9.
|
14
|
-
analyser_hj3415-2.9.
|
11
|
+
analyser_hj3415-2.9.8.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
|
12
|
+
analyser_hj3415-2.9.8.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
13
|
+
analyser_hj3415-2.9.8.dist-info/METADATA,sha256=wGpIR0YUDxZbzVxnCxQLDF7qmMkVgT8T0quDwRJha2A,6524
|
14
|
+
analyser_hj3415-2.9.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|