analyser_hj3415 3.1.1__tar.gz → 3.2.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/PKG-INFO +1 -1
  2. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/compile.py +11 -0
  3. analyser_hj3415-3.2.0/analyser_hj3415/analyser/tsa/__init__.py +15 -0
  4. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/tsa/prophet.py +5 -5
  5. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/cli.py +79 -54
  6. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/pyproject.toml +1 -1
  7. analyser_hj3415-3.1.1/analyser_hj3415/analyser/tsa/__init__.py +0 -7
  8. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/.gitignore +0 -0
  9. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/README.md +0 -0
  10. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/__init__.py +0 -0
  11. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/__init__.py +0 -0
  12. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/__init__.py +0 -0
  13. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/blue.py +0 -0
  14. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/common.py +0 -0
  15. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/growth.py +0 -0
  16. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/mil.py +0 -0
  17. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/eval/red.py +0 -0
  18. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/analyser/tsa/lstm.py +0 -0
  19. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/workroom/__init__.py +0 -0
  20. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/workroom/mysklearn.py +0 -0
  21. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/workroom/mysklearn2.py +0 -0
  22. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/analyser_hj3415/workroom/score.py +0 -0
  23. {analyser_hj3415-3.1.1 → analyser_hj3415-3.2.0}/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.1.1
3
+ Version: 3.2.0
4
4
  Summary: Stock analyser and database processing programs
5
5
  Requires-Python: >=3.6
6
6
  Description-Content-Type: text/markdown
@@ -36,6 +36,7 @@ class Compile:
36
36
  self.prophet.code = code
37
37
 
38
38
  def get(self, refresh=False) -> dict:
39
+
39
40
  print(f"{self.code}/{self.name}의 compiling을 시작합니다.")
40
41
  redis_name = self.code + '_compile_scores'
41
42
  print(
@@ -110,6 +111,16 @@ class Compile:
110
111
  corp_lstm.initializing()
111
112
  corp_lstm.get_final_predictions(refresh=refresh, num=5)
112
113
 
114
+ @staticmethod
115
+ def analyse_lstm_mis(refresh: bool):
116
+ mi_lstm = tsa.MILSTM('wti')
117
+ print(f"*** LSTM prediction redis cashing Market Index items ***")
118
+ for mi_type in tsa.MIs.keys():
119
+ mi_lstm.mi_type = mi_type
120
+ print(f"{mi_lstm.mi_type}")
121
+ mi_lstm.initializing()
122
+ mi_lstm.get_final_predictions(refresh=refresh, num=5)
123
+
113
124
  @staticmethod
114
125
  def red_ranking(expect_earn: float = 0.06, refresh=False) -> OrderedDict:
115
126
  # 이전 expect earn 과 비교하여 다르거나 없으면 강제 refresh 설정
@@ -0,0 +1,15 @@
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
+ }
@@ -128,10 +128,10 @@ class MyProphet:
128
128
  fig2 = self.model.plot_components(self.df_forecast)
129
129
  plt.show() # 시각화 창 띄우기
130
130
 
131
- def export(self, to="str") -> Optional[str]:
131
+ def export(self, to="html") -> Optional[str]:
132
132
  """
133
133
  prophet과 plotly로 그래프를 그려서 html을 문자열로 반환
134
- :param to: str, png, htmlfile
134
+ :param to: html, png, file
135
135
  :return:
136
136
  """
137
137
  # Plotly를 사용한 시각화
@@ -161,7 +161,7 @@ class MyProphet:
161
161
  showlegend=False,
162
162
  )
163
163
 
164
- if to == 'str':
164
+ if to == 'html':
165
165
  # 그래프 HTML로 변환 (string 형식으로 저장)
166
166
  graph_html = plot(fig, output_type='div')
167
167
  return graph_html
@@ -169,8 +169,8 @@ class MyProphet:
169
169
  # 그래프를 PNG 파일로 저장
170
170
  fig.write_image(f"myprophet_{self.ticker}.png")
171
171
  return None
172
- elif to == 'htmlfile':
173
- # 그래프를 HTML 저장
172
+ elif to == 'file':
173
+ # 그래프를 HTML 파일로 저장
174
174
  plot(fig, filename=f'myprophet_{self.ticker}.html', auto_open=False)
175
175
  return None
