analyser_hj3415 3.4.0__py3-none-any.whl → 3.4.2__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/analyser/eval/growth.py +1 -0
- analyser_hj3415/analyser/tsa/prophet.py +53 -1
- {analyser_hj3415-3.4.0.dist-info → analyser_hj3415-3.4.2.dist-info}/METADATA +1 -1
- {analyser_hj3415-3.4.0.dist-info → analyser_hj3415-3.4.2.dist-info}/RECORD +6 -6
- {analyser_hj3415-3.4.0.dist-info → analyser_hj3415-3.4.2.dist-info}/WHEEL +0 -0
- {analyser_hj3415-3.4.0.dist-info → analyser_hj3415-3.4.2.dist-info}/entry_points.txt +0 -0
@@ -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,19 +5,19 @@ analyser_hj3415/analyser/compile.py,sha256=wMTuVadcSODHjjTP5ma_GuygujqCeYDQkad2r
|
|
5
5
|
analyser_hj3415/analyser/eval/__init__.py,sha256=IP1d0Q3nOCAD3zK1qxrC685MkJQfUh-qaXc7xptTxk8,80
|
6
6
|
analyser_hj3415/analyser/eval/blue.py,sha256=p9_ddqLMJGq5HSn6NApuLhrX29qD--AASig9F71eb8I,10952
|
7
7
|
analyser_hj3415/analyser/eval/common.py,sha256=sNXapoofShA43ww_SLjXmIjkrAr1AhAcezdaN_X_3Us,11443
|
8
|
-
analyser_hj3415/analyser/eval/growth.py,sha256=
|
8
|
+
analyser_hj3415/analyser/eval/growth.py,sha256=sfJ7h06efrTfL4ylhUCV525IzUzilbun1ya9r5SVCtU,6526
|
9
9
|
analyser_hj3415/analyser/eval/mil.py,sha256=mFMiFCuCBvlQrhQcM5hMg8U4zF32TS1GnUmk8fPd950,15178
|
10
10
|
analyser_hj3415/analyser/eval/red.py,sha256=8aJPpiVzLOZtt6kILCzqcfL8BrEVgIld1iI3StGvg8A,12193
|
11
11
|
analyser_hj3415/analyser/tsa/__init__.py,sha256=pg20ZQRABedTdaIoOr5t043RNKtJ7ji_WmnZrD1IhPg,147
|
12
12
|
analyser_hj3415/analyser/tsa/common.py,sha256=OnsZ_cFYmNzmk0tV5qSqVW-5jJyrwMWHguWdS2Z6fvY,979
|
13
13
|
analyser_hj3415/analyser/tsa/lstm.py,sha256=P8peqg6ZUpCSNKupjFlyba3xbPZoYtpd2UihXib_4Do,28548
|
14
|
-
analyser_hj3415/analyser/tsa/prophet.py,sha256=
|
14
|
+
analyser_hj3415/analyser/tsa/prophet.py,sha256=AlDU6YmjSf094diTVpMe0w06Z-FZ_2KAsDm2rshzxpA,16957
|
15
15
|
analyser_hj3415/workroom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
analyser_hj3415/workroom/mysklearn.py,sha256=wJXKz5MqqTzADdG2mqRMMzc_G9RzwYjj5_j4gyOopxQ,2030
|
17
17
|
analyser_hj3415/workroom/mysklearn2.py,sha256=1lIy6EWEQHkOzDS-av8U0zQH6DuCLKWMI73dnJx5KRs,1495
|
18
18
|
analyser_hj3415/workroom/score.py,sha256=P6nHBJYmyhigGtT4qna4BmNtvt4B93b7SKyzdstJK24,17376
|
19
19
|
analyser_hj3415/workroom/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
|
20
|
-
analyser_hj3415-3.4.
|
21
|
-
analyser_hj3415-3.4.
|
22
|
-
analyser_hj3415-3.4.
|
23
|
-
analyser_hj3415-3.4.
|
20
|
+
analyser_hj3415-3.4.2.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
|
21
|
+
analyser_hj3415-3.4.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
22
|
+
analyser_hj3415-3.4.2.dist-info/METADATA,sha256=F3_EIBCZD-sDpwathQJp9cCa_yF46fgHDegSF_FPeB8,6777
|
23
|
+
analyser_hj3415-3.4.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|