analyser_hj3415 3.2.1__tar.gz → 3.2.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 (24) hide show
  1. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/PKG-INFO +1 -1
  2. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/__init__.py +0 -5
  3. analyser_hj3415-3.2.2/analyser_hj3415/analyser/__init__.py +12 -0
  4. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/compile.py +73 -8
  5. analyser_hj3415-3.2.2/analyser_hj3415/analyser/tsa/__init__.py +3 -0
  6. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/tsa/lstm.py +1 -5
  7. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/tsa/prophet.py +2 -3
  8. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/cli.py +1 -2
  9. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/pyproject.toml +1 -1
  10. analyser_hj3415-3.2.1/analyser_hj3415/analyser/tsa/__init__.py +0 -15
  11. analyser_hj3415-3.2.1/analyser_hj3415/workroom/__init__.py +0 -0
  12. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/.gitignore +0 -0
  13. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/README.md +0 -0
  14. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/__init__.py +0 -0
  15. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/blue.py +0 -0
  16. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/common.py +0 -0
  17. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/growth.py +0 -0
  18. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/mil.py +0 -0
  19. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/analyser/eval/red.py +0 -0
  20. {analyser_hj3415-3.2.1/analyser_hj3415/analyser → analyser_hj3415-3.2.2/analyser_hj3415/workroom}/__init__.py +0 -0
  21. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/workroom/mysklearn.py +0 -0
  22. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/workroom/mysklearn2.py +0 -0
  23. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.2}/analyser_hj3415/workroom/score.py +0 -0
  24. {analyser_hj3415-3.2.1 → analyser_hj3415-3.2.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.2.1
3
+ Version: 3.2.2
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -6,8 +6,3 @@ env_path = get_env_path()
6
6
  if env_path is None:
7
7
  mylogger.warning(f"환경변수 파일(.env)를 찾을수 없습니다. 기본 설정값으로 프로그램을 실행합니다.")
8
8
  load_dotenv(env_path)
9
-
10
- from analyser_hj3415.analyser import eval
11
- from analyser_hj3415.analyser import compile
12
- from analyser_hj3415.analyser import tsa
13
-
@@ -0,0 +1,12 @@
1
+ MIs = {
2
+ "wti": "CL=F",
3
+ "gold": "GC=F",
4
+ "silver": "SI=F",
5
+ "usdidx": "DX-Y.NYB",
6
+ "usdkrw": "KRW=X",
7
+ "sp500": "^GSPC",
8
+ "kospi": "^KS11",
9
+ "nikkei": "^N225",
10
+ "china": "^HSI",
11
+ "irx": "^IRX",
12
+ }
@@ -5,15 +5,14 @@ from typing import Union
5
5
  from db_hj3415 import myredis,mymongo
6
6
  from utils_hj3415 import tools, setup_logger
7
7
 
8
- from analyser_hj3415.analyser import tsa
9
- from analyser_hj3415.analyser import eval
8
+ from analyser_hj3415.analyser import tsa, eval, MIs
10
9
 
11
10
  mylogger = setup_logger(__name__,'WARNING')
12
11
  expire_time = tools.to_int(os.getenv('DEFAULT_EXPIRE_TIME_H', 48)) * 3600
13
12
 
14
13
  class MICompile:
15
14
  def __init__(self, mi_type: str):
16
- assert mi_type in tsa.MIs.keys(), f"Invalid MI type ({tsa.MIs.keys()})"
15
+ assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
17
16
  self._mi_type = mi_type
18
17
  self.prophet = tsa.MIProphet(mi_type)
19
18
  self.lstm = tsa.MILSTM(mi_type)
@@ -24,30 +23,64 @@ class MICompile:
24
23
 
25
24
  @mi_type.setter
26
25
  def mi_type(self, mi_type: str):
27
- assert mi_type in tsa.MIs.keys(), f"Invalid MI type ({tsa.MIs.keys()})"
26
+ assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
28
27
  self._mi_type = mi_type
29
28
  self.prophet.mi_type = mi_type
30
29
  self.lstm.mi_type = mi_type
31
30
 
32
31
  def get(self, refresh=False) -> dict:
32
+ """
33
+ 특정 MI(Market Index) 타입 데이터를 컴파일하고 반환합니다.
34
+ 데이터를 Redis 캐시에서 가져오거나, 새로 생성하여 캐시에 저장합니다.
35
+
36
+ Args:
37
+ refresh (bool, optional):
38
+ - True: 캐시를 무시하고 데이터를 새로 생성하여 저장.
39
+ - False: 캐시된 데이터를 가져오며, 없을 경우 새로 생성.
40
+ Defaults to False.
41
+
42
+ Returns:
43
+ dict: MI 데이터를 포함하는 딕셔너리로 반환하며, 다음의 키를 포함합니다:
44
+ - 'name' (str): MI 타입 이름.
45
+ - 'trading_action' (str): 예측된 매매 신호 ('buy', 'sell', 'hold').
46
+ - 'prophet_score' (float): Prophet 모델의 예측 점수.
47
+ - 'lstm_grade' (float): LSTM 모델의 최종 예측 점수.
48
+ - 'is_lstm_up' (bool): LSTM 모델이 상승 신호를 나타내는지 여부.
49
+ - 'prophet_html' (str): prophet_html,
50
+ - 'lstm_html' (str): lstm_html ,
51
+ Example:
52
+ {
53
+ 'name': 'example_mi',
54
+ 'trading_action': 'buy',
55
+ 'prophet_score': 0.88,
56
+ 'lstm_grade': 0.92,
57
+ 'is_lstm_up': True,
58
+ 'prophet_html': prophet_html...,
59
+ 'lstm_html': lstm_html...,
60
+ }
61
+ """
33
62
  print(f"{self.mi_type}의 compiling을 시작합니다.")
34
63
  redis_name = self.mi_type + '_mi_compile'
35
64
  print(
36
65
  f"redisname: '{redis_name}' / refresh : {refresh} / expire_time : {expire_time / 3600}h")
37
66
 
38
67
  def fetch_mi_compile() -> dict:
39
- trading_action, prophet_score = self.prophet.scoring()
40
68
  print(f"{self.mi_type}")
69
+ trading_action, prophet_score = self.prophet.scoring()
70
+ prophet_html = self.prophet.export()
41
71
  self.lstm.initializing()
42
72
  _, lstm_grade = self.lstm.get_final_predictions(refresh=refresh, num=5)
43
73
  is_lstm_up = self.lstm.is_lstm_up()
74
+ lstm_html= self.lstm.export()
44
75
 
45
76
  return {
46
77
  'name': self.mi_type,
47
78
  'trading_action': trading_action,
48
79
  'prophet_score': prophet_score,
49
80
  'lstm_grade': lstm_grade,
50
- 'is_lstm_up': is_lstm_up
81
+ 'is_lstm_up': is_lstm_up,
82
+ 'prophet_html': prophet_html,
83
+ 'lstm_html': lstm_html,
51
84
  }
52
85
 
53
86
  data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_mi_compile, timer=expire_time)