176
176
  else:
@@ -93,69 +93,89 @@ def analyser_manager():
93
93
  red.code = args.code
94
94
  print(f"*** Red - {red} ***")
95
95
  pprint.pprint(red.get(args.refresh))
96
- mymongo.Logs.save('cli','INFO', f'run >> analyser red get {args.code}')
96
+ # mymongo.Logs.save('cli','INFO', f'run >> analyser red get {args.code}')
97
97
 
98
98
  elif args.command == 'ranking':
99
- mymongo.Logs.save('cli','INFO', 'run >> analyser red ranking')
100
- if args.expect_earn is None:
101
- result = compile.Compile.red_ranking(refresh=args.refresh)
102
- else:
103
- result = compile.Compile.red_ranking(expect_earn=args.expect_earn, refresh=args.refresh)
104
- print(result)
99
+ mymongo.Logs.save('cli', 'INFO', 'run >> analyser red ranking')
100
+ try:
101
+ if args.expect_earn is None:
102
+ result = compile.Compile.red_ranking(refresh=args.refresh)
103
+ else:
104
+ result = compile.Compile.red_ranking(expect_earn=args.expect_earn, refresh=args.refresh)
105
+ print(result)
106
+ except Exception as e:
107
+ print(e)
108
+ mymongo.Logs.save('cli', 'ERROR', f'analyser red ranking 실행중 에러 - {e}')
105
109
 
106
110
  elif args.type == 'mil':
107
111
  if args.command == 'get':
108
- if args.code == 'all':
109
- mil = eval.Mil('005930')
110
- print("**** Mil - all codes ****")
111
- for i, code in enumerate(myredis.Corps.list_all_codes()):
112
- mil.code = code
113
- print(f"*** {i} / {mil} ***")
114
- pprint.pprint(mil.get(args.refresh, verbose=False))
115
- else:
116
- assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
117
- mil = eval.Mil(args.code)
118
- print(f"*** Mil - {mil} ***")
119
- pprint.pprint(mil.get(args.refresh))
120
- mymongo.Logs.save('cli','INFO', f'run >> analyser mil get {args.code}')
112
+ mymongo.Logs.save('cli', 'INFO', f'run >> analyser mil get {args.code}')
113
+ try:
114
+ if args.code == 'all':
115
+ mil = eval.Mil('005930')
116
+ print("**** Mil - all codes ****")
117
+ for i, code in enumerate(myredis.Corps.list_all_codes()):
118
+ mil.code = code
119
+ print(f"*** {i} / {mil} ***")
120
+ pprint.pprint(mil.get(args.refresh, verbose=False))
121
+ else:
122
+ assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
123
+ mil = eval.Mil(args.code)
124
+ print(f"*** Mil - {mil} ***")
125
+ pprint.pprint(mil.get(args.refresh))
126
+ except Exception as e:
127
+ print(e)
128
+ mymongo.Logs.save('cli', 'ERROR', f'analyser mil get {args.code} 실행중 에러 - {e}')
121
129
 
122
130
  elif args.type == 'blue':
123
131
  if args.command == 'get':
124
- if args.code == 'all':
125
- blue = eval.Blue('005930')
126
- print("**** Blue - all codes ****")
127
- for i, code in enumerate(myredis.Corps.list_all_codes()):
128
- blue.code = code
129
- print(f"*** {i} / {blue} ***")
130
- pprint.pprint(blue.get(args.refresh, verbose=False))
131
- else:
132
- assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
133
- blue = eval.Blue(args.code)
134
- print(f"*** Blue - {blue} ***")
135
- pprint.pprint(blue.get(args.refresh))
136
- mymongo.Logs.save('cli','INFO', f'run >> analyser blue get {args.code}')
132
+ mymongo.Logs.save('cli', 'INFO', f'run >> analyser blue get {args.code}')
133
+ try:
134
+ if args.code == 'all':
135
+ blue = eval.Blue('005930')
136
+ print("**** Blue - all codes ****")
137
+ for i, code in enumerate(myredis.Corps.list_all_codes()):
138
+ blue.code = code
139
+ print(f"*** {i} / {blue} ***")
140
+ pprint.pprint(blue.get(args.refresh, verbose=False))
141
+ else:
142
+ assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
143
+ blue = eval.Blue(args.code)
144
+ print(f"*** Blue - {blue} ***")
145
+ pprint.pprint(blue.get(args.refresh))
146
+ except Exception as e:
147
+ print(e)
148
+ mymongo.Logs.save('cli', 'ERROR', f'analyser blue get {args.code} 실행중 에러 - {e}')
137
149
 
