analyser_hj3415 2.5.1__tar.gz → 2.5.3__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-2.5.1 → analyser_hj3415-2.5.3}/.gitignore +1 -0
  2. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/inspectionProfiles/profiles_settings.xml +1 -0
  3. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/PKG-INFO +3 -3
  4. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/analysers/eval.py +3 -2
  5. analyser_hj3415-2.5.3/analyser_hj3415/cli.py +102 -0
  6. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/pyproject.toml +5 -4
  7. analyser_hj3415-2.5.1/analyser_hj3415/cli.py +0 -32
  8. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.DS_Store +0 -0
  9. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.gitattributes +0 -0
  10. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/.gitignore +0 -0
  11. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/analyser-hj3415.iml +0 -0
  12. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/misc.xml +0 -0
  13. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/modules.xml +0 -0
  14. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/.idea/vcs.xml +0 -0
  15. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/LICENSE +0 -0
  16. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/README.md +0 -0
  17. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/.DS_Store +0 -0
  18. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/__init__.py +0 -0
  19. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/analysers/report.py +0 -0
  20. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/analysers/score.py +0 -0
  21. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/myredis.py +0 -0
  22. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/tools.py +0 -0
  23. {analyser_hj3415-2.5.1 → analyser_hj3415-2.5.3}/analyser_hj3415/trash.py +0 -0
@@ -1,2 +1,3 @@
1
1
 
2
2
  .DS_Store
3
+ /dist/
@@ -1,5 +1,6 @@
1
1
  <component name="InspectionProjectProfileManager">
2
2
  <settings>
3
+ <option name="PROJECT_PROFILE" value="Default" />
3
4
  <option name="USE_PROJECT_PROFILE" value="false" />
4
5
  <version value="1.0" />
5
6
  </settings>
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: analyser_hj3415
3
- Version: 2.5.1
3
+ Version: 2.5.3
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.6.10
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
@@ -2,7 +2,7 @@
2
2
  """
3
3
  import math
4
4
 
5
- from analyser_hj3415 import tools
5
+ from analyser_hj3415 import tools, cli
6
6
  from utils_hj3415 import utils
7
7
  from db_hj3415 import myredis
8
8
 
@@ -17,7 +17,8 @@ logger.setLevel(logging.WARNING)
17
17
 
18
18
 
19
19
  # 주식을 통한 기대수익률 - 금리가 3%일 경우 두배인 6% 정도로 잡는다.
20
- EXPECT_EARN = 0.06
20
+ EXPECT_EARN = cli.AnalyserSettingsManager(cli.SETTINGS_FILE).get_value('EXPECT_EARN')
21
+ print("EXPECT_EARN: ", EXPECT_EARN)
21
22
 
22
23
 
23
24
  def red(code: str) -> dict:
@@ -0,0 +1,102 @@
1
+ import argparse
2
+ import os
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
8
+
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,
17
+ }
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='전체 세팅값 출력')
69
+
70
+ args = parser.parse_args()
71
+
72
+ if args.type == 'red':
73
+ if args.command == 'ranking':
74
+ result = red_ranking()
75
+ print(result)
76
+ if args.noti:
77
+ noti.telegram_to('manager', "오늘의 red ranking을 레디스캐시에 저장했습니다.(유효 12시간)")
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))
88
+ if args.noti:
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())
98
+ else:
99
+ parser.print_help()
100
+
101
+
102
+
@@ -4,19 +4,19 @@ build-backend = "flit_core.buildapi"
4
4
 
5
5
  [project]
6
6
  name = "analyser_hj3415"
7
- version = "2.5.1"
7
+ version = "2.5.3"
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.1",
15
- "db-hj3415>=3.6.10",
14
+ "utils-hj3415>=2.7.0",
15
+ "db-hj3415>=3.7.2",
16
16
  ]
17
17
 
18
18
  [project.scripts]
19
- analyser = "analyser_hj3415.cli:analyser"
19
+ analyser = "analyser_hj3415.cli:analyser_manager"
20
20
 
21
21
  [project.urls]
22
22
  Home = "https://www.hyungjin.kr"
@@ -24,4 +24,5 @@ Home = "https://www.hyungjin.kr"
24
24
  [tool.flit.sdist]
25
25
  exclude = [
26
26
  'tests/',
27
+ 'analyser_hj3415/settings.json'
27
28
  ]
@@ -1,32 +0,0 @@
1
- import argparse
2
- from utils_hj3415 import noti
3
-
4
-
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,
10
- }
11
- parser = argparse.ArgumentParser()
12
- parser.add_argument('command', help=f"Commands - {commands.keys()}")
13
- parser.add_argument('--noti', action='store_true', help='작업완료후 메시지 전송여부')
14
-
15
- args = parser.parse_args()
16
-
17
- if args.command in commands.keys():
18
- if args.command == 'ranking':
19
- print(commands['ranking']())
20
- if args.noti:
21
- 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))
27
- if args.noti:
28
- noti.telegram_to('manager', "오늘의 mil and score를 레디스캐시에 저장했습니다.(유효 12시간)")
29
- else:
30
- print(f"The command should be in {list(commands.keys())}")
31
-
32
-
File without changes