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

@@ -9,14 +9,38 @@ import mns_common.component.em.em_stock_info_api as em_stock_info_api
9
9
  import mns_common.component.common_service_fun_api as common_service_fun_api
10
10
  import mns_common.api.ths.company.company_product_area_industry_index_query as company_product_area_industry_index_query
11
11
  from loguru import logger
12
- import pandas as pd
13
12
  from mns_common.db.MongodbUtil import MongodbUtil
14
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
15
17
 
16
18
  mongodb_util = MongodbUtil('27017')
17
19
 
18
20
 
19
- def sync_company_product_area_industry(symbol):
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):
20
44
  real_time_quotes_all_stocks = em_stock_info_api.get_a_stock_info()
21
45
  real_time_quotes_all_stocks = common_service_fun_api.classify_symbol(real_time_quotes_all_stocks)
22
46
  if symbol is not None:
@@ -33,25 +57,96 @@ def sync_company_product_area_industry(symbol):
33
57
  market = '151'
34
58
 
35
59
  company_product_area_industry_list = company_product_area_industry_index_query.company_product_area_industry(
36
- symbol, market)
60
+ symbol, market, date)
37
61
  for company_one in company_product_area_industry_list:
38
- analysis_type = company_one['analysis_type']
39
- time_operate_index_item_list = company_one['time_operate_index_item_list']
40
- time_operate_index_item_df = pd.DataFrame(time_operate_index_item_list)
41
- time_operate_index_item_df['symbol'] = symbol
42
- time_operate_index_item_df['analysis_type'] = analysis_type
62
+ try:
63
+ analysis_type = company_one['analysis_type']
64
+ time_operate_index_item_list = company_one['time_operate_index_item_list']
65
+ time_operate_index_item_df = pd.DataFrame(time_operate_index_item_list)
66
+ time_operate_index_item_df['symbol'] = symbol
67
+ time_operate_index_item_df['analysis_type'] = analysis_type
43
68
 
44
- time_operate_index_item_df['_id'] = symbol + '_' + time_operate_index_item_df['time']+'_'+ analysis_type
45
- mongodb_util.save_mongo(time_operate_index_item_df, db_name_constant.COMPANY_BUSINESS_INFO)
69
+ time_operate_index_item_df['_id'] = symbol + '_' + time_operate_index_item_df[
70
+ 'time'] + '_' + analysis_type
71
+ handle_industry_area_product(time_operate_index_item_df, symbol)
72
+ except BaseException as e:
73
+ logger.error("同步经营数据异常:{},{}", symbol, e)
46
74
 
75
+ logger.info("同步经营数据完成:{}", stock_one.symbol)
47
76
  except BaseException as e:
48
77
  logger.error("同步经营数据:{},{}", stock_one.symbol, e)
49
78
 
50
- return None
79
+
80
+ def handle_industry_area_product(time_operate_index_item_df, symbol):
81
+ if data_frame_util.is_empty(time_operate_index_item_df):
82
+ return None
83
+
84
+ for business_one in time_operate_index_item_df.itertuples():
85
+ time = business_one.time
86
+ analysis_type = business_one.analysis_type
87
+
88
+ product_index_item_list = business_one.product_index_item_list
89
+ for product_one in product_index_item_list:
90
+ try:
91
+ # 初始化数据
92
+ income_amount = 0
93
+ income_percent = 0
94
+ cost_amount = 0
95
+ cost_percent = 0
96
+ gross_profit_amount = 0
97
+ gross_profit_percent = 0
98
+ gross_profit_rate_amount = 0
99
+ gross_profit_rate_percent = 0
100
+
101
+ product_name = product_one['product_name']
102
+ index_analysis_list = product_one['index_analysis_list']
103
+ for index_one in index_analysis_list:
104
+ try:
105
+ index_id = index_one['index_id']
106
+ if index_id == 'income':
107
+ income_amount = index_one['index_value']
108
+ income_percent = index_one['account']
109
+ elif index_id == 'cost':
110
+ cost_amount = index_one['index_value']
111
+ cost_percent = index_one['account']
112
+ elif index_id == 'gross_profit':
113
+ gross_profit_amount = index_one['index_value']
114
+ gross_profit_percent = index_one['account']
115
+
116
+ elif index_id == 'gross_profit_rate':
117
+ gross_profit_rate_amount = index_one['index_value']
118
+ gross_profit_rate_percent = index_one['account']
119
+ except BaseException as e:
120
+ logger.error("同步经营数据异常:{},{}", symbol, e)
121
+
122
+ id_key = symbol + '_' + time + '_' + analysis_type + '_' + product_name
123
+ result_dict = {
124
+ '_id': id_key,
125
+ 'symbol': symbol,
126
+ 'time': time,
127
+ 'analysis_type': analysis_type,
128
+ 'product_name': product_name,
129
+
130
+ 'income_amount': income_amount,
131
+ 'income_percent': income_percent,
132
+
133
+ 'cost_amount': cost_amount,
134
+ 'cost_percent': cost_percent,
135
+
136
+ 'gross_profit_amount': gross_profit_amount,
137
+ 'gross_profit_percent': gross_profit_percent,
138
+
139
+ 'gross_profit_rate_amount': gross_profit_rate_amount,
140
+ 'gross_profit_rate_percent': gross_profit_rate_percent,
141
+ }
142
+ result_dict_df = pd.DataFrame(result_dict, index=[1])
143
+ mongodb_util.save_mongo(result_dict_df, db_name_constant.COMPANY_BUSINESS_INFO)
144
+ except BaseException as e:
145
+ logger.error("同步经营数据异常:{},{}", symbol, e)
51
146
 