138
150
  elif args.type == 'growth':
139
151
  if args.command == 'get':
140
- if args.code == 'all':
141
- growth = eval.Growth('005930')
142
- print("**** Growth - all codes ****")
143
- for i, code in enumerate(myredis.Corps.list_all_codes()):
144
- growth.code = code
145
- print(f"*** {i} / {growth} ***")
146
- pprint.pprint(growth.get(args.refresh, verbose=False))
147
- else:
148
- assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
149
- growth = eval.Growth(args.code)
150
- print(f"*** growth - {growth} ***")
151
- pprint.pprint(growth.get(args.refresh))
152
- mymongo.Logs.save('cli','INFO', f'run >> analyser growth get {args.code}')
152
+ mymongo.Logs.save('cli', 'INFO', f'run >> analyser growth get {args.code}')
153
+ try:
154
+ if args.code == 'all':
155
+ growth = eval.Growth('005930')
156
+ print("**** Growth - all codes ****")
157
+ for i, code in enumerate(myredis.Corps.list_all_codes()):
158
+ growth.code = code
159
+ print(f"*** {i} / {growth} ***")
160
+ pprint.pprint(growth.get(args.refresh, verbose=False))
161
+ else:
162
+ assert tools.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
163
+ growth = eval.Growth(args.code)
164
+ print(f"*** growth - {growth} ***")
165
+ pprint.pprint(growth.get(args.refresh))
166
+ except Exception as e:
167
+ print(e)
168
+ mymongo.Logs.save('cli', 'ERROR', f'analyser growth get {args.code} 실행중 에러 - {e}')
153
169
 
154
170
  elif args.type == 'prophet':
155
171
  if args.command == 'ranking':
156
- result = compile.Compile.prophet_ranking(refresh=args.refresh)
157
- print(result)
158
- mymongo.Logs.save('cli','INFO', 'run >> analyser prophet ranking')
172
+ mymongo.Logs.save('cli', 'INFO', 'run >> analyser prophet ranking')
173
+ try:
174
+ result = compile.Compile.prophet_ranking(refresh=args.refresh)
175
+ print(result)
176
+ except Exception as e:
177
+ print(e)
178
+ mymongo.Logs.save('cli', 'ERROR', f'analyser prophet ranking 실행중 에러 - {e}')
159
179
  elif args.command == 'score':
160
180
  if args.target in MIs.keys():
161
181
  myprophet = tsa.MIProphet(args.target)
@@ -168,11 +188,16 @@ def analyser_manager():
168
188
 
169
189
  elif args.type == 'lstm':
170
190
  if args.command == 'caching':
171
- if args.top:
172
- compile.Compile.analyse_lstm_topn(refresh=args.refresh, top=args.top)
173
- else:
174
- compile.Compile.analyse_lstm_topn(refresh=args.refresh)
175
- mymongo.Logs.save('cli','INFO', f'run >> analyser lstm caching / top={args.top if args.top else 20}')
191
+ mymongo.Logs.save('cli', 'INFO', f'run >> analyser lstm caching')
192
+ try:
193
+ if args.top:
194
+ compile.Compile.analyse_lstm_topn(refresh=args.refresh, top=args.top)
195
+ else:
196
+ compile.Compile.analyse_lstm_topn(refresh=args.refresh)
197
+ compile.Compile.analyse_lstm_mis(refresh=args.refresh)
198
+ except Exception as e:
199
+ print(e)
200
+ mymongo.Logs.save('cli','ERROR', f'analyser lstm caching 실행중 에러 - {e}')
176
201
  elif args.command == 'predict':
177
202
  if args.target in MIs.keys():
178
203
  mylstm = tsa.MILSTM(args.target)
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
 
6
6
  [project]
7
7
  name = "analyser_hj3415"
8
- version = "3.1.1"
8
+ version = "3.2.0"
9
9
  description = "Stock analyser and database processing programs"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.6"
@@ -1,7 +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
- }