analyser_hj3415 2.2.0__tar.gz → 2.4.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/PKG-INFO +3 -3
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/score.py +6 -7
- analyser_hj3415-2.4.0/analyser_hj3415/cli.py +24 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/myredis.py +51 -5
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/trash.py +80 -1
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/pyproject.toml +5 -5
- analyser_hj3415-2.2.0/analyser_hj3415/cli.py +0 -109
- analyser_hj3415-2.2.0/analyser_hj3415/run.py +0 -0
- analyser_hj3415-2.2.0/tests/_trial_temp/_trial_marker +0 -0
- analyser_hj3415-2.2.0/tests/_trial_temp/test.log +0 -1
- analyser_hj3415-2.2.0/tests/testeval.py +0 -110
- analyser_hj3415-2.2.0/tests/testmyredis.py +0 -58
- analyser_hj3415-2.2.0/tests/testreport.py +0 -23
- analyser_hj3415-2.2.0/tests/testscore.py +0 -90
- analyser_hj3415-2.2.0/tests/testtools.py +0 -58
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.DS_Store +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.gitattributes +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.gitignore +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/.gitignore +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/analyser-hj3415.iml +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/misc.xml +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/modules.xml +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/vcs.xml +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/LICENSE +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/README.md +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/.DS_Store +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/__init__.py +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/eval.py +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/report.py +0 -0
- {analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/analyser_hj3415/tools.py +0 -0
@@ -1,12 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: analyser_hj3415
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.4.0
|
4
4
|
Summary: Stock analyser and database processing programs
|
5
5
|
Author-email: Hyungjin Kim <hj3415@gmail.com>
|
6
6
|
Description-Content-Type: text/markdown
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
8
|
-
Requires-Dist: utils-hj3415>=2.6.
|
9
|
-
Requires-Dist: db-hj3415>=3.
|
8
|
+
Requires-Dist: utils-hj3415>=2.6.1
|
9
|
+
Requires-Dist: db-hj3415>=3.4.0
|
10
10
|
Project-URL: Home, https://www.hyungjin.kr
|
11
11
|
|
12
12
|
### analyser-hj3415
|
@@ -7,7 +7,6 @@ from typing import Tuple
|
|
7
7
|
from db_hj3415 import myredis, mymongo
|
8
8
|
from analyser_hj3415.analysers import eval
|
9
9
|
from utils_hj3415 import utils
|
10
|
-
from analyser_hj3415 import myredis as analyser_redis
|
11
10
|
|
12
11
|
import logging
|
13
12
|
|
@@ -45,7 +44,7 @@ def red(code: str) -> int:
|
|
45
44
|
recent_price = float('nan')
|
46
45
|
return 0
|
47
46
|
|
48
|
-
red_price =
|
47
|
+
red_price = eval.red(code)['red_price']
|
49
48
|
deviation = cal_deviation(recent_price, red_price)
|
50
49
|
if red_price < 0 or (recent_price >= red_price):
|
51
50
|
score = 0
|
@@ -86,9 +85,9 @@ def mil(code: str) -> Tuple[int, int, int, int]:
|
|
86
85
|
Returns:
|
87
86
|
tuple: 주주수익률, 이익지표, 투자수익률, PFCF포인트
|
88
87
|
"""
|
89
|
-
mil_dict =
|
88
|
+
mil_dict = eval.mil(code)
|
90
89
|
|
91
|
-
print(pprint.pformat(mil_dict, width=200))
|
90
|
+
# print(pprint.pformat(mil_dict, width=200))
|
92
91
|
|
93
92
|
# 주주수익률 평가
|
94
93
|
if math.isnan(mil_dict['주주수익률']):
|
@@ -179,9 +178,9 @@ def blue(code: str) -> Tuple[int, int, int, int, int]:
|
|
179
178
|
|
180
179
|
c104y = myredis.C104(code, 'c104y')
|
181
180
|
|
182
|
-
blue_dict =
|
181
|
+
blue_dict = eval.blue(code)
|
183
182
|
|
184
|
-
print(pprint.pformat(blue_dict, width=200))
|
183
|
+
# print(pprint.pformat(blue_dict, width=200))
|
185
184
|
|
186
185
|
def 유동비율평가(유동비율: float) -> int:
|
187
186
|
# 채점은 0을 기준으로 마이너스 해간다. 즉 0이 제일 좋은 상태임.
|
@@ -276,7 +275,7 @@ def growth(code: str) -> Tuple[int, int]:
|
|
276
275
|
Returns:
|
277
276
|
tuple : 매출액증가율, 영업이익률 평가 포인트
|
278
277
|
"""
|
279
|
-
growth_dict =
|
278
|
+
growth_dict = eval.growth(code)
|
280
279
|
|
281
280
|
logger.debug(pprint.pformat(growth_dict, width=200))
|
282
281
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import argparse
|
2
|
+
from utils_hj3415 import noti
|
3
|
+
|
4
|
+
|
5
|
+
def analyser():
|
6
|
+
from analyser_hj3415.myredis import red_ranking
|
7
|
+
commands = {
|
8
|
+
'ranking': red_ranking
|
9
|
+
}
|
10
|
+
parser = argparse.ArgumentParser()
|
11
|
+
parser.add_argument('command', help=f"Commands - {commands.keys()}")
|
12
|
+
parser.add_argument('--noti', action='store_true', help='작업완료후 메시지 전송여부')
|
13
|
+
|
14
|
+
args = parser.parse_args()
|
15
|
+
|
16
|
+
if args.command in commands.keys():
|
17
|
+
if args.command == 'ranking':
|
18
|
+
print(commands['ranking']())
|
19
|
+
if args.noti:
|
20
|
+
noti.telegram_to('manager', "오늘의 red ranking을 저장했습니다.(유효 12시간)")
|
21
|
+
else:
|
22
|
+
print(f"The command should be in {list(commands.keys())}")
|
23
|
+
|
24
|
+
|
@@ -1,11 +1,53 @@
|
|
1
|
-
from analyser_hj3415.analysers import eval
|
1
|
+
from analyser_hj3415.analysers import eval, score
|
2
2
|
from db_hj3415.myredis import Base
|
3
3
|
import json
|
4
|
+
from collections import OrderedDict
|
5
|
+
from db_hj3415 import myredis as db_myredis
|
6
|
+
|
4
7
|
|
5
8
|
page = '.analyser'
|
6
9
|
|
7
10
|
|
8
|
-
def
|
11
|
+
def red_ranking() -> OrderedDict:
|
12
|
+
"""
|
13
|
+
redis를 사용하며 red score를 계산해서 0이상의 값을 가지는 종목을 순서대로 저장하여 반환한다.
|
14
|
+
:return: OrderedDict([('023590', 101),
|
15
|
+
('009970', 99),
|
16
|
+
('010060', 91),...])
|
17
|
+
"""
|
18
|
+
redis_name = 'red_ranking'
|
19
|
+
|
20
|
+
try:
|
21
|
+
cached_data = Base.redis_client.get(redis_name).decode('utf-8')
|
22
|
+
except AttributeError:
|
23
|
+
# redis에 해당하는 값이 없는 경우
|
24
|
+
data = {}
|
25
|
+
for i, code in enumerate(db_myredis.Corps.list_all_codes()):
|
26
|
+
s = score.red(code)
|
27
|
+
if s <= 0:
|
28
|
+
continue
|
29
|
+
data[code] = s
|
30
|
+
# print(i, code, s)
|
31
|
+
|
32
|
+
# print(data)
|
33
|
+
if data:
|
34
|
+
# 데이터를 Redis에 캐싱
|
35
|
+
Base.redis_client.set(redis_name, json.dumps(data))
|
36
|
+
# 12시간 후 키가 자동으로 제거됨
|
37
|
+
Base.redis_client.expire(redis_name, 3600 * 12)
|
38
|
+
print("analysers.eval 데이터 계산하기 - myredis.red_ranking")
|
39
|
+
# ordereddict를 이용해서 딕셔너리의 값을 기준으로 내림차순 정렬함.
|
40
|
+
return OrderedDict(sorted(data.items(), key=lambda item: item[1], reverse=True))
|
41
|
+
else:
|
42
|
+
print(f"Redis 캐시에서 데이터 가져오기(남은시간:{round(Base.redis_client.ttl(redis_name)/3600,1)}시간) - myredis.red_ranking")
|
43
|
+
# ordereddict를 이용해서 딕셔너리의 값을 기준으로 내림차순 정렬함.
|
44
|
+
return OrderedDict(sorted(json.loads(cached_data).items(), key=lambda item: item[1], reverse=True))
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
def red_n_score(code: str) -> dict:
|
9
51
|
"""
|
10
52
|
redis 사용 - 소멸타이머 사용
|
11
53
|
리턴값
|
@@ -24,6 +66,7 @@ def red(code: str) -> dict:
|
|
24
66
|
except AttributeError:
|
25
67
|
# redis에 해당하는 값이 없는 경우
|
26
68
|
data = eval.red(code)
|
69
|
+
data['score'] = score.red(code)
|
27
70
|
# print(data)
|
28
71
|
if data:
|
29
72
|
# 데이터를 Redis에 캐싱
|
@@ -37,7 +80,7 @@ def red(code: str) -> dict:
|
|
37
80
|
return json.loads(cached_data)
|
38
81
|
|
39
82
|
|
40
|
-
def
|
83
|
+
def mil_n_score(code: str) -> dict:
|
41
84
|
"""
|
42
85
|
redis 사용 - 소멸타이머 사용
|
43
86
|
리턴값
|
@@ -79,6 +122,7 @@ def mil(code: str) -> dict:
|
|
79
122
|
except AttributeError:
|
80
123
|
# redis에 해당하는 값이 없는 경우
|
81
124
|
data = eval.mil(code)
|
125
|
+
data['score'] = score.mil(code)
|
82
126
|
# print(data)
|
83
127
|
if data:
|
84
128
|
# 데이터를 Redis에 캐싱
|
@@ -92,7 +136,7 @@ def mil(code: str) -> dict:
|
|
92
136
|
return json.loads(cached_data)
|
93
137
|
|
94
138
|
|
95
|
-
def
|
139
|
+
def blue_n_score(code: str) -> dict:
|
96
140
|
"""
|
97
141
|
redis 사용 - 소멸타이머 사용
|
98
142
|
리턴값
|
@@ -130,6 +174,7 @@ def blue(code: str) -> dict:
|
|
130
174
|
except AttributeError:
|
131
175
|
# redis에 해당하는 값이 없는 경우
|
132
176
|
data = eval.blue(code)
|
177
|
+
data['score'] = score.blue(code)
|
133
178
|
# print(data)
|
134
179
|
if data:
|
135
180
|
# 데이터를 Redis에 캐싱
|
@@ -143,7 +188,7 @@ def blue(code: str) -> dict:
|
|
143
188
|
return json.loads(cached_data)
|
144
189
|
|
145
190
|
|
146
|
-
def
|
191
|
+
def growth_n_score(code: str) -> dict:
|
147
192
|
"""
|
148
193
|
redis 사용 - 소멸타이머 사용
|
149
194
|
리턴값
|
@@ -162,6 +207,7 @@ def growth(code: str) -> dict:
|
|
162
207
|
except AttributeError:
|
163
208
|
# redis에 해당하는 값이 없는 경우
|
164
209
|
data = eval.growth(code)
|
210
|
+
data['score'] = score.growth(code)
|
165
211
|
# print(data)
|
166
212
|
if data:
|
167
213
|
# 데이터를 Redis에 캐싱
|
@@ -207,4 +207,83 @@ def mil(code: str) -> Tuple[int, int, int, int]:
|
|
207
207
|
p = 0
|
208
208
|
score4 = 0 if 0 > p else p
|
209
209
|
|
210
|
-
return score1, score2, score3, score4
|
210
|
+
return score1, score2, score3, score4
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
def dbmanager():
|
216
|
+
cmd = ['repair', 'sync', 'eval', 'update']
|
217
|
+
parser = argparse.ArgumentParser()
|
218
|
+
parser.add_argument('cmd', help=f"Command - {cmd}")
|
219
|
+
parser.add_argument('target', help="Target for scraping (type 6digit code or 'all' or 'parts')")
|
220
|
+
parser.add_argument('-d', '--db_path', help="Set mongo database path")
|
221
|
+
|
222
|
+
args = parser.parse_args()
|
223
|
+
|
224
|
+
db_path = args.db_path if args.db_path else "mongodb://192.168.0.173:27017"
|
225
|
+
client = mongo.connect_mongo(db_path)
|
226
|
+
|
227
|
+
if args.cmd in cmd:
|
228
|
+
if args.cmd == 'repair':
|
229
|
+
if args.target == 'all' or utils.is_6digit(args.target):
|
230
|
+
need_for_repair_codes = chk_db.chk_integrity_corps(client, args.target)
|
231
|
+
# repair dict 예시 - {'343510': ['c106', 'c104', 'c103'], '298000': ['c104'], '091810': ['c104']}
|
232
|
+
print(f"Need for repairing codes :{need_for_repair_codes}")
|
233
|
+
if need_for_repair_codes:
|
234
|
+
# x = input("Do you want to try to repair db by scraping? (y/N)")
|
235
|
+
# if x == 'y' or x == 'Y':
|
236
|
+
for code, failed_page_list in need_for_repair_codes.items():
|
237
|
+
for page in failed_page_list:
|
238
|
+
if page == 'c101':
|
239
|
+
nfsrun.c101([code, ], db_path)
|
240
|
+
elif page == 'c103':
|
241
|
+
nfsrun.c103([code, ], db_path)
|
242
|
+
elif page == 'c104':
|
243
|
+
nfsrun.c104([code, ], db_path)
|
244
|
+
elif page == 'c106':
|
245
|
+
nfsrun.c106([code, ], db_path)
|
246
|
+
recheck_result = chk_db.chk_integrity_corps(client, code)
|
247
|
+
if recheck_result:
|
248
|
+
# 다시 스크랩해도 오류가 지속되는 경우
|
249
|
+
print(f"The db integrity failure persists..{recheck_result}")
|
250
|
+
# x = input(f"Do you want to delete {code} on DB? (y/N)")
|
251
|
+
# if x == 'y' or x == 'Y':
|
252
|
+
# mongo.Corps.del_db(client, code)
|
253
|
+
# else:
|
254
|
+
# print("Canceled.")
|
255
|
+
mongo.Corps.del_db(client, code)
|
256
|
+
# else:
|
257
|
+
# print("Done.")
|
258
|
+
else:
|
259
|
+
print("Done.")
|
260
|
+
else:
|
261
|
+
print(f"Invalid target option : {args.target}")
|
262
|
+
elif args.cmd == 'update':
|
263
|
+
if args.target == 'all' or utils.is_6digit(args.target):
|
264
|
+
need_for_update_codes = list(chk_db.chk_modifying_corps(client, args.target).keys())
|
265
|
+
# need_for_update_codes 예시 - [codes....]
|
266
|
+
print(f"Need for updating codes :{need_for_update_codes}")
|
267
|
+
if need_for_update_codes:
|
268
|
+
nfsrun.c103(need_for_update_codes, db_path)
|
269
|
+
nfsrun.c104(need_for_update_codes, db_path)
|
270
|
+
nfsrun.c106(need_for_update_codes, db_path)
|
271
|
+
elif args.target == 'parts':
|
272
|
+
pass
|
273
|
+
else:
|
274
|
+
print(f"Invalid target option : {args.target}")
|
275
|
+
elif args.cmd == 'sync':
|
276
|
+
if args.target == 'all':
|
277
|
+
chk_db.sync_mongo_with_krx(client)
|
278
|
+
else:
|
279
|
+
print(f"The target should be 'all' in sync command.")
|
280
|
+
elif args.cmd == 'eval':
|
281
|
+
if args.target == 'all':
|
282
|
+
# eval을 평가해서 데이터베이스에 저장한다.
|
283
|
+
eval.make_today_eval_df(client, refresh=True)
|
284
|
+
else:
|
285
|
+
print(f"The target should be 'all' in sync command.")
|
286
|
+
else:
|
287
|
+
print(f"The command should be in {cmd}")
|
288
|
+
|
289
|
+
client.close()
|
@@ -4,24 +4,24 @@ build-backend = "flit_core.buildapi"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "analyser_hj3415"
|
7
|
-
version = "2.
|
7
|
+
version = "2.4.0"
|
8
8
|
authors = [{name = "Hyungjin Kim", email = "hj3415@gmail.com"}]
|
9
9
|
description = "Stock analyser and database processing programs"
|
10
10
|
readme = "README.md"
|
11
11
|
license = {file = "LICENSE"}
|
12
12
|
classifiers = ["License :: OSI Approved :: MIT License"]
|
13
13
|
dependencies = [
|
14
|
-
"utils-hj3415>=2.6.
|
15
|
-
"db-hj3415>=3.
|
14
|
+
"utils-hj3415>=2.6.1",
|
15
|
+
"db-hj3415>=3.4.0",
|
16
16
|
]
|
17
17
|
|
18
18
|
[project.scripts]
|
19
|
-
|
20
|
-
evalmanager = "analyser_hj3415.cli:evalmanager"
|
19
|
+
analyser = "analyser_hj3415.cli:analyser"
|
21
20
|
|
22
21
|
[project.urls]
|
23
22
|
Home = "https://www.hyungjin.kr"
|
24
23
|
|
25
24
|
[tool.flit.sdist]
|
26
25
|
exclude = [
|
26
|
+
'tests/',
|
27
27
|
]
|
@@ -1,109 +0,0 @@
|
|
1
|
-
import argparse
|
2
|
-
from utils_hj3415 import utils
|
3
|
-
from .db import chk_db, mongo
|
4
|
-
from . import eval, report
|
5
|
-
from scraper2_hj3415.nfscrapy import run as nfsrun
|
6
|
-
|
7
|
-
|
8
|
-
def dbmanager():
|
9
|
-
cmd = ['repair', 'sync', 'eval', 'update']
|
10
|
-
parser = argparse.ArgumentParser()
|
11
|
-
parser.add_argument('cmd', help=f"Command - {cmd}")
|
12
|
-
parser.add_argument('target', help="Target for scraping (type 6digit code or 'all' or 'parts')")
|
13
|
-
parser.add_argument('-d', '--db_path', help="Set mongo database path")
|
14
|
-
|
15
|
-
args = parser.parse_args()
|
16
|
-
|
17
|
-
db_path = args.db_path if args.db_path else "mongodb://192.168.0.173:27017"
|
18
|
-
client = mongo.connect_mongo(db_path)
|
19
|
-
|
20
|
-
if args.cmd in cmd:
|
21
|
-
if args.cmd == 'repair':
|
22
|
-
if args.target == 'all' or utils.is_6digit(args.target):
|
23
|
-
need_for_repair_codes = chk_db.chk_integrity_corps(client, args.target)
|
24
|
-
# repair dict 예시 - {'343510': ['c106', 'c104', 'c103'], '298000': ['c104'], '091810': ['c104']}
|
25
|
-
print(f"Need for repairing codes :{need_for_repair_codes}")
|
26
|
-
if need_for_repair_codes:
|
27
|
-
# x = input("Do you want to try to repair db by scraping? (y/N)")
|
28
|
-
# if x == 'y' or x == 'Y':
|
29
|
-
for code, failed_page_list in need_for_repair_codes.items():
|
30
|
-
for page in failed_page_list:
|
31
|
-
if page == 'c101':
|
32
|
-
nfsrun.c101([code, ], db_path)
|
33
|
-
elif page == 'c103':
|
34
|
-
nfsrun.c103([code, ], db_path)
|
35
|
-
elif page == 'c104':
|
36
|
-
nfsrun.c104([code, ], db_path)
|
37
|
-
elif page == 'c106':
|
38
|
-
nfsrun.c106([code, ], db_path)
|
39
|
-
recheck_result = chk_db.chk_integrity_corps(client, code)
|
40
|
-
if recheck_result:
|
41
|
-
# 다시 스크랩해도 오류가 지속되는 경우
|
42
|
-
print(f"The db integrity failure persists..{recheck_result}")
|
43
|
-
# x = input(f"Do you want to delete {code} on DB? (y/N)")
|
44
|
-
# if x == 'y' or x == 'Y':
|
45
|
-
# mongo.Corps.del_db(client, code)
|
46
|
-
# else:
|
47
|
-
# print("Canceled.")
|
48
|
-
mongo.Corps.del_db(client, code)
|
49
|
-
# else:
|
50
|
-
# print("Done.")
|
51
|
-
else:
|
52
|
-
print("Done.")
|
53
|
-
else:
|
54
|
-
print(f"Invalid target option : {args.target}")
|
55
|
-
elif args.cmd == 'update':
|
56
|
-
if args.target == 'all' or utils.is_6digit(args.target):
|
57
|
-
need_for_update_codes = list(chk_db.chk_modifying_corps(client, args.target).keys())
|
58
|
-
# need_for_update_codes 예시 - [codes....]
|
59
|
-
print(f"Need for updating codes :{need_for_update_codes}")
|
60
|
-
if need_for_update_codes:
|
61
|
-
nfsrun.c103(need_for_update_codes, db_path)
|
62
|
-
nfsrun.c104(need_for_update_codes, db_path)
|
63
|
-
nfsrun.c106(need_for_update_codes, db_path)
|
64
|
-
elif args.target == 'parts':
|
65
|
-
pass
|
66
|
-
else:
|
67
|
-
print(f"Invalid target option : {args.target}")
|
68
|
-
elif args.cmd == 'sync':
|
69
|
-
if args.target == 'all':
|
70
|
-
chk_db.sync_mongo_with_krx(client)
|
71
|
-
else:
|
72
|
-
print(f"The target should be 'all' in sync command.")
|
73
|
-
elif args.cmd == 'eval':
|
74
|
-
if args.target == 'all':
|
75
|
-
# eval을 평가해서 데이터베이스에 저장한다.
|
76
|
-
eval.make_today_eval_df(client, refresh=True)
|
77
|
-
else:
|
78
|
-
print(f"The target should be 'all' in sync command.")
|
79
|
-
else:
|
80
|
-
print(f"The command should be in {cmd}")
|
81
|
-
|
82
|
-
client.close()
|
83
|
-
|
84
|
-
|
85
|
-
def evalmanager():
|
86
|
-
cmd = ['report', ]
|
87
|
-
parser = argparse.ArgumentParser()
|
88
|
-
parser.add_argument('cmd', help=f"Command - {cmd}")
|
89
|
-
parser.add_argument('target', help="Target for scraping (type 6digit code or 'all' or 'parts')")
|
90
|
-
parser.add_argument('-d', '--db_path', help="Set mongo database path")
|
91
|
-
|
92
|
-
args = parser.parse_args()
|
93
|
-
|
94
|
-
db_path = args.db_path if args.db_path else "mongodb://192.168.0.173:27017"
|
95
|
-
client = mongo.connect_mongo(db_path)
|
96
|
-
|
97
|
-
if args.cmd in cmd:
|
98
|
-
if args.cmd == 'report':
|
99
|
-
if utils.is_6digit(args.target):
|
100
|
-
print(report.Report(client, args.target))
|
101
|
-
else:
|
102
|
-
print(f"Invalid target option : {args.target}")
|
103
|
-
else:
|
104
|
-
print(f"The command should be in {cmd}")
|
105
|
-
|
106
|
-
|
107
|
-
if __name__ == "__main__":
|
108
|
-
# dbmanager()
|
109
|
-
evalmanager()
|
File without changes
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
2024-08-21 11:38:08+0900 [-] Log opened.
|
@@ -1,110 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
import pprint
|
3
|
-
import random
|
4
|
-
from db_hj3415 import cli, myredis
|
5
|
-
print("테스트용 서버로 주소 설정")
|
6
|
-
cli.save_mongo_addr('mongodb://hj3415:piyrw421@192.168.100.175:27017')
|
7
|
-
cli.save_redis_addr('192.168.100.175')
|
8
|
-
from analyser_hj3415.analysers import eval
|
9
|
-
|
10
|
-
|
11
|
-
class EvalTests(unittest.TestCase):
|
12
|
-
def setUp(self):
|
13
|
-
self.test_codes = myredis.Corps.list_all_codes()
|
14
|
-
|
15
|
-
def tearDown(self):
|
16
|
-
pass
|
17
|
-
|
18
|
-
def test_red(self):
|
19
|
-
test_one = random.choice(self.test_codes)
|
20
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
21
|
-
pprint.pprint(eval.red(test_one))
|
22
|
-
|
23
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
24
|
-
pprint.pprint(eval.red(test_one))
|
25
|
-
|
26
|
-
def test_red_all(self):
|
27
|
-
print(f'Totol {len(self.test_codes)} items')
|
28
|
-
for i, code in enumerate(self.test_codes):
|
29
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
30
|
-
print(eval.red(code))
|
31
|
-
import time
|
32
|
-
time.sleep(2)
|
33
|
-
print(f'Totol {len(self.test_codes)} items')
|
34
|
-
for i, code in enumerate(self.test_codes):
|
35
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
36
|
-
print(eval.red(code))
|
37
|
-
|
38
|
-
def test_mil(self):
|
39
|
-
test_one = random.choice(self.test_codes)
|
40
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
41
|
-
pprint.pprint(eval.mil(test_one))
|
42
|
-
|
43
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
44
|
-
pprint.pprint(eval.mil(test_one))
|
45
|
-
|
46
|
-
def test_mil_all(self):
|
47
|
-
print(f'Totol {len(self.test_codes)} items')
|
48
|
-
for i, code in enumerate(self.test_codes):
|
49
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
50
|
-
print(eval.mil(code))
|
51
|
-
|
52
|
-
import time
|
53
|
-
time.sleep(2)
|
54
|
-
print(f'Totol {len(self.test_codes)} items')
|
55
|
-
for i, code in enumerate(self.test_codes):
|
56
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
57
|
-
print(eval.mil(code))
|
58
|
-
|
59
|
-
def test_blue(self):
|
60
|
-
test_one = random.choice(self.test_codes)
|
61
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
62
|
-
pprint.pprint(eval.blue(test_one))
|
63
|
-
|
64
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
65
|
-
pprint.pprint(eval.blue(test_one))
|
66
|
-
|
67
|
-
def test_blue_all(self):
|
68
|
-
print(f'Totol {len(self.test_codes)} items')
|
69
|
-
for i, code in enumerate(self.test_codes):
|
70
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
71
|
-
print(eval.blue(code))
|
72
|
-
|
73
|
-
import time
|
74
|
-
time.sleep(2)
|
75
|
-
print(f'Totol {len(self.test_codes)} items')
|
76
|
-
for i, code in enumerate(self.test_codes):
|
77
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
78
|
-
print(eval.blue(code))
|
79
|
-
|
80
|
-
def test_growth(self):
|
81
|
-
test_one = random.choice(self.test_codes)
|
82
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
83
|
-
pprint.pprint(eval.growth(test_one))
|
84
|
-
|
85
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
86
|
-
pprint.pprint(eval.growth(test_one))
|
87
|
-
|
88
|
-
def test_growth_all(self):
|
89
|
-
print(f'Totol {len(self.test_codes)} items')
|
90
|
-
for i, code in enumerate(self.test_codes):
|
91
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
92
|
-
print(eval.growth(code))
|
93
|
-
|
94
|
-
import time
|
95
|
-
time.sleep(2)
|
96
|
-
print(f'Totol {len(self.test_codes)} items')
|
97
|
-
for i, code in enumerate(self.test_codes):
|
98
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
99
|
-
print(eval.growth(code))
|
100
|
-
|
101
|
-
def test_eval_all(self):
|
102
|
-
pp = pprint.PrettyPrinter(width=200)
|
103
|
-
print(f'Totol {len(self.test_codes)} items')
|
104
|
-
for i, code in enumerate(self.test_codes):
|
105
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
106
|
-
print(eval.red(code))
|
107
|
-
pp.pprint(eval.mil(code))
|
108
|
-
pp.pprint(eval.blue(code))
|
109
|
-
pprint.pprint(eval.growth(code), width=150)
|
110
|
-
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import time
|
2
|
-
import unittest
|
3
|
-
import pprint
|
4
|
-
import random
|
5
|
-
from analyser_hj3415 import myredis
|
6
|
-
from db_hj3415 import cli
|
7
|
-
from db_hj3415.myredis import Corps
|
8
|
-
print("테스트용 서버로 주소 설정")
|
9
|
-
cli.save_mongo_addr('mongodb://hj3415:piyrw421@192.168.100.175:27017')
|
10
|
-
cli.save_redis_addr('192.168.100.175')
|
11
|
-
|
12
|
-
|
13
|
-
class MyredisTests(unittest.TestCase):
|
14
|
-
def setUp(self):
|
15
|
-
self.test_codes = Corps.list_all_codes()
|
16
|
-
|
17
|
-
def tearDown(self):
|
18
|
-
pass
|
19
|
-
|
20
|
-
def test_red(self):
|
21
|
-
test_one = random.choice(self.test_codes)
|
22
|
-
print(test_one, '/', Corps.get_name(test_one))
|
23
|
-
pprint.pprint(myredis.red(test_one))
|
24
|
-
|
25
|
-
time.sleep(2)
|
26
|
-
|
27
|
-
print(test_one, '/', Corps.get_name(test_one))
|
28
|
-
pprint.pprint(myredis.red(test_one))
|
29
|
-
|
30
|
-
def test_mil(self):
|
31
|
-
test_one = random.choice(self.test_codes)
|
32
|
-
print(test_one, '/', Corps.get_name(test_one))
|
33
|
-
pprint.pprint(myredis.mil(test_one))
|
34
|
-
|
35
|
-
time.sleep(2)
|
36
|
-
|
37
|
-
print(test_one, '/', Corps.get_name(test_one))
|
38
|
-
pprint.pprint(myredis.mil(test_one))
|
39
|
-
|
40
|
-
def test_blue(self):
|
41
|
-
test_one = random.choice(self.test_codes)
|
42
|
-
print(test_one, '/', Corps.get_name(test_one))
|
43
|
-
pprint.pprint(myredis.blue(test_one))
|
44
|
-
|
45
|
-
time.sleep(2)
|
46
|
-
|
47
|
-
print(test_one, '/', Corps.get_name(test_one))
|
48
|
-
pprint.pprint(myredis.blue(test_one))
|
49
|
-
|
50
|
-
def test_growth(self):
|
51
|
-
test_one = random.choice(self.test_codes)
|
52
|
-
print(test_one, '/', Corps.get_name(test_one))
|
53
|
-
pprint.pprint(myredis.growth(test_one))
|
54
|
-
|
55
|
-
time.sleep(2)
|
56
|
-
|
57
|
-
print(test_one, '/', Corps.get_name(test_one))
|
58
|
-
pprint.pprint(myredis.growth(test_one))
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import pprint
|
2
|
-
import unittest
|
3
|
-
import random
|
4
|
-
|
5
|
-
from db_hj3415 import cli, myredis
|
6
|
-
print("테스트용 서버로 주소 설정")
|
7
|
-
cli.save_mongo_addr('mongodb://hj3415:piyrw421@192.168.100.175:27017')
|
8
|
-
cli.save_redis_addr('192.168.100.175')
|
9
|
-
|
10
|
-
from analyser_hj3415.analysers.report import Report
|
11
|
-
|
12
|
-
|
13
|
-
class ReportTest(unittest.TestCase):
|
14
|
-
def setUp(self):
|
15
|
-
self.test_codes = myredis.Corps.list_all_codes()
|
16
|
-
|
17
|
-
def tearDown(self):
|
18
|
-
pass
|
19
|
-
|
20
|
-
def test_Report(self):
|
21
|
-
test_one = random.choice(self.test_codes)
|
22
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
23
|
-
print(Report(client, self.rndcode))
|
@@ -1,90 +0,0 @@
|
|
1
|
-
import time
|
2
|
-
import unittest
|
3
|
-
import random
|
4
|
-
|
5
|
-
from db_hj3415 import cli, myredis
|
6
|
-
print("테스트용 서버로 주소 설정")
|
7
|
-
cli.save_mongo_addr('mongodb://hj3415:piyrw421@192.168.100.175:27017')
|
8
|
-
cli.save_redis_addr('192.168.100.175')
|
9
|
-
|
10
|
-
from analyser_hj3415.analysers import score
|
11
|
-
|
12
|
-
|
13
|
-
class ScoreTests(unittest.TestCase):
|
14
|
-
def setUp(self):
|
15
|
-
self.test_codes = myredis.Corps.list_all_codes()
|
16
|
-
|
17
|
-
def tearDown(self):
|
18
|
-
pass
|
19
|
-
|
20
|
-
def test_red(self):
|
21
|
-
test_one = random.choice(self.test_codes)
|
22
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
23
|
-
print(score.red(test_one))
|
24
|
-
|
25
|
-
time.sleep(1)
|
26
|
-
|
27
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
28
|
-
print(score.red(test_one))
|
29
|
-
|
30
|
-
def test_red_all(self):
|
31
|
-
print(f'Totol {len(self.test_codes)} items')
|
32
|
-
for i, code in enumerate(self.test_codes):
|
33
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
34
|
-
print(score.red(code))
|
35
|
-
|
36
|
-
def test_mil(self):
|
37
|
-
test_one = random.choice(self.test_codes)
|
38
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
39
|
-
print(score.mil(test_one))
|
40
|
-
|
41
|
-
def test_mil_all(self):
|
42
|
-
print(f'Totol {len(self.test_codes)} items')
|
43
|
-
for i, code in enumerate(self.test_codes):
|
44
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
45
|
-
print(score.mil(code))
|
46
|
-
|
47
|
-
def test_blue(self):
|
48
|
-
test_one = random.choice(self.test_codes)
|
49
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
50
|
-
p1, p2, p3, p4, p5 = score.blue(test_one)
|
51
|
-
print(test_one, "유동비율", p1, "이자보상배율", p2, "순부채비율", p3, "순운전자본회전율", p4, "재고자산회전율", p5)
|
52
|
-
|
53
|
-
def test_blue_all(self):
|
54
|
-
print(f'Totol {len(self.test_codes)} items')
|
55
|
-
for i, code in enumerate(self.test_codes):
|
56
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
57
|
-
p1, p2, p3, p4, p5 = score.blue(code)
|
58
|
-
print(code, "유동비율", p1, "이자보상배율", p2, "순부채비율", p3, "순운전자본회전율", p4, "재고자산회전율", p5)
|
59
|
-
|
60
|
-
def test_growth_one(self):
|
61
|
-
test_one = random.choice(self.test_codes)
|
62
|
-
print(test_one, '/', myredis.Corps.get_name(test_one))
|
63
|
-
p1, p2 = score.growth(test_one)
|
64
|
-
print(test_one, "매출액증가율", p1, "영업이익률", p2)
|
65
|
-
|
66
|
-
def test_growth_all(self):
|
67
|
-
print(f'Totol {len(self.test_codes)} items')
|
68
|
-
for i, code in enumerate(self.test_codes):
|
69
|
-
print(i, '/', code, '/', myredis.Corps.get_name(code))
|
70
|
-
p1, p2 = score.growth(code)
|
71
|
-
print(code, "매출액증가율", p1, "영업이익률", p2)
|
72
|
-
|
73
|
-
def test_one(self):
|
74
|
-
test_one = random.choice(self.test_codes)
|
75
|
-
name = myredis.Corps.get_name(test_one)
|
76
|
-
print('/'.join([str(1), str(test_one), str(name)]))
|
77
|
-
print('red', score.red(test_one))
|
78
|
-
print('mil', score.mil(test_one))
|
79
|
-
print('blue', score.blue(test_one))
|
80
|
-
print('growth', score.growth(test_one))
|
81
|
-
|
82
|
-
def test_all(self):
|
83
|
-
for i, test_one in enumerate(self.test_codes):
|
84
|
-
name = myredis.Corps.get_name(test_one)
|
85
|
-
print('/'.join([str(i+1), str(test_one), str(name)]))
|
86
|
-
print('red', score.red(test_one))
|
87
|
-
print('mil', score.mil(test_one))
|
88
|
-
print('blue', score.blue(test_one))
|
89
|
-
print('growth', score.growth(test_one))
|
90
|
-
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
from analyser_hj3415 import tools
|
3
|
-
from db_hj3415 import mongo
|
4
|
-
import math
|
5
|
-
|
6
|
-
|
7
|
-
class EvalToolsTests(unittest.TestCase):
|
8
|
-
def setUp(self):
|
9
|
-
self.addr = "mongodb://hj3415:piyrw421@192.168.100.175:27017/"
|
10
|
-
self.client = mongo.connect_mongo(self.addr)
|
11
|
-
mongo.Base.initialize_client(self.client)
|
12
|
-
self.test_codes = mongo.Corps.list_all_codes()
|
13
|
-
|
14
|
-
def tearDown(self):
|
15
|
-
self.client.close()
|
16
|
-
|
17
|
-
def test_set_data(self):
|
18
|
-
tester = ['2023/03', '2023/03', '2023/06', '2024/09', '', math.nan, None]
|
19
|
-
print(tools.set_data(*tester))
|
20
|
-
|
21
|
-
def test_calc당기순이익(self):
|
22
|
-
for code in self.test_codes:
|
23
|
-
print(code, tools.calc당기순이익(code))
|
24
|
-
|
25
|
-
def test_calc유동자산(self):
|
26
|
-
for code in self.test_codes:
|
27
|
-
print(code, tools.calc유동자산(code))
|
28
|
-
|
29
|
-
def test_calc유동부채(self):
|
30
|
-
for code in self.test_codes:
|
31
|
-
print(code, tools.calc유동부채(code))
|
32
|
-
|
33
|
-
def test_calc비유동부채(self):
|
34
|
-
# 예수부채를 사용하는 보험사계열
|
35
|
-
code = '000370'
|
36
|
-
for code in self.test_codes:
|
37
|
-
print(code, tools.calc비유동부채(code))
|
38
|
-
|
39
|
-
def test_calc유동비율(self):
|
40
|
-
for code in self.test_codes:
|
41
|
-
print(code, tools.calc유동비율(code, pop_count=2))
|
42
|
-
|
43
|
-
def test_findFCF(self):
|
44
|
-
for code in self.test_codes:
|
45
|
-
fcf_dict = tools.findFCF(code)
|
46
|
-
print(code, fcf_dict, mongo.C1034.latest_dict_value(fcf_dict))
|
47
|
-
|
48
|
-
def test_getmarketcap(self):
|
49
|
-
for code in self.test_codes:
|
50
|
-
print(code, tools.get_marketcap(code))
|
51
|
-
|
52
|
-
def test_findPFCF(self):
|
53
|
-
for code in self.test_codes:
|
54
|
-
pfcf_dict = tools.findPFCF(code)
|
55
|
-
print(code, pfcf_dict, mongo.C1034.latest_dict_value(pfcf_dict))
|
56
|
-
|
57
|
-
|
58
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{analyser_hj3415-2.2.0 → analyser_hj3415-2.4.0}/.idea/inspectionProfiles/profiles_settings.xml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|