analyser_hj3415 2.9.9__py3-none-any.whl → 2.9.10__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 CHANGED
@@ -209,23 +209,21 @@ def analyser_manager():
209
209
  elif args.type == 'prophet':
210
210
  if args.command == 'ranking':
211
211
  myprophet = tsa.MyProphet
212
- myprophet.expire_time_h = 72
213
- result = myprophet.ranking(refresh=args.refresh)
212
+ result = myprophet.ranking(refresh=args.refresh, expire_time_h=24)
214
213
  print(result)
215
214
  log_cli.save('INFO', 'run >> analyser prophet ranking')
216
215
 
217
216
  elif args.type == 'lstm':
218
217
  mylstm = tsa.MyLSTM
219
- mylstm.expire_time_h = 72
220
218
  if args.command == 'caching':
221
219
  if args.top:
222
- mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, top=args.top)
220
+ mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, expire_time_h=24, top=args.top)
223
221
  else:
224
- mylstm.caching_based_on_prophet_ranking(refresh=args.refresh)
222
+ mylstm.caching_based_on_prophet_ranking(refresh=args.refresh, expire_time_h=24)
225
223
  log_cli.save('INFO', f'run >> analyser lstm caching / top={args.top if args.top else 20})')
226
224
  elif args.command == 'get':
227
225
  assert utils.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
228
- result = mylstm(args.code).get_final_predictions(refresh=args.refresh)
226
+ result = mylstm(args.code).get_final_predictions(refresh=args.refresh, expire_time_h=24)
229
227
  log_cli.save('INFO', f'run >> analyser lstm get {args.code}')
230
228
 
231
229
  elif args.type == 'setting':
analyser_hj3415/tsa.py CHANGED
@@ -30,10 +30,8 @@ import logging
30
30
 
31
31
  tsa_logger = helpers.setup_logger('tsa_logger', logging.WARNING)
32
32
 
33
- expire_time = 3600 * 24
34
33
 
35
34
  class MyProphet:
36
- expire_time_h = 24
37
35
  def __init__(self, code: str):
38
36
  assert utils.is_6digit(code), f'Invalid value : {code}'
39
37
  self.scaler = StandardScaler()
@@ -195,7 +193,7 @@ class MyProphet:
195
193
  Exception("to 인자가 맞지 않습니다.")
196
194
 
197
195
  @classmethod
198
- def ranking(cls, refresh = False) -> OrderedDict:
196
+ def ranking(cls, refresh = False, expire_time_h = 24) -> OrderedDict:
199
197
  """
200
198
  가장 최근 날짜의 랭킹 분석
201
199
  :param refresh:
@@ -205,7 +203,7 @@ class MyProphet:
205
203
  redis_name = 'myprophet_ranking'
206
204
 
207
205
  print(
208
- f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {MyProphet.expire_time_h}h")
206
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time_h}h")
209
207
 
210
208
  def fetch_ranking() -> dict:
211
209
  data = {}
@@ -224,7 +222,7 @@ class MyProphet:
224
222
  print(f"{i}.{p.code}/{p.name} date: {recent_date} 가격:{recent_price} 기대하한값:{yhat_lower} 편차:{deviation}")
225
223
  return data
226
224
 
227
- data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=MyProphet.expire_time_h * 3600)
225
+ data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=expire_time_h * 3600)
228
226
 
229
227
  return OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
230
228
 
@@ -265,7 +263,6 @@ class MyLSTM:
265
263
  """
266
264
  # 미래 몇일을 예측할 것인가?
267
265
  future_days = 30
268
- expire_time_h = 48
269
266
 
270
267
  def __init__(self, code: str):
271
268
  assert utils.is_6digit(code), f'Invalid value : {code}'
@@ -489,7 +486,7 @@ class MyLSTM:
489
486
  test_r2=test_r2,
490
487
  )
491
488
 
492
- def get_final_predictions(self, refresh, num=5) -> tuple:
489
+ def get_final_predictions(self, refresh: bool, expire_time_h: int, num=5) -> tuple:
493
490
  """
494
491
  미래 예측치를 레디스 캐시를 이용하여 반환함
495
492
  :param refresh:
@@ -500,7 +497,7 @@ class MyLSTM:
500
497
  redis_name = f'{self.code}_mylstm_predictions'
501
498
 
502
499
  print(
503
- f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {MyLSTM.expire_time_h}h")
500
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time_h}h")
504
501
 
505
502
  def fetch_final_predictions(num_in) -> tuple:
506
503
  """
@@ -531,7 +528,7 @@ class MyLSTM:
531
528
 
532
529
  return future_dates_str, final_future_predictions.tolist()
533
530
 
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)
531
+ future_dates_str, final_future_predictions = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_final_predictions, num, timer=expire_time_h * 3600)
535
532
 