@@ -57,7 +90,7 @@ class MICompile:
57
90
  def analyser_lstm_all_mi(refresh: bool):
58
91
  mi_lstm = tsa.MILSTM('wti')
59
92
  print(f"*** LSTM prediction redis cashing Market Index items ***")
60
- for mi_type in tsa.MIs.keys():
93
+ for mi_type in MIs.keys():
61
94
  mi_lstm.mi_type = mi_type
62
95
  print(f"{mi_lstm.mi_type}")
63
96
  mi_lstm.initializing()
@@ -88,7 +121,37 @@ class CorpCompile:
88
121
  self.prophet.code = code
89
122
 
90
123
  def get(self, refresh=False) -> dict:
91
-
124
+ """
125
+ 특정 기업 데이터를 컴파일하여 반환합니다.
126
+ 데이터를 Redis 캐시에서 가져오거나, 새로 생성하여 캐시에 저장합니다.
127
+
128
+ Args:
129
+ refresh (bool, optional):
130
+ - True: 캐시를 무시하고 데이터를 새로 생성하여 저장.
131
+ - False: 캐시된 데이터를 가져오며, 없을 경우 새로 생성.
132
+ Defaults to False.
133
+
134
+ Returns:
135
+ dict: 기업 데이터를 포함하는 딕셔너리로 반환되며, 다음의 키를 포함합니다:
136
+ - 'name' (str): 기업 이름.
137
+ - 'red_score' (float): 기업의 Red Score (위험 점수).
138
+ - '이익지표' (float): 기업의 이익 지표.
139
+ - '주주수익률' (float): 주주 수익률.
140
+ - 'trading_action' (str): 예측된 매매 신호 ('buy', 'sell', 'hold').
141
+ - 'prophet_score' (float): Prophet 모델의 예측 점수.
142
+ - 'prophet_html' (str): prophet_html,
143
+
144
+ Example:
145
+ {
146
+ 'name': 'Samsung Electronics',
147
+ 'red_score': 0.85,
148
+ '이익지표': 0.75,
149
+ '주주수익률': 0.10,
150
+ 'trading_action': 'buy',
151
+ 'prophet_score': 0.92,
152
+ 'prophet_html': prophet_html...,
153
+ }
154
+ """
92
155
  print(f"{self.code}/{self.name}의 compiling을 시작합니다.")
93
156
  redis_name = self.code + '_corp_compile'
