analyser_hj3415 3.4.0__tar.gz → 3.4.2__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 (23) hide show
  1. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/PKG-INFO +1 -1
  2. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/growth.py +1 -0
  3. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/tsa/prophet.py +53 -1
  4. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/pyproject.toml +1 -1
  5. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/.gitignore +0 -0
  6. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/README.md +0 -0
  7. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/__init__.py +0 -0
  8. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/__init__.py +0 -0
  9. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/compile.py +0 -0
  10. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/__init__.py +0 -0
  11. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/blue.py +0 -0
  12. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/common.py +0 -0
  13. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/mil.py +0 -0
  14. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/eval/red.py +0 -0
  15. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/tsa/__init__.py +0 -0
  16. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/tsa/common.py +0 -0
  17. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/analyser/tsa/lstm.py +0 -0
  18. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/cli.py +0 -0
  19. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/workroom/__init__.py +0 -0
  20. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/workroom/mysklearn.py +0 -0
  21. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/workroom/mysklearn2.py +0 -0
  22. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/analyser_hj3415/workroom/score.py +0 -0
  23. {analyser_hj3415-3.4.0 → analyser_hj3415-3.4.2}/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.4.0
3
+ Version: 3.4.2
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -170,6 +170,7 @@ class Growth:
170
170
  로그:
171
171
  - 캐시 검색 상태와 새로 생성된 데이터를 출력합니다.
172
172
  """
173
+
173
174
  redis_name = f"{self.code}_growth"
174
175
  mylogger.info(f"{self} GrowthData를 레디스캐시에서 가져오거나 새로 생성합니다.. refresh : {refresh}")
175
176
  if verbose:
@@ -1,5 +1,7 @@
1
1
  from datetime import datetime, timedelta
2
- from typing import Optional, Tuple
2
+ from typing import Optional, Tuple, List, Dict
3
+
4
+ import pandas
3
5
  import yfinance as yf
4
6
  import pandas as pd
5
7
  from prophet import Prophet
@@ -33,6 +35,16 @@ class ProphetData:
33
35
  trading_action: str = ''
34
36
  score: int = None
35
37
 
38
+ @dataclass
39
+ class ProphetChartData:
40
+ ticker: str
41
+
42
+ labels: List[pandas.Timestamp]
43
+ prices: List[Dict[pandas.Timestamp, float]]
44
+ yhats: List[Dict[pandas.Timestamp, float]]
45
+ yhat_uppers: List[Dict[pandas.Timestamp, float]]
46
+ yhat_lowers: List[Dict[pandas.Timestamp, float]]
47
+
36
48
 
37
49
  class MyProphet:
38
50
  def __init__(self, ticker: str):
@@ -242,6 +254,46 @@ class MyProphet:
242
254
 
243
255
  return prophet_data
244
256
 
257
+ def generate_chart_data(self, refresh: bool) -> ProphetChartData:
258
+ """
259
+ 1. 현재 주가 (실제 데이터)
260
+ • df_real['ds'] → x축 (날짜)
261
+ • df_real['y'] → y축 (실제 주가)
262
+
263
+ 2. 예측 값 범위 (최소/최대)
264
+ • df_forecast['ds'] → x축 (날짜)
265
+ • df_forecast['yhat_lower'] → y축 (최소 예측값)
266
+ • df_forecast['yhat_upper'] → y축 (최대 예측값)
267
+ """
268
+ print("**** Start generate_chart_data... ****")
269
+ redis_name = f'{self.ticker}_myprophet_chart_data'
270
+
271
+ print(
272
+ f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time / 3600}h")
273
+
274
+ def fetch_generate_prophet_chart_data() -> ProphetChartData:
275
+ self.initializing()
276
+
277
+ # 날짜를 기준으로 합치기 (outer join)
278
+ merged_df = pd.merge(self.df_real, self.df_forecast, on="ds", how="outer")
279
+ # 날짜 정렬
280
+ merged_df = merged_df.sort_values(by="ds").reset_index(drop=True)
281
+
282
+ data = ProphetChartData(
283
+ ticker=self.ticker,
284
+ labels=merged_df["ds"].tolist(),
285
+ prices=[{"x": ds, "y": y} for ds, y in zip(merged_df["ds"], merged_df["y"]) if pd.notna(y)], # type: ignore
286
+ yhats=[{"x": ds, "y": yhat} for ds, yhat in zip(merged_df["ds"], merged_df["yhat"])], # type: ignore
287
+ yhat_uppers=[{"x": ds, "y": yhat_upper} for ds, yhat_upper in zip(merged_df["ds"], merged_df["yhat_upper"])], # type: ignore
288
+ yhat_lowers=[{"x": ds, "y": yhat_lower} for ds, yhat_lower in zip(merged_df["ds"], merged_df["yhat_lower"])], # type: ignore
289
+ )
290
+ return data
291
+
292
+ prophet_chart_data = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_generate_prophet_chart_data,
293
+ timer=expire_time)
294
+ return prophet_chart_data
295
+
296
+
245
297
  def visualization(self):
246
298
  """
247
299
  Prophet 모델의 예측 결과를 시각화합니다.
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
 
6
6
  [project]
7
7
  name = "analyser_hj3415"
8
- version = "3.4.0"
8
+ version = "3.4.2"
9
9
  description = "Stock analyser and database processing programs"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.6"