mns-scheduler 1.1.8.4__py3-none-any.whl → 1.4.5.7__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.
Files changed (139) hide show
  1. mns_scheduler/__init__.py +1 -3
  2. mns_scheduler/auto_da_ban/auto_da_ban_service.py +89 -0
  3. mns_scheduler/company_info/clean/__init__.py +1 -1
  4. mns_scheduler/company_info/clean/company_info_clean_api.py +62 -21
  5. mns_scheduler/company_info/common/company_common_query_service.py +45 -0
  6. mns_scheduler/company_info/constant/__init__.py +1 -1
  7. mns_scheduler/company_info/constant/company_constant_data.py +335 -224
  8. mns_scheduler/company_info/de_list_stock/__init__.py +1 -1
  9. mns_scheduler/company_info/de_list_stock/de_list_stock_service.py +1 -1
  10. mns_scheduler/company_info/em_stock_info/sync_em_stock_info_sync.py +134 -0
  11. mns_scheduler/company_info/sync/company_info_set_service.py +208 -0
  12. mns_scheduler/company_info/sync/sync_company_info_task.py +203 -0
  13. mns_scheduler/company_info/task/company_announce_info_task.py +77 -0
  14. mns_scheduler/company_info/task/company_base_info_task.py +64 -0
  15. mns_scheduler/company_info/task/company_business_info_task.py +177 -0
  16. mns_scheduler/company_info/task/company_hold_info_task.py +66 -0
  17. mns_scheduler/company_info/task/company_industry_info_task.py +167 -0
  18. mns_scheduler/company_info/task/company_total_task.py +69 -0
  19. mns_scheduler/concept/clean/kpl_concept_clean_api.py +1 -1
  20. mns_scheduler/concept/clean/ths_concept_clean_api.py +20 -4
  21. mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +23 -18
  22. mns_scheduler/concept/ths/common/ths_concept_update_common_api.py +4 -1
  23. mns_scheduler/concept/ths/detaill/ths_concept_detail_api.py +7 -7
  24. mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py +9 -4
  25. mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +2 -2
  26. mns_scheduler/db/col_move_service.py +3 -3
  27. mns_scheduler/db/script/__init__.py +1 -1
  28. mns_scheduler/db/script/col_move_script.py +1 -1
  29. mns_scheduler/db/script/db_move/__init__.py +7 -0
  30. mns_scheduler/db/script/db_move/col_move_one_service.py +34 -0
  31. mns_scheduler/db/script/sync/__init__.py +1 -1
  32. mns_scheduler/db/script/sync/remote_data_sync_to_local.py +65 -4
  33. mns_scheduler/db/script/sync/sync_hui_ce_test_data.py +80 -0
  34. mns_scheduler/db/script/sync/sync_hui_ce_test_data_01.py +69 -0
  35. mns_scheduler/db/script/update/__init__.py +7 -0
  36. mns_scheduler/db/script/update/update_col_field.py +36 -0
  37. mns_scheduler/finance/__init__.py +1 -1
  38. mns_scheduler/finance/em/__init__.py +7 -0
  39. mns_scheduler/finance/{em_financial_asset_liability_sync_service_api.py → em/em_financial_asset_liability_sync_service_api.py} +2 -2
  40. mns_scheduler/finance/{em_financial_profit_sync_service_api.py → em/em_financial_profit_sync_service_api.py} +27 -26
  41. mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +3 -3
  42. mns_scheduler/finance/{sync_financial_report_service_api.py → sync_financial_report_service_task.py} +80 -27
  43. mns_scheduler/finance/xue_qiu/__init__.py +7 -0
  44. mns_scheduler/finance/xue_qiu/down_load_xueqiu_report_api.py +77 -0
  45. mns_scheduler/finance/xue_qiu/sync_xue_qiu_fiance_data.py +161 -0
  46. mns_scheduler/hk/__init__.py +1 -1
  47. mns_scheduler/hk/hk_company_info_sync_service_api.py +4 -4
  48. mns_scheduler/hk/hk_industry_info_sync_service_api.py +3 -5
  49. mns_scheduler/industry/__init__.py +7 -0
  50. mns_scheduler/industry/ths/__init__.py +7 -0
  51. mns_scheduler/industry/ths/ths_industry_index_service.py +58 -0
  52. mns_scheduler/industry/ths/ths_industry_sync_service.py +68 -0
  53. mns_scheduler/irm/__init__.py +1 -1
  54. mns_scheduler/irm/api/__init__.py +1 -1
  55. mns_scheduler/irm/api/sh_stock_sns_sse_info_api.py +8 -58
  56. mns_scheduler/irm/api/sz_stock_sns_sse_info_api.py +15 -26
  57. mns_scheduler/irm/stock_irm_cninfo_service.py +43 -31
  58. mns_scheduler/irm/stock_question_id_service.py +169 -0
  59. mns_scheduler/k_line/clean/daily/__init__.py +1 -1
  60. mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py +52 -6
  61. mns_scheduler/k_line/clean/daily/daily_k_line_service.py +7 -2
  62. mns_scheduler/k_line/clean/k_line_info_clean_impl.py +3 -2
  63. mns_scheduler/k_line/clean/k_line_info_clean_task.py +42 -15
  64. mns_scheduler/k_line/clean/week_month/__init__.py +1 -1
  65. mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py +124 -26
  66. mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py +2 -2
  67. mns_scheduler/k_line/common/__init__.py +7 -0
  68. mns_scheduler/k_line/common/k_line_common_api.py +188 -0
  69. mns_scheduler/k_line/hot_stocks/__init__.py +1 -1
  70. mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py +1 -1
  71. mns_scheduler/k_line/{sync → month_week_daily}/bfq_k_line_sync.py +14 -29
  72. mns_scheduler/k_line/{sync → month_week_daily}/daily_week_month_line_sync.py +11 -12
  73. mns_scheduler/k_line/sync_status/__init__.py +7 -0
  74. mns_scheduler/k_line/sync_status/k_line_sync_status_check.py +54 -0
  75. mns_scheduler/k_line/test/__init__.py +1 -1
  76. mns_scheduler/k_line/test/k_line_info_clean_his_data.py +14 -3
  77. mns_scheduler/k_line/year_quarter/__init__.py +7 -0
  78. mns_scheduler/k_line/year_quarter/year_quarter_line_sync.py +76 -0
  79. mns_scheduler/kpl/selection/symbol/sync_best_choose_symbol.py +1 -2
  80. mns_scheduler/kpl/selection/symbol/sync_kpl_concept_symbol_choose_reason_api.py +108 -0
  81. mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py +5 -0
  82. mns_scheduler/lhb/__init__.py +1 -1
  83. mns_scheduler/lhb/stock_lhb_sync_service.py +1 -1
  84. mns_scheduler/open/__init__.py +1 -1
  85. mns_scheduler/open/sync_one_day_open_data_to_db_service.py +2 -3
  86. mns_scheduler/risk/__init__.py +1 -1
  87. mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +8 -2
  88. mns_scheduler/risk/financial/annual_report_audit_check_api.py +13 -3
  89. mns_scheduler/risk/financial/net_assets_check_api.py +21 -18
  90. mns_scheduler/risk/financial/profit_income_check_api.py +7 -2
  91. mns_scheduler/risk/financial_report_risk_check_api.py +1 -1
  92. mns_scheduler/risk/major_violations/register_and_investigate_stock_sync_api.py +1 -1
  93. mns_scheduler/risk/self/wei_pan_stock_api.py +1 -1
  94. mns_scheduler/risk/test/__init__.py +1 -1
  95. mns_scheduler/risk/test/fix_blask_list.py +4 -6
  96. mns_scheduler/risk/transactions/transactions_check_api.py +22 -4
  97. mns_scheduler/self_choose/__init__.py +1 -1
  98. mns_scheduler/self_choose/ths_self_choose_service.py +99 -43
  99. mns_scheduler/trade/auto_login/trader_auto_service.py +7 -4
  100. mns_scheduler/trade/auto_sell_service_api.py +4 -4
  101. mns_scheduler/trade/balance/__init__.py +7 -0
  102. mns_scheduler/trade/balance/ths_account_balance_service.py +7 -0
  103. mns_scheduler/trade/sync_position_api.py +39 -6
  104. mns_scheduler/trade/task/trader_task_service.py +38 -10
  105. mns_scheduler/trade/tfp/__init__.py +7 -0
  106. mns_scheduler/trade/tfp/stock_tfp_info_sync.py +56 -0
  107. mns_scheduler/zb/stock_zb_pool_sync.py +1 -16
  108. mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +2 -2
  109. mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +1 -1
  110. mns_scheduler/zt/script/__init__.py +1 -1
  111. mns_scheduler/zt/script/fix_error_deal_day.py +41 -0
  112. mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py +2 -2
  113. mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +2 -2
  114. mns_scheduler/zt/script/sync_now_higt_chg_zt.py +8 -7
  115. mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +260 -83
  116. mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +33 -90
  117. mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +27 -13
  118. mns_scheduler/zz_task/compensation/__init__.py +0 -0
  119. mns_scheduler/zz_task/compensation/compensate_task.py +161 -0
  120. mns_scheduler/zz_task/compensation/compensate_task_one_day.py +142 -0
  121. mns_scheduler/zz_task/data_sync_task.py +197 -103
  122. {mns_scheduler-1.1.8.4.dist-info → mns_scheduler-1.4.5.7.dist-info}/METADATA +1 -1
  123. mns_scheduler-1.4.5.7.dist-info/RECORD +176 -0
  124. {mns_scheduler-1.1.8.4.dist-info → mns_scheduler-1.4.5.7.dist-info}/WHEEL +1 -1
  125. mns_scheduler/2014-2015-test/2014_2015_chg_statistics.py +0 -87
  126. mns_scheduler/big_deal/ths_big_deal_sync.py +0 -98
  127. mns_scheduler/company_info/base/sync_company_base_info_api.py +0 -439
  128. mns_scheduler/company_info/base/sync_company_hold_info_api.py +0 -40
  129. mns_scheduler/company_info/remark/company_remark_info_sync.py +0 -46
  130. mns_scheduler/db/real_time_task_check.py +0 -84
  131. mns_scheduler/debt/kzz_bond_info_sync.py +0 -33
  132. mns_scheduler-1.1.8.4.dist-info/RECORD +0 -142
  133. /mns_scheduler/{2014-2015-test → auto_da_ban}/__init__.py +0 -0
  134. /mns_scheduler/company_info/{base → common}/__init__.py +0 -0
  135. /mns_scheduler/{big_deal → company_info/em_stock_info}/__init__.py +0 -0
  136. /mns_scheduler/company_info/{remark → sync}/__init__.py +0 -0
  137. /mns_scheduler/{debt → company_info/task}/__init__.py +0 -0
  138. /mns_scheduler/k_line/{sync → month_week_daily}/__init__.py +0 -0
  139. {mns_scheduler-1.1.8.4.dist-info → mns_scheduler-1.4.5.7.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,10 @@
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
- end = file_path.index('mns') + 16
7
+ end = file_path.index('mns') + 17
6
8
  project_path = file_path[0:end]
7
9
  sys.path.append(project_path)
8
10
 
@@ -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
 
@@ -228,7 +230,7 @@ def get_em_profit_api(symbol):
228
230
  stock_profit_sheet_by_report_em = ak.stock_profit_sheet_by_report_em(sec_code)
229
231
  except Exception as e:
230
232
  logger.error("同步利润表异常:{},{}", symbol, e)
231
- if data_frame_util.is_empty(stock_profit_sheet_by_report_em):
233
+ if data_frame_util.is_empty(stock_profit_sheet_by_report_em.copy()):
232
234
  return None
233
235
  stock_profit_sheet_by_report_em = check_columns(stock_profit_sheet_by_report_em)
234
236
  stock_profit_sheet_by_report_em = stock_profit_sheet_by_report_em[[
@@ -293,57 +295,56 @@ 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
297
- new_profit_df.fillna(0, inplace=True)
298
+ return pd.DataFrame()
299
+ new_profit_df = new_profit_df.fillna(0)
298
300
  return new_profit_df
299
301
 
300
302
 
301
303
  def check_columns(profit_df):
302
304
  if 'TOTAL_OPERATE_INCOME' not in profit_df.columns:
303
- profit_df['TOTAL_OPERATE_INCOME'] = 0
305
+ profit_df = profit_df.assign(TOTAL_OPERATE_INCOME=0)
304
306
 
305
307
  if 'FAIRVALUE_CHANGE_INCOME' not in profit_df.columns:
306
- profit_df['FAIRVALUE_CHANGE_INCOME'] = 0
308
+ profit_df = profit_df.assign(FAIRVALUE_CHANGE_INCOME=0)
307
309
 
308
310
  if 'INTEREST_INCOME' not in profit_df.columns:
309
- profit_df['INTEREST_INCOME'] = 0
311
+ profit_df = profit_df.assign(INTEREST_INCOME=0)
310
312
  if 'TOTAL_OPERATE_COST' not in profit_df.columns:
311
- profit_df['TOTAL_OPERATE_COST'] = 0
313
+ profit_df = profit_df.assign(TOTAL_OPERATE_COST=0)
312
314
  if 'OPERATE_COST' not in profit_df.columns:
313
- profit_df['OPERATE_COST'] = 0
315
+ profit_df = profit_df.assign(OPERATE_COST=0)
314
316
  if 'INTEREST_EXPENSE' not in profit_df.columns:
315
- profit_df['INTEREST_EXPENSE'] = 0
317
+ profit_df = profit_df.assign(INTEREST_EXPENSE=0)
316
318
  if 'FEE_COMMISSION_EXPENSE' not in profit_df.columns:
317
- profit_df['FEE_COMMISSION_EXPENSE'] = 0
319
+ profit_df = profit_df.assign(FEE_COMMISSION_EXPENSE=0)
318
320
  if 'RESEARCH_EXPENSE' not in profit_df.columns:
319
- profit_df['RESEARCH_EXPENSE'] = 0
321
+ profit_df = profit_df.assign(RESEARCH_EXPENSE=0)
320
322
  if 'SALE_EXPENSE' not in profit_df.columns:
321
- profit_df['SALE_EXPENSE'] = 0
323
+ profit_df = profit_df.assign(SALE_EXPENSE=0)
322
324
  if 'MANAGE_EXPENSE' not in profit_df.columns:
323
- profit_df['MANAGE_EXPENSE'] = 0
325
+ profit_df = profit_df.assign(MANAGE_EXPENSE=0)
324
326
  if 'FINANCE_EXPENSE' not in profit_df.columns:
325
- profit_df['FINANCE_EXPENSE'] = 0
327
+ profit_df = profit_df.assign(FINANCE_EXPENSE=0)
326
328
  if 'FE_INTEREST_EXPENSE' not in profit_df.columns:
327
- profit_df['FE_INTEREST_EXPENSE'] = 0
329
+ profit_df = profit_df.assign(FE_INTEREST_EXPENSE=0)
328
330
  if 'FE_INTEREST_INCOME' not in profit_df.columns:
329
- profit_df['FE_INTEREST_INCOME'] = 0
331
+ profit_df = profit_df.assign(FE_INTEREST_INCOME=0)
330
332
  if 'CREDIT_IMPAIRMENT_INCOME' not in profit_df.columns:
331
- profit_df['CREDIT_IMPAIRMENT_INCOME'] = 0
333
+ profit_df = profit_df.assign(CREDIT_IMPAIRMENT_INCOME=0)
332
334
  if 'ACCOUNTS_RECE' not in profit_df.columns:
333
- profit_df['ACCOUNTS_RECE'] = 0
334
-
335
+ profit_df = profit_df.assign(ACCOUNTS_RECE=0)
335
336
  if 'LOAN_ADVANCE' not in profit_df.columns:
336
- profit_df['LOAN_ADVANCE'] = 0
337
+ profit_df = profit_df.assign(LOAN_ADVANCE=0)
337
338
  if 'MONETARYFUNDS' not in profit_df.columns:
338
- profit_df['MONETARYFUNDS'] = 0
339
+ profit_df = profit_df.assign(MONETARYFUNDS=0)
339
340
  return profit_df
340
341
 
341
342
 
342
- import mns_common.api.em.east_money_stock_api as east_money_stock_api
343
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
343
344
 
344
345
  if __name__ == '__main__':
345
- get_em_profit_api('600519')
346
- em_df = east_money_stock_api.get_real_time_quotes_all_stocks()
346
+ get_em_profit_api('688302')
347
+ em_df = em_stock_info_api.get_a_stock_info()
347
348
  for em_one in em_df.itertuples():
348
349
  try:
349
350
  get_em_profit_api(em_one.symbol)
@@ -2,14 +2,14 @@ import sys
2
2
  import os
3
3
 
4
4
  file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 16
5
+ end = file_path.index('mns') + 17
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
 
9
9
  import mns_common.component.common_service_fun_api as common_service_fun_api
10
10
  from mns_common.db.MongodbUtil import MongodbUtil
11
11
  import mns_common.constant.db_name_constant as db_name_constant
12
- import mns_common.api.em.east_money_stock_api as east_money_stock_api
12
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
13
13
  import mns_common.utils.data_frame_util as data_frame_util
14
14
 
15
15
  mongodb_util = MongodbUtil('27017')
@@ -39,7 +39,7 @@ def find_asset_liability_report(period_time):
39
39
 
40
40
  # 查出未报告的股票
41
41
  def find_un_report_symbol(period_time, report_name):
42
- real_time_quotes_df = east_money_stock_api.get_real_time_quotes_all_stocks()
42
+ real_time_quotes_df = em_stock_info_api.get_a_stock_info()
43
43
  real_time_quotes_df = real_time_quotes_df.loc[~(real_time_quotes_df['name'].str.contains('退'))]
44
44
  real_time_quotes_df.dropna(subset=['list_date'], axis=0, inplace=True)
45
45
 
@@ -2,21 +2,22 @@ import sys
2
2
  import os
3
3
 
4
4
  file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 16
5
+ end = file_path.index('mns') + 17
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
8
  from datetime import datetime
9
9
 
10
10
  import mns_common.constant.db_name_constant as db_name_constant
11
- import mns_scheduler.finance.em_financial_profit_sync_service_api as em_financial_profit_sync_service_api
11
+ import mns_scheduler.finance.em.em_financial_profit_sync_service_api as em_financial_profit_sync_service_api
12
12
  from mns_common.db.MongodbUtil import MongodbUtil
13
13
  from loguru import logger
14
14
  import \
15
- mns_scheduler.finance.em_financial_asset_liability_sync_service_api as em_financial_asset_liability_sync_service_api
15
+ mns_scheduler.finance.em.em_financial_asset_liability_sync_service_api as em_financial_asset_liability_sync_service_api
16
16
  import mns_scheduler.risk.financial_report_risk_check_api as financial_report_risk_check_api
17
17
  import mns_common.utils.data_frame_util as data_frame_util
18
- import mns_scheduler.finance.finance_common_api as finance_common_api
18
+ import mns_scheduler.finance.em.finance_common_api as finance_common_api
19
19
  import mns_scheduler.risk.compliance.undisclosed_annual_report_api as undisclosed_annual_report_api
20
+ import mns_scheduler.finance.xue_qiu.sync_xue_qiu_fiance_data as sync_xue_qiu_fiance_data
20
21
 
21
22
  mongodb_util = MongodbUtil('27017')
22
23
 
@@ -26,39 +27,90 @@ mongodb_util = MongodbUtil('27017')
26
27
  # 3、上市公司季报披露时间:
27
28
  # 1季报:每年4月1日-- -4月30日。
28
29
  # 2季报(中报) :每年7月1日--8月30日。
29
- # 3季报:每年10月1日--10月31日4季报(年报) :每年1月1日--4月30日
30
+ # 3季报:每年10月1日--10月31日
31
+ # 4季报(年报) :每年1月1日--4月30日
30
32
 
31
33
  def sync_financial_report():
32
34
  now_date = datetime.now()
33
35
  now_year = now_date.year
34
36
  now_month = now_date.month
35
37
  sync_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
36
- # 年报
37
- if 1 <= now_month <= 5:
38
+
39
+ if now_month in [1, 2, 3, 4]:
40
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year - 1) + '年报', None)
41
+
42
+ # 年报
38
43
  period = 4
39
44
  period_time = str(now_year - 1) + "-12-31 00:00:00"
40
- sync_profit_report(period_time, sync_time, period)
41
- sync_asset_liability_report(period_time, sync_time, period)
45
+ sync_em_profit_report(period_time, sync_time, period)
46
+ sync_em_asset_liability_report(period_time, sync_time, period)
47
+
48
+ # 一季报
49
+ if now_month == 4:
50
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '一季报', None)
51
+
52
+ period = 1
53
+ period_time = str(now_year) + "-03-31 00:00:00"
54
+ sync_em_profit_report(period_time, sync_time, period)
55
+ sync_em_asset_liability_report(period_time, sync_time, period)
56
+
42
57
 