94
157
  print(
@@ -103,6 +166,7 @@ class CorpCompile:
103
166
 
104
167
  mylogger.info("\tProphet 최근 데이터 조회중..")
105
168
  trading_action, prophet_score = self.prophet.scoring()
169
+ prophet_html = self.prophet.export()
106
170
 
107
171
  return {
108
172
  'name': self.name,
@@ -111,6 +175,7 @@ class CorpCompile:
111
175
  '주주수익률': mil_data.주주수익률,
112
176
  'trading_action': trading_action,
113
177
  'prophet_score': prophet_score,
178
+ 'prophet_html': prophet_html,
114
179
  }
115
180
  data_dict = myredis.Base.fetch_and_cache_data(redis_name, refresh, fetch_corp_compile, timer=expire_time)
116
181
  return data_dict
@@ -0,0 +1,3 @@
1
+ from analyser_hj3415.analyser.tsa.lstm import *
2
+ from analyser_hj3415.analyser.tsa.prophet import *
3
+
@@ -1,6 +1,3 @@
1
- """
2
- Time Series Analysis
3
- """
4
1
  import os
5
2
  import numpy as np
6
3
  import yfinance as yf
@@ -20,6 +17,7 @@ from dataclasses import dataclass
20
17
 
21
18
  from utils_hj3415 import tools, setup_logger
22
19
  from db_hj3415 import myredis
20
+ from analyser_hj3415.analyser import MIs
23
21
 
24
22
 
25
23
  mylogger = setup_logger(__name__,'WARNING')
@@ -702,7 +700,6 @@ class CorpLSTM(MyLSTM):
702
700
 
703
701
  class MILSTM(MyLSTM):
704
702
  def __init__(self, mi_type: str):
705
- from analyser_hj3415.analyser.tsa import MIs
706
703
  assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
707
704
  self._mi_type = mi_type
708
705
  super().__init__(ticker=MIs[mi_type])
@@ -713,7 +710,6 @@ class MILSTM(MyLSTM):
713
710
 
714
711
  @mi_type.setter
715
712
  def mi_type(self, mi_type: str):
716
- from analyser_hj3415.analyser.tsa import MIs
717
713
  assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
718
714
  self._mi_type = mi_type
719
715
  self.ticker = MIs[mi_type]
@@ -11,7 +11,8 @@ from plotly.offline import plot
11
11
  from utils_hj3415 import tools, setup_logger
12
12
  from db_hj3415 import myredis
13
13
 
14
- from analyser_hj3415.analyser import eval
14
+ from analyser_hj3415.analyser import eval, MIs
15
+
15
16
 
16
17
  mylogger = setup_logger(__name__,'WARNING')
17
18
 
@@ -252,7 +253,6 @@ class CorpProphet(MyProphet):
252
253
 
253
254
  class MIProphet(MyProphet):
254
255
  def __init__(self, mi_type: str):
255
- from analyser_hj3415.analyser.tsa import MIs
256
256
  assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
257
257
  self._mi_type = mi_type
258
258
  super().__init__(ticker=MIs[mi_type])
@@ -263,7 +263,6 @@ class MIProphet(MyProphet):
263
263
 
264
264
  @mi_type.setter
265
265
  def mi_type(self, mi_type: str):
266
- from analyser_hj3415.analyser.tsa import MIs
267
266
  assert mi_type in MIs.keys(), f"Invalid MI type ({MIs.keys()})"
268
267
  self._mi_type = mi_type
269
268
  self.ticker = MIs[mi_type]
@@ -2,12 +2,11 @@ import argparse
2
2
  import pprint
3
3
 
4
4
  from utils_hj3415 import tools
5
- from analyser_hj3415.analyser import eval, tsa, compile
5
+ from analyser_hj3415.analyser import eval, tsa, compile, MIs
6
6
  from db_hj3415 import myredis, mymongo
7
7
 
8
8
 
9
9
  def analyser_manager():
10
- from analyser_hj3415.analyser.tsa import MIs
11
10
  parser = argparse.ArgumentParser(description="Analyser Commands")
12
11
  type_subparsers = parser.add_subparsers(dest='type', help='분석 타입')
13
12
 
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
 
6
6
  [project]
7
7
  name = "analyser_hj3415"
8
- version = "3.2.1"
8
+ version = "3.2.2"
9
9
  description = "Stock analyser and database processing programs"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.6"
@@ -1,15 +0,0 @@
1
- from analyser_hj3415.analyser.tsa.lstm import *
2
- from analyser_hj3415.analyser.tsa.prophet import *
3
-
4
- MIs = {
5
- "wti": "CL=F",
6
- "gold": "GC=F",
7
- "silver": "SI=F",
8
- "usdidx": "DX-Y.NYB",
9
- "usdkrw": "KRW=X",
10
- "sp500": "^GSPC",
11
- "kospi": "^KS11",
12
- "nikkei": "^N225",
13
- "china": "^HSI",
14
- "irx": "^IRX",
15
- }