analyser_hj3415 2.5.0__py2.py3-none-any.whl → 2.5.2__py2.py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
analyser_hj3415/cli.py CHANGED
@@ -1,32 +1,102 @@
1
1
  import argparse
2
- from utils_hj3415 import noti
2
+ import os
3
3
 
4
+ from utils_hj3415 import noti, utils
5
+ from utils_hj3415.utils import SettingsManager
6
+ from analyser_hj3415.myredis import red_ranking, mil_n_score
7
+ from db_hj3415 import myredis
4
8
 
5
- def analyser():
6
- from analyser_hj3415.myredis import red_ranking, mil_n_score
7
- commands = {
8
- 'ranking': red_ranking,
9
- 'mil': mil_n_score,
9
+
10
+ # 파일 경로 상수
11
+ SETTINGS_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'settings.json')
12
+
13
+
14
+ class AnalyserSettingsManager(SettingsManager):
15
+ DEFAULT_SETTINGS = {
16
+ 'EXPECT_EARN': 0.06,
10
17
  }
11
- parser = argparse.ArgumentParser()
12
- parser.add_argument('command', help=f"Commands - {commands.keys()}")
13
- parser.add_argument('--noti', action='store_true', help='작업완료후 메시지 전송여부')
18
+ TITLES = DEFAULT_SETTINGS.keys()
19
+
20
+ def set_value(self, title: str, value: str):
21
+ assert title in self.TITLES, f"title 인자는 {self.TITLES} 중에 있어야 합니다."
22
+ self.settings_dict[title] = value
23
+ self.save_settings()
24
+ print(f"{title}: {value}가 저장되었습니다")
25
+
26
+ def get_value(self, title: str) -> str:
27
+ assert title in self.TITLES, f"title 인자는 {self.TITLES} 중에 있어야 합니다."
28
+ return self.settings_dict.get(title, self.DEFAULT_SETTINGS[title])
29
+
30
+ def reset_value(self, title: str):
31
+ assert title in self.TITLES, f"title 인자는 {self.TITLES} 중에 있어야 합니다."
32
+ self.set_value(title, self.DEFAULT_SETTINGS[title])
33
+ print(f"{title}이 기본값 ({self.DEFAULT_SETTINGS[title]}) 으로 초기화 되었습니다.")
34
+
35
+
36
+ def analyser_manager():
37
+ settings_manager = AnalyserSettingsManager(SETTINGS_FILE)
38
+
39
+ parser = argparse.ArgumentParser(description="Analyser Commands")
40
+ type_subparsers = parser.add_subparsers(dest='type', help='분석 타입')
41
+
42
+ # red 명령어 서브파서
43
+ red_parser = type_subparsers.add_parser('red', help='red 타입')
44
+ red_subparser = red_parser.add_subparsers(dest='command', help='red 관련된 명령')
45
+ # red - ranking 파서
46
+ ranking_parser = red_subparser.add_parser('ranking', help='red 랭킹 책정 및 레디스 저장')
47
+ ranking_parser.add_argument('--noti', action='store_true', help='작업 완료 후 메시지 전송 여부')
48
+
49
+ # mil 명령어 서브파서
50
+ mil_parser = type_subparsers.add_parser('mil', help='millennial 타입')
51
+ mil_subparser = mil_parser.add_subparsers(dest='command', help='mil 관련된 명령')
52
+ # mil - score 파서
53
+ score_parser = mil_subparser.add_parser('score', help='mil score 책정 및 레디스 저장')
54
+ score_parser.add_argument('code', type=str, help='종목코드 or all')
55
+ score_parser.add_argument('--noti', action='store_true', help='작업 완료 후 메시지 전송 여부')
56
+
57
+ # setting 명령어 서브파서
58
+ setting_parser = type_subparsers.add_parser('setting', help='Set and Get settings')
59
+ setting_subparser = setting_parser.add_subparsers(dest='command', help='setting 관련된 명령')
60
+ # setting - set 파서
61
+ set_parser = setting_subparser.add_parser('set', help='세팅값 저장')
62
+ set_parser.add_argument('title', choices=AnalyserSettingsManager.TITLES, help='타이틀')
63
+ set_parser.add_argument('value', help='세팅값')
64
+ # setting - get 파서
65
+ get_parser = setting_subparser.add_parser('get', help='타이틀 세팅값 불러오기')
66
+ get_parser.add_argument('title', choices=AnalyserSettingsManager.TITLES, help='타이틀')
67
+ # setting - print 파서
68
+ setting_subparser.add_parser('print', help='전체 세팅값 출력')
14
69
 