43
- # 一季报
44
- elif now_month == 5:
45
- period = 1
46
- period_time = str(now_year) + "-03-31 00:00:00"
47
- sync_profit_report(period_time, sync_time, period)
48
- sync_asset_liability_report(period_time, sync_time, period)
49
58
 
50
59
  # 二季报
51
- elif 7 <= now_month <= 8:
60
+ elif now_month in [7, 8]:
61
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '中报', None)
62
+
52
63
  period = 2
53
64
  period_time = str(now_year) + "-06-30 00:00:00"
54
- sync_profit_report(period_time, sync_time, period)
55
- sync_asset_liability_report(period_time, sync_time, period)
65
+ sync_em_profit_report(period_time, sync_time, period)
66
+ sync_em_asset_liability_report(period_time, sync_time, period)
67
+
68
+
69
+
56
70
  # 三季报
57
71
  elif now_month == 10:
72
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '三季报', None)
73
+
58
74
  period = 3
59
75
  period_time = str(now_year) + "-09-30 00:00:00"
60
- sync_profit_report(period_time, sync_time, period)
61
- sync_asset_liability_report(period_time, sync_time, period)
76
+ sync_em_profit_report(period_time, sync_time, period)
77
+ sync_em_asset_liability_report(period_time, sync_time, period)
78
+
79
+ elif now_month == 5:
80
+
81
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year - 1) + '年报', None)
82
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '一季报', None)
83
+
84
+ # 补偿年报和一季度,出不了报告的
85
+ miss_period_04 = 4
86
+ miss_period_time_04 = str(now_year - 1) + "-12-31 00:00:00"
87
+
88
+ sync_em_profit_report(miss_period_time_04, sync_time, miss_period_04)
89
+ sync_em_asset_liability_report(miss_period_time_04, sync_time, miss_period_04)
90
+
91
+ period_01 = 1
92
+ period_time_01 = str(now_year) + "-03-31 00:00:00"
93
+ sync_em_profit_report(period_time_01, sync_time, period_01)
94
+ sync_em_asset_liability_report(period_time_01, sync_time, period_01)
95
+
96
+ elif now_month == 9:
97
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '中报', None)
98
+
99
+ # 补偿二季度
100
+ period_02 = 2
101
+ period_time_02 = str(now_year) + "-06-30 00:00:00"
102
+ sync_em_profit_report(period_time_02, sync_time, period_02)
103
+ sync_em_asset_liability_report(period_time_02, sync_time, period_02)
104
+
105
+ elif now_month in [11, 12]:
106
+ sync_xue_qiu_fiance_data.sync_xue_qiu_very_period_report(str(now_year) + '三季报', None)
107
+
108
+ # 补偿三季度
109
+ period_03 = 3
110
+ period_time_03 = str(now_year) + "-09-30 00:00:00"
111
+ sync_em_profit_report(period_time_03, sync_time, period_03)
112
+ sync_em_asset_liability_report(period_time_03, sync_time, period_03)
113
+
62
114
  # 未出报告check
