mns-scheduler 1.0.8.7__py3-none-any.whl → 1.4.3.2__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.
- mns_scheduler/__init__.py +1 -3
- mns_scheduler/company_info/announce/company_announce_sync_service.py +65 -0
- mns_scheduler/company_info/{company_info_sync_api.py → base/sync_company_base_info_api.py} +239 -227
- mns_scheduler/company_info/base/sync_company_hold_info_api.py +37 -0
- mns_scheduler/company_info/base/sync_company_product_area_industry.py +161 -0
- mns_scheduler/company_info/clean/company_info_clean_api.py +133 -0
- mns_scheduler/company_info/constant/company_constant_data.py +497 -0
- mns_scheduler/company_info/{de_list_stock_service.py → de_list_stock/de_list_stock_service.py} +1 -1
- mns_scheduler/company_info/em_stock_info/__init__.py +7 -0
- mns_scheduler/company_info/em_stock_info/sync_em_stock_info_sync.py +80 -0
- mns_scheduler/company_info/remark/__init__.py +7 -0
- mns_scheduler/company_info/remark/company_remark_info_sync.py +46 -0
- mns_scheduler/concept/clean/kpl_concept_clean_api.py +1 -1
- mns_scheduler/concept/clean/ths_concept_clean_api.py +74 -51
- mns_scheduler/concept/ths/common/ths_concept_sync_common_api.py +112 -56
- mns_scheduler/concept/ths/common/ths_concept_update_common_api.py +6 -6
- mns_scheduler/concept/ths/detaill/__init__.py +0 -0
- mns_scheduler/concept/ths/detaill/ths_concept_detail_api.py +226 -0
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_new_index_api.py +169 -0
- mns_scheduler/concept/ths/update_concept_info/sync_one_concept_all_symbols_api.py +11 -23
- mns_scheduler/concept/ths/update_concept_info/sync_one_symbol_all_concepts_api.py +19 -15
- mns_scheduler/db/col_move_service.py +10 -7
- mns_scheduler/db/db_status.py +1 -1
- mns_scheduler/db/script/__init__.py +7 -0
- mns_scheduler/db/script/col_move_script.py +45 -0
- mns_scheduler/db/script/db_move/__init__.py +7 -0
- mns_scheduler/db/script/db_move/col_move_one_service.py +34 -0
- mns_scheduler/db/script/sync/__init__.py +7 -0
- mns_scheduler/db/script/sync/local_mongo_util.py +231 -0
- mns_scheduler/db/script/sync/remote_data_sync_to_local.py +105 -0
- mns_scheduler/db/script/sync/remote_mongo_util.py +306 -0
- mns_scheduler/db/script/sync/sync_hui_ce_test_data.py +80 -0
- mns_scheduler/db/script/sync/sync_hui_ce_test_data_01.py +69 -0
- mns_scheduler/db/script/update/__init__.py +7 -0
- mns_scheduler/db/script/update/update_col_field.py +36 -0
- mns_scheduler/finance/__init__.py +1 -1
- mns_scheduler/finance/{em_financial_asset_liability_sync_service_api.py → em/em_financial_asset_liability_sync_service_api.py} +3 -3
- mns_scheduler/finance/{em_financial_profit_sync_service_api.py → em/em_financial_profit_sync_service_api.py} +30 -25
- mns_scheduler/finance/{finance_common_api.py → em/finance_common_api.py} +4 -4
- mns_scheduler/finance/sync_financial_report_service_task.py +202 -0
- mns_scheduler/finance/xue_qiu/down_load_xueqiu_report_api.py +77 -0
- mns_scheduler/finance/xue_qiu/sync_xue_qiu_fiance_data.py +161 -0
- mns_scheduler/hk/__init__.py +1 -1
- mns_scheduler/hk/hk_company_info_sync_service_api.py +49 -5
- mns_scheduler/hk/hk_industry_info_sync_service_api.py +68 -0
- mns_scheduler/industry/__init__.py +7 -0
- mns_scheduler/industry/ths/__init__.py +7 -0
- mns_scheduler/industry/ths/ths_industry_index_service.py +58 -0
- mns_scheduler/industry/ths/ths_industry_sync_service.py +68 -0
- mns_scheduler/irm/__init__.py +1 -1
- mns_scheduler/irm/api/__init__.py +1 -1
- mns_scheduler/irm/api/sh_stock_sns_sse_info_api.py +1 -1
- mns_scheduler/irm/api/sz_stock_sns_sse_info_api.py +1 -1
- mns_scheduler/irm/stock_irm_cninfo_service.py +15 -13
- mns_scheduler/k_line/clean/daily/__init__.py +1 -1
- mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py +57 -7
- mns_scheduler/k_line/clean/daily/daily_k_line_service.py +16 -3
- mns_scheduler/k_line/clean/k_line_info_clean_impl.py +3 -2
- mns_scheduler/k_line/clean/k_line_info_clean_task.py +42 -31
- mns_scheduler/k_line/clean/week_month/__init__.py +1 -1
- mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py +125 -27
- mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py +72 -17
- mns_scheduler/k_line/common/__init__.py +7 -0
- mns_scheduler/k_line/common/k_line_common_api.py +188 -0
- mns_scheduler/k_line/hot_stocks/__init__.py +1 -1
- mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py +1 -1
- mns_scheduler/k_line/month_week_daily/bfq_k_line_sync.py +77 -0
- mns_scheduler/k_line/{sync → month_week_daily}/daily_week_month_line_sync.py +14 -14
- mns_scheduler/k_line/sync_status/__init__.py +7 -0
- mns_scheduler/k_line/sync_status/k_line_sync_status_check.py +54 -0
- mns_scheduler/k_line/test/__init__.py +7 -0
- mns_scheduler/k_line/test/k_line_info_clean_his_data.py +41 -0
- mns_scheduler/k_line/year_quarter/__init__.py +7 -0
- mns_scheduler/k_line/year_quarter/year_quarter_line_sync.py +76 -0
- mns_scheduler/kpl/selection/symbol/sync_best_choose_symbol.py +4 -2
- mns_scheduler/kpl/selection/symbol/sync_kpl_concept_symbol_choose_reason_api.py +108 -0
- mns_scheduler/kpl/selection/total/sync_kpl_best_total_sync_api.py +12 -7
- mns_scheduler/lhb/__init__.py +1 -1
- mns_scheduler/lhb/stock_lhb_sync_service.py +1 -1
- mns_scheduler/open/__init__.py +1 -1
- mns_scheduler/open/sync_one_day_open_data_to_db_service.py +6 -22
- mns_scheduler/risk/__init__.py +1 -1
- mns_scheduler/risk/compliance/__init__.py +0 -0
- mns_scheduler/risk/compliance/undisclosed_annual_report_api.py +71 -0
- mns_scheduler/risk/financial/__init__.py +0 -0
- mns_scheduler/risk/financial/annual_report_audit_check_api.py +54 -0
- mns_scheduler/risk/financial/net_assets_check_api.py +75 -0
- mns_scheduler/risk/financial/profit_income_check_api.py +80 -0
- mns_scheduler/risk/financial/stock_equity_mortgage_check_api.py +1 -0
- mns_scheduler/risk/financial_report_risk_check_api.py +42 -0
- mns_scheduler/risk/major_violations/__init__.py +0 -0
- mns_scheduler/risk/{register_and_investigate_stock_sync_api.py → major_violations/register_and_investigate_stock_sync_api.py} +17 -8
- mns_scheduler/risk/self/__init__.py +0 -0
- mns_scheduler/risk/{wei_pan_stock_api.py → self/wei_pan_stock_api.py} +10 -4
- mns_scheduler/risk/test/__init__.py +7 -0
- mns_scheduler/{finance → risk}/test/fix_blask_list.py +6 -10
- mns_scheduler/risk/transactions/__init__.py +0 -0
- mns_scheduler/risk/transactions/transactions_check_api.py +183 -0
- mns_scheduler/self_choose/__init__.py +7 -0
- mns_scheduler/self_choose/ths_self_choose_service.py +158 -0
- mns_scheduler/trade/auto_ipo_buy_api.py +2 -2
- mns_scheduler/trade/auto_login/__init__.py +7 -0
- mns_scheduler/trade/auto_login/trader_auto_service.py +32 -0
- mns_scheduler/trade/auto_sell_service_api.py +10 -8
- mns_scheduler/trade/balance/__init__.py +7 -0
- mns_scheduler/trade/balance/ths_account_balance_service.py +7 -0
- mns_scheduler/trade/sync_position_api.py +41 -8
- mns_scheduler/trade/task/__init__.py +7 -0
- mns_scheduler/trade/task/trader_task_service.py +65 -0
- mns_scheduler/trade/tfp/__init__.py +7 -0
- mns_scheduler/trade/tfp/stock_tfp_info_sync.py +56 -0
- mns_scheduler/zb/stock_zb_pool_sync.py +1 -15
- mns_scheduler/zt/high_chg/sync_high_chg_pool_service.py +2 -3
- mns_scheduler/zt/high_chg/sync_high_chg_real_time_quotes_service.py +12 -8
- mns_scheduler/zt/open_data/kcx_high_chg_open_data_sync.py +10 -25
- mns_scheduler/zt/script/__init__.py +1 -1
- mns_scheduler/zt/script/fix_error_deal_day.py +41 -0
- mns_scheduler/zt/script/kcx_high_chg_open_his_data_handle.py +2 -11
- mns_scheduler/zt/script/sync_high_chg_pool_his_data.py +2 -2
- mns_scheduler/zt/script/sync_now_higt_chg_zt.py +43 -0
- mns_scheduler/zt/zt_pool/em_zt_pool_sync_api.py +413 -0
- mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py +193 -0
- mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py +58 -0
- mns_scheduler/zz_task/compensation/__init__.py +0 -0
- mns_scheduler/zz_task/compensation/compensate_task.py +161 -0
- mns_scheduler/zz_task/compensation/compensate_task_one_day.py +142 -0
- mns_scheduler/zz_task/data_sync_task.py +271 -121
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/METADATA +1 -1
- mns_scheduler-1.4.3.2.dist-info/RECORD +169 -0
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/WHEEL +1 -1
- mns_scheduler/backup/app/ths_new_concept_sync_app.py +0 -122
- mns_scheduler/backup/em/em_new_concept_his_sync.py +0 -99
- mns_scheduler/backup/em/em_new_concept_sync_common_api.py +0 -139
- mns_scheduler/backup/em/em_new_concept_sync_web.py +0 -55
- mns_scheduler/backup/wen_cai/wen_cai_concept_sync.py +0 -51
- mns_scheduler/big_deal/ths_big_deal_sync.py +0 -98
- mns_scheduler/company_info/company_constant_data.py +0 -322
- mns_scheduler/concept/ths/sync_new_index/sync_ths_concept_by_ak_api.py +0 -103
- mns_scheduler/concept/ths/sync_new_index/sync_ths_new_concept_by_web_api.py +0 -89
- mns_scheduler/finance/financial_high_risk_stock_clean_service_api.py +0 -202
- mns_scheduler/finance/sync_financial_report_service_api.py +0 -113
- mns_scheduler/real_time/realtime_quotes_now_create_db_index.py +0 -27
- mns_scheduler/real_time/realtime_quotes_now_sync.py +0 -232
- mns_scheduler/risk/stock_equity_mortgage_sync_api.py +0 -32
- mns_scheduler/zt/zt_pool/zt_pool_sync_api.py +0 -151
- mns_scheduler/zz_task/sync_realtime_quotes_task.py +0 -28
- mns_scheduler-1.0.8.7.dist-info/RECORD +0 -112
- /mns_scheduler/{backup/app → company_info/announce}/__init__.py +0 -0
- /mns_scheduler/{backup/em → company_info/base}/__init__.py +0 -0
- /mns_scheduler/{backup/wen_cai → company_info/clean}/__init__.py +0 -0
- /mns_scheduler/{big_deal → company_info/constant}/__init__.py +0 -0
- /mns_scheduler/{real_time → company_info/de_list_stock}/__init__.py +0 -0
- /mns_scheduler/{backup → finance/em}/__init__.py +0 -0
- /mns_scheduler/finance/{test → xue_qiu}/__init__.py +0 -0
- /mns_scheduler/k_line/{sync → month_week_daily}/__init__.py +0 -0
- {mns_scheduler-1.0.8.7.dist-info → mns_scheduler-1.4.3.2.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
5
|
+
end = file_path.index('mns') + 17
|
|
6
6
|
project_path = file_path[0:end]
|
|
7
7
|
sys.path.append(project_path)
|
|
8
8
|
import pandas as pd
|
|
@@ -85,6 +85,12 @@ def init_day_line_data(k_line_info, stock_qfq_daily):
|
|
|
85
85
|
k_line_info.loc[:, 'avg_thirty_last'] = 0
|
|
86
86
|
k_line_info.loc[:, 'avg_sixty_last'] = 0
|
|
87
87
|
|
|
88
|
+
k_line_info.loc[:, 'slope_five_last'] = 0
|
|
89
|
+
k_line_info.loc[:, 'slope_ten_last'] = 0
|
|
90
|
+
k_line_info.loc[:, 'slope_twenty_last'] = 0
|
|
91
|
+
k_line_info.loc[:, 'slope_thirty_last'] = 0
|
|
92
|
+
k_line_info.loc[:, 'slope_sixty_last'] = 0
|
|
93
|
+
|
|
88
94
|
k_line_info.loc[:, 'std_amount_ten'] = 0
|
|
89
95
|
k_line_info.loc[:, 'mean_amount_ten'] = 0
|
|
90
96
|
k_line_info.loc[:, 'std_amount_thirty'] = 0
|
|
@@ -105,6 +111,8 @@ def init_day_line_data(k_line_info, stock_qfq_daily):
|
|
|
105
111
|
|
|
106
112
|
k_line_info.loc[:, 'diff_close_from_open_last'] = 0
|
|
107
113
|
|
|
114
|
+
k_line_info.loc[:, 'max_chg_30'] = 0
|
|
115
|
+
|
|
108
116
|
return k_line_info
|
|
109
117
|
|
|
110
118
|
|
|
@@ -116,8 +124,10 @@ def calculate_30_day_max_chg(stock_qfq_daily, k_line_info):
|
|
|
116
124
|
deal_days = stock_qfq_daily_30.shape[0]
|
|
117
125
|
|
|
118
126
|
if deal_days < 30:
|
|
127
|
+
# 排除第一天
|
|
119
128
|
stock_qfq_daily_30 = stock_qfq_daily_30[0: deal_days - 1]
|
|
120
|
-
if deal_days == 0:
|
|
129
|
+
if deal_days == 0 or deal_days == 1:
|
|
130
|
+
k_line_info['max_chg_30'] = 0
|
|
121
131
|
return k_line_info
|
|
122
132
|
|
|
123
133
|
stock_qfq_daily_30['date_time'] = pd.to_datetime(stock_qfq_daily_30['date'])
|
|
@@ -196,24 +206,31 @@ def calculate_exchange_and_k_line_avg_param(stock_qfq_daily):
|
|
|
196
206
|
|
|
197
207
|
# 收盘价格与均线差值
|
|
198
208
|
stock_qfq_daily['close_difference_five'] = round(
|
|
199
|
-
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_five']) / stock_qfq_daily['
|
|
209
|
+
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_five']) / stock_qfq_daily['avg_five'],
|
|
200
210
|
2)
|
|
201
211
|
|
|
202
212
|
stock_qfq_daily['close_difference_ten'] = round(
|
|
203
|
-
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_ten']) / stock_qfq_daily['
|
|
213
|
+
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_ten']) / stock_qfq_daily['avg_ten'],
|
|
204
214
|
2)
|
|
205
215
|
|
|
206
216
|
stock_qfq_daily['close_difference_twenty'] = round(
|
|
207
|
-
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_twenty']) / stock_qfq_daily['
|
|
217
|
+
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_twenty']) / stock_qfq_daily['avg_twenty'],
|
|
208
218
|
2)
|
|
209
219
|
|
|
210
220
|
stock_qfq_daily['close_difference_thirty'] = round(
|
|
211
|
-
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_thirty']) / stock_qfq_daily['
|
|
221
|
+
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_thirty']) / stock_qfq_daily['avg_thirty'],
|
|
212
222
|
2)
|
|
213
223
|
|
|
214
224
|
stock_qfq_daily['close_difference_sixty'] = round(
|
|
215
|
-
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_sixty']) / stock_qfq_daily['
|
|
225
|
+
100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_sixty']) / stock_qfq_daily['avg_sixty'],
|
|
216
226
|
2)
|
|
227
|
+
if (('slope_' + 'five' not in stock_qfq_daily.columns)
|
|
228
|
+
or ('slope_' + 'ten' not in stock_qfq_daily.columns) \
|
|
229
|
+
or ('slope_' + 'twenty' not in stock_qfq_daily.columns) \
|
|
230
|
+
or ('slope_' + 'thirty' not in stock_qfq_daily.columns) \
|
|
231
|
+
or ('slope_' + 'sixty' not in stock_qfq_daily.columns)):
|
|
232
|
+
# 计算均线斜率
|
|
233
|
+
stock_qfq_daily = calculate_slope(stock_qfq_daily, windows=['five', 'ten', 'twenty', 'thirty', 'sixty'])
|
|
217
234
|
|
|
218
235
|
stock_qfq_daily = stock_qfq_daily[[
|
|
219
236
|
"symbol",
|
|
@@ -251,6 +268,11 @@ def calculate_exchange_and_k_line_avg_param(stock_qfq_daily):
|
|
|
251
268
|
"avg_twenty",
|
|
252
269
|
'avg_thirty',
|
|
253
270
|
'avg_sixty',
|
|
271
|
+
"slope_five",
|
|
272
|
+
"slope_ten",
|
|
273
|
+
"slope_twenty",
|
|
274
|
+
'slope_thirty',
|
|
275
|
+
'slope_sixty',
|
|
254
276
|
"classification",
|
|
255
277
|
"_id",
|
|
256
278
|
"date"
|
|
@@ -261,6 +283,34 @@ def calculate_exchange_and_k_line_avg_param(stock_qfq_daily):
|
|
|
261
283
|
return stock_qfq_daily
|
|
262
284
|
|
|
263
285
|
|
|
286
|
+
def fix_avg_slope_name(k_line_info, stock_qfq_daily):
|
|
287
|
+
stock_qfq_daily_one = stock_qfq_daily.iloc[0:1]
|
|
288
|
+
k_line_info['slope_five_last'] = stock_qfq_daily_one['slope_five']
|
|
289
|
+
k_line_info['slope_ten_last'] = stock_qfq_daily_one['slope_ten']
|
|
290
|
+
k_line_info['slope_twenty_last'] = stock_qfq_daily_one['slope_twenty']
|
|
291
|
+
k_line_info['slope_thirty_last'] = stock_qfq_daily_one['slope_thirty']
|
|
292
|
+
k_line_info['slope_sixty_last'] = stock_qfq_daily_one['slope_sixty']
|
|
293
|
+
return k_line_info
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
# 计算均线
|
|
297
|
+
def calculate_moving_averages(data, windows=['five', 'ten', 'twenty', 'thirty', 'sixty']):
|
|
298
|
+
for window in windows:
|
|
299
|
+
data[f'avg_{window}', window] = data['close'].rolling(window=window).mean()
|
|
300
|
+
return data
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# 计算均线斜率
|
|
304
|
+
def calculate_slope(data, windows=['five', 'ten', 'twenty', 'thirty', 'sixty']):
|
|
305
|
+
for window in windows:
|
|
306
|
+
if 'slope_' + window in data.columns:
|
|
307
|
+
continue
|
|
308
|
+
data[f'slope_{window}'] = data[f'avg_{window}'].diff() / data[f'avg_{window}'].shift(1)
|
|
309
|
+
data[f'slope_{window}'] = data[f'slope_{window}'] * 100
|
|
310
|
+
data[f'slope_{window}'] = round(data[f'slope_{window}'], 2)
|
|
311
|
+
return data
|
|
312
|
+
|
|
313
|
+
|
|
264
314
|
# 设置当天k线形态 下一个交易日判断当前交易日k线形态
|
|
265
315
|
def set_k_line_patterns(stock_qfq_daily_one):
|
|
266
316
|
open = list(stock_qfq_daily_one['open'])[0]
|
|
@@ -2,7 +2,7 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
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 mns_common.db.MongodbUtil import MongodbUtil
|
|
@@ -10,6 +10,7 @@ import mns_common.utils.date_handle_util as date_handle_util
|
|
|
10
10
|
import mns_scheduler.k_line.hot_stocks.recent_hot_stocks_clean_service as recent_hot_stocks_clean_service
|
|
11
11
|
import mns_scheduler.k_line.clean.daily.daily_k_line_clean_common_service as daily_k_line_clean_common_service
|
|
12
12
|
from mns_common.component.classify.symbol_classify_param import stock_type_classify_param
|
|
13
|
+
import mns_scheduler.k_line.clean.week_month.sub_new_week_month_k_line_service as sub_new_week_month_k_line_service
|
|
13
14
|
|
|
14
15
|
mongodb_util = MongodbUtil('27017')
|
|
15
16
|
# 普通股日线查询数据 60
|
|
@@ -17,7 +18,7 @@ NORMAL_DAILY_K_LINE_NUMBER = 60
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def handle_day_line(k_line_info, str_day, symbol, deal_days):
|
|
20
|
-
sub_stock_new_max_deal_days = stock_type_classify_param['
|
|
21
|
+
sub_stock_new_max_deal_days = stock_type_classify_param['sub_new_stock_max_deal_days']
|
|
21
22
|
if deal_days > sub_stock_new_max_deal_days:
|
|
22
23
|
return handle_day_line_normal(k_line_info, str_day, symbol, deal_days)
|
|
23
24
|
|
|
@@ -54,15 +55,25 @@ def handle_day_line_sub_new(k_line_info, str_day, symbol, deal_days):
|
|
|
54
55
|
stock_qfq_daily = stock_qfq_daily.iloc[0:deal_days - 1]
|
|
55
56
|
# 计算换手平均值 k线 5 10 20 30 60均线
|
|
56
57
|
stock_qfq_daily = daily_k_line_clean_common_service.calculate_exchange_and_k_line_avg_param(stock_qfq_daily)
|
|
58
|
+
# 计算30天最大涨幅
|
|
59
|
+
k_line_info = daily_k_line_clean_common_service.calculate_30_day_max_chg(stock_qfq_daily, k_line_info)
|
|
57
60
|
# 设置五日k线和
|
|
58
61
|
k_line_info = daily_k_line_clean_common_service.set_sum_five_chg(k_line_info, deal_days)
|
|
59
62
|
# 计算当前交易日开盘时的涨幅
|
|
60
63
|
k_line_info = daily_k_line_clean_common_service.calculate_open_chg(stock_qfq_daily, k_line_info)
|
|
61
64
|
# 计算 昨日最高点到开盘涨幅差值 and # 昨日最高点到当日收盘涨幅之间的差值 and # 昨日收盘到当日开盘涨幅之间的差值
|
|
62
65
|
k_line_info = daily_k_line_clean_common_service.calculate_chg_diff_value(k_line_info)
|
|
66
|
+
# 计算 月线
|
|
67
|
+
k_line_info = sub_new_week_month_k_line_service.handle_month_line(k_line_info, stock_qfq_daily, deal_days)
|
|
68
|
+
# 计算周线
|
|
69
|
+
k_line_info = sub_new_week_month_k_line_service.handle_week_line(k_line_info, stock_qfq_daily, deal_days)
|
|
70
|
+
|
|
63
71
|
# 排除最近有三板以上的股票 todo
|
|
64
72
|
# 计算最近热门大涨的股票
|
|
65
73
|
recent_hot_stocks_clean_service.calculate_recent_hot_stocks(stock_qfq_daily, symbol, str_day)
|
|
74
|
+
# 修改 avg name
|
|
75
|
+
k_line_info = daily_k_line_clean_common_service.fix_avg_slope_name(k_line_info, stock_qfq_daily)
|
|
76
|
+
|
|
66
77
|
return k_line_info
|
|
67
78
|
|
|
68
79
|
|
|
@@ -99,9 +110,11 @@ def handle_day_line_normal(k_line_info, str_day, symbol, deal_days):
|
|
|
99
110
|
# 排除最近有三板以上的股票 todo
|
|
100
111
|
# 计算最近热门大涨的股票
|
|
101
112
|
recent_hot_stocks_clean_service.calculate_recent_hot_stocks(stock_qfq_daily, symbol, str_day)
|
|
102
|
-
|
|
113
|
+
# 修改 avg name
|
|
114
|
+
k_line_info = daily_k_line_clean_common_service.fix_avg_slope_name(k_line_info, stock_qfq_daily)
|
|
103
115
|
return k_line_info
|
|
104
116
|
|
|
117
|
+
|
|
105
118
|
# if __name__ == '__main__':
|
|
106
119
|
# query1 = {"symbol": '301596', 'date': {"$lte": date_handle_util.no_slash_date('2024-05-31')}}
|
|
107
120
|
# stock_qfq_daily_301596 = mongodb_util.descend_query(query1, 'stock_qfq_daily', 'date', 15)
|
|
@@ -16,7 +16,7 @@ mongodb_util = MongodbUtil('27017')
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
# 日线 周线 月线 成交量 筹码信息
|
|
19
|
-
def calculate_k_line_info(str_day, symbol, diff_days):
|
|
19
|
+
def calculate_k_line_info(str_day, symbol, diff_days, stock_qfq_year_df):
|
|
20
20
|
k_line_info = pd.DataFrame([[
|
|
21
21
|
str_day,
|
|
22
22
|
symbol, diff_days]],
|
|
@@ -27,7 +27,8 @@ def calculate_k_line_info(str_day, symbol, diff_days):
|
|
|
27
27
|
# 交易天数
|
|
28
28
|
deal_days = k_line_common_service_api.get_deal_days(str_day, symbol)
|
|
29
29
|
# 处理周线 月线
|
|
30
|
-
k_line_info = week_month_k_line_service.handle_month_week_line(k_line_info, str_day, symbol,
|
|
30
|
+
k_line_info = week_month_k_line_service.handle_month_week_line(k_line_info, str_day, symbol,
|
|
31
|
+
deal_days, stock_qfq_year_df)
|
|
31
32
|
# 处理日线
|
|
32
33
|
k_line_info = daily_k_line_service.handle_day_line(k_line_info, str_day, symbol, deal_days)
|
|
33
34
|
return k_line_info
|
|
@@ -9,15 +9,16 @@ sys.path.append(project_path)
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
import mns_common.utils.date_handle_util as date_handle_util
|
|
11
11
|
from mns_common.db.MongodbUtil import MongodbUtil
|
|
12
|
-
import mns_common.
|
|
12
|
+
import mns_common.component.em.em_stock_info_api as em_stock_info_api
|
|
13
13
|
from loguru import logger
|
|
14
14
|
import threading
|
|
15
15
|
import mns_common.component.trade_date.trade_date_common_service_api as trade_date_common_service_api
|
|
16
16
|
import mns_common.component.common_service_fun_api as common_service_fun_api
|
|
17
|
-
import mns_scheduler.k_line.
|
|
17
|
+
import mns_scheduler.k_line.month_week_daily.daily_week_month_line_sync as daily_week_month_line_sync_api
|
|
18
18
|
import mns_scheduler.k_line.clean.k_line_info_clean_impl as k_line_info_clean_impl
|
|
19
19
|
import mns_common.utils.data_frame_util as data_frame_util
|
|
20
20
|
import mns_common.component.company.company_common_service_api as company_common_service_api
|
|
21
|
+
import mns_common.constant.db_name_constant as db_name_constant
|
|
21
22
|
|
|
22
23
|
K_LINE_CLEAN_DB_NAME = 'k_line_clean_fail_name'
|
|
23
24
|
|
|
@@ -67,10 +68,17 @@ def sync_k_line_info(str_day, symbol_list):
|
|
|
67
68
|
|
|
68
69
|
diff_days = list(company_info_df['diff_days'])[0]
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
now_year = int(str_day[0:4])
|
|
72
|
+
last_year = now_year - 1
|
|
73
|
+
|
|
74
|
+
query_year_line = {'symbol': symbol, 'year': {"$in": [str(now_year), str(last_year)]}}
|
|
75
|
+
stock_qfq_year_df = mongodb_util.find_query_data(db_name_constant.STOCK_QFQ_YEAR, query_year_line)
|
|
76
|
+
|
|
77
|
+
k_line_result = k_line_info_clean_impl.calculate_k_line_info(str_day, symbol, diff_days,
|
|
78
|
+
stock_qfq_year_df)
|
|
71
79
|
save_k_line_data(symbol, str_day, k_line_result)
|
|
72
80
|
if result_k_line_list_df is None:
|
|
73
|
-
result_k_line_list_df =
|
|
81
|
+
result_k_line_list_df = k_line_result
|
|
74
82
|
else:
|
|
75
83
|
result_k_line_list_df = pd.concat([result_k_line_list_df, k_line_result])
|
|
76
84
|
|
|
@@ -87,18 +95,27 @@ def handle_fail_data(str_day, real_time_quotes_now):
|
|
|
87
95
|
k_line_fail_df = mongodb_util.find_query_data(K_LINE_CLEAN_DB_NAME, query)
|
|
88
96
|
if data_frame_util.is_not_empty(k_line_fail_df):
|
|
89
97
|
fail_data_df = real_time_quotes_now.loc[real_time_quotes_now['symbol'].isin(k_line_fail_df['symbol'])]
|
|
90
|
-
|
|
98
|
+
now_year = int(str_day[0:4])
|
|
99
|
+
last_year = now_year - 1
|
|
100
|
+
|
|
101
|
+
query_year_line = {'year': {"$in": [str(now_year), str(last_year)]}}
|
|
102
|
+
stock_qfq_year_df = mongodb_util.find_query_data(db_name_constant.STOCK_QFQ_YEAR, query_year_line)
|
|
103
|
+
single_threaded_sync_task(fail_data_df, str_day, 88, stock_qfq_year_df)
|
|
91
104
|
|
|
92
105
|
|
|
93
106
|
# 多线程同步任务
|
|
94
107
|
def multi_threaded_k_line_sync(str_day):
|
|
95
108
|
# 退市代码
|
|
96
|
-
de_list_company_symbols = company_common_service_api.get_de_list_company()
|
|
97
|
-
real_time_quotes_now = east_money_stock_api.get_real_time_quotes_all_stocks()
|
|
98
|
-
real_time_quotes_now = real_time_quotes_now.loc[~(real_time_quotes_now['symbol'].isin(de_list_company_symbols))]
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
de_list_company_df = mongodb_util.find_all_data(db_name_constant.DE_LIST_STOCK)
|
|
111
|
+
de_list_company_df = de_list_company_df.loc[de_list_company_df['de_list_date'] < str_day]
|
|
112
|
+
real_time_quotes_now = em_stock_info_api.get_a_stock_info()
|
|
113
|
+
real_time_quotes_now = real_time_quotes_now.loc[
|
|
114
|
+
~(real_time_quotes_now['symbol'].isin(de_list_company_df['symbol']))]
|
|
115
|
+
|
|
116
|
+
# 将list_date列中的所有NaN值设置为19890604
|
|
117
|
+
real_time_quotes_now['list_date'].fillna(19890604, inplace=True)
|
|
118
|
+
real_time_quotes_now['list_date'] = real_time_quotes_now['list_date'].replace(99990909, 19890604)
|
|
102
119
|
|
|
103
120
|
# 将日期数值转换为日期时间格式
|
|
104
121
|
real_time_quotes_now['list_date_01'] = pd.to_datetime(real_time_quotes_now['list_date'], format='%Y%m%d')
|
|
@@ -111,8 +128,15 @@ def multi_threaded_k_line_sync(str_day):
|
|
|
111
128
|
|
|
112
129
|
# exclude b symbol
|
|
113
130
|
real_time_quotes_now = common_service_fun_api.exclude_b_symbol(real_time_quotes_now.copy())
|
|
114
|
-
|
|
115
|
-
real_time_quotes_now =
|
|
131
|
+
|
|
132
|
+
real_time_quotes_now = real_time_quotes_now.loc[real_time_quotes_now['list_date_01'] <= now_date]
|
|
133
|
+
|
|
134
|
+
now_year = int(str_day[0:4])
|
|
135
|
+
last_year = now_year - 1
|
|
136
|
+
|
|
137
|
+
query_year_line = {'year': {"$in": [str(now_year), str(last_year)]}}
|
|
138
|
+
stock_qfq_year_df = mongodb_util.find_query_data(db_name_constant.STOCK_QFQ_YEAR, query_year_line)
|
|
139
|
+
|
|
116
140
|
total_count = real_time_quotes_now.shape[0]
|
|
117
141
|
global result
|
|
118
142
|
result = pd.DataFrame() # 重新初始化 result 变量
|
|
@@ -125,9 +149,9 @@ def multi_threaded_k_line_sync(str_day):
|
|
|
125
149
|
|
|
126
150
|
end_count = (page + 1) * MAX_PAGE_NUMBER
|
|
127
151
|
begin_count = page * MAX_PAGE_NUMBER
|
|
128
|
-
page_df = real_time_quotes_now.
|
|
152
|
+
page_df = real_time_quotes_now.iloc[begin_count:end_count]
|
|
129
153
|
|
|
130
|
-
thread = threading.Thread(target=single_threaded_sync_task, args=(page_df, str_day, page))
|
|
154
|
+
thread = threading.Thread(target=single_threaded_sync_task, args=(page_df, str_day, page, stock_qfq_year_df))
|
|
131
155
|
threads.append(thread)
|
|
132
156
|
thread.start()
|
|
133
157
|
|
|
@@ -141,11 +165,12 @@ def multi_threaded_k_line_sync(str_day):
|
|
|
141
165
|
|
|
142
166
|
|
|
143
167
|
# 单线程同步任务
|
|
144
|
-
def single_threaded_sync_task(page_df, str_day, page):
|
|
168
|
+
def single_threaded_sync_task(page_df, str_day, page, stock_qfq_year_df):
|
|
145
169
|
global result
|
|
146
170
|
for stock_one in page_df.itertuples():
|
|
147
171
|
try:
|
|
148
|
-
k_line_df = k_line_info_clean_impl.calculate_k_line_info(str_day, stock_one.symbol, stock_one.diff_days
|
|
172
|
+
k_line_df = k_line_info_clean_impl.calculate_k_line_info(str_day, stock_one.symbol, stock_one.diff_days,
|
|
173
|
+
stock_qfq_year_df)
|
|
149
174
|
save_k_line_data(stock_one.symbol, str_day, k_line_df)
|
|
150
175
|
if k_line_df is None:
|
|
151
176
|
result = k_line_df
|
|
@@ -176,19 +201,5 @@ def create_k_line_index():
|
|
|
176
201
|
mongodb_util.create_index('k_line_info', [("str_day", 1), ("symbol", 1)])
|
|
177
202
|
|
|
178
203
|
|
|
179
|
-
def clean_history_data():
|
|
180
|
-
query = {"$and": [{"trade_date": {"$gte": '2023-11-06'}}, {"trade_date": {"$lte": '2023-11-16'}}]}
|
|
181
|
-
trade_date_list_df = mongodb_util.find_query_data('trade_date_list', query)
|
|
182
|
-
trade_date_list_df = trade_date_list_df.sort_values(by=['trade_date'], ascending=False)
|
|
183
|
-
for trade_data_one in trade_date_list_df.itertuples():
|
|
184
|
-
try:
|
|
185
|
-
sync_k_line_info_task(trade_data_one.trade_date)
|
|
186
|
-
logger.info("清洗数据到:{}", trade_data_one.trade_date)
|
|
187
|
-
except BaseException as e:
|
|
188
|
-
logger.error("发生异常:{},{}", trade_data_one.trade_date, e)
|
|
189
|
-
|
|
190
|
-
|
|
191
204
|
if __name__ == '__main__':
|
|
192
|
-
|
|
193
|
-
# clean_history_data()
|
|
194
|
-
# sync_k_line_info("2023-12-22")
|
|
205
|
+
sync_k_line_info_task('2025-11-13')
|
|
@@ -2,22 +2,27 @@ import sys
|
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
4
|
file_path = os.path.abspath(__file__)
|
|
5
|
-
end = file_path.index('mns') +
|
|
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 mns_common.db.MongodbUtil import MongodbUtil
|
|
9
9
|
import mns_common.utils.date_handle_util as date_handle_util
|
|
10
10
|
from mns_common.component.classify.symbol_classify_param import stock_type_classify_param
|
|
11
|
+
import mns_common.utils.data_frame_util as data_frame_util
|
|
12
|
+
|
|
13
|
+
# import functools
|
|
11
14
|
|
|
12
15
|
mongodb_util = MongodbUtil('27017')
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
# 处理月线 周线 todo 暂时简单计算周线之和
|
|
16
|
-
def handle_month_week_line(k_line_info, str_day, symbol, deal_days
|
|
17
|
-
|
|
19
|
+
def handle_month_week_line(k_line_info, str_day, symbol, deal_days,
|
|
20
|
+
stock_qfq_year_df):
|
|
21
|
+
sub_stock_new_max_deal_days = stock_type_classify_param['sub_new_stock_max_deal_days']
|
|
18
22
|
if deal_days > sub_stock_new_max_deal_days:
|
|
19
23
|
k_line_info = handle_month_line(k_line_info, str_day, symbol)
|
|
20
24
|
k_line_info = handle_week_line(k_line_info, str_day, symbol)
|
|
25
|
+
k_line_info = set_year_k_line(k_line_info, symbol, stock_qfq_year_df, str_day)
|
|
21
26
|
else:
|
|
22
27
|
k_line_info['week01'] = 0
|
|
23
28
|
k_line_info['week02'] = 0
|
|
@@ -33,37 +38,130 @@ def handle_month_week_line(k_line_info, str_day, symbol, deal_days):
|
|
|
33
38
|
k_line_info['month02'] = 0
|
|
34
39
|
k_line_info['month01_date'] = '19890729'
|
|
35
40
|
k_line_info['month02_date'] = '19890729'
|
|
41
|
+
# 上市交易日不到100天的默认设置年线数据为0
|
|
42
|
+
k_line_info['now_year_chg'] = 0
|
|
43
|
+
k_line_info['now_year_open_from_high_chg'] = 0
|
|
44
|
+
k_line_info['now_year_low_from_high_chg'] = 0
|
|
45
|
+
|
|
46
|
+
k_line_info['last_year_chg'] = 0
|
|
47
|
+
k_line_info['last_year_open_from_high_chg'] = 0
|
|
48
|
+
k_line_info['last_year_low_from_high_chg'] = 0
|
|
49
|
+
|
|
50
|
+
return k_line_info
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# 年线数据设置
|
|
54
|
+
def set_year_k_line(k_line_info, symbol, stock_qfq_year_df, str_day):
|
|
55
|
+
now_year = int(str_day[0:4])
|
|
56
|
+
last_year = str(now_year - 1)
|
|
57
|
+
stock_qfq_now_year_df = stock_qfq_year_df.loc[(stock_qfq_year_df['symbol'] == symbol)
|
|
58
|
+
& (stock_qfq_year_df['year'] == str(now_year))]
|
|
59
|
+
if data_frame_util.is_empty(stock_qfq_now_year_df):
|
|
60
|
+
k_line_info['now_year_chg'] = 0
|
|
61
|
+
k_line_info['now_year_open_from_high_chg'] = 0
|
|
62
|
+
k_line_info['now_year_low_from_high_chg'] = 0
|
|
63
|
+
else:
|
|
64
|
+
k_line_info['now_year_chg'] = list(stock_qfq_now_year_df['chg'])[0]
|
|
65
|
+
k_line_info['now_year_open_from_high_chg'] = list(stock_qfq_now_year_df['open_to_high_pct'])[0]
|
|
66
|
+
k_line_info['now_year_low_from_high_chg'] = list(stock_qfq_now_year_df['low_to_high_pct'])[0]
|
|
67
|
+
|
|
68
|
+
stock_qfq_last_year_df = stock_qfq_year_df.loc[(stock_qfq_year_df['symbol'] == symbol)
|
|
69
|
+
& (stock_qfq_year_df['year'] == last_year)]
|
|
70
|
+
|
|
71
|
+
if data_frame_util.is_empty(stock_qfq_last_year_df):
|
|
72
|
+
k_line_info['last_year_chg'] = 0
|
|
73
|
+
k_line_info['last_year_open_from_high_chg'] = 0
|
|
74
|
+
k_line_info['last_year_low_from_high_chg'] = 0
|
|
75
|
+
else:
|
|
76
|
+
k_line_info['last_year_chg'] = list(stock_qfq_last_year_df['chg'])[0]
|
|
77
|
+
k_line_info['last_year_open_from_high_chg'] = list(stock_qfq_last_year_df['open_to_high_pct'])[0]
|
|
78
|
+
k_line_info['last_year_low_from_high_chg'] = list(stock_qfq_last_year_df['low_to_high_pct'])[0]
|
|
79
|
+
|
|
36
80
|
return k_line_info
|
|
37
81
|
|
|
82
|
+
# 处理月线
|
|
83
|
+
|
|
38
84
|
|
|
39
|
-
# 处理月线
|
|
40
85
|
def handle_month_line(k_line_info, str_day, symbol):
|
|
41
|
-
|
|
86
|
+
now_year = int(str_day[0:4])
|
|
87
|
+
last_year = str(now_year - 1)
|
|
88
|
+
|
|
89
|
+
now_month_begin_day = str_day[0:7] + '-01'
|
|
90
|
+
|
|
91
|
+
last_year_begin_day = last_year + '-01-01'
|
|
92
|
+
# now_year_begin_day = str(now_year) + '-01-01'
|
|
93
|
+
|
|
42
94
|
query = {"symbol": symbol,
|
|
43
|
-
'date': {"$
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
k_line_info['month_num'] = month_num
|
|
47
|
-
if month_num > 0:
|
|
48
|
-
k_line_info['sum_month'] = round(sum(stock_hfq_monthly['chg']), 2)
|
|
49
|
-
else:
|
|
95
|
+
'date': {"$gte": date_handle_util.no_slash_date(last_year_begin_day)}}
|
|
96
|
+
stock_hfq_monthly_all = mongodb_util.find_query_data('stock_qfq_monthly', query)
|
|
97
|
+
if data_frame_util.is_empty(stock_hfq_monthly_all):
|
|
50
98
|
k_line_info['sum_month'] = 0
|
|
51
99
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
k_line_info['
|
|
100
|
+
else:
|
|
101
|
+
stock_hfq_monthly_all = stock_hfq_monthly_all.sort_values(by=['date'], ascending=False)
|
|
102
|
+
stock_hfq_monthly_all = stock_hfq_monthly_all.loc[
|
|
103
|
+
stock_hfq_monthly_all['date'] <= date_handle_util.no_slash_date(now_month_begin_day)]
|
|
104
|
+
|
|
105
|
+
# stock_hfq_monthly_last_year = stock_hfq_monthly_all.loc[
|
|
106
|
+
# stock_hfq_monthly_all['date'] < date_handle_util.no_slash_date(now_year_begin_day)]
|
|
107
|
+
#
|
|
108
|
+
# stock_hfq_monthly_now_year = stock_hfq_monthly_all.loc[
|
|
109
|
+
# stock_hfq_monthly_all['date'] > date_handle_util.no_slash_date(now_year_begin_day)]
|
|
110
|
+
|
|
111
|
+
# 最近两个月k线
|
|
112
|
+
before_two_month_stock_hfq_monthly = stock_hfq_monthly_all.iloc[0:2]
|
|
113
|
+
month_num = before_two_month_stock_hfq_monthly.shape[0]
|
|
114
|
+
k_line_info['month_num'] = month_num
|
|
115
|
+
|
|
116
|
+
if month_num == 0:
|
|
117
|
+
k_line_info['sum_month'] = 0
|
|
118
|
+
k_line_info['month01'] = 0
|
|
119
|
+
k_line_info['month02'] = 0
|
|
120
|
+
k_line_info['month01_date'] = '19890729'
|
|
121
|
+
k_line_info['month02_date'] = '19890729'
|
|
122
|
+
elif month_num == 1:
|
|
123
|
+
k_line_info['month01'] = before_two_month_stock_hfq_monthly.iloc[0].chg
|
|
124
|
+
k_line_info['month02'] = 0
|
|
125
|
+
k_line_info['month01_date'] = before_two_month_stock_hfq_monthly.iloc[0].date
|
|
126
|
+
k_line_info['month02_date'] = '19890729'
|
|
127
|
+
k_line_info['sum_month'] = before_two_month_stock_hfq_monthly.iloc[0].chg
|
|
128
|
+
elif month_num == 2:
|
|
129
|
+
k_line_info['month01'] = before_two_month_stock_hfq_monthly.iloc[0].chg
|
|
130
|
+
k_line_info['month02'] = before_two_month_stock_hfq_monthly.iloc[1].chg
|
|
131
|
+
k_line_info['month01_date'] = before_two_month_stock_hfq_monthly.iloc[0].date
|
|
132
|
+
k_line_info['month02_date'] = before_two_month_stock_hfq_monthly.iloc[1].date
|
|
133
|
+
close_price = before_two_month_stock_hfq_monthly.iloc[0].close
|
|
134
|
+
open_price = before_two_month_stock_hfq_monthly.iloc[1].last_price
|
|
135
|
+
sum_chg = round((close_price - open_price) * 100 / open_price, 2)
|
|
136
|
+
k_line_info['sum_month'] = sum_chg
|
|
137
|
+
#
|
|
138
|
+
# last_year_month_number = stock_hfq_monthly_last_year.shape[0]
|
|
139
|
+
# if last_year_month_number == 0:
|
|
140
|
+
# k_line_info['last_year_chg'] = 0
|
|
141
|
+
# elif last_year_month_number == 1:
|
|
142
|
+
# k_line_info['last_year_chg'] = stock_hfq_monthly_last_year.iloc[0].chg
|
|
143
|
+
# else:
|
|
144
|
+
# # chg_list = list(stock_hfq_monthly_last_year['chg'])
|
|
145
|
+
# # # 将列表中的每个元素加上1
|
|
146
|
+
# # updated_list = [round((x / 100) + 1, 2) for x in chg_list]
|
|
147
|
+
# #
|
|
148
|
+
# # # 使用 functools.reduce 将列表中的所有元素相乘
|
|
149
|
+
# # last_year_chg = functools.reduce(lambda x, y: x * y, updated_list)
|
|
150
|
+
# close_price = stock_hfq_monthly_last_year.iloc[0].close
|
|
151
|
+
# open_price = stock_hfq_monthly_last_year.iloc[last_year_month_number - 1].last_price
|
|
152
|
+
# last_year_chg = round((close_price - open_price) * 100 / open_price, 2)
|
|
153
|
+
# k_line_info['last_year_chg'] = last_year_chg
|
|
154
|
+
#
|
|
155
|
+
# now_year_month_number = stock_hfq_monthly_now_year.shape[0]
|
|
156
|
+
# if now_year_month_number == 0:
|
|
157
|
+
# k_line_info['now_year_chg'] = 0
|
|
158
|
+
# elif now_year_month_number == 1:
|
|
159
|
+
# k_line_info['now_year_chg'] = stock_hfq_monthly_now_year.iloc[0].chg
|
|
160
|
+
# else:
|
|
161
|
+
# close_price = stock_hfq_monthly_now_year.iloc[0].close
|
|
162
|
+
# open_price = stock_hfq_monthly_now_year.iloc[now_year_month_number - 1].last_price
|
|
163
|
+
# last_year_chg = round((close_price - open_price) * 100 / open_price, 2)
|
|
164
|
+
# k_line_info['now_year_chg'] = last_year_chg
|
|
67
165
|
|
|
68
166
|
return k_line_info
|
|
69
167
|
|