15
70
  args = parser.parse_args()
16
71
 
17
- if args.command in commands.keys():
72
+ if args.type == 'red':
18
73
  if args.command == 'ranking':
19
- print(commands['ranking']())
74
+ result = red_ranking()
75
+ print(result)
20
76
  if args.noti:
21
77
  noti.telegram_to('manager', "오늘의 red ranking을 레디스캐시에 저장했습니다.(유효 12시간)")
22
- elif args.command == 'mil':
23
- print("**** mil_n_score ****")
24
- for code, _ in red_ranking().items():
25
- print("<<<<< ", code, ">>>>>")
26
- print(commands['mil'](code))
78
+ elif args.type == 'mil':
79
+ if args.command == 'score':
80
+ if args.code == 'all':
81
+ print("**** mil_n_score all code ****")
82
+ for i, code in enumerate(myredis.Corps.list_all_codes()):
83
+ print(f'{i} / {code}')
84
+ mil_n_score(code)
85
+ else:
86
+ assert utils.is_6digit(args.code), "code 인자는 6자리 숫자이어야 합니다."
87
+ print(args.code, mil_n_score(args.code))
27
88
  if args.noti:
28
- noti.telegram_to('manager', "오늘의 mil and score를 레디스캐시에 저장했습니다.(유효 12시간)")
89
+ noti.telegram_to('manager', f"오늘의 mil and score({args.code})를 레디스캐시에 저장했습니다.(유효 12시간)")
90
+ elif args.type == 'setting':
91
+ if args.command == 'set':
92
+ settings_manager.set_value(args.title, args.value)
93
+ elif args.command == 'get':
94
+ value = settings_manager.get_value(args.title)
95
+ print(f"{args.title} 값: {value}")
96
+ elif args.command == 'print':
97
+ print(settings_manager.load_settings())
29
98
  else:
30
- print(f"The command should be in {list(commands.keys())}")
99
+ parser.print_help()
100
+
31
101
 
32
102
 
@@ -0,0 +1 @@
1
+ {}
analyser_hj3415/tools.py CHANGED
@@ -31,6 +31,7 @@ def calc당기순이익(code: str) -> Tuple[str, float]:
31
31
  logger.debug(f'In the calc당기순이익... code:{code}')
32
32
  c103q = C103(code, 'c103재무상태표q')
33
33
  try:
34
+ # print("*(지배)당기순이익: ", c103q.latest_value_pop2('*(지배)당기순이익'))
34
35
  return c103q.latest_value_pop2('*(지배)당기순이익')
35
36
  except:
36
37
  logger.warning(f"{code} - (지배)당기순이익이 없는 종목. 수동으로 계산합니다(금융관련업종일 가능성있음).")
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: analyser_hj3415
3
- Version: 2.5.0
3
+ Version: 2.5.2
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.1
9
- Requires-Dist: db-hj3415>=3.4.0
8
+ Requires-Dist: utils-hj3415>=2.7.0
9
+ Requires-Dist: db-hj3415>=3.7.2
10
10
  Project-URL: Home, https://www.hyungjin.kr
11
11
 
12
12
  ### analyser-hj3415