63
115
  undisclosed_annual_report_api.un_disclosed_report_check(sync_time, now_year, period, period_time)
64
116
  # 新股或者未出报告的
@@ -66,7 +118,7 @@ def sync_financial_report():
66
118
 
67
119
 
68
120
  # 同步资产表
69
- def sync_asset_liability_report(period_time, sync_time, period):
121
+ def sync_em_asset_liability_report(period_time, sync_time, period):
70
122
  un_report_asset_df = finance_common_api.find_un_report_symbol(period_time,
71
123
  db_name_constant.EM_STOCK_ASSET_LIABILITY)
72
124
  for un_report_asset_one in un_report_asset_df.itertuples():
@@ -91,8 +143,8 @@ def sync_asset_liability_report(period_time, sync_time, period):
91
143
  logger.error("同步资产表异常:{},{},{}", symbol, period_time, e)
92
144
 
93
145
 
94
- # 同步利润表
95
- def sync_profit_report(period_time, sync_time, period):
146
+ # 同步em利润表
147
+ def sync_em_profit_report(period_time, sync_time, period):
96
148
  un_report_profit_df = finance_common_api.find_un_report_symbol(period_time, db_name_constant.EM_STOCK_PROFIT)
97
149
  for un_report_profit_one in un_report_profit_df.itertuples():
