mns-common 1.2.4.4__py3-none-any.whl → 1.2.4.6__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/api/ths/zt/ths_stock_zt_pool_api.py +5 -6
- mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py +368 -0
- mns_common/component/zt/zt_common_service_api.py +4 -4
- {mns_common-1.2.4.4.dist-info → mns_common-1.2.4.6.dist-info}/METADATA +1 -1
- {mns_common-1.2.4.4.dist-info → mns_common-1.2.4.6.dist-info}/RECORD +7 -6
- {mns_common-1.2.4.4.dist-info → mns_common-1.2.4.6.dist-info}/WHEEL +0 -0
- {mns_common-1.2.4.4.dist-info → mns_common-1.2.4.6.dist-info}/top_level.txt +0 -0
|
@@ -177,6 +177,10 @@ def get_real_time_zt_info():
|
|
|
177
177
|
|
|
178
178
|
zt_df = common_service_fun_api.symbol_amount_simple(zt_df)
|
|
179
179
|
zt_df = common_service_fun_api.exclude_new_stock(zt_df)
|
|
180
|
+
zt_df.fillna(0, inplace=True)
|
|
181
|
+
zt_df['chg'] = zt_df['chg'].astype(float)
|
|
182
|
+
zt_df['chg'] = round(
|
|
183
|
+
zt_df['chg'], 2)
|
|
180
184
|
return zt_df
|
|
181
185
|
|
|
182
186
|
|
|
@@ -273,9 +277,4 @@ def zt_reason_group(zt_pool_df):
|
|
|
273
277
|
import mns_common.api.ths.self_choose.ths_self_choose_api as ths_self_choose_api
|
|
274
278
|
|
|
275
279
|
if __name__ == '__main__':
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
res = get_zt_reason(None)
|
|
279
|
-
res = res.loc[res['connected_boards_numbers'] > 1]
|
|
280
|
-
for stock_one in res.itertuples():
|
|
281
|
-
ths_self_choose_api.add_stock_to_account(stock_one.symbol, cookie_test)
|
|
280
|
+
get_real_time_zt_info()
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
file_path = os.path.abspath(__file__)
|
|
5
|
+
end = file_path.index('mns') + 16
|
|
6
|
+
project_path = file_path[0:end]
|
|
7
|
+
sys.path.append(project_path)
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
file_path = os.path.abspath(__file__)
|
|
13
|
+
end = file_path.index('mns') + 14
|
|
14
|
+
project_path = file_path[0:end]
|
|
15
|
+
sys.path.append(project_path)
|
|
16
|
+
import re
|
|
17
|
+
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
18
|
+
import mns_common.component.zt.zt_common_service_api as zt_common_service_api
|
|
19
|
+
from loguru import logger
|
|
20
|
+
# question
|
|
21
|
+
# 必填,查询问句
|
|
22
|
+
#
|
|
23
|
+
# sort_key
|
|
24
|
+
# 非必填,指定用于排序的字段,值为返回结果的列名
|
|
25
|
+
#
|
|
26
|
+
# sort_order
|
|
27
|
+
# 非必填,排序规则,至为asc(升序)或desc(降序)
|
|
28
|
+
#
|
|
29
|
+
# page
|
|
30
|
+
# 非必填,查询的页号,默认为1
|
|
31
|
+
#
|
|
32
|
+
# perpage
|
|
33
|
+
# 非必填,每页数据条数,默认值100,由于问财做了数据限制,最大值为100,指定大于100的数值无效。
|
|
34
|
+
#
|
|
35
|
+
# loop
|
|
36
|
+
# 非必填,是否循环分页,返回多页合并数据。默认值为False,可以设置为True或具体数值。
|
|
37
|
+
#
|
|
38
|
+
# 当设置为True时,程序会一直循环到最后一页,返回全部数据。
|
|
39
|
+
#
|
|
40
|
+
# 当设置具体数值n时,循环请求n页,返回n页合并数据。
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
import mns_common.api.em.east_money_stock_api as east_money_stock_api
|
|
44
|
+
from mns_common.db.MongodbUtil import MongodbUtil
|
|
45
|
+
import pandas as pd
|
|
46
|
+
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
47
|
+
import mns_common.api.ths.wen_cai.ths_wen_cai_api as ths_wen_cai_api
|
|
48
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
49
|
+
import mns_common.utils.date_handle_util as date_handle_util
|
|
50
|
+
import mns_common.api.akshare.stock_zt_pool_api as stock_zt_pool_api
|
|
51
|
+
import mns_common.component.cache.cache_service as cache_service
|
|
52
|
+
|
|
53
|
+
mongodb_util = MongodbUtil('27017')
|
|
54
|
+
|
|
55
|
+
# 缓存key
|
|
56
|
+
THS_NOW_ZT_POOL = 'ths_now_zt_pool'
|
|
57
|
+
# 缓存过期时间
|
|
58
|
+
CACHE_TIME_OUT_TIME = 60
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# 频繁调用容易被封
|
|
62
|
+
def get_ths_stock_zt_reason_with_cache(str_day):
|
|
63
|
+
stock_zt_reason = cache_service.get_cache(THS_NOW_ZT_POOL)
|
|
64
|
+
if data_frame_util.is_empty(stock_zt_reason):
|
|
65
|
+
stock_zt_reason = get_zt_reason(str_day)
|
|
66
|
+
# time_out 为秒
|
|
67
|
+
cache_service.set_cache_time_out(THS_NOW_ZT_POOL, stock_zt_reason, CACHE_TIME_OUT_TIME)
|
|
68
|
+
return stock_zt_reason
|
|
69
|
+
else:
|
|
70
|
+
return stock_zt_reason
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def get_zt_reason(str_day):
|
|
74
|
+
if data_frame_util.is_string_not_empty(str_day):
|
|
75
|
+
key_word = str_day + '涨停'
|
|
76
|
+
else:
|
|
77
|
+
key_word = '涨停'
|
|
78
|
+
zt_df = ths_wen_cai_api.wen_cai_api(key_word, 'stock')
|
|
79
|
+
if data_frame_util.is_empty(zt_df):
|
|
80
|
+
return None
|
|
81
|
+
zt_df.fillna('', inplace=True)
|
|
82
|
+
no_slash_day = date_handle_util.no_slash_date(str_day)
|
|
83
|
+
no_slash_day = "[" + no_slash_day + "]"
|
|
84
|
+
zt_df = zt_df.rename(columns={
|
|
85
|
+
"股票代码": "code",
|
|
86
|
+
"股票简称": "name",
|
|
87
|
+
"涨停" + no_slash_day: "zt_tag",
|
|
88
|
+
"首次涨停时间" + no_slash_day: "first_closure_time",
|
|
89
|
+
"最终涨停时间" + no_slash_day: "last_closure_time",
|
|
90
|
+
"涨停明细数据" + no_slash_day: "zt_detail",
|
|
91
|
+
"连续涨停天数" + no_slash_day: "connected_boards_numbers",
|
|
92
|
+
"涨停原因类别" + no_slash_day: "zt_reason",
|
|
93
|
+
"涨停封单量" + no_slash_day: "closure_volume",
|
|
94
|
+
"涨停封单额" + no_slash_day: "closure_funds",
|
|
95
|
+
"涨停封单量占成交量比" + no_slash_day: "closure_funds_per_amount",
|
|
96
|
+
"涨停封单量占流通a股比" + no_slash_day: "closure_funds_per_flow_mv",
|
|
97
|
+
"涨停开板次数" + no_slash_day: "frying_plates_numbers",
|
|
98
|
+
"a股市值(不含限售股)" + no_slash_day: "flow_mv",
|
|
99
|
+
"几天几板" + no_slash_day: "statistics_detail",
|
|
100
|
+
"涨停类型" + no_slash_day: "zt_type",
|
|
101
|
+
"code": "symbol",
|
|
102
|
+
"最新价": "now_price",
|
|
103
|
+
"最新涨跌幅": "chg",
|
|
104
|
+
|
|
105
|
+
})
|
|
106
|
+
zt_df['symbol'] = zt_df['symbol'].astype(str)
|
|
107
|
+
if 'statistics_detail' in zt_df.columns:
|
|
108
|
+
zt_df['statistics'] = zt_df['statistics_detail'].apply(convert_statistics)
|
|
109
|
+
if 'code' in zt_df.columns:
|
|
110
|
+
del zt_df['code']
|
|
111
|
+
if 'flow_mv' in zt_df.columns:
|
|
112
|
+
del zt_df['flow_mv']
|
|
113
|
+
zt_df['zt_flag'] = True
|
|
114
|
+
zt_df['str_day'] = str_day
|
|
115
|
+
zt_df = zt_df.fillna('')
|
|
116
|
+
return zt_df
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# 定义一个函数,用于将统计数据转换成相应的格式
|
|
120
|
+
def convert_statistics(stat):
|
|
121
|
+
try:
|
|
122
|
+
if stat is None:
|
|
123
|
+
return '1/1'
|
|
124
|
+
match = re.match(r'(\d+)天(\d+)板', stat)
|
|
125
|
+
if match:
|
|
126
|
+
n, m = map(int, match.groups())
|
|
127
|
+
return f'{n}/{m}'
|
|
128
|
+
elif stat == '首板涨停':
|
|
129
|
+
return '1/1'
|
|
130
|
+
else:
|
|
131
|
+
return stat
|
|
132
|
+
except BaseException as e:
|
|
133
|
+
logger.error("转换出现异常:{},{}", e, stat)
|
|
134
|
+
return '1/1'
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# 获取实时行情涨停列表
|
|
138
|
+
def get_real_time_zt_info():
|
|
139
|
+
real_time_df = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
140
|
+
real_time_df_zt = real_time_df.loc[real_time_df['chg'] > common_service_fun_api.ZT_CHG]
|
|
141
|
+
if data_frame_util.is_empty(real_time_df_zt):
|
|
142
|
+
return pd.DataFrame()
|
|
143
|
+
real_time_df_zt = real_time_df_zt[[
|
|
144
|
+
'symbol',
|
|
145
|
+
'name',
|
|
146
|
+
'chg',
|
|
147
|
+
'amount',
|
|
148
|
+
'quantity_ratio',
|
|
149
|
+
'high',
|
|
150
|
+
'low',
|
|
151
|
+
'open',
|
|
152
|
+
'list_date',
|
|
153
|
+
'exchange',
|
|
154
|
+
'wei_bi',
|
|
155
|
+
'flow_mv',
|
|
156
|
+
'total_mv',
|
|
157
|
+
'buy_1_num'
|
|
158
|
+
]]
|
|
159
|
+
company_df = company_common_service_api.get_company_info_industry()
|
|
160
|
+
company_df = company_df[[
|
|
161
|
+
'_id',
|
|
162
|
+
"industry",
|
|
163
|
+
"first_sw_industry",
|
|
164
|
+
"second_sw_industry",
|
|
165
|
+
"third_sw_industry",
|
|
166
|
+
"ths_concept_name",
|
|
167
|
+
"ths_concept_code",
|
|
168
|
+
"ths_concept_sync_day",
|
|
169
|
+
"em_industry",
|
|
170
|
+
"company_type",
|
|
171
|
+
"mv_circulation_ratio",
|
|
172
|
+
"ths_concept_list_info",
|
|
173
|
+
"kpl_plate_name",
|
|
174
|
+
"kpl_plate_list_info",
|
|
175
|
+
"diff_days"
|
|
176
|
+
]]
|
|
177
|
+
company_df = company_df.loc[company_df['_id'].isin(real_time_df_zt['symbol'])]
|
|
178
|
+
company_df = company_df.set_index(['_id'], drop=True)
|
|
179
|
+
real_time_df_zt = real_time_df_zt.set_index(['symbol'], drop=False)
|
|
180
|
+
real_time_df_zt = pd.merge(real_time_df_zt, company_df, how='outer',
|
|
181
|
+
left_index=True, right_index=True)
|
|
182
|
+
real_time_df_zt = common_service_fun_api.classify_symbol(real_time_df_zt)
|
|
183
|
+
real_time_df_zt = common_service_fun_api.total_mv_classification(real_time_df_zt)
|
|
184
|
+
real_time_df_zt = common_service_fun_api.symbol_amount_simple(real_time_df_zt)
|
|
185
|
+
real_time_df_zt = common_service_fun_api.exclude_new_stock(real_time_df_zt)
|
|
186
|
+
real_time_df_zt.fillna(0, inplace=True)
|
|
187
|
+
real_time_df_zt['chg'] = real_time_df_zt['chg'].astype(float)
|
|
188
|
+
real_time_df_zt['chg'] = round(
|
|
189
|
+
real_time_df_zt['chg'], 2)
|
|
190
|
+
real_time_df_zt = real_time_df_zt.sort_values(by=['chg'], ascending=False)
|
|
191
|
+
return real_time_df_zt
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def get_now_zt_pool_with_reason(str_day):
|
|
195
|
+
# 实时行情涨停信息
|
|
196
|
+
real_time_zt_df = get_real_time_zt_info()
|
|
197
|
+
# 昨日涨停列表
|
|
198
|
+
last_trade_zt = zt_common_service_api.get_last_trade_day_zt(str_day)
|
|
199
|
+
# 东方财富涨停列表
|
|
200
|
+
em_now_zt_pool = stock_zt_pool_api.stock_em_zt_pool_df(date_handle_util.no_slash_date(str_day))
|
|
201
|
+
if data_frame_util.is_not_empty(em_now_zt_pool):
|
|
202
|
+
real_time_zt_df_wei_bi_100 = real_time_zt_df.loc[real_time_zt_df['symbol'].isin(em_now_zt_pool['symbol'])]
|
|
203
|
+
real_time_zt_df_high_chg = real_time_zt_df.loc[~(real_time_zt_df['symbol'].isin(em_now_zt_pool['symbol']))]
|
|
204
|
+
else:
|
|
205
|
+
real_time_zt_df_high_chg = real_time_zt_df
|
|
206
|
+
|
|
207
|
+
em_now_zt_pool = em_now_zt_pool[
|
|
208
|
+
['symbol', 'connected_boards_numbers',
|
|
209
|
+
'statistics', 'closure_funds', 'first_closure_time',
|
|
210
|
+
'last_closure_time', 'frying_plates_numbers']]
|
|
211
|
+
|
|
212
|
+
em_now_zt_pool = em_now_zt_pool.set_index(['symbol'], drop=True)
|
|
213
|
+
real_time_zt_df_wei_bi_100 = real_time_zt_df_wei_bi_100.set_index(['symbol'], drop=False)
|
|
214
|
+
real_time_zt_df_wei_bi_100 = pd.merge(real_time_zt_df_wei_bi_100, em_now_zt_pool, how='outer',
|
|
215
|
+
left_index=True, right_index=True)
|
|
216
|
+
|
|
217
|
+
# 初始化数据
|
|
218
|
+
real_time_zt_df_high_chg['closure_funds'] = 0
|
|
219
|
+
real_time_zt_df_high_chg['first_closure_time'] = '153000'
|
|
220
|
+
real_time_zt_df_high_chg['last_closure_time'] = '153000'
|
|
221
|
+
real_time_zt_df_high_chg['frying_plates_numbers'] = 0
|
|
222
|
+
|
|
223
|
+
real_time_zt_df_high_chg_last_trade_zt = real_time_zt_df_high_chg.loc[
|
|
224
|
+
real_time_zt_df_high_chg['symbol'].isin(last_trade_zt['symbol'])]
|
|
225
|
+
real_time_zt_df_high_chg_last_trade_no_zt = real_time_zt_df_high_chg.loc[
|
|
226
|
+
~(real_time_zt_df_high_chg['symbol'].isin(last_trade_zt['symbol']))]
|
|
227
|
+
|
|
228
|
+
last_trade_zt_copy_today_high_chg = last_trade_zt.loc[
|
|
229
|
+
last_trade_zt['symbol'].isin(real_time_zt_df_high_chg_last_trade_zt['symbol'])]
|
|
230
|
+
last_trade_zt_copy_today_high_chg = last_trade_zt_copy_today_high_chg[
|
|
231
|
+
['symbol', 'connected_boards_numbers', 'statistics']]
|
|
232
|
+
last_trade_zt_copy_today_high_chg['connected_boards_numbers'] = last_trade_zt_copy_today_high_chg[
|
|
233
|
+
'connected_boards_numbers'] + 1
|
|
234
|
+
|
|
235
|
+
last_trade_zt_copy_today_high_chg = last_trade_zt_copy_today_high_chg.set_index(['symbol'], drop=True)
|
|
236
|
+
real_time_zt_df_high_chg_last_trade_zt = real_time_zt_df_high_chg_last_trade_zt.set_index(['symbol'], drop=False)
|
|
237
|
+
real_time_zt_df_high_chg_last_trade_zt = pd.merge(real_time_zt_df_high_chg_last_trade_zt,
|
|
238
|
+
last_trade_zt_copy_today_high_chg, how='outer',
|
|
239
|
+
left_index=True, right_index=True)
|
|
240
|
+
|
|
241
|
+
real_time_zt_df_high_chg_last_trade_no_zt['connected_boards_numbers'] = 1
|
|
242
|
+
real_time_zt_df_high_chg_last_trade_no_zt['statistics'] = '1/1'
|
|
243
|
+
real_time_zt_df_high_chg_last_trade_zt['statistics'] = real_time_zt_df_high_chg_last_trade_zt['statistics'].apply(
|
|
244
|
+
add_one_to_each_side)
|
|
245
|
+
now_zt_pool_df = pd.concat([real_time_zt_df_wei_bi_100,
|
|
246
|
+
real_time_zt_df_high_chg_last_trade_zt,
|
|
247
|
+
real_time_zt_df_high_chg_last_trade_no_zt])
|
|
248
|
+
|
|
249
|
+
now_zt_pool_df = merge_zt_reason(now_zt_pool_df, str_day, last_trade_zt)
|
|
250
|
+
|
|
251
|
+
result_first = now_zt_pool_df.loc[now_zt_pool_df['connected_boards_numbers'] == 1]
|
|
252
|
+
result_connected_boards = now_zt_pool_df.loc[now_zt_pool_df['connected_boards_numbers'] > 1]
|
|
253
|
+
result_connected_boards = result_connected_boards.sort_values(by=['connected_boards_numbers'], ascending=False)
|
|
254
|
+
result_first = result_first.sort_values(by=['first_closure_time'], ascending=True)
|
|
255
|
+
|
|
256
|
+
now_zt_pool_df = pd.concat([result_connected_boards,
|
|
257
|
+
result_first])
|
|
258
|
+
now_zt_pool_df = now_zt_pool_df.fillna('未知数据')
|
|
259
|
+
now_zt_pool_df.drop_duplicates('symbol', keep='last', inplace=True)
|
|
260
|
+
return now_zt_pool_df
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def merge_zt_reason(now_zt_pool_df, str_day, last_trade_zt):
|
|
264
|
+
try:
|
|
265
|
+
zt_reason_df = get_ths_stock_zt_reason_with_cache(str_day)
|
|
266
|
+
except BaseException as e:
|
|
267
|
+
zt_reason_df = None
|
|
268
|
+
logger.error("获取涨停原因异常:{}", e)
|
|
269
|
+
|
|
270
|
+
last_trade_zt_copy = last_trade_zt.copy()
|
|
271
|
+
last_trade_zt_copy = last_trade_zt_copy[['symbol', 'zt_reason']]
|
|
272
|
+
|
|
273
|
+
if data_frame_util.is_empty(zt_reason_df):
|
|
274
|
+
now_zt_pool_df['zt_reason'] = '暂无'
|
|
275
|
+
|
|
276
|
+
last_trade_zt_copy = last_trade_zt_copy.set_index(['symbol'], drop=True)
|
|
277
|
+
now_zt_pool_df = now_zt_pool_df.set_index(['symbol'], drop=False)
|
|
278
|
+
now_zt_pool_df = pd.merge(now_zt_pool_df, last_trade_zt_copy, how='outer',
|
|
279
|
+
left_index=True, right_index=True)
|
|
280
|
+
now_zt_pool_df.dropna(subset=['symbol'], inplace=True)
|
|
281
|
+
return now_zt_pool_df
|
|
282
|
+
zt_reason_df = zt_reason_df[['symbol', 'zt_reason']]
|
|
283
|
+
|
|
284
|
+
zt_reason_df = zt_reason_df.set_index(['symbol'], drop=True)
|
|
285
|
+
now_zt_pool_df = now_zt_pool_df.set_index(['symbol'], drop=False)
|
|
286
|
+
result_zt_df = pd.merge(now_zt_pool_df, zt_reason_df, how='outer',
|
|
287
|
+
left_index=True, right_index=True)
|
|
288
|
+
|
|
289
|
+
# 找出 'symbol' 列中为 NaN 值的数据
|
|
290
|
+
zt_reason_na = result_zt_df[result_zt_df['zt_reason'].isna()]
|
|
291
|
+
zt_reason_not_na = result_zt_df[result_zt_df['zt_reason'].notna()]
|
|
292
|
+
|
|
293
|
+
last_trade_zt_copy = last_trade_zt_copy.set_index(['symbol'], drop=True)
|
|
294
|
+
del zt_reason_na['zt_reason']
|
|
295
|
+
zt_reason_na = zt_reason_na.set_index(['symbol'], drop=False)
|
|
296
|
+
zt_reason_na = pd.merge(zt_reason_na, last_trade_zt_copy, how='outer',
|
|
297
|
+
left_index=True, right_index=True)
|
|
298
|
+
zt_reason_na['zt_reason'] = zt_reason_na['zt_reason'].fillna('未有')
|
|
299
|
+
|
|
300
|
+
# 删除昨日涨停 今日未涨停的
|
|
301
|
+
zt_reason_na.dropna(subset=['symbol'], inplace=True)
|
|
302
|
+
|
|
303
|
+
result = pd.concat([zt_reason_na,
|
|
304
|
+
zt_reason_not_na])
|
|
305
|
+
|
|
306
|
+
result.dropna(subset=['symbol'], inplace=True)
|
|
307
|
+
result.drop_duplicates('symbol', keep='last', inplace=True)
|
|
308
|
+
|
|
309
|
+
result['zt_reason'] = result['zt_reason'].replace({0: '其他',
|
|
310
|
+
'': '其他',
|
|
311
|
+
'0': '其他', })
|
|
312
|
+
|
|
313
|
+
return result
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
# 定义一个函数来处理字符串 涨停统计加1
|
|
317
|
+
def add_one_to_each_side(s):
|
|
318
|
+
left, right = s.split('/')
|
|
319
|
+
new_left = str(int(left) + 1)
|
|
320
|
+
new_right = str(int(right) + 1)
|
|
321
|
+
return f"{new_left}/{new_right}"
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def zt_reason_group(zt_pool_df):
|
|
325
|
+
if data_frame_util.is_empty(zt_pool_df):
|
|
326
|
+
return pd.DataFrame()
|
|
327
|
+
|
|
328
|
+
zt_pool_df = common_service_fun_api.exclude_st_symbol(zt_pool_df)
|
|
329
|
+
if data_frame_util.is_empty(zt_pool_df):
|
|
330
|
+
return pd.DataFrame()
|
|
331
|
+
|
|
332
|
+
zt_pool_df['symbol'] = zt_pool_df['symbol'].astype(str)
|
|
333
|
+
result_group_df = None
|
|
334
|
+
for zt_stock_one in zt_pool_df.itertuples():
|
|
335
|
+
try:
|
|
336
|
+
zt_reason = zt_stock_one.zt_reason
|
|
337
|
+
if data_frame_util.is_string_empty(zt_reason):
|
|
338
|
+
continue
|
|
339
|
+
zt_reason_list = zt_reason.split("+")
|
|
340
|
+
if len(zt_reason_list) > 0:
|
|
341
|
+
for zt_reason_one in zt_reason_list:
|
|
342
|
+
zt_reason_dict = {'zt_reason_name': zt_reason_one,
|
|
343
|
+
'number': 1
|
|
344
|
+
}
|
|
345
|
+
zt_reason_df_new = pd.DataFrame(zt_reason_dict, index=[0])
|
|
346
|
+
if result_group_df is None:
|
|
347
|
+
result_group_df = zt_reason_df_new
|
|
348
|
+
else:
|
|
349
|
+
exist_zt_reason = result_group_df.loc[result_group_df['zt_reason_name'] == zt_reason_one]
|
|
350
|
+
if data_frame_util.is_not_empty(exist_zt_reason):
|
|
351
|
+
result_group_df.loc[result_group_df['zt_reason_name'] == zt_reason_one, "number"] = \
|
|
352
|
+
exist_zt_reason['number'] + 1
|
|
353
|
+
else:
|
|
354
|
+
result_group_df = pd.concat([result_group_df, zt_reason_df_new])
|
|
355
|
+
|
|
356
|
+
except BaseException as e:
|
|
357
|
+
logger.error("涨停原因分组出现异常:{},{}", zt_stock_one.symbol, e)
|
|
358
|
+
if data_frame_util.is_not_empty(result_group_df):
|
|
359
|
+
result_group_df = result_group_df.sort_values(by=['number'], ascending=False)
|
|
360
|
+
|
|
361
|
+
return result_group_df
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
if __name__ == '__main__':
|
|
365
|
+
while True:
|
|
366
|
+
result_zt_df_test = get_now_zt_pool_with_reason('2024-09-27')
|
|
367
|
+
zt_reason_group(result_zt_df_test)
|
|
368
|
+
logger.info(1)
|
|
@@ -23,10 +23,10 @@ from loguru import logger
|
|
|
23
23
|
def get_last_trade_day_zt(str_day):
|
|
24
24
|
last_trade_day = trade_date_common_service_api.get_last_trade_day(str_day)
|
|
25
25
|
query = {'str_day': last_trade_day}
|
|
26
|
-
|
|
27
|
-
if
|
|
28
|
-
|
|
29
|
-
return
|
|
26
|
+
last_trade_day_zt = mongodb_util.find_query_data(db_name_constant.STOCK_ZT_POOL, query)
|
|
27
|
+
if last_trade_day_zt is None or last_trade_day_zt.shape[0] == 0:
|
|
28
|
+
last_trade_day_zt = stock_zt_pool_api.stock_em_zt_pool_df(date_handle_util.no_slash_date(last_trade_day))
|
|
29
|
+
return last_trade_day_zt
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
# 按照字段分组
|
|
@@ -49,7 +49,8 @@ mns_common/api/ths/self_choose/ths_self_choose_api.py,sha256=TkV4r8iRkgcm4OaclUT
|
|
|
49
49
|
mns_common/api/ths/wen_cai/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
50
50
|
mns_common/api/ths/wen_cai/ths_wen_cai_api.py,sha256=TiDbKIB57ARrnGb70vSJ7-c7lodQqivwlC2IWs95xFw,4718
|
|
51
51
|
mns_common/api/ths/zt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
-
mns_common/api/ths/zt/ths_stock_zt_pool_api.py,sha256=
|
|
52
|
+
mns_common/api/ths/zt/ths_stock_zt_pool_api.py,sha256=GIYdc5J7ZrV25Elbf0n3bBZOc7x4OrlI0jFrO3du8lY,10756
|
|
53
|
+
mns_common/api/ths/zt/ths_stock_zt_pool_v2_api.py,sha256=6um86lOc0XExVgzEv0UTHp48qbh5wGHJI72uwc5btP4,15791
|
|
53
54
|
mns_common/component/__init__.py,sha256=8b2PuXJM5fLoq71cWPXp695czQuaRtyR6OVHajGjDPc,161
|
|
54
55
|
mns_common/component/common_service_fun_api.py,sha256=PLKsIJxlI_MPHeU8s70ncBtKpo1xkFrCE1e1LfWMK7Q,4995
|
|
55
56
|
mns_common/component/cache/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
@@ -93,7 +94,7 @@ mns_common/component/self_choose/self_choose_service_api.py,sha256=3dKqpQSIhkdRj
|
|
|
93
94
|
mns_common/component/trade_date/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
94
95
|
mns_common/component/trade_date/trade_date_common_service_api.py,sha256=PHrcUjgLdNKbqyMGot0poKtiLBys_wRZoheMhPJE-U4,3032
|
|
95
96
|
mns_common/component/zt/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
96
|
-
mns_common/component/zt/zt_common_service_api.py,sha256=
|
|
97
|
+
mns_common/component/zt/zt_common_service_api.py,sha256=6pHRLLJjKcLLBA-xXkAU8SE6DZ5dgVFBRVjJmhkL0II,11945
|
|
97
98
|
mns_common/constant/__init__.py,sha256=2U9DiKslxsWwLLEcZKjS8UiQPN1QgALvnK3HiJNIZE0,163
|
|
98
99
|
mns_common/constant/black_list_classify_enum.py,sha256=I8U_DcltzYvlWjgn-TFLImgVgPuO0lxMnEJAQJBljdo,3995
|
|
99
100
|
mns_common/constant/db_name_constant.py,sha256=4Lw2Q9m90-YspA3bSZa5-py57TXre2oc3E33pGt-gYo,3118
|
|
@@ -111,7 +112,7 @@ mns_common/utils/date_handle_util.py,sha256=qkEyKLYiVq6qpKVp32MLKwRtGKVBK6AY5at2
|
|
|
111
112
|
mns_common/utils/db_util.py,sha256=hSmfNAN4vEeEaUva6_cicZEhb2jSnib-Gvk2reke1vc,2590
|
|
112
113
|
mns_common/utils/file_util.py,sha256=egWu6PenGPRp_ixrNTHKarT4dAnOT6FETR82EHUZJnQ,1042
|
|
113
114
|
mns_common/utils/ip_util.py,sha256=UTcYfz_uytB__6nlBf7T-izuI7hi4XdB6ET0sJgEel4,969
|
|
114
|
-
mns_common-1.2.4.
|
|
115
|
-
mns_common-1.2.4.
|
|
116
|
-
mns_common-1.2.4.
|
|
117
|
-
mns_common-1.2.4.
|
|
115
|
+
mns_common-1.2.4.6.dist-info/METADATA,sha256=3zBavkVyiTXkiyH6kf6la57nPoDMhH-XWovgnpKYSXo,61
|
|
116
|
+
mns_common-1.2.4.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
117
|
+
mns_common-1.2.4.6.dist-info/top_level.txt,sha256=ZC58kAR-8Hvc6U2xhYNBNLAh3mb6sZazbdj5nZpvEkQ,11
|
|
118
|
+
mns_common-1.2.4.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|