analyser_hj3415 2.3.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.
Files changed (31) hide show
  1. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/PKG-INFO +3 -3
  2. analyser_hj3415-2.4.0/analyser_hj3415/cli.py +24 -0
  3. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/myredis.py +42 -0
  4. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/trash.py +80 -1
  5. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/pyproject.toml +5 -5
  6. analyser_hj3415-2.3.0/analyser_hj3415/cli.py +0 -109
  7. analyser_hj3415-2.3.0/analyser_hj3415/run.py +0 -0
  8. analyser_hj3415-2.3.0/tests/_trial_temp/_trial_marker +0 -0
  9. analyser_hj3415-2.3.0/tests/_trial_temp/test.log +0 -1
  10. analyser_hj3415-2.3.0/tests/testeval.py +0 -110
  11. analyser_hj3415-2.3.0/tests/testmyredis.py +0 -58
  12. analyser_hj3415-2.3.0/tests/testreport.py +0 -23
  13. analyser_hj3415-2.3.0/tests/testscore.py +0 -90
  14. analyser_hj3415-2.3.0/tests/testtools.py +0 -58
  15. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.DS_Store +0 -0
  16. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.gitattributes +0 -0
  17. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.gitignore +0 -0
  18. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/.gitignore +0 -0
  19. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/analyser-hj3415.iml +0 -0
  20. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
  21. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/misc.xml +0 -0
  22. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/modules.xml +0 -0
  23. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/.idea/vcs.xml +0 -0
  24. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/LICENSE +0 -0
  25. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/README.md +0 -0
  26. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/.DS_Store +0 -0
  27. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/__init__.py +0 -0
  28. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/eval.py +0 -0
  29. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/report.py +0 -0
  30. {analyser_hj3415-2.3.0 → analyser_hj3415-2.4.0}/analyser_hj3415/analysers/score.py +0 -0
  31. {analyser_hj3415-2.3.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.0
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.0
9
- Requires-Dist: db-hj3415>=3.3.2
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
@@ -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,10 +1,52 @@
1
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
 
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
+
8
50
  def red_n_score(code: str) -> dict:
9
51
  """
10
52
  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.3.0"
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.0",
15
- "db-hj3415>=3.3.2",
14
+ "utils-hj3415>=2.6.1",
15
+ "db-hj3415>=3.4.0",
16
16
  ]
17
17
 
18
18
  [project.scripts]
19
- dbmanager = "analyser_hj3415.cli:dbmanager"
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 16:23:57+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_n_score(self):
21
- test_one = random.choice(self.test_codes)
22
- print(test_one, '/', Corps.get_name(test_one))
23
- pprint.pprint(myredis.red_n_score(test_one))
24
-
25
- time.sleep(2)
26
-
27
- print(test_one, '/', Corps.get_name(test_one))
28
- pprint.pprint(myredis.red_n_score(test_one))
29
-
30
- def test_mil_n_score(self):
31
- test_one = random.choice(self.test_codes)
32
- print(test_one, '/', Corps.get_name(test_one))
33
- pprint.pprint(myredis.mil_n_score(test_one))
34
-
35
- time.sleep(2)
36
-
37
- print(test_one, '/', Corps.get_name(test_one))
38
- pprint.pprint(myredis.mil_n_score(test_one))
39
-
40
- def test_blue_n_score(self):
41
- test_one = random.choice(self.test_codes)
42
- print(test_one, '/', Corps.get_name(test_one))
43
- pprint.pprint(myredis.blue_n_score(test_one))
44
-
45
- time.sleep(2)
46
-
47
- print(test_one, '/', Corps.get_name(test_one))
48
- pprint.pprint(myredis.blue_n_score(test_one))
49
-
50
- def test_growth_n_score(self):
51
- test_one = random.choice(self.test_codes)
52
- print(test_one, '/', Corps.get_name(test_one))
53
- pprint.pprint(myredis.growth_n_score(test_one))
54
-
55
- time.sleep(2)
56
-
57
- print(test_one, '/', Corps.get_name(test_one))
58
- pprint.pprint(myredis.growth_n_score(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