98
150
  try:
@@ -142,8 +194,9 @@ def sync_miss_report(sync_time):
142
194
 
143
195
 
144
196
  if __name__ == '__main__':
145
- now_date = datetime.now()
146
- now_year = now_date.year
147
- now_month = now_date.month
148
- sync_time_test = now_date.strftime('%Y-%m-%d %H:%M:%S')
197
+ now_date_test = datetime.now()
198
+ now_year_test = now_date_test.year
199
+ now_month_test = now_date_test.month
200
+ sync_time_test = now_date_test.strftime('%Y-%m-%d %H:%M:%S')
149
201
  sync_miss_report(sync_time_test)
202
+ sync_financial_report()
@@ -0,0 +1,7 @@
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)
@@ -0,0 +1,77 @@
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
+ import requests
9
+ import pandas as pd
10
+ from loguru import logger
11
+
12
+
13
+ # report_type income 利润表
14
+ # cash_flow 现金流量
15
+ # balance 资产负债
16
+
17
+
18
+ def get_xue_qiu_report(symbol, report_type, cookie, count, period_type):
19
+ # 请求 URL
20
+ url = (f"https://stock.xueqiu.com/v5/stock/finance/cn/{report_type}.json?symbol={symbol}&type={period_type}"
21
+ f"&is_detail=true&count={count}")
22
+
23
+ # 请求头(关键是 cookies)
24
+ headers = {
25
+ "accept": "application/json, text/plain, */*",
26
+ "accept-language": "zh-CN,zh;q=0.9",
27
+ "origin": "https://xueqiu.com",
28
+ "referer": f"https://xueqiu.com/snowman/S/{symbol}/detail",
29
+ "sec-fetch-mode": "cors",
30
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
31
+ # ⚠ 替换为你浏览器访问雪球后的 Cookie(需含 xq_a_token)
32
+ "cookie": cookie,
33
+ }
34
+
35
+ # 发送请求
36
+ response = requests.get(url, headers=headers)
37
+
38
+ # 检查结果
39
+ if response.status_code == 200:
40
+ data = response.json()
41
+
42
+ # 提取财报数据列表
43
+ raw_list = data['data']['list']
44
+ processed_list = []
45
+
46
+ for entry in raw_list:
47
+ flat_entry = {}
48
+ for key, value in entry.items():
49
+ if isinstance(value, list) and len(value) == 2:
50
+ # 处理列表字段:提取两个值,空则填 0
51
+ v0 = value[0] if value[0] is not None else 0
52
+ v1 = value[1] if value[1] is not None else 0
53
+ flat_entry[key] = v0
54
+ flat_entry[key + "_chg"] = round(v1 * 100, 2)
55
+ elif value is None:
56
+ # 整个字段为空,设置为 0 和 0(变化量)
57
+ flat_entry[key] = 0
58
+ else:
59
+ flat_entry[key] = value
60
+ processed_list.append(flat_entry)
61
+
62
+ # 转换为 DataFrame
63
+ df = pd.DataFrame(processed_list)
64
+ return df
65
+
66
+ else:
67
+ logger.error("请求失败,状态码:{}", response.status_code)
68
+ return pd.DataFrame()
69
+
70
+
71
+ import mns_common.component.cookie.cookie_info_service as cookie_info_service
72
+
73
+ if __name__ == '__main__':
74
+ cash_flow_df = get_xue_qiu_report('SZ301662', 'cash_flow', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
75
+ income_df = get_xue_qiu_report('SZ301662', 'income', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
76
+ balance_df = get_xue_qiu_report('SZ301662', 'balance', cookie_info_service.get_xue_qiu_cookie(), 1, 'all')
77
+ pass
@@ -0,0 +1,161 @@
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
+ from mns_common.db.MongodbUtil import MongodbUtil
10
+ import mns_common.constant.extra_income_db_name as extra_income_db_name
11
+ import mns_scheduler.finance.xue_qiu.down_load_xueqiu_report_api as down_load_xueqiu_report_api
12
+ import mns_common.component.common_service_fun_api as common_service_fun_api
13
+ import pandas as pd
14
+ from loguru import logger
15
+ import time
16
+ import mns_common.utils.data_frame_util as data_frame_util
17
+ import mns_common.component.cookie.cookie_info_service as cookie_info_service
18
+ from datetime import datetime
19
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
20
+
21
+ mongodb_util_27017 = MongodbUtil('27017')
22
+
23
+
24
+ # report_type income 利润表
25
+ # cash_flow 现金流量
26
+ # balance 资产负债
27
+ # 同步所有股票 报表
28
+ def sync_all_stocks_report():
29
+ em_a_stock_info_df = em_stock_info_api.get_a_stock_info()
30
+ em_a_stock_info_df = common_service_fun_api.add_pre_prefix(em_a_stock_info_df)
31
+ # 或等效写法 df['A'].str[0:6]
32
+
33
+ fail_list = []
34
+
35
+ xue_qiu_cookie = cookie_info_service.get_xue_qiu_cookie()
36
+ report_type_list = ['income', 'balance', 'cash_flow']
37
+ for stock_one in em_a_stock_info_df.itertuples():
38
+ fail_list = save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, True, fail_list, '', False)
39
+
40
+ handle_number = 0
41
+ # 处理失败的
42
+ while len(fail_list) > 0:
43
+ fail_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'].isin(fail_list)]
44
+ for fail_one in fail_df.itertuples():
45
+ fail_list = save_one_symbol_data(fail_one, report_type_list, xue_qiu_cookie, True, fail_list, '', False)
46
+ handle_number = handle_number + 1
47
+ if handle_number > 10:
48
+ break
49
+
50
+
51
+ def save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, save_tag, fail_list, report_name, check_exist):
52
+ try:
53
+ symbol_prefix = stock_one.symbol_prefix
54
+ name = stock_one.name
55
+ symbol = stock_one.symbol
56
+ for report_type in report_type_list:
57
+ if report_type == 'income':
58
+ col_name = extra_income_db_name.XUE_QIU_LRB_INCOME
59
+ elif report_type == 'balance':
60
+ col_name = extra_income_db_name.XUE_QIU_ASSET_DEBT
61
+ elif report_type == 'cash_flow':
62
+ col_name = extra_income_db_name.XUE_QIU_CASH_FLOW
63
+ if check_exist:
64
+ query_exist = {'symbol': symbol, 'report_name': report_name}
65
+ # 存在数据 不在同步
66
+ if mongodb_util_27017.exist_data_query(col_name, query_exist):
67
+ continue
68
+
69
+ index_create = [('symbol', 1), ('report_date', 1)]
70
+ mongodb_util_27017.create_index(col_name, index_create)
71
+
72
+ index_create_01 = [('symbol', 1), ('sync_time', 1)]
73
+ mongodb_util_27017.create_index(col_name, index_create_01)
74
+
75
+ if check_exist:
76
+ # 季度同步只同步一条数据
77
+ result_df = down_load_xueqiu_report_api.get_xue_qiu_report(symbol_prefix, report_type, xue_qiu_cookie,
78
+ 1,
79
+ 'all')
80
+ else:
81
+ result_df = down_load_xueqiu_report_api.get_xue_qiu_report(symbol_prefix, report_type, xue_qiu_cookie,
82
+ 200,
83
+ 'all')
84
+
85
+ now_date = datetime.now()
86
+ sync_time = now_date.strftime('%Y-%m-%d %H:%M:%S')
87
+
88
+ if data_frame_util.is_empty(result_df):
89
+ logger.error("财务信息为空,代码:{}:{}", symbol, name)
90
+ continue
91
+ else:
92
+ # 季度同步check
93
+ if check_exist:
94
+ result_df = result_df.loc[result_df['report_name'] == report_name]
95
+ if data_frame_util.is_empty(result_df):
96
+ continue
97
+
98
+ result_df['sync_time'] = sync_time
99
+ time.sleep(0.5)
100
+ # 1. 将毫秒时间戳转为 datetime
101
+ result_df['report_date'] = pd.to_datetime(result_df['report_date'], unit='ms')
102
+
103
+ # 2. 格式化为 '%Y-%m-%d' 字符串
104
+ result_df['report_date'] = result_df['report_date'].dt.strftime('%Y-%m-%d')
105
+
106
+ result_df['_id'] = symbol + '_' + result_df['report_date']
107
+ result_df['symbol'] = symbol
108
+
109
+ # 1. 将毫秒时间戳转为 datetime
110
+ result_df['ctime'] = pd.to_datetime(result_df['ctime'], unit='ms')
111
+
112
+ # 2. 格式化为 '%Y-%m-%d' 字符串
113
+ result_df['ctime'] = result_df['ctime'].dt.strftime('%Y-%m-%d')
114
+ result_df.loc[result_df['report_name'].str.contains('年报'), 'period'] = 4
115
+ result_df.loc[result_df['report_name'].str.contains('一季报'), 'period'] = 1
116
+ result_df.loc[result_df['report_name'].str.contains('中报'), 'period'] = 2
117
+ result_df.loc[result_df['report_name'].str.contains('三季报'), 'period'] = 3
118
+ result_df['year'] = result_df['report_name'].str[:4]
119
+ if save_tag:
120
+ mongodb_util_27017.save_mongo(result_df, col_name)
121
+ else:
122
+ mongodb_util_27017.insert_mongo(result_df, col_name)
123
+
124
+ if symbol in fail_list:
125
+ fail_list.remove(symbol)
126
+ logger.info("同步财务数据完成:{}:{}", symbol, name, report_name)
127
+ except BaseException as e:
128
+ logger.error("同步错误:{},异常信息:{}", symbol, e)
129
+ fail_list.append(symbol)
130
+ return fail_list
131
+
132
+
133
+ def sync_xue_qiu_very_period_report(report_name, symbol):
134
+ em_a_stock_info_df = em_stock_info_api.get_a_stock_info()
135
+ if symbol is not None:
136
+ em_a_stock_info_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'] == symbol]
137
+ em_a_stock_info_df = common_service_fun_api.add_pre_prefix(em_a_stock_info_df)
138
+ # 或等效写法 df['A'].str[0:6]
139
+
140
+ fail_list = []
141
+
142
+ xue_qiu_cookie = cookie_info_service.get_xue_qiu_cookie()
143
+ report_type_list = ['income', 'balance', 'cash_flow']
144
+ for stock_one in em_a_stock_info_df.itertuples():
145
+ fail_list = save_one_symbol_data(stock_one, report_type_list, xue_qiu_cookie, False, fail_list, report_name,
146
+ True)
147
+
148
+ handle_number = 0
149
+ # 处理失败的
150
+ while len(fail_list) > 0:
151
+ fail_df = em_a_stock_info_df.loc[em_a_stock_info_df['symbol'].isin(fail_list)]
152
+ for fail_one in fail_df.itertuples():
153
+ fail_list = save_one_symbol_data(fail_one, report_type_list, xue_qiu_cookie, False, fail_list, report_name,
154
+ True)
155
+ handle_number = handle_number + 1
156
+ if handle_number > 10:
157
+ break
158
+
159
+
160
+ if __name__ == '__main__':
161
+ sync_all_stocks_report()
@@ -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') + 16
5
+ end = file_path.index('mns') + 17
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
@@ -2,10 +2,10 @@ import sys
2
2
  import os
