analyser_hj3415 4.0.4__py3-none-any.whl → 4.0.6__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/tsa/common.py +24 -0
- analyser_hj3415/analyser/tsa/lstm.py +7 -5
- analyser_hj3415/analyser/tsa/prophet.py +11 -9
- {analyser_hj3415-4.0.4.dist-info → analyser_hj3415-4.0.6.dist-info}/METADATA +1 -1
- {analyser_hj3415-4.0.4.dist-info → analyser_hj3415-4.0.6.dist-info}/RECORD +7 -7
- {analyser_hj3415-4.0.4.dist-info → analyser_hj3415-4.0.6.dist-info}/WHEEL +0 -0
- {analyser_hj3415-4.0.4.dist-info → analyser_hj3415-4.0.6.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,9 @@
|
|
1
1
|
import numpy as np
|
2
|
+
from dataclasses import dataclass, field
|
3
|
+
from typing import List
|
4
|
+
import pandas as pd
|
5
|
+
from marshmallow import fields, Schema
|
6
|
+
from marshmallow_dataclass import class_schema
|
2
7
|
|
3
8
|
|
4
9
|
def is_up_by_OLS(data: dict) -> bool:
|
@@ -31,3 +36,22 @@ def is_up_by_OLS(data: dict) -> bool:
|
|
31
36
|
|
32
37
|
# 4) 기울기가 양수면 "우상향 추세"로 판별
|
33
38
|
return slope > 0
|
39
|
+
|
40
|
+
@dataclass
|
41
|
+
class PandasTimestampField(fields.DateTime):
|
42
|
+
"""pandas.Timestamp를 ISO 8601 문자열로 직렬화하고 역직렬화하는 필드"""
|
43
|
+
|
44
|
+
def _serialize(self, value, attr, obj, **kwargs):
|
45
|
+
return value.isoformat() if isinstance(value, pd.Timestamp) else None
|
46
|
+
|
47
|
+
def _deserialize(self, value, attr, data, **kwargs):
|
48
|
+
return pd.Timestamp(value)
|
49
|
+
|
50
|
+
@dataclass
|
51
|
+
class ChartPoint:
|
52
|
+
"""prices 리스트의 각 원소(x, y)를 표현할 데이터 클래스"""
|
53
|
+
x: pd.Timestamp = field(metadata={"marshmallow_field": PandasTimestampField()})
|
54
|
+
y: float
|
55
|
+
|
56
|
+
|
57
|
+
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import os
|
2
2
|
import numpy as np
|
3
|
-
import pandas
|
4
3
|
import yfinance as yf
|
5
4
|
from datetime import datetime, timedelta
|
6
5
|
import pandas as pd
|
@@ -11,11 +10,13 @@ from tensorflow.keras.layers import LSTM, Dense, Dropout # type: ignore
|
|
11
10
|
from tensorflow.keras.callbacks import EarlyStopping # type: ignore
|
12
11
|
from tensorflow.keras import Input # type: ignore
|
13
12
|
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
|
14
|
-
from dataclasses import dataclass
|
13
|
+
from dataclasses import dataclass, field
|
14
|
+
from marshmallow import fields
|
15
15
|
|
16
16
|
from utils_hj3415 import tools, setup_logger
|
17
17
|
from db_hj3415 import myredis
|
18
18
|
from analyser_hj3415.analyser import MIs, tsa
|
19
|
+
from analyser_hj3415.analyser.tsa.common import PandasTimestampField, ChartPoint
|
19
20
|
|
20
21
|
mylogger = setup_logger(__name__,'INFO')
|
21
22
|
expire_time = tools.to_int(os.getenv('DEFAULT_EXPIRE_TIME_H', 48)) * 3600
|
@@ -76,9 +77,10 @@ class LSTMGrade:
|
|
76
77
|
@dataclass
|
77
78
|
class LSTMChartData:
|
78
79
|
ticker: str
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
labels: List[pd.Timestamp] = field(metadata={"marshmallow_field": fields.List(PandasTimestampField())})
|
82
|
+
prices: List[ChartPoint]
|
83
|
+
future_prices: List[ChartPoint]
|
82
84
|
grade: LSTMGrade
|
83
85
|
num: int
|
84
86
|
is_lstm_up: bool
|
@@ -2,19 +2,20 @@ from collections import OrderedDict
|
|
2
2
|
from datetime import datetime, timedelta
|
3
3
|
from typing import Tuple, List, Dict, Union
|
4
4
|
|
5
|
-
import pandas
|
6
5
|
import pickle
|
7
6
|
import yfinance as yf
|
8
7
|
import pandas as pd
|
9
8
|
from prophet import Prophet
|
10
9
|
from sklearn.preprocessing import StandardScaler
|
11
|
-
from dataclasses import dataclass
|
10
|
+
from dataclasses import dataclass, field
|
11
|
+
from marshmallow import fields
|
12
12
|
import os
|
13
13
|
|
14
14
|
from utils_hj3415 import tools, setup_logger
|
15
15
|
from db_hj3415 import myredis
|
16
16
|
|
17
17
|
from analyser_hj3415.analyser import eval, MIs, tsa
|
18
|
+
from analyser_hj3415.analyser.tsa.common import PandasTimestampField, ChartPoint
|
18
19
|
|
19
20
|
|
20
21
|
mylogger = setup_logger(__name__,'INFO')
|
@@ -34,15 +35,16 @@ class ProphetLatestData:
|
|
34
35
|
trading_action: str = ''
|
35
36
|
score: int = None
|
36
37
|
|
38
|
+
|
37
39
|
@dataclass
|
38
40
|
class ProphetChartData:
|
39
41
|
ticker: str
|
40
42
|
|
41
|
-
labels: List[
|
42
|
-
prices: List[
|
43
|
-
yhats: List[
|
44
|
-
yhat_uppers: List[
|
45
|
-
yhat_lowers: List[
|
43
|
+
labels: List[pd.Timestamp] = field(metadata={"marshmallow_field": fields.List(PandasTimestampField())})
|
44
|
+
prices: List[ChartPoint]
|
45
|
+
yhats: List[ChartPoint]
|
46
|
+
yhat_uppers: List[ChartPoint]
|
47
|
+
yhat_lowers: List[ChartPoint]
|
46
48
|
|
47
49
|
is_prophet_up: bool
|
48
50
|
|
@@ -133,7 +135,6 @@ class MyProphet:
|
|
133
135
|
|
134
136
|
# ds 열에서 타임존 제거
|
135
137
|
df['ds'] = df['ds'].dt.tz_localize(None)
|
136
|
-
|
137
138
|
# 추가 변수를 정규화
|
138
139
|
df['volume_scaled'] = self.scaler.fit_transform(df[['volume']])
|
139
140
|
mylogger.debug('_preprocessing_for_prophet')
|
@@ -170,12 +171,13 @@ class MyProphet:
|
|
170
171
|
mylogger.debug(forecast)
|
171
172
|
return forecast
|
172
173
|
|
173
|
-
mylogger.
|
174
|
+
mylogger.debug("Initializing data for MyProphet")
|
174
175
|
|
175
176
|
self.scaler = StandardScaler()
|
176
177
|
self.model = Prophet()
|
177
178
|
|
178
179
|
self.raw_data = get_raw_data()
|
180
|
+
mylogger.debug(self.raw_data)
|
179
181
|
self.df_real = preprocessing_for_prophet()
|
180
182
|
self.df_forecast = make_forecast()
|
181
183
|
|
@@ -8,10 +8,10 @@ analyser_hj3415/analyser/eval/growth.py,sha256=sfJ7h06efrTfL4ylhUCV525IzUzilbun1
|
|
8
8
|
analyser_hj3415/analyser/eval/mil.py,sha256=mFMiFCuCBvlQrhQcM5hMg8U4zF32TS1GnUmk8fPd950,15178
|
9
9
|
analyser_hj3415/analyser/eval/red.py,sha256=b-Odud8pxQIO2NjI7m3HbK4FOND5WhaoYV94mCHqDPo,13907
|
10
10
|
analyser_hj3415/analyser/tsa/__init__.py,sha256=pg20ZQRABedTdaIoOr5t043RNKtJ7ji_WmnZrD1IhPg,147
|
11
|
-
analyser_hj3415/analyser/tsa/common.py,sha256
|
12
|
-
analyser_hj3415/analyser/tsa/lstm.py,sha256=
|
13
|
-
analyser_hj3415/analyser/tsa/prophet.py,sha256=
|
14
|
-
analyser_hj3415-4.0.
|
15
|
-
analyser_hj3415-4.0.
|
16
|
-
analyser_hj3415-4.0.
|
17
|
-
analyser_hj3415-4.0.
|
11
|
+
analyser_hj3415/analyser/tsa/common.py,sha256=-HypxZ1d7x2nh1oksrel4T329SmF9MRP6zWvJRNzkjQ,1737
|
12
|
+
analyser_hj3415/analyser/tsa/lstm.py,sha256=Ew6banylC0rXFKiyKz2n5kE3lmJUP65NZvr11VjOsVM,28115
|
13
|
+
analyser_hj3415/analyser/tsa/prophet.py,sha256=sJPbJg7bTViF0jWeFfFrThwpryLmn528RmELxeARYe0,17713
|
14
|
+
analyser_hj3415-4.0.6.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
|
15
|
+
analyser_hj3415-4.0.6.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
16
|
+
analyser_hj3415-4.0.6.dist-info/METADATA,sha256=qY0pRPoAC5E6_OHQ-thpKIcOP5ZWDqi6ImKtSOKZYAc,6777
|
17
|
+
analyser_hj3415-4.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|