536
533
  # 문자열을 날짜 형식으로 변환
537
534
  future_dates = [datetime.strptime(date, '%Y-%m-%d') for date in future_dates_str]
@@ -541,14 +538,14 @@ class MyLSTM:
541
538
 
542
539
  return future_dates, final_future_predictions
543
540
 
544
- def export(self, refresh=False, to="str") -> Optional[str]:
541
+ def export(self, refresh=False, expire_time_h=24, to="str") -> Optional[str]:
545
542
  """
546
543
  prophet과 plotly로 그래프를 그려서 html을 문자열로 반환
547
544
  :param refresh:
548
545
  :param to: str, htmlfile, png
549
546
  :return:
550
547
  """
551
- future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh)
548
+ future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh, expire_time_h=expire_time_h)
552
549
  final_future_predictions = final_future_predictions.reshape(-1) # 차원을 하나 줄인다.
553
550
 
554
551
  # 데이터 준비
@@ -636,7 +633,7 @@ class MyLSTM:
636
633
  Exception("to 인자가 맞지 않습니다.")
637
634
 
638
635
  def visualization(self, refresh=True):
639
- future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh)
636
+ future_dates, final_future_predictions = self.get_final_predictions(refresh=refresh, expire_time_h=1)
640
637
 
641
638
  # 시각화1
642
639
  plt.figure(figsize=(10, 6))
@@ -664,15 +661,15 @@ class MyLSTM:
664
661
  plt.show()"""
665
662
 
666
663
  @staticmethod
667
- def caching_based_on_prophet_ranking(refresh: bool, top=20):
668
- ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking().items(), top))
664
+ def caching_based_on_prophet_ranking(refresh: bool, expire_time_h: int, top=20):
665
+ ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking(refresh=False).items(), top))
669
666
  tsa_logger.info(ranking_topn)
670
667
  mylstm = MyLSTM('005930')
671
668
  print(f"*** LSTM prediction redis cashing top{top} items ***")
672
669
  for i, (code, _) in enumerate(ranking_topn.items()):
673
670
  mylstm.code = code
674
671
  print(f"{i+1}. {mylstm.code}/{mylstm.name}")
675
- mylstm.get_final_predictions(refresh=refresh, num=5)
672
+ mylstm.get_final_predictions(refresh=refresh, expire_time_h=expire_time_h, num=5)
676
673
 
677
674
 
678
675
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: analyser_hj3415
3
- Version: 2.9.9
3
+ Version: 2.9.10
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -1,13 +1,13 @@
1
1
  analyser_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- analyser_hj3415/cli.py,sha256=CHdIdsPVzXRQoMazp0QJD-6-_DjlLTyJ4C1IBD3IQL8,12517
2
+ analyser_hj3415/cli.py,sha256=X7GRhmrWRdHfp84gCjkRjl2wjlOHx1ft82dLe-bnoBI,12514
3
3
  analyser_hj3415/eval.py,sha256=WWIvB4BebjW9GNGcF8rMd-MLL-lPXUBOH01_FpSq95I,38811
4
- analyser_hj3415/tsa.py,sha256=yNYeLpuUH7eGNAmSadvkbHQ91gz9Z1o_u9dGwntF4OI,26916
4
+ analyser_hj3415/tsa.py,sha256=8JSAdLLApcRDIjrTo8pveHliBUObzpGWlq-yxZNsIZw,26984
5
5
  analyser_hj3415/workroom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  analyser_hj3415/workroom/mysklearn.py,sha256=wJXKz5MqqTzADdG2mqRMMzc_G9RzwYjj5_j4gyOopxQ,2030
7
7
  analyser_hj3415/workroom/mysklearn2.py,sha256=1lIy6EWEQHkOzDS-av8U0zQH6DuCLKWMI73dnJx5KRs,1495
8
8
  analyser_hj3415/workroom/score.py,sha256=P6nHBJYmyhigGtT4qna4BmNtvt4B93b7SKyzdstJK24,17376
9
9
  analyser_hj3415/workroom/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
10
- analyser_hj3415-2.9.9.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
11
- analyser_hj3415-2.9.9.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
12
- analyser_hj3415-2.9.9.dist-info/METADATA,sha256=vTdeO4MRJYOfIOpyiuBPYC0XafTIbPA0NllgE1UD9ow,6776
13
- analyser_hj3415-2.9.9.dist-info/RECORD,,
10
+ analyser_hj3415-2.9.10.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
11
+ analyser_hj3415-2.9.10.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
12
+ analyser_hj3415-2.9.10.dist-info/METADATA,sha256=WUsWOQrGgiBwKWOOdGKnd2eBxDWCnJhHXZgJSQuqx4s,6777
13
+ analyser_hj3415-2.9.10.dist-info/RECORD,,