3
3
 
4
4
  file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 16
5
+ end = file_path.index('mns') + 17
6
6
  project_path = file_path[0:end]
7
7
  sys.path.append(project_path)
8
- import mns_common.api.em.east_money_stock_hk_api as east_money_stock_hk_api
8
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
9
9
  import akshare as ak
10
10
  import mns_common.constant.db_name_constant as db_name_constant
11
11
  from mns_common.db.MongodbUtil import MongodbUtil
@@ -48,8 +48,7 @@ def get_ths_cookie():
48
48
 
49
49
  # https://quote.eastmoney.com/center/gridlist.html#hk_stocks
50
50
  def sync_hk_company_info():
51
- cookie = get_em_cookie()
52
- hk_real_time_df = east_money_stock_hk_api.hk_real_time_quotes(cookie)
51
+ hk_real_time_df = em_stock_info_api.get_hk_stock_info()
53
52
 
54
53
  hk_real_time_df = hk_real_time_df[[
55
54
  "symbol",
@@ -100,4 +99,5 @@ def sync_hk_company_info():
100
99
 
101
100
 
102
101
  if __name__ == '__main__':
102
+ get_hk_ggt_component()
103
103
  sync_hk_company_info()
@@ -2,16 +2,15 @@ import sys
2
2
  import os
3
3
 
4
4
  file_path = os.path.abspath(__file__)
5
- end = file_path.index('mns') + 16
5
+ 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.api.em.east_money_stock_hk_api as east_money_stock_hk_api
9
+ import mns_common.component.em.em_stock_info_api as em_stock_info_api
10
10
  import akshare as ak
11
11
  import mns_common.constant.db_name_constant as db_name_constant
12
12
  from mns_common.db.MongodbUtil import MongodbUtil
13
13
  from functools import lru_cache
14
- import mns_common.component.common_service_fun_api as common_service_fun_api
15
14
  import mns_common.component.zt.zt_common_service_api as zt_common_service_api
16
15
 
17
16
  mongodb_util = MongodbUtil('27017')
@@ -39,8 +38,7 @@ def get_em_cookie():
39
38
 
40
39
 
41
40
  def sync_hk_company_industry():
42
- cookie = get_em_cookie()
43
- hk_real_time_df = east_money_stock_hk_api.hk_real_time_quotes(cookie)
41
+ hk_real_time_df = em_stock_info_api.get_hk_stock_info()
44
42
 
45
43
  hk_real_time_df = hk_real_time_df[[
46
44
  "symbol",
@@ -0,0 +1,7 @@
1
+ import sys
2
+ import os
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)
@@ -0,0 +1,7 @@
1
+ import sys
2
+ import os
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)