analyser_hj3415 2.9.13__tar.gz → 2.9.15__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.13
3
+ Version: 2.9.15
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -193,7 +193,7 @@ class MyProphet:
193
193
  Exception("to 인자가 맞지 않습니다.")
194
194
 
195
195
  @classmethod
196
- def ranking(cls, refresh = False, expire_time_h = 24) -> OrderedDict:
196
+ def ranking(cls, refresh = False, expire_time_h = 24, top='all') -> OrderedDict:
197
197
  """
198
198
  가장 최근 날짜의 랭킹 분석
199
199
  :param refresh:
@@ -228,7 +228,14 @@ class MyProphet:
228
228
 
229
229
  data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=expire_time_h * 3600)
230
230
 
231
- return OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
231
+ ranking = OrderedDict(sorted(data_dict.items(), key=lambda item: item[1], reverse=True))
232
+ if top == 'all':
233
+ return ranking
234
+ else:
235
+ if isinstance(top, int):
236
+ return OrderedDict(list(ranking.items())[:top])
237
+ else:
238
+ raise ValueError("top 인자는 'all' 이나 int형 이어야 합니다.")
232
239
 
233
240
  @dataclass
234
241
  class LSTMData:
@@ -664,9 +671,18 @@ class MyLSTM:
664
671
  plt.title('Stock Price Prediction with LSTM Ensemble')
665
672
  plt.show()"""
666
673
 
674
+ def is_up(self)-> bool:
675
+ # 튜플의 [0]은 날짜 [1]은 값 배열
676
+ data = self.get_final_predictions(refresh=False, expire_time_h=24)[1]
677
+ # 데이터를 1D 배열로 변환
678
+ flattened_data = data.flatten()
679
+ tsa_logger.debug(f"flattened_data : {flattened_data}")
680
+ # 증가 여부 확인
681
+ return all(flattened_data[i] < flattened_data[i + 1] for i in range(len(flattened_data) - 1))
682
+
667
683
  @staticmethod
668
684
  def caching_based_on_prophet_ranking(refresh: bool, expire_time_h: int, top=20):
669
- ranking_topn = OrderedDict(itertools.islice(MyProphet.ranking(refresh=False).items(), top))
685
+ ranking_topn = MyProphet.ranking(refresh=False, top=top)
670
686
  tsa_logger.info(ranking_topn)
671
687
  mylstm = MyLSTM('005930')
672
688
  print(f"*** LSTM prediction redis cashing top{top} items ***")
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
 
6
6
  [project]
7
7
  name = "analyser_hj3415"
8
- version = "2.9.13"
8
+ version = "2.9.15"
9
9
  description = "Stock analyser and database processing programs"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.6"