@@ -0,0 +1,15 @@
1
+ analyser_hj3415/.DS_Store,sha256=qr9-0FPn5CFKe6kEu8_dWCNhzQ0sN7bwQgffKsaJEEo,6148
2
+ analyser_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ analyser_hj3415/cli.py,sha256=27l5X0L657FIybpZdNUBl94KfmghyFOHF2OlY7AjO58,4635
4
+ analyser_hj3415/myredis.py,sha256=T5ESGx1QBrO7mTMlSzqIm975Wks-X9WqrPWVWgFRHUE,10758
5
+ analyser_hj3415/settings.json,sha256=RBNvo1WzZ4oRRq0W9-hknpT7T8If536DEMBg9hyq_4o,2
6
+ analyser_hj3415/tools.py,sha256=T7QYJekKvWNlJtiqu_FaiX3FGfDc71NY4vrbEDfBEt0,13705
7
+ analyser_hj3415/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
8
+ analyser_hj3415/analysers/eval.py,sha256=DIuy0jsF5zP2I26rDeGoeguqw3yvgud-3Pr6argDnYc,13310
9
+ analyser_hj3415/analysers/report.py,sha256=yY-AeDHOqDPrm4lpvZv3NPTJK1Z7lKsjoO5ck8AP6u4,9007
10
+ analyser_hj3415/analysers/score.py,sha256=tyc1NA_0K7b2mjTTMdJVH_OlqBAqAMrcPOvWPYFudfg,15853
11
+ analyser_hj3415-2.5.2.dist-info/entry_points.txt,sha256=ZfjPnJuH8SzvhE9vftIPMBIofsc65IAWYOhqOC_L5ck,65
12
+ analyser_hj3415-2.5.2.dist-info/LICENSE,sha256=QVKTp0dTnB5xG8RLgG17LwSWCKNEzYoVVM6KjoCPKc0,1079
13
+ analyser_hj3415-2.5.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
14
+ analyser_hj3415-2.5.2.dist-info/METADATA,sha256=HAr1OI0_4vgeNjVNp7lXayvmrBPoW1CoVQ_BOUTIzVo,6417
15
+ analyser_hj3415-2.5.2.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ analyser=analyser_hj3415.cli:analyser_manager
3
+
@@ -1,14 +0,0 @@
1
- analyser_hj3415/.DS_Store,sha256=OQfTSOHL-zjUtnNyBpNRVUJUstR4j6I7jihKDFQQmME,6148
2
- analyser_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- analyser_hj3415/cli.py,sha256=NKE69OV8_G0HcBHnX_cM1Zr3-AmxyR7rX1kPv5cVT3o,1188
4
- analyser_hj3415/myredis.py,sha256=T5ESGx1QBrO7mTMlSzqIm975Wks-X9WqrPWVWgFRHUE,10758
5
- analyser_hj3415/tools.py,sha256=SNsrnL5CKmKAdFkmlwgREMIkWDRi6N9LngCdhhhop3Y,13606
6
- analyser_hj3415/trash.py,sha256=zF-W0piqkGr66UP6-iybo9EXh2gO0RP6R1FnIpsGkl8,12262
7
- analyser_hj3415/analysers/eval.py,sha256=mlHi6EPc8l8O6vKnWyX4Cz1BaeGhUpWM8gVZRNhm-JU,13299
8
- analyser_hj3415/analysers/report.py,sha256=whggmLXl7yF-BjQ6JKgxmhILT2T4uFP-rit_BSes9xM,9189
9
- analyser_hj3415/analysers/score.py,sha256=j5bH_r2-Sc53JWgmdBmL7pJk9cc8oQ7iZkYRPPOA-so,16217
10
- analyser_hj3415-2.5.0.dist-info/entry_points.txt,sha256=vBiMpIhNh39VC3UPwgxQNPb54N8vMlr4g0zRcCOjPyo,57
11
- analyser_hj3415-2.5.0.dist-info/LICENSE,sha256=QVKTp0dTnB5xG8RLgG17LwSWCKNEzYoVVM6KjoCPKc0,1079
12
- analyser_hj3415-2.5.0.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
13
- analyser_hj3415-2.5.0.dist-info/METADATA,sha256=nJyR2yM5g5C-wqJ9PXgk7Cecnro3hqHMrR6ESGSDdxU,6417
14
- analyser_hj3415-2.5.0.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- analyser=analyser_hj3415.cli:analyser
3
-