ezKit 1.8.1__tar.gz → 1.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ezkit-1.8.1/ezKit.egg-info → ezkit-1.8.2}/PKG-INFO +1 -1
- ezkit-1.8.2/ezKit/cls.py +90 -0
- ezkit-1.8.2/ezKit/stock.py +61 -0
- {ezkit-1.8.1 → ezkit-1.8.2/ezKit.egg-info}/PKG-INFO +1 -1
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit.egg-info/SOURCES.txt +2 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/setup.py +1 -1
- {ezkit-1.8.1 → ezkit-1.8.2}/LICENSE +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/MANIFEST.in +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/README.md +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/__init__.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/bottle.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/bottle_extensions.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/cipher.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/database.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/http.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/mongo.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/qywx.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/redis.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/sendemail.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/token.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/utils.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit/xftp.py +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit.egg-info/dependency_links.txt +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit.egg-info/requires.txt +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/ezKit.egg-info/top_level.txt +0 -0
- {ezkit-1.8.1 → ezkit-1.8.2}/setup.cfg +0 -0
ezkit-1.8.2/ezKit/cls.py
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
"""财联社数据"""
|
2
|
+
import re
|
3
|
+
|
4
|
+
import pandas as pd
|
5
|
+
import requests
|
6
|
+
from loguru import logger
|
7
|
+
|
8
|
+
from . import stock, utils
|
9
|
+
|
10
|
+
|
11
|
+
def up_down_analysis(
|
12
|
+
target: str = "up_pool",
|
13
|
+
df: bool = False
|
14
|
+
) -> list | pd.DataFrame | None:
|
15
|
+
"""涨停跌停数据"""
|
16
|
+
|
17
|
+
if not utils.v_true(target, str):
|
18
|
+
logger.error(f"error type: {target}")
|
19
|
+
return None
|
20
|
+
|
21
|
+
info: str = "获取涨停池股票"
|
22
|
+
match True:
|
23
|
+
case True if target == "up_pool":
|
24
|
+
info = "获取涨停池股票"
|
25
|
+
case True if target == "continuous_up_pool":
|
26
|
+
info = "获取连板池股票"
|
27
|
+
case True if target == "up_open_pool":
|
28
|
+
info = "获取炸板池股票"
|
29
|
+
case True if target == "down_pool":
|
30
|
+
info = "获取跌停池股票"
|
31
|
+
case _:
|
32
|
+
pass
|
33
|
+
|
34
|
+
try:
|
35
|
+
logger.info(f"{info} ......")
|
36
|
+
|
37
|
+
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
38
|
+
headers = {"User-Agent": user_agent}
|
39
|
+
|
40
|
+
# 涨停池: https://x-quote.cls.cn/quote/index/up_down_analysis?rever=1&way=last_px&type=up_pool
|
41
|
+
# 连板池: https://x-quote.cls.cn/quote/index/up_down_analysis?rever=1&way=last_px&type=continuous_up_pool
|
42
|
+
# 炸板池: https://x-quote.cls.cn/quote/index/up_down_analysis?rever=1&way=last_px&type=up_open_pool
|
43
|
+
# 跌停池: https://x-quote.cls.cn/quote/index/up_down_analysis?rever=1&way=last_px&type=down_pool
|
44
|
+
api = f"https://x-quote.cls.cn/quote/index/up_down_analysis?rever=1&way=last_px&type={target}"
|
45
|
+
|
46
|
+
response = requests.get(api, headers=headers, timeout=10)
|
47
|
+
|
48
|
+
response_dict: dict = response.json()
|
49
|
+
|
50
|
+
result: list = []
|
51
|
+
|
52
|
+
for i in response_dict["data"]:
|
53
|
+
|
54
|
+
# if re.match(r"^(sz00|sh60)", i["secu_code"]):
|
55
|
+
# print(i["secu_code"])
|
56
|
+
|
57
|
+
# if re.search(r"ST|银行", i["secu_name"]):
|
58
|
+
# print(i["secu_name"])
|
59
|
+
|
60
|
+
# 主板, 非ST, 非银行, 非证券
|
61
|
+
if (not re.match(r"^(sz00|sh60)", i["secu_code"])) or re.search(r"ST|银行|证券", i["secu_name"]):
|
62
|
+
continue
|
63
|
+
|
64
|
+
if target in ["up_pool", "up_pool"]:
|
65
|
+
result.append({
|
66
|
+
"code": stock.coderename(i["secu_code"], restore=True),
|
67
|
+
"name": i["secu_name"],
|
68
|
+
"up_days": i["limit_up_days"],
|
69
|
+
"reason": i["up_reason"]
|
70
|
+
})
|
71
|
+
|
72
|
+
if target in ["up_open_pool", "down_pool"]:
|
73
|
+
result.append({
|
74
|
+
"code": stock.coderename(i["secu_code"], restore=True),
|
75
|
+
"name": i["secu_name"]
|
76
|
+
})
|
77
|
+
|
78
|
+
if utils.v_true(df, bool) is False:
|
79
|
+
logger.success(f"{info} [成功]")
|
80
|
+
return result
|
81
|
+
|
82
|
+
# data: pd.DataFrame = pd.DataFrame(response_dict["data"], columns=["secu_code", "secu_name", "limit_up_days", "up_reason"])
|
83
|
+
# data = data.rename(columns={"secu_code": "code", "secu_name": "name", "limit_up_days": "up_days", "up_reason": "reason"})
|
84
|
+
|
85
|
+
return pd.DataFrame(data=pd.DataFrame(result))
|
86
|
+
|
87
|
+
except Exception as e:
|
88
|
+
logger.error(f"{info} [失败]")
|
89
|
+
logger.exception(e)
|
90
|
+
return None
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"""股票"""
|
2
|
+
# pylint: disable=R0911
|
3
|
+
from copy import deepcopy
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from loguru import logger
|
7
|
+
|
8
|
+
from . import utils
|
9
|
+
|
10
|
+
|
11
|
+
def coderename(target: str | dict, restore: bool = False) -> str | dict | None:
|
12
|
+
"""
|
13
|
+
正向:
|
14
|
+
coderename('000001') => 'sz000001'
|
15
|
+
coderename({'code': '000001', 'name': '平安银行'}) => {'code': 'sz000001', 'name': '平安银行'}
|
16
|
+
反向:
|
17
|
+
coderename('sz000001', restore=True) => '000001'
|
18
|
+
coderename({'code': 'sz000001', 'name': '平安银行'}) => {'code': '000001', 'name': '平安银行'}
|
19
|
+
"""
|
20
|
+
|
21
|
+
try:
|
22
|
+
|
23
|
+
_object: Any = None
|
24
|
+
_code_name: Any = None
|
25
|
+
|
26
|
+
# 判断 target 是 string 还是 dictionary
|
27
|
+
if isinstance(target, str) and utils.v_true(target, str):
|
28
|
+
_code_name = target
|
29
|
+
elif isinstance(target, dict) and utils.v_true(target, dict):
|
30
|
+
_object = deepcopy(target)
|
31
|
+
_code_name = str(deepcopy(target["code"]))
|
32
|
+
else:
|
33
|
+
return None
|
34
|
+
|
35
|
+
# 是否还原
|
36
|
+
if restore:
|
37
|
+
if len(_code_name) == 8 and ("sh" in _code_name or "sz" in _code_name):
|
38
|
+
_code_name = _code_name[2:8]
|
39
|
+
else:
|
40
|
+
return None
|
41
|
+
else:
|
42
|
+
if _code_name[0:2] == "00":
|
43
|
+
_code_name = "sz" + _code_name
|
44
|
+
elif _code_name[0:2] == "60":
|
45
|
+
_code_name = "sh" + _code_name
|
46
|
+
else:
|
47
|
+
return None
|
48
|
+
|
49
|
+
# 返回结果
|
50
|
+
if utils.v_true(target, str):
|
51
|
+
return _code_name
|
52
|
+
|
53
|
+
if utils.v_true(target, dict):
|
54
|
+
_object["code"] = _code_name
|
55
|
+
return _object
|
56
|
+
|
57
|
+
return None
|
58
|
+
|
59
|
+
except Exception as e:
|
60
|
+
logger.exception(e)
|
61
|
+
return None
|
@@ -6,12 +6,14 @@ ezKit/__init__.py
|
|
6
6
|
ezKit/bottle.py
|
7
7
|
ezKit/bottle_extensions.py
|
8
8
|
ezKit/cipher.py
|
9
|
+
ezKit/cls.py
|
9
10
|
ezKit/database.py
|
10
11
|
ezKit/http.py
|
11
12
|
ezKit/mongo.py
|
12
13
|
ezKit/qywx.py
|
13
14
|
ezKit/redis.py
|
14
15
|
ezKit/sendemail.py
|
16
|
+
ezKit/stock.py
|
15
17
|
ezKit/token.py
|
16
18
|
ezKit/utils.py
|
17
19
|
ezKit/xftp.py
|
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
|
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
|