analyser_hj3415 2.9.18__py3-none-any.whl → 2.10.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- analyser_hj3415/tsa.py +41 -15
- {analyser_hj3415-2.9.18.dist-info → analyser_hj3415-2.10.1.dist-info}/METADATA +3 -3
- {analyser_hj3415-2.9.18.dist-info → analyser_hj3415-2.10.1.dist-info}/RECORD +5 -5
- {analyser_hj3415-2.9.18.dist-info → analyser_hj3415-2.10.1.dist-info}/WHEEL +0 -0
- {analyser_hj3415-2.9.18.dist-info → analyser_hj3415-2.10.1.dist-info}/entry_points.txt +0 -0
analyser_hj3415/tsa.py
CHANGED
@@ -192,6 +192,21 @@ class MyProphet:
|
|
192
192
|
else:
|
193
193
|
Exception("to 인자가 맞지 않습니다.")
|
194
194
|
|
195
|
+
def scoring(self) -> int:
|
196
|
+
last_real_data = self.df_real.iloc[-1]
|
197
|
+
recent_price = last_real_data['y']
|
198
|
+
recent_date = datetime.strftime(last_real_data['ds'], '%Y-%m-%d')
|
199
|
+
yhat_dict = self.get_yhat()
|
200
|
+
tsa_logger.info(f'recent_price: {recent_price}, yhat_dict: {yhat_dict}')
|
201
|
+
yhat_lower = int(yhat_dict['yhat_lower'])
|
202
|
+
deviation = int(eval.Tools.cal_deviation(recent_price, yhat_lower))
|
203
|
+
if recent_price > yhat_lower:
|
204
|
+
score = -deviation
|
205
|
+
else:
|
206
|
+
score = deviation
|
207
|
+
print(f"{self.code}/{self.name} date: {recent_date} 가격:{recent_price} 기대하한값:{yhat_lower} 편차:{deviation} score:{score}")
|
208
|
+
return score
|
209
|
+
|
195
210
|
@classmethod
|
196
211
|
def ranking(cls, refresh = False, expire_time_h = 24, top='all') -> OrderedDict:
|
197
212
|
"""
|
@@ -208,22 +223,14 @@ class MyProphet:
|
|
208
223
|
def fetch_ranking() -> dict:
|
209
224
|
data = {}
|
210
225
|
p = MyProphet('005930')
|
211
|
-
for
|
226
|
+
for code in myredis.Corps.list_all_codes():
|
212
227
|
try:
|
213
228
|
p.code = code
|
214
229
|
except ValueError:
|
215
230
|
tsa_logger.error(f'myprophet ranking error : {code}/{myredis.Corps(code, "c101").get_name()}')
|
216
231
|
continue
|
217
|
-
|
218
|
-
|
219
|
-
recent_date = datetime.strftime(last_real_data['ds'], '%Y-%m-%d')
|
220
|
-
yhat_dict = p.get_yhat()
|
221
|
-
tsa_logger.info(f'recent_price: {recent_price}, yhat_dict: {yhat_dict}')
|
222
|
-
yhat_lower = int(yhat_dict['yhat_lower'])
|
223
|
-
if recent_price < yhat_lower:
|
224
|
-
deviation = int(eval.Tools.cal_deviation(recent_price, yhat_lower))
|
225
|
-
data[code] = deviation
|
226
|
-
print(f"{i}.{p.code}/{p.name} date: {recent_date} 가격:{recent_price} 기대하한값:{yhat_lower} 편차:{deviation}")
|
232
|
+
score = p.scoring()
|
233
|
+
data[code] = score
|
227
234
|
return data
|
228
235
|
|
229
236
|
data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_ranking, timer=expire_time_h * 3600)
|
@@ -346,12 +353,28 @@ class MyLSTM:
|
|
346
353
|
y.append(data[i + time_step, 0])
|
347
354
|
return np.array(X), np.array(y)
|
348
355
|
|
356
|
+
|
349
357
|
X_train, y_train_1d = create_dataset(train_data_2d)
|
350
358
|
X_test, y_test_1d = create_dataset(test_data_2d)
|
359
|
+
tsa_logger.debug(X_train.shape)
|
360
|
+
tsa_logger.debug(X_test.shape)
|
351
361
|
|
352
|
-
|
353
|
-
|
354
|
-
|
362
|
+
try:
|
363
|
+
# LSTM 모델 입력을 위해 데이터를 3차원으로 변환
|
364
|
+
X_train_3d = X_train.reshape(X_train.shape[0], X_train.shape[1], 1)
|
365
|
+
X_test_3d = X_test.reshape(X_test.shape[0], X_test.shape[1], 1)
|
366
|
+
except IndexError:
|
367
|
+
return LSTMData(
|
368
|
+
code=self.code,
|
369
|
+
data_2d=np.array([]),
|
370
|
+
train_size=0,
|
371
|
+
train_data_2d=np.array([]),
|
372
|
+
test_data_2d=np.array([]),
|
373
|
+
X_train_3d=np.array([]),
|
374
|
+
X_test_3d=np.array([]),
|
375
|
+
y_train_1d=np.array([]),
|
376
|
+
y_test_1d=np.array([]),
|
377
|
+
)
|
355
378
|
|
356
379
|
tsa_logger.debug(f'n_dim - X_train_3d : {X_train_3d.ndim}, X_test_3d : {X_test_3d.ndim}, y_train : {y_train_1d.ndim}, y_test : {y_test_1d.ndim}')
|
357
380
|
tsa_logger.debug(f'len - X_train_3d : {len(X_train_3d)}, X_test_3d : {len(X_test_3d)}, y_train : {len(y_train_1d)}, y_test : {len(y_test_1d)}')
|
@@ -517,8 +540,11 @@ class MyLSTM:
|
|
517
540
|
:return:
|
518
541
|
"""
|
519
542
|
# 앙상블 테스트와 채점
|
520
|
-
|
543
|
+
try:
|
544
|
+
_, _, ensemble_future_predictions_2d = self.ensemble_training(
|
521
545
|
num=num_in)
|
546
|
+
except IndexError:
|
547
|
+
return [], []
|
522
548
|
|
523
549
|
"""if grading:
|
524
550
|
lstm_grade = self.grading(ensemble_train_predictions_2d, ensemble_test_predictions_2d)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: analyser_hj3415
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.10.1
|
4
4
|
Summary: Stock analyser and database processing programs
|
5
5
|
Requires-Python: >=3.6
|
6
6
|
Description-Content-Type: text/markdown
|
7
|
-
Requires-Dist: utils-hj3415>=2.9.
|
8
|
-
Requires-Dist: db-hj3415>=4.
|
7
|
+
Requires-Dist: utils-hj3415>=2.9.4
|
8
|
+
Requires-Dist: db-hj3415>=4.2.3
|
9
9
|
Requires-Dist: scikit-learn>=1.5.2
|
10
10
|
Requires-Dist: plotly>=5.24.1
|
11
11
|
Requires-Dist: yfinance>=0.2.44
|
@@ -1,13 +1,13 @@
|
|
1
1
|
analyser_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
analyser_hj3415/cli.py,sha256=a4oUwfPFEdd3r2Fq2EMHBITcp6lbXUjZvVWvCHIvCUQ,12540
|
3
3
|
analyser_hj3415/eval.py,sha256=eNrcbpVyj7SZJevWqatlj_gJ2EQTmLZAz2nPG5qNv6k,38811
|
4
|
-
analyser_hj3415/tsa.py,sha256=
|
4
|
+
analyser_hj3415/tsa.py,sha256=gbpS4ZXgHYlN1MggqA3UUiTkmz8-WvYkxto_yjQt13g,28558
|
5
5
|
analyser_hj3415/workroom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
analyser_hj3415/workroom/mysklearn.py,sha256=wJXKz5MqqTzADdG2mqRMMzc_G9RzwYjj5_j4gyOopxQ,2030
|
7
7
|
analyser_hj3415/workroom/mysklearn2.py,sha256=1lIy6EWEQHkOzDS-av8U0zQH6DuCLKWMI73dnJx5KRs,1495
|
8
8
|
analyser_hj3415/workroom/score.py,sha256=P6nHBJYmyhigGtT4qna4BmNtvt4B93b7SKyzdstJK24,17376
|
9
9
|
analyser_hj3415/workroom/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
|
10
|
-
analyser_hj3415-2.
|
11
|
-
analyser_hj3415-2.
|
12
|
-
analyser_hj3415-2.
|
13
|
-
analyser_hj3415-2.
|
10
|
+
analyser_hj3415-2.10.1.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
|
11
|
+
analyser_hj3415-2.10.1.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
|
12
|
+
analyser_hj3415-2.10.1.dist-info/METADATA,sha256=HDWRHN49PtQQ0rzT2L9QObehx9r1E773C0vj2hQfcIc,6777
|
13
|
+
analyser_hj3415-2.10.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|