52
147
 
53
148
  if __name__ == '__main__':
54
- # sync_company_product_area_industry('002562')
149
+ sync_company_product_area_industry('002562', None)
55
150
  # sync_company_product_area_industry('002323')
56
151
  # sync_company_product_area_industry('300901')
57
152
  # sync_company_product_area_industry('603225')
@@ -59,4 +154,5 @@ if __name__ == '__main__':
59
154
  # sync_company_product_area_industry('600849')
60
155
  # sync_company_product_area_industry('000508')
61
156
  # sync_company_product_area_industry('810011')
62
- sync_company_product_area_industry(None)
157
+
158
+ sync_company_product_area_industry(None, None)
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mns-scheduler
3
- Version: 1.3.6.2
3
+ Version: 1.3.6.4
4
4
 
@@ -5,7 +5,7 @@ mns_scheduler/company_info/announce/company_announce_sync_service.py,sha256=q8zY
5
5
  mns_scheduler/company_info/base/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
6
6
  mns_scheduler/company_info/base/sync_company_base_info_api.py,sha256=SIBQqUbAZXGCfAoYq78McvIZ6vrttlCfAlqhZl23z9U,21050
7
7
  mns_scheduler/company_info/base/sync_company_hold_info_api.py,sha256=ep9CthkoL_NNqkZgAeAdZqaf7_LNFDCrZonUjrT7w5o,1587
8
- mns_scheduler/company_info/base/sync_company_product_area_industry.py,sha256=U5f_D1eiZix8DCLxYsBi8MHjLWfTV4uaP3o0KQyRrZk,2884
8
+ mns_scheduler/company_info/base/sync_company_product_area_industry.py,sha256=6l-n15TTD175qCK3Zsy2xS5lf0fiHJ7W-3Ri8r18FIc,7173
9
9
  mns_scheduler/company_info/clean/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
10
10
  mns_scheduler/company_info/clean/company_info_clean_api.py,sha256=P_-Nms6S1nVyqVOFKDT-Cq1RvriZV4IMz9eZCDF5Ovk,6104
11
11
  mns_scheduler/company_info/constant/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
@@ -165,7 +165,7 @@ mns_scheduler/zz_task/data_sync_task.py,sha256=XD8xkzH16L4DvQu2VScmsY4nnwHkj3dYP
165
165
  mns_scheduler/zz_task/compensation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
166
  mns_scheduler/zz_task/compensation/compensate_task.py,sha256=Dyo66NcSnXZ-Cne4_v77BBb27SemAiuGXRLnvQ26X0E,6464
167
167
  mns_scheduler/zz_task/compensation/compensate_task_one_day.py,sha256=ize69Ocy1k5rf8Xckk1izcEJ361HBtWH1zoJrScBS28,5751
168
- mns_scheduler-1.3.6.2.dist-info/METADATA,sha256=HtVAx5h5ZHfeoLxYBXSO_N_574vxgCCy_L3b-Ga4mfw,64
169
- mns_scheduler-1.3.6.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
170
- mns_scheduler-1.3.6.2.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
171
- mns_scheduler-1.3.6.2.dist-info/RECORD,,
168
+ mns_scheduler-1.3.6.4.dist-info/METADATA,sha256=G4urY-VgUgJW6XOBtaRKvL8Pk7ZEN3bTAIqaHfBdShk,64
169
+ mns_scheduler-1.3.6.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
170
+ mns_scheduler-1.3.6.4.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
171
+ mns_scheduler-1.3.6.4.dist-info/RECORD,,