mns-scheduler 1.3.5.0__py3-none-any.whl → 1.4.3.0__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-scheduler might be problematic. Click here for more details.

Files changed (32) hide show
  1. mns_scheduler/company_info/base/sync_company_base_info_api.py +148 -65
  2. mns_scheduler/company_info/base/sync_company_hold_info_api.py +2 -5
  3. mns_scheduler/company_info/base/sync_company_product_area_industry.py +161 -0
  4. mns_scheduler/company_info/clean/company_info_clean_api.py +1 -1
  5. mns_scheduler/company_info/constant/company_constant_data.py +3 -0
  6. mns_scheduler/company_info/em_stock_info/sync_em_stock_info_sync.py +33 -30
  7. mns_scheduler/{debt → finance/em}/__init__.py +1 -1
  8. mns_scheduler/finance/{em_financial_asset_liability_sync_service_api.py → em/em_financial_asset_liability_sync_service_api.py} +1 -1
  9. mns_scheduler/finance/{em_financial_profit_sync_service_api.py → em/em_financial_profit_sync_service_api.py} +5 -3
  10. mns_scheduler/finance/{sync_financial_report_service_api.py → sync_financial_report_service_task.py} +75 -22
  11. mns_scheduler/finance/xue_qiu/__init__.py +7 -0
  12. mns_scheduler/finance/xue_qiu/down_load_xueqiu_report_api.py +77 -0
  13. mns_scheduler/finance/xue_qiu/sync_xue_qiu_fiance_data.py +161 -0
  14. mns_scheduler/irm/stock_irm_cninfo_service.py +3 -2
  15. mns_scheduler/k_line/clean/k_line_info_clean_task.py +7 -2
  16. mns_scheduler/k_line/sync_status/__init__.py +7 -0
  17. mns_scheduler/k_line/sync_status/k_line_sync_status_check.py +54 -0
  18. mns_scheduler/kpl/selection/symbol/sync_kpl_concept_symbol_choose_reason_api.py +7 -1
  19. mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +1 -1
  20. mns_scheduler/risk/transactions/transactions_check_api.py +1 -1
  21. mns_scheduler/self_choose/ths_self_choose_service.py +21 -13
  22. mns_scheduler/trade/sync_position_api.py +38 -5
  23. mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +36 -17
  24. mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +23 -12
  25. mns_scheduler/zz_task/compensation/compensate_task_one_day.py +2 -2
  26. mns_scheduler/zz_task/data_sync_task.py +27 -7
  27. {mns_scheduler-1.3.5.0.dist-info → mns_scheduler-1.4.3.0.dist-info}/METADATA +1 -1
  28. {mns_scheduler-1.3.5.0.dist-info → mns_scheduler-1.4.3.0.dist-info}/RECORD +31 -26
  29. mns_scheduler/debt/kzz_bond_info_sync.py +0 -33
  30. /mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +0 -0
  31. {mns_scheduler-1.3.5.0.dist-info → mns_scheduler-1.4.3.0.dist-info}/WHEEL +0 -0
  32. {mns_scheduler-1.3.5.0.dist-info → mns_scheduler-1.4.3.0.dist-info}/top_level.txt +0 -0
@@ -34,67 +34,6 @@ result_lock = threading.Lock()
34
34
  result = []
35
35
 
36
36
 
