mns-common 1.3.9.2__py3-none-any.whl → 1.6.1.4__py3-none-any.whl
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.
Potentially problematic release.
This version of mns-common might be problematic. Click here for more details.
- mns_common/__init__.py +1 -0
- mns_common/api/akshare/__init__.py +0 -1
- mns_common/api/akshare/k_line_api.py +20 -82
- mns_common/api/akshare/stock_bid_ask_api.py +21 -14
- mns_common/api/akshare/stock_zb_pool.py +2 -0
- mns_common/api/akshare/stock_zt_pool_api.py +1 -1
- mns_common/api/em/gd/east_money_stock_gdfx_free_top_10_api.py +62 -7
- mns_common/api/em/real_time/__init__.py +1 -1
- mns_common/api/em/real_time/east_money_debt_api.py +168 -71
- mns_common/api/em/real_time/east_money_etf_api.py +165 -27
- mns_common/api/em/real_time/east_money_stock_a_api.py +37 -38
- mns_common/api/em/real_time/east_money_stock_a_v2_api.py +97 -53
- mns_common/api/em/real_time/east_money_stock_common_api.py +174 -0
- mns_common/api/em/real_time/east_money_stock_hk_api.py +252 -271
- mns_common/api/em/real_time/east_money_stock_hk_gtt_api.py +291 -0
- mns_common/api/em/real_time/east_money_stock_multi_thread_api_v3.py +154 -0
- mns_common/api/em/real_time/east_money_stock_us_api.py +210 -82
- mns_common/api/em/real_time/real_time_quotes_repeat_api.py +195 -0
- mns_common/api/foreign_exchange/foreign_exchange_api.py +38 -0
- mns_common/api/k_line/stock_k_line_data_api.py +11 -1
- mns_common/api/kpl/common/__init__.py +3 -2
- mns_common/api/kpl/common/kpl_common_api.py +35 -0
- mns_common/api/kpl/symbol/symbol_his_quotes_api.py +1 -1
- mns_common/api/kpl/theme/kpl_theme_api.py +69 -0
- mns_common/api/kpl/yidong/__init__.py +7 -0
- mns_common/api/kpl/yidong/stock_bid_yi_dong_api.py +52 -0
- mns_common/api/proxies/liu_guan_proxy_api.py +55 -5
- mns_common/api/ths/company/company_product_area_industry_index_query.py +46 -0
- mns_common/api/ths/company/ths_company_info_api.py +2 -1
- mns_common/api/ths/company/ths_company_info_web.py +159 -0
- mns_common/api/ths/concept/app/ths_concept_index_app.py +3 -1
- mns_common/api/ths/wen_cai/ths_wen_cai_api.py +1 -1
- mns_common/api/ths/zt/ths_stock_zt_pool_api.py +20 -1
- mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py +105 -29
- mns_common/api/ths/zt/ths_stock_zt_reason_web_api.py +100 -0
- mns_common/api/us/ths_us_company_info_api.py +131 -0
- mns_common/api/xueqiu/xue_qiu_k_line_api.py +31 -23
- mns_common/component/common_service_fun_api.py +28 -8
- mns_common/component/company/company_common_service_new_api.py +2 -0
- mns_common/component/cookie/cookie_enum.py +16 -0
- mns_common/component/cookie/cookie_info_service.py +18 -8
- mns_common/component/data/data_init_api.py +13 -8
- mns_common/component/deal/deal_service_api.py +70 -8
- mns_common/component/deal/deal_service_v2_api.py +167 -0
- mns_common/component/em/em_stock_info_api.py +12 -3
- mns_common/component/exception/ExceptionMonitor.py +86 -0
- mns_common/component/exception/__init__.py +7 -0
- mns_common/component/main_line/__init__.py +7 -0
- mns_common/component/main_line/main_line_zt_reason_service.py +257 -0
- mns_common/component/proxies/proxy_common_api.py +199 -31
- mns_common/component/tfp/stock_tfp_api.py +82 -12
- mns_common/component/us/__init__.py +7 -0
- mns_common/component/us/us_stock_etf_info_api.py +130 -0
- mns_common/constant/db_name_constant.py +75 -26
- mns_common/constant/extra_income_db_name.py +97 -11
- mns_common/constant/strategy_classify.py +72 -0
- mns_common/db/MongodbUtil.py +3 -0
- mns_common/db/MongodbUtilLocal.py +3 -0
- {mns_common-1.3.9.2.dist-info → mns_common-1.6.1.4.dist-info}/METADATA +1 -1
- {mns_common-1.3.9.2.dist-info → mns_common-1.6.1.4.dist-info}/RECORD +64 -47
- mns_common/api/ths/concept/web/ths_company_info_web.py +0 -163
- mns_common/component/qmt/qmt_buy_service.py +0 -172
- mns_common/component/task/real_time_data_sync_check.py +0 -97
- /mns_common/{component/qmt → api/foreign_exchange}/__init__.py +0 -0
- /mns_common/{component/task → api/kpl/theme}/__init__.py +0 -0
- {mns_common-1.3.9.2.dist-info → mns_common-1.6.1.4.dist-info}/WHEEL +0 -0
- {mns_common-1.3.9.2.dist-info → mns_common-1.6.1.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
3
|
+
import requests
|
|
4
|
+
from loguru import logger
|
|
5
|
+
import datetime
|
|
6
|
+
|
|
7
|
+
fs = "m:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23,m:0 t:81 s:2048"
|
|
8
|
+
fields = ("f2,f3,f5,f6,f8,"
|
|
9
|
+
"f9,f10,f22,f12,f13,"
|
|
10
|
+
"f14,f15,f16,f17,f18,"
|
|
11
|
+
"f20,f21,f23,f26,f33,"
|
|
12
|
+
"f34,f35,f37,f38,f39,"
|
|
13
|
+
"f62,f64,f65,f67,f68,"
|
|
14
|
+
"f66,f69,f70,f71,f72,"
|
|
15
|
+
"f76,f77,f78,f82,f83,"
|
|
16
|
+
"f84,f102,f184,f100,f103,"
|
|
17
|
+
"f352,f191,f193,f24,f25")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# 获取所有股票实时行情数据 f33,委比
|
|
21
|
+
def rename_real_time_quotes_df(temp_df):
|
|
22
|
+
temp_df = temp_df.rename(columns={
|
|
23
|
+
"f2": "now_price",
|
|
24
|
+
"f3": "chg",
|
|
25
|
+
"f5": "volume",
|
|
26
|
+
"f6": "amount",
|
|
27
|
+
"f8": "exchange",
|
|
28
|
+
"f10": "quantity_ratio",
|
|
29
|
+
"f22": "up_speed",
|
|
30
|
+
"f11": "up_speed_05",
|
|
31
|
+
"f12": "symbol",
|
|
32
|
+
"f14": "name",
|
|
33
|
+
"f15": "high",
|
|
34
|
+
"f16": "low",
|
|
35
|
+
"f17": "open",
|
|
36
|
+
"f18": "yesterday_price",
|
|
37
|
+
"f20": "total_mv",
|
|
38
|
+
"f21": "flow_mv",
|
|
39
|
+
"f26": "list_date",
|
|
40
|
+
"f33": "wei_bi",
|
|
41
|
+
"f34": "outer_disk",
|
|
42
|
+
"f35": "inner_disk",
|
|
43
|
+
"f62": "today_main_net_inflow",
|
|
44
|
+
"f66": "super_large_order_net_inflow",
|
|
45
|
+
"f69": "super_large_order_net_inflow_ratio",
|
|
46
|
+
"f72": "large_order_net_inflow",
|
|
47
|
+
# "f78": "medium_order_net_inflow",
|
|
48
|
+
# "f84": "small_order_net_inflow",
|
|
49
|
+
"f100": "industry",
|
|
50
|
+
# "f103": "concept",
|
|
51
|
+
"f184": "today_main_net_inflow_ratio",
|
|
52
|
+
"f352": "average_price",
|
|
53
|
+
"f211": "buy_1_num",
|
|
54
|
+
"f212": "sell_1_num"
|
|
55
|
+
})
|
|
56
|
+
if data_frame_util.is_empty(temp_df):
|
|
57
|
+
return pd.DataFrame()
|
|
58
|
+
else:
|
|
59
|
+
temp_df.loc[temp_df['buy_1_num'] == '-', 'buy_1_num'] = 0
|
|
60
|
+
temp_df.loc[temp_df['sell_1_num'] == '-', 'sell_1_num'] = 0
|
|
61
|
+
temp_df.loc[temp_df['up_speed_05'] == '-', 'up_speed_05'] = 0
|
|
62
|
+
temp_df.loc[temp_df['up_speed'] == '-', 'up_speed'] = 0
|
|
63
|
+
temp_df.loc[temp_df['average_price'] == '-', 'average_price'] = 0
|
|
64
|
+
temp_df.loc[temp_df['wei_bi'] == '-', 'wei_bi'] = 0
|
|
65
|
+
temp_df.loc[temp_df['yesterday_price'] == '-', 'yesterday_price'] = 0
|
|
66
|
+
temp_df.loc[temp_df['now_price'] == '-', 'now_price'] = 0
|
|
67
|
+
temp_df.loc[temp_df['chg'] == '-', 'chg'] = 0
|
|
68
|
+
temp_df.loc[temp_df['volume'] == '-', 'volume'] = 0
|
|
69
|
+
temp_df.loc[temp_df['amount'] == '-', 'amount'] = 0
|
|
70
|
+
temp_df.loc[temp_df['exchange'] == '-', 'exchange'] = 0
|
|
71
|
+
temp_df.loc[temp_df['quantity_ratio'] == '-', 'quantity_ratio'] = 0
|
|
72
|
+
temp_df.loc[temp_df['high'] == '-', 'high'] = 0
|
|
73
|
+
temp_df.loc[temp_df['low'] == '-', 'low'] = 0
|
|
74
|
+
temp_df.loc[temp_df['open'] == '-', 'open'] = 0
|
|
75
|
+
temp_df.loc[temp_df['total_mv'] == '-', 'total_mv'] = 0
|
|
76
|
+
temp_df.loc[temp_df['flow_mv'] == '-', 'flow_mv'] = 0
|
|
77
|
+
temp_df.loc[temp_df['inner_disk'] == '-', 'inner_disk'] = 0
|
|
78
|
+
temp_df.loc[temp_df['outer_disk'] == '-', 'outer_disk'] = 0
|
|
79
|
+
temp_df.loc[temp_df['today_main_net_inflow_ratio'] == '-', 'today_main_net_inflow_ratio'] = 0
|
|
80
|
+
temp_df.loc[temp_df['today_main_net_inflow'] == '-', 'today_main_net_inflow'] = 0
|
|
81
|
+
temp_df.loc[temp_df['super_large_order_net_inflow'] == '-', 'super_large_order_net_inflow'] = 0
|
|
82
|
+
temp_df.loc[temp_df['super_large_order_net_inflow_ratio'] == '-', 'super_large_order_net_inflow_ratio'] = 0
|
|
83
|
+
temp_df.loc[temp_df['large_order_net_inflow'] == '-', 'large_order_net_inflow'] = 0
|
|
84
|
+
# temp_df.loc[temp_df['medium_order_net_inflow'] == '-', 'medium_order_net_inflow'] = 0
|
|
85
|
+
# temp_df.loc[temp_df['small_order_net_inflow'] == '-', 'small_order_net_inflow'] = 0
|
|
86
|
+
|
|
87
|
+
temp_df["list_date"] = pd.to_numeric(temp_df["list_date"], errors="coerce")
|
|
88
|
+
temp_df["wei_bi"] = pd.to_numeric(temp_df["wei_bi"], errors="coerce")
|
|
89
|
+
temp_df["average_price"] = pd.to_numeric(temp_df["average_price"], errors="coerce")
|
|
90
|
+
temp_df["yesterday_price"] = pd.to_numeric(temp_df["yesterday_price"], errors="coerce")
|
|
91
|
+
temp_df["now_price"] = pd.to_numeric(temp_df["now_price"], errors="coerce")
|
|
92
|
+
temp_df["chg"] = pd.to_numeric(temp_df["chg"], errors="coerce")
|
|
93
|
+
temp_df["volume"] = pd.to_numeric(temp_df["volume"], errors="coerce")
|
|
94
|
+
temp_df["amount"] = pd.to_numeric(temp_df["amount"], errors="coerce")
|
|
95
|
+
temp_df["exchange"] = pd.to_numeric(temp_df["exchange"], errors="coerce")
|
|
96
|
+
temp_df["quantity_ratio"] = pd.to_numeric(temp_df["quantity_ratio"], errors="coerce")
|
|
97
|
+
temp_df["high"] = pd.to_numeric(temp_df["high"], errors="coerce")
|
|
98
|
+
temp_df["low"] = pd.to_numeric(temp_df["low"], errors="coerce")
|
|
99
|
+
temp_df["open"] = pd.to_numeric(temp_df["open"], errors="coerce")
|
|
100
|
+
temp_df["total_mv"] = pd.to_numeric(temp_df["total_mv"], errors="coerce")
|
|
101
|
+
temp_df["flow_mv"] = pd.to_numeric(temp_df["flow_mv"], errors="coerce")
|
|
102
|
+
temp_df["outer_disk"] = pd.to_numeric(temp_df["outer_disk"], errors="coerce")
|
|
103
|
+
temp_df["inner_disk"] = pd.to_numeric(temp_df["inner_disk"], errors="coerce")
|
|
104
|
+
temp_df["today_main_net_inflow"] = pd.to_numeric(temp_df["today_main_net_inflow"], errors="coerce")
|
|
105
|
+
temp_df["super_large_order_net_inflow"] = pd.to_numeric(temp_df["super_large_order_net_inflow"],
|
|
106
|
+
errors="coerce")
|
|
107
|
+
temp_df["super_large_order_net_inflow_ratio"] = pd.to_numeric(temp_df["super_large_order_net_inflow_ratio"],
|
|
108
|
+
errors="coerce")
|
|
109
|
+
temp_df["large_order_net_inflow"] = pd.to_numeric(temp_df["large_order_net_inflow"],
|
|
110
|
+
errors="coerce")
|
|
111
|
+
# temp_df["medium_order_net_inflow"] = pd.to_numeric(temp_df["medium_order_net_inflow"],
|
|
112
|
+
# errors="coerce")
|
|
113
|
+
# temp_df["small_order_net_inflow"] = pd.to_numeric(temp_df["small_order_net_inflow"], errors="coerce")
|
|
114
|
+
|
|
115
|
+
# 大单比例
|
|
116
|
+
temp_df['large_order_net_inflow_ratio'] = round((temp_df['large_order_net_inflow'] / temp_df['amount']) * 100,
|
|
117
|
+
2)
|
|
118
|
+
|
|
119
|
+
# 外盘是内盘倍数
|
|
120
|
+
temp_df['disk_ratio'] = round((temp_df['outer_disk'] - temp_df['inner_disk']) / temp_df['inner_disk'], 2)
|
|
121
|
+
# 只有外盘没有内盘
|
|
122
|
+
temp_df.loc[temp_df["inner_disk"] == 0, ['disk_ratio']] = 1688
|
|
123
|
+
temp_df = temp_df.sort_values(by=['chg'], ascending=False)
|
|
124
|
+
return temp_df
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def get_stocks_num(pn, proxies, page_number, time_out):
|
|
128
|
+
"""
|
|
129
|
+
获取单页股票数据
|
|
130
|
+
"""
|
|
131
|
+
# 获取当前日期和时间
|
|
132
|
+
current_time = datetime.datetime.now()
|
|
133
|
+
|
|
134
|
+
# 将当前时间转换为时间戳(以毫秒为单位)
|
|
135
|
+
current_timestamp_ms = int(current_time.timestamp() * 1000)
|
|
136
|
+
|
|
137
|
+
url = "https://13.push2.eastmoney.com/api/qt/clist/get"
|
|
138
|
+
params = {
|
|
139
|
+
"cb": "jQuery1124046660442520420653_" + str(current_timestamp_ms),
|
|
140
|
+
"pn": str(pn),
|
|
141
|
+
"pz": str(page_number), # 每页最大200条
|
|
142
|
+
"po": "1",
|
|
143
|
+
"np": "3",
|
|
144
|
+
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
|
|
145
|
+
"fltt": "2",
|
|
146
|
+
"invt": "2",
|
|
147
|
+
"wbp2u": "|0|0|0|web",
|
|
148
|
+
"fid": "f3",
|
|
149
|
+
"fs": fs,
|
|
150
|
+
"fields": fields,
|
|
151
|
+
"_": current_timestamp_ms
|
|
152
|
+
}
|
|
153
|
+
try:
|
|
154
|
+
if proxies is None:
|
|
155
|
+
r = requests.get(url, params, timeout=time_out)
|
|
156
|
+
else:
|
|
157
|
+
r = requests.get(url, params, proxies=proxies, timeout=time_out)
|
|
158
|
+
data_text = r.text
|
|
159
|
+
|
|
160
|
+
begin_index_total = data_text.index('"total":')
|
|
161
|
+
end_index_total = data_text.index('"diff"')
|
|
162
|
+
return int(data_text[begin_index_total + 8:end_index_total - 1])
|
|
163
|
+
|
|
164
|
+
except Exception as e:
|
|
165
|
+
logger.error("获取股票数量异常:{}", str(e))
|
|
166
|
+
return 0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
import mns_common.component.proxies.proxy_common_api as proxy_common_api
|
|
170
|
+
|
|
171
|
+
if __name__ == '__main__':
|
|
172
|
+
proxy_ip = proxy_common_api.generate_proxy_ip_api(1)
|
|
173
|
+
proxies = {"https": proxy_ip}
|
|
174
|
+
get_stocks_num(1, proxies, 100, 30)
|