analyser_hj3415 2.9.6__tar.gz → 2.9.8__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: analyser_hj3415
3
- Version: 2.9.6
3
+ Version: 2.9.8
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -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
- result = tsa.MyProphet.ranking(refresh=args.refresh)
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을 레디스캐시에 저장했습니다.(유효 24시간)")
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
- result = tsa.MyLSTM('005930').caching_based_on_prophet_ranking(refresh=args.refresh)
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을 레디스캐시에 저장했습니다.(유효 24시간)")
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 = tsa.MyLSTM(args.code).get_final_predictions(refresh=args.refresh)
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})를 레디스 캐시에 저장했습니다.(유효 12시간)")
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)
@@ -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 : {expire_time / 3600}h")
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=expire_time)
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 : {expire_time / 3600}h")
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=expire_time)
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
- def caching_based_on_prophet_ranking(self, refresh: bool, top=20):
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
- print(f"{i+1}. {self.code}/{self.name}")
670
- self.code = code
671
- self.get_final_predictions(refresh=refresh, num=5)
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
 
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
 
6
6
  [project]
7
7
  name = "analyser_hj3415"
8
- version = "2.9.6"
8
+ version = "2.9.8"
9
9
  description = "Stock analyser and database processing programs"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.6"