37
- # 计算实际流通比例
38
- def calculate_circulation_ratio(symbol):
39
- query = {"symbol": symbol}
40
- stock_gdfx_free_top_10 = mongodb_util.descend_query(query, 'stock_gdfx_free_top_10', "period", 10)
41
- if stock_gdfx_free_top_10.shape[0] == 0:
42
- mv_circulation_ratio = 1
43
- else:
44
- # 排除香港结算公司 大于5%减持不用发公告 香港中央结算 HKSCC
45
- stock_gdfx_free_top_10['is_hk'] = stock_gdfx_free_top_10['shareholder_name'].apply(
46
- lambda shareholder_name: "HK" if shareholder_name.startswith('香港中央结算') or shareholder_name.startswith(
47
- 'HKSCC') else "A")
48
-
49
- # 持股大于5% # 排除香港结算公司 大于5%减持不用发公告 香港中央结算 HKSCC
50
- stock_gdfx_free_top_10 = stock_gdfx_free_top_10.loc[
51
- (stock_gdfx_free_top_10['circulation_ratio'] >= 5) & (stock_gdfx_free_top_10['is_hk'] == 'A')]
52
-
53
- circulation_ratio = sum(stock_gdfx_free_top_10['circulation_ratio'])
54
- mv_circulation_ratio = round((100 - circulation_ratio) / 100, 2)
55
- # 防止错误数据
56
- if mv_circulation_ratio < 0:
57
- mv_circulation_ratio = 1
58
- return mv_circulation_ratio
59
-
60
-
61
- def get_east_money_stock_info():
62
- all_real_time_quotes = em_stock_info_api.get_a_stock_info()
63
- all_real_time_quotes = all_real_time_quotes[['symbol',
64
- 'name',
65
- "now_price",
66
- 'total_mv',
67
- 'flow_mv',
68
- 'pe_ttm',
69
- 'sz_sh',
70
- 'area',
71
- 'pb',
72
- 'list_date',
73
- 'ROE',
74
- 'total_share',
75
- 'flow_share',
76
- 'industry',
77
- 'amount',
78
- "hk_stock_code",
79
- "hk_stock_name",
80
- 'concept']]
81
-
82
- return all_real_time_quotes
83
-
84
-
85
- def create_index():
86
- mongodb_util.create_index('company_info',
87
- [("classification", 1)])
88
- mongodb_util.create_index('company_info',
89
- [("industry", 1)])
90
- mongodb_util.create_index('company_info',
91
- [("flow_mv", 1)])
92
- mongodb_util.create_index('company_info',
93
- [("list_date", 1)])
94
- mongodb_util.create_index('company_info',
95
- [("symbol", 1)])
96
-
97
-
98
37
  # 同步公司基本信息
99
38
 
100
39
  def sync_company_base_info(symbol_list):
@@ -102,6 +41,8 @@ def sync_company_base_info(symbol_list):
102
41
  result = []
103
42
  create_index()
104
43
  east_money_stock_info = get_east_money_stock_info()
44
+ east_money_stock_info = east_money_stock_info.sort_values(by=['list_date'], ascending=False)
45
+
105
46
  de_listed_stock_list = company_common_service_api.get_de_list_company()
106
47
  east_money_stock_info = east_money_stock_info.loc[~(
107
48
  east_money_stock_info['symbol'].isin(de_listed_stock_list))]
@@ -145,6 +86,30 @@ def sync_company_base_info(symbol_list):
145
86
  single_thread_sync_company_info(fail_df, kpl_real_time_quotes, exist_company_df)
146
87
 
147
88
 
89
+ def get_east_money_stock_info():
90
+ all_real_time_quotes = em_stock_info_api.get_a_stock_info()
91
+ all_real_time_quotes = all_real_time_quotes[['symbol',
92
+ 'name',
93
+ "now_price",
94
+ 'total_mv',
95
+ 'flow_mv',
96
+ 'pe_ttm',
97
+ 'sz_sh',
98
+ 'area',
99
+ 'pb',
100
+ 'list_date',
101
+ 'ROE',
102
+ 'total_share',
103
+ 'flow_share',
104
+ 'industry',
105
+ 'amount',
106
+ "hk_stock_code",
107
+ "hk_stock_name",
108
+ 'concept']]
109
+
110
+ return all_real_time_quotes
111
+
112
+
148
113
  def single_thread_sync_company_info(east_money_stock_info,
149
114
  kpl_real_time_quotes, exist_company_df):
150
115
  global result
@@ -201,12 +166,23 @@ def single_thread_sync_company_info(east_money_stock_info,
201
166
  company_info_type['total_mv_sp'] = company_one.total_mv_sp
202
167
  company_info_type['flow_mv_level'] = company_one.flow_mv_level
203
168
  company_info_type['classification'] = company_one.classification
204
- company_info_type['mv_circulation_ratio'] = calculate_circulation_ratio(company_one.symbol)
205
- # 获取同花顺最新概念
206
- company_info_type = ths_concept_common_service_api.set_ths_concept(company_one.symbol, company_info_type)
169
+
207
170
  now_date = datetime.now()
208
171
  str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
172
+
173
+ now_str_day = now_date.strftime('%Y-%m-%d')
209
174
  company_info_type['sync_date'] = str_now_date
175
+
176
+ result_dict = calculate_circulation_ratio(company_one.symbol, now_str_day)
177
+
178
+ company_info_type['mv_circulation_ratio'] = result_dict['mv_circulation_ratio']
179
+ company_info_type['qfii_type'] = result_dict['qfii_type']
180
+ company_info_type['qfii_number'] = result_dict['qfii_number']
181
+ company_info_type['share_holder_sync_day'] = result_dict['share_holder_sync_day']
182
+
183
+ # 获取同花顺最新概念
184
+ company_info_type = ths_concept_common_service_api.set_ths_concept(company_one.symbol, company_info_type)
185
+
210
186
  fix_symbol_industry_df = company_constant_data.get_fix_symbol_industry()
211
187
  if company_one.symbol in list(fix_symbol_industry_df['symbol']):
212
188
  # fix sw_industry
@@ -257,6 +233,113 @@ def single_thread_sync_company_info(east_money_stock_info,
257
233
  result = fail_list
258
234
 
259
235
 
236
+ # 计算实际流通比例
237
+ def calculate_circulation_ratio(symbol, now_str_day):
238
+ query = {"symbol": symbol}
239
+ stock_gdfx_free_top_1 = mongodb_util.descend_query(query, 'stock_gdfx_free_top_10', "period", 1)
240
+ if stock_gdfx_free_top_1.shape[0] == 0:
241
+ mv_circulation_ratio = 1
242
+ qfii_number = 0
243
+ qfii_type = 'A股'
244
+ share_holder_sync_day = now_str_day
245
+ else:
246
+ period_time = list(stock_gdfx_free_top_1['period'])[0]
247
+
248
+ query_free = {'symbol': symbol, 'period': period_time}
249
+ stock_gdfx_free_top_10 = mongodb_util.find_query_data('stock_gdfx_free_top_10', query_free)
250
+
251
+ stock_gdfx_free_top_10['shares_number_str'] = stock_gdfx_free_top_10['shares_number'].astype(str)
252
+
253
+ stock_gdfx_free_top_10['id_key'] = stock_gdfx_free_top_10['symbol'] + '_' + stock_gdfx_free_top_10[
254
+ 'period'] + '_' + stock_gdfx_free_top_10.shares_number_str
255
+
256
+ stock_gdfx_free_top_10.drop_duplicates('id_key', keep='last', inplace=True)
257
+
258
+ # 排除香港结算公司 大于5%减持不用发公告 香港中央结算 HKSCC
259
+ stock_gdfx_free_top_10['is_hk'] = stock_gdfx_free_top_10['shareholder_name'].apply(
260
+ lambda shareholder_name: "HK" if shareholder_name.startswith('香港中央结算') or shareholder_name.startswith(
261
+ 'HKSCC') else "A")
262
+
263
+ # 持股大于5% 减持需要发公告
264
+ # 排除香港结算公司不发公共 小于5%减持不用发公告
265
+ # 香港中央结算 HKSCC
266
+ stock_free_top_greater_than_5 = stock_gdfx_free_top_10.loc[
267
+ (stock_gdfx_free_top_10['circulation_ratio'] >= 5) & (stock_gdfx_free_top_10['is_hk'] == 'A')]
268
+
269
+ stock_free_qfii = stock_gdfx_free_top_10.loc[stock_gdfx_free_top_10['shareholder_nature'] == 'QFII']
270
+
271
+ share_holder_sync_day = list(stock_gdfx_free_top_10['create_day'])[0]
272
+
273
+ # qfii 数量
274
+ qfii_number = stock_free_qfii.shape[0]
275
+ # qfii 类型
276
+ qfii_type = set_qfii_type(qfii_number, stock_free_qfii.copy())
277
+
278
+ circulation_ratio = sum(stock_free_top_greater_than_5['circulation_ratio'])
279
+ mv_circulation_ratio = round((100 - circulation_ratio) / 100, 2)
280
+ # 防止错误数据
281
+ if mv_circulation_ratio < 0:
282
+ mv_circulation_ratio = 1
283
+
284
+ result_dict = {
285
+ 'mv_circulation_ratio': mv_circulation_ratio,
286
+ 'qfii_type': qfii_type,
287
+ 'qfii_number': qfii_number,
288
+ 'share_holder_sync_day': share_holder_sync_day
289
+
290
+ }
291
+ return result_dict
292
+
293
+
294
+ def set_qfii_type(qfii_number, stock_free_qfii):
295
+ if qfii_number > 0:
296
+ stock_free_qfii['new_change'] = stock_free_qfii['change']
297
+ stock_free_qfii.loc[stock_free_qfii['change_ratio'] == 0, 'new_change'] = 0
298
+ stock_free_qfii.loc[stock_free_qfii['change'] == '新进', 'new_change'] = \
299
+ stock_free_qfii['shares_number']
300
+ stock_free_qfii['new_change'] = stock_free_qfii['new_change'].astype(float)
301
+
302
+ stock_free_qfii_new_in = stock_free_qfii.loc[stock_free_qfii['change'] == '新进']
303
+ if data_frame_util.is_not_empty(stock_free_qfii_new_in):
304
+ qfii_type = 1
305
+ return qfii_type
306
+
307
+ stock_free_qfii_add = stock_free_qfii.loc[
308
+ (~stock_free_qfii['change'].isin(['不变', '新进'])) & (stock_free_qfii['new_change'] > 0)]
309
+
310
+ if data_frame_util.is_not_empty(stock_free_qfii_add):
311
+ qfii_type = 2
312
+ return qfii_type
313
+
314
+ stock_free_qfii_not_change = stock_free_qfii.loc[stock_free_qfii['change'] == '不变']
315
+
316
+ if data_frame_util.is_not_empty(stock_free_qfii_not_change):
317
+ qfii_type = 3
318
+ return qfii_type
319
+
320
+ stock_free_qfii_reduce = stock_free_qfii.loc[
321
+ (~stock_free_qfii['change'].isin(['不变', '新进'])) & (stock_free_qfii['new_change'] < 0)]
322
+
323
+ if data_frame_util.is_not_empty(stock_free_qfii_reduce):
324
+ qfii_type = 4
325
+ return qfii_type
326
+ else:
327
+ return 0
328
+
329
+
330
+ def create_index():
331
+ mongodb_util.create_index('company_info',
332
+ [("classification", 1)])
333
+ mongodb_util.create_index('company_info',
334
+ [("industry", 1)])
335
+ mongodb_util.create_index('company_info',
336
+ [("flow_mv", 1)])
337
+ mongodb_util.create_index('company_info',
338
+ [("list_date", 1)])
339
+ mongodb_util.create_index('company_info',
340
+ [("symbol", 1)])
341
+
342
+
260
343
  def set_kpl_data(kpl_real_time_quotes_one, company_info_type, company_one):
261
344
  if data_frame_util.is_not_empty(kpl_real_time_quotes_one):
262
345
  company_info_type['kpl_plate_name'] = list(kpl_real_time_quotes_one['plate_name_list'])[0]
@@ -444,5 +527,5 @@ if __name__ == '__main__':
444
527
  # query = {"total_operate_income": 0}
445
528
  # un_report_company_info = mongodb_util.find_query_data(db_name_constant.COMPANY_INFO, query)
446
529
  # symbol_list = list(un_report_company_info['symbol'])
530
+ sync_company_base_info(['920009'])
447
531
  sync_company_base_info(None)
448
- # group_by_industry()
@@ -27,11 +27,8 @@ def sync_company_hold_info(symbol):
27
27
  now_date = datetime.now()
28
28
  sync_str_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
29
29
  if data_frame_util.is_not_empty(company_hold_info_df):
30
- query = {'symbol': symbol}
31
- result = mongodb_util.remove_data(query, db_name_constant.COMPANY_HOLDING_INFO)
32
- if result.acknowledged:
33
- company_hold_info_df['sync_str_date'] = sync_str_date
34
- mongodb_util.insert_mongo(company_hold_info_df, db_name_constant.COMPANY_HOLDING_INFO)
30
+ company_hold_info_df['sync_str_date'] = sync_str_date
31
+ mongodb_util.insert_mongo(company_hold_info_df, db_name_constant.COMPANY_HOLDING_INFO)
35
32
  except BaseException as e:
36
33
  logger.error("同步公司控股子公司信息:{},{}", symbol, e)
37
34
 
@@ -0,0 +1,161 @@
1
+ import os
2
+ import sys
3
+
4
+ file_path = os.path.abspath(__file__)
5
+ end = file_path.index('mns') + 17
6
+ project_path = file_path[0:end]
7
+ sys.path.append(project_path)
8
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
9
+ import mns_common.component.common_service_fun_api as common_service_fun_api
10
+ import mns_common.api.ths.company.company_product_area_industry_index_query as company_product_area_industry_index_query
11
+ from loguru import logger
12
+ from mns_common.db.MongodbUtil import MongodbUtil
13
+ import mns_common.constant.db_name_constant as db_name_constant
14
+ import mns_common.utils.data_frame_util as data_frame_util
15
+ import pandas as pd
16
+ from datetime import datetime
17
+
18
+ mongodb_util = MongodbUtil('27017')
19
+
20
+
21
+ def sync_company_product_area_industry_task(symbol):
22
+ now_date = datetime.now()
23
+ now_year = now_date.year
24
+ now_month = now_date.month
25
+
26
+ if now_month in [1, 2, 3, 4]:
27
+ period_time_year = str(now_year - 1) + "-12-31"
28
+ sync_company_product_area_industry(symbol, period_time_year)
29
+
30
+ if now_month in [4, 5, 6]:
31
+ period_time_one = str(now_year) + "-03-31"
32
+ sync_company_product_area_industry(symbol, period_time_one)
33
+
34
+ elif now_month in [7, 8, 9]:
35
+ period_time_two = str(now_year) + "-06-30"
36
+ sync_company_product_area_industry(symbol, period_time_two)
37
+
38
+ elif now_month in [10, 11, 12]:
39
+ period_time_three = str(now_year) + "-09-30"
40
+ sync_company_product_area_industry(symbol, period_time_three)
41
+
42
+
43
+ def sync_company_product_area_industry(symbol, date):
44
+ real_time_quotes_all_stocks = em_stock_info_api.get_a_stock_info()
45
+ real_time_quotes_all_stocks = common_service_fun_api.classify_symbol(real_time_quotes_all_stocks)
46
+ if symbol is not None:
47
+ real_time_quotes_all_stocks = real_time_quotes_all_stocks.loc[real_time_quotes_all_stocks['symbol'] == symbol]
48
+ for stock_one in real_time_quotes_all_stocks.itertuples():
49
+ try:
50
+ symbol = stock_one.symbol
51
+
52
+ classification = stock_one.classification
53
+ if classification in ['H', 'K']:
54
+ market = '17'
55
+ elif classification in ['S', 'C']:
56
+ market = '33'
57
+ elif classification in ['X']:
58
+ market = '151'
59
+
60
+ company_product_area_industry_list = company_product_area_industry_index_query.company_product_area_industry(
61
+ symbol, market, date)
62
+ for company_one in company_product_area_industry_list:
63
+ try:
64
+ analysis_type = company_one['analysis_type']
65
+ time_operate_index_item_list = company_one['time_operate_index_item_list']
66
+ time_operate_index_item_df = pd.DataFrame(time_operate_index_item_list)
67
+ if data_frame_util.is_empty(time_operate_index_item_df):
68
+ continue
69
+ time_operate_index_item_df['symbol'] = symbol
70
+ time_operate_index_item_df['analysis_type'] = analysis_type
71
+
72
+ time_operate_index_item_df['_id'] = symbol + '_' + time_operate_index_item_df[
73
+ 'time'] + '_' + analysis_type
74
+ handle_industry_area_product(time_operate_index_item_df, symbol)
75
+ except BaseException as e:
76
+ logger.error("同步经营数据异常:{},{}", symbol, e)
77
+
78
+ logger.info("同步经营数据完成:{}", stock_one.symbol)
79
+ except BaseException as e:
80
+ logger.error("同步经营数据:{},{}", stock_one.symbol, e)
81
+
82
+
83
+ def handle_industry_area_product(time_operate_index_item_df, symbol):
84
+ if data_frame_util.is_empty(time_operate_index_item_df):
85
+ return None
86
+
87
+ for business_one in time_operate_index_item_df.itertuples():
88
+ time = business_one.time
89
+ analysis_type = business_one.analysis_type
90
+
91
+ product_index_item_list = business_one.product_index_item_list
92
+ for product_one in product_index_item_list:
93
+ try:
94
+ # 初始化数据
95
+ income_amount = 0
96
+ income_percent = 0
97
+ cost_amount = 0
98
+ cost_percent = 0
99
+ gross_profit_amount = 0
100
+ gross_profit_percent = 0
101
+ gross_profit_rate_amount = 0
102
+ gross_profit_rate_percent = 0
103
+
104
+ product_name = product_one['product_name']
105
+ index_analysis_list = product_one['index_analysis_list']
106
+ for index_one in index_analysis_list:
107
+ try:
108
+ index_id = index_one['index_id']
109
+ if index_id == 'income':
110
+ income_amount = index_one['index_value']
111
+ income_percent = index_one['account']
112
+ elif index_id == 'cost':
113
+ cost_amount = index_one['index_value']
114
+ cost_percent = index_one['account']
115
+ elif index_id == 'gross_profit':
116
+ gross_profit_amount = index_one['index_value']
117
+ gross_profit_percent = index_one['account']
118
+
119
+ elif index_id == 'gross_profit_rate':
120
+ gross_profit_rate_amount = index_one['index_value']
121
+ gross_profit_rate_percent = index_one['account']
122
+ except BaseException as e:
123
+ logger.error("同步经营数据异常:{},{}", symbol, e)
124
+
125
+ id_key = symbol + '_' + time + '_' + analysis_type + '_' + product_name
126
+ result_dict = {
127
+ '_id': id_key,
128
+ 'symbol': symbol,
129
+ 'time': time,
130
+ 'analysis_type': analysis_type,
131
+ 'product_name': product_name,
132
+
133
+ 'income_amount': income_amount,
134
+ 'income_percent': income_percent,
135
+
136
+ 'cost_amount': cost_amount,
137
+ 'cost_percent': cost_percent,
138
+
139
+ 'gross_profit_amount': gross_profit_amount,
140
+ 'gross_profit_percent': gross_profit_percent,
141
+
142
+ 'gross_profit_rate_amount': gross_profit_rate_amount,
143
+ 'gross_profit_rate_percent': gross_profit_rate_percent,
144
+ }
145
+ result_dict_df = pd.DataFrame(result_dict, index=[1])
146
+ mongodb_util.save_mongo(result_dict_df, db_name_constant.COMPANY_BUSINESS_INFO)
147
+ except BaseException as e:
148
+ logger.error("同步经营数据异常:{},{}", symbol, e)
149
+
150
+
151
+ if __name__ == '__main__':
152
+ sync_company_product_area_industry('300211', '2025-09-30')
153
+ # sync_company_product_area_industry('002323')
154
+ # sync_company_product_area_industry('300901')
155
+ # sync_company_product_area_industry('603225')
156
+ # sync_company_product_area_industry('688039')
157
+ # sync_company_product_area_industry('600849')
158
+ # sync_company_product_area_industry('000508')
159
+ # sync_company_product_area_industry('810011')
160
+
161
+ sync_company_product_area_industry(None, None)
@@ -47,7 +47,7 @@ def clean_company_info(symbol):
47
47
  company_info['company_type'] = company_info['business_nature']
48
48
 
49
49
  # 将list_date列中的所有NaN值设置为99990909
50
- company_info.fillna({'list_date': 20990909.0}, inplace=True)
50
+ company_info.fillna({'list_date': 19890604}, inplace=True)
51
51
 
52
52
  # 将日期数值转换为日期时间格式
53
53
  company_info['list_date_01'] = pd.to_datetime(company_info['list_date'], format='%Y%m%d')
@@ -443,6 +443,9 @@ def filed_sort(company_info):
443
443
  "final_controller_name",
444
444
  "final_controller_rate",
445
445
  "mv_circulation_ratio",
446
+ 'qfii_type',
447
+ 'qfii_number',
448
+ 'share_holder_sync_day',
446
449
  "flow_mv_sp",
447
450
  "total_mv_sp",
448
451
  "now_price",
@@ -6,66 +6,69 @@ end = file_path.index('mns') + 17
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
 
9
- import mns_common.component.proxies.proxy_common_api as proxy_common_api
10
9
  from mns_common.db.MongodbUtil import MongodbUtil
11
10
  from loguru import logger
12
- import mns_common.api.em.real_time.east_money_stock_a_v2_api as east_money_stock_a_v2_api
13
11
  import mns_common.api.em.real_time.east_money_debt_api as east_money_debt_api
14
12
  import mns_common.api.em.real_time.east_money_etf_api as east_money_etf_api
15
- import mns_common.api.em.real_time.east_money_stock_hk_api as east_money_stock_hk_api
13
+ import mns_common.api.em.real_time.east_money_stock_a_v2_api as east_money_stock_a_v2_api
14
+ from datetime import datetime
16
15
  import mns_common.constant.extra_income_db_name as extra_income_db_name
16
+ import mns_common.api.em.real_time.east_money_stock_hk_api as east_money_stock_hk_api
17
17
  import mns_common.component.cookie.cookie_info_service as cookie_info_service
18
-
19
18
  import mns_common.api.em.real_time.east_money_stock_us_api as east_money_stock_us_api
20
19
 
21
20
  mongodb_util = MongodbUtil('27017')
22
21
 
23
22
 
24
23
  def sync_all_em_stock_info():
24
+ now_date = datetime.now()
25
+ str_now_date = now_date.strftime('%Y-%m-%d %H:%M:%S')
26
+
25
27
  logger.info("同步东方财富a,etf,kzz,us,hk,信息开始")
26
- proxy_ip = proxy_common_api.generate_proxy_ip_api(5)
27
- proxies = {"https": proxy_ip}
28
+
28
29
  try:
29
30
  # 这里需要使用详情接口 获取全量数据
30
- em_a_stock_info_df = east_money_stock_a_v2_api.get_all_real_time_quotes(proxies)
31
+ em_a_stock_info_df = east_money_stock_a_v2_api.get_stock_real_time_quotes(60)
32
+ em_a_stock_info_df['list_date'] = em_a_stock_info_df['list_date'].fillna(19890604)
31
33
  em_a_stock_info_df['_id'] = em_a_stock_info_df['symbol']
34
+ em_a_stock_info_df['sync_time'] = str_now_date
32
35
  mongodb_util.save_mongo(em_a_stock_info_df, extra_income_db_name.EM_A_STOCK_INFO)
33
36
  except BaseException as e:
34
37
  logger.error("同步东方财富A股信息异常:{}", e)
35
38
  try:
36
- em_etf_info = east_money_etf_api.get_etf_real_time_quotes(proxies)
37
- em_etf_info['_id'] = em_etf_info['symbol']
39
+ em_etf_info = east_money_etf_api.get_etf_real_time_quotes(30, 6)
40
+ em_etf_info['sync_time'] = str_now_date
38
41
  mongodb_util.save_mongo(em_etf_info, extra_income_db_name.EM_ETF_INFO)
39
42
  except BaseException as e:
40
43
  logger.error("同步东方财富ETF信息异常:{}", e)
41
44
 
42
45
  try:
43
- em_kzz_info = east_money_debt_api.get_debt_real_time_quotes(proxies)
44
-
46
+ em_kzz_info = east_money_debt_api.get_kzz_real_time_quotes(30, 6)
45
47
  em_kzz_info['_id'] = em_kzz_info['symbol']
48
+ em_kzz_info['sync_time'] = str_now_date
46
49
  mongodb_util.save_mongo(em_kzz_info, extra_income_db_name.EM_KZZ_INFO)
47
50
  except BaseException as e:
48
51
  logger.error("同步东方财富可转债信息异常:{}", e)
49
52
 
50
- em_cookie = cookie_info_service.get_em_cookie()
51
- try:
52
- em_hk_stock_info = east_money_stock_hk_api.get_hk_real_time_quotes(em_cookie, proxies)
53
- em_hk_stock_info['_id'] = em_hk_stock_info['symbol']
54
- mongodb_util.save_mongo(em_hk_stock_info, extra_income_db_name.EM_HK_STOCK_INFO)
55
- except BaseException as e:
56
- logger.error("同步东方财富港股信息异常:{}", e)
57
-
58
- try:
59
- em_cookie = cookie_info_service.get_em_cookie()
60
- em_us_stock_info = east_money_stock_us_api.get_us_stock_real_time_quotes(em_cookie, proxies)
61
- em_us_stock_info['_id'] = em_us_stock_info['symbol']
62
- mongodb_util.save_mongo(em_us_stock_info, extra_income_db_name.EM_US_STOCK_INFO)
63
- em_us_etf_info = em_us_stock_info.loc[(em_us_stock_info['amount'] != 0) & (em_us_stock_info['total_mv'] == 0)]
64
- em_us_etf_info = em_us_etf_info.sort_values(by=['amount'], ascending=False)
65
- mongodb_util.save_mongo(em_us_etf_info, extra_income_db_name.EM_US_ETF_INFO)
66
-
67
- except BaseException as e:
68
- logger.error("同步东方财富美股信息异常:{}", e)
53
+ # em_cookie = cookie_info_service.get_em_cookie()
54
+ # try:
55
+ # em_hk_stock_info = east_money_stock_hk_api.get_hk_real_time_quotes(em_cookie, proxies)
56
+ # em_hk_stock_info['_id'] = em_hk_stock_info['symbol']
57
+ # mongodb_util.save_mongo(em_hk_stock_info, extra_income_db_name.EM_HK_STOCK_INFO)
58
+ # except BaseException as e:
59
+ # logger.error("同步东方财富港股信息异常:{}", e)
60
+ #
61
+ # try:
62
+ # em_cookie = cookie_info_service.get_em_cookie()
63
+ # em_us_stock_info = east_money_stock_us_api.get_us_stock_real_time_quotes(em_cookie, proxies)
64
+ # em_us_stock_info['_id'] = em_us_stock_info['symbol']
65
+ # mongodb_util.save_mongo(em_us_stock_info, extra_income_db_name.EM_US_STOCK_INFO)
66
+ # em_us_etf_info = em_us_stock_info.loc[(em_us_stock_info['amount'] != 0) & (em_us_stock_info['total_mv'] == 0)]
67
+ # em_us_etf_info = em_us_etf_info.sort_values(by=['amount'], ascending=False)
68
+ # mongodb_util.save_mongo(em_us_etf_info, extra_income_db_name.EM_US_ETF_INFO)
69
+ #
70
+ # except BaseException as e:
71
+ # logger.error("同步东方财富美股信息异常:{}", e)
69
72
  logger.info("同步东方财富a,etf,kzz,us,hk,信息完成")
70
73
 
71
74
 
@@ -2,6 +2,6 @@ import sys
2
2
  import os
3
3
 
4
4
  file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 17
5
+ end = file_path.index('mns') + 16
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
@@ -7,7 +7,7 @@ project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
  import akshare as ak
9
9
  from mns_common.db.MongodbUtil import MongodbUtil
10
- import mns_scheduler.finance.finance_common_api as finance_common_api
10
+ import mns_scheduler.finance.em.finance_common_api as finance_common_api
11
11
  import mns_common.constant.db_name_constant as db_name_constant
12
12
 
13
13
  mongodb_util = MongodbUtil('27017')
@@ -1,6 +1,8 @@
1
1
  import sys
2
2
  import os
3
3
 
4
+ import pandas as pd
5
+
4
6
  file_path = os.path.abspath(__file__)
5
7
  end = file_path.index('mns') + 17
6
8
  project_path = file_path[0:end]
@@ -12,7 +14,7 @@ import mns_common.utils.data_frame_util as data_frame_util
12
14
 
13
15
  mongodb_util = MongodbUtil('27017')
14
16
  import mns_common.constant.db_name_constant as db_name_constant
15
- import mns_scheduler.finance.finance_common_api as finance_common_api
17
+ import mns_scheduler.finance.em.finance_common_api as finance_common_api
16
18
  from loguru import logger
17
19
 
18
20
 
@@ -293,7 +295,7 @@ def get_em_profit_api(symbol):
293
295
  else:
294
296
  new_profit_df = stock_profit_sheet_by_report_em
295
297
  if data_frame_util.is_empty(new_profit_df):
296
- return None
298
+ return pd.DataFrame()
297
299
  new_profit_df = new_profit_df.fillna(0)
298
300
  return new_profit_df
299
301
 
@@ -341,7 +343,7 @@ def check_columns(profit_df):
341
343
  import mns_common.component.em.em_stock_info_api as em_stock_info_api
342
344
 
343
345
  if __name__ == '__main__':
344
- get_em_profit_api('002193')
346
+ get_em_profit_api('688302')
345
347
  em_df = em_stock_info_api.get_a_stock_info()
346
348
  for em_one in em_df.itertuples():
347
349
  try: