mns-scheduler 1.2.6.1__py3-none-any.whl → 1.2.6.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.

Potentially problematic release.


This version of mns-scheduler might be problematic. Click here for more details.

@@ -85,11 +85,11 @@ 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[:, 'slop_five_last'] = 0
89
- k_line_info.loc[:, 'slop_ten_last'] = 0
90
- k_line_info.loc[:, 'slop_twenty_last'] = 0
91
- k_line_info.loc[:, 'slop_thirty_last'] = 0
92
- k_line_info.loc[:, 'slop_sixty_last'] = 0
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
93
 
94
94
  k_line_info.loc[:, 'std_amount_ten'] = 0
95
95
  k_line_info.loc[:, 'mean_amount_ten'] = 0
@@ -224,9 +224,13 @@ def calculate_exchange_and_k_line_avg_param(stock_qfq_daily):
224
224
  stock_qfq_daily['close_difference_sixty'] = round(
225
225
  100 * (stock_qfq_daily['close'] - stock_qfq_daily['avg_sixty']) / stock_qfq_daily['avg_sixty'],
226
226
  2)
227
-
228
- # 计算均线斜率
229
- stock_qfq_daily = calculate_slope(stock_qfq_daily, windows=['five', 'ten', 'twenty', 'thirty', 'sixty'])
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'])
230
234
 
231
235
  stock_qfq_daily = stock_qfq_daily[[
232
236
  "symbol",
@@ -299,6 +303,8 @@ def calculate_moving_averages(data, windows=['five', 'ten', 'twenty', 'thirty',
299
303
  # 计算均线斜率
300
304
  def calculate_slope(data, windows=['five', 'ten', 'twenty', 'thirty', 'sixty']):
301
305
  for window in windows:
306
+ if 'slope_' + window in data.columns:
307
+ continue
302
308
  data[f'slope_{window}'] = data[f'avg_{window}'].diff() / data[f'avg_{window}'].shift(1)
303
309
  data[f'slope_{window}'] = data[f'slope_{window}'] * 100
304
310
  data[f'slope_{window}'] = round(data[f'slope_{window}'], 2)
@@ -114,6 +114,7 @@ def handle_day_line_normal(k_line_info, str_day, symbol, deal_days):
114
114
  k_line_info = daily_k_line_clean_common_service.fix_avg_slope_name(k_line_info, stock_qfq_daily)
115
115
  return k_line_info
116
116
 
117
+
117
118
  # if __name__ == '__main__':
118
119
  # query1 = {"symbol": '301596', 'date': {"$lte": date_handle_util.no_slash_date('2024-05-31')}}
119
120
  # stock_qfq_daily_301596 = mongodb_util.descend_query(query1, 'stock_qfq_daily', 'date', 15)
@@ -8,6 +8,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
11
12
 
12
13
  mongodb_util = MongodbUtil('27017')
13
14
 
@@ -16,8 +17,11 @@ mongodb_util = MongodbUtil('27017')
16
17
  def handle_month_week_line(k_line_info, str_day, symbol, deal_days):
17
18
  sub_stock_new_max_deal_days = stock_type_classify_param['sub_new_stock_max_deal_days']
18
19
  if deal_days > sub_stock_new_max_deal_days:
20
+ k_line_info['last_year_chg'] = 0
21
+ k_line_info['now_year_chg'] = 0
19
22
  k_line_info = handle_month_line(k_line_info, str_day, symbol)
20
23
  k_line_info = handle_week_line(k_line_info, str_day, symbol)
24
+
21
25
  else:
22
26
  k_line_info['week01'] = 0
23
27
  k_line_info['week02'] = 0
@@ -33,37 +37,95 @@ def handle_month_week_line(k_line_info, str_day, symbol, deal_days):
33
37
  k_line_info['month02'] = 0
34
38
  k_line_info['month01_date'] = '19890729'
35
39
  k_line_info['month02_date'] = '19890729'
40
+
41
+ k_line_info['last_year_chg'] = 0
42
+ k_line_info['now_year_chg'] = 0
43
+
36
44
  return k_line_info
37
45
 
38
46
 
39
47
  # 处理月线
40
48
  def handle_month_line(k_line_info, str_day, symbol):
41
- month_begin_day = str_day[0:7] + '-01'
49
+ now_year = int(str_day[0:4])
50
+ last_year = str(now_year - 1)
51
+
52
+ now_month_begin_day = str_day[0:7] + '-01'
53
+
54
+ now_month = str_day[5:7]
55
+ # 前两个月
56
+ before_two_month = int(now_month) - 2
57
+
58
+ before_two_month_begin_day = str(now_year) + str(before_two_month) + '01'
59
+
60
+ last_year_begin_day = last_year + '-01-01'
61
+ now_year_begin_day = str(now_year) + '-01-01'
62
+
42
63
  query = {"symbol": symbol,
43
- 'date': {"$lt": date_handle_util.no_slash_date(month_begin_day)}}
44
- stock_hfq_monthly = mongodb_util.descend_query(query, 'stock_qfq_monthly', 'date', 2)
45
- month_num = stock_hfq_monthly.shape[0]
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:
64
+ 'date': {"$gte": date_handle_util.no_slash_date(last_year_begin_day)}}
65
+ stock_hfq_monthly_all = mongodb_util.find_query_data('stock_qfq_monthly', query)
66
+ if data_frame_util.is_empty(stock_hfq_monthly_all):
50
67
  k_line_info['sum_month'] = 0
51
68
 
52
- if month_num == 0:
53
- k_line_info['month01'] = 0
54
- k_line_info['month02'] = 0
55
- k_line_info['month01_date'] = '19890729'
56
- k_line_info['month02_date'] = '19890729'
57
- elif month_num == 1:
58
- k_line_info['month01'] = stock_hfq_monthly.iloc[0].chg
59
- k_line_info['month02'] = 0
60
- k_line_info['month01_date'] = stock_hfq_monthly.iloc[0].date
61
- k_line_info['month02_date'] = '19890729'
62
- elif month_num == 2:
63
- k_line_info['month01'] = stock_hfq_monthly.iloc[0].chg
64
- k_line_info['month02'] = stock_hfq_monthly.iloc[1].chg
65
- k_line_info['month01_date'] = stock_hfq_monthly.iloc[0].date
66
- k_line_info['month02_date'] = stock_hfq_monthly.iloc[1].date
69
+ else:
70
+ stock_hfq_monthly_all = stock_hfq_monthly_all.sort_values(by=['date'], ascending=False)
71
+ stock_hfq_monthly_all = stock_hfq_monthly_all.loc[
72
+ stock_hfq_monthly_all['date'] <= date_handle_util.no_slash_date(now_month_begin_day)]
73
+
74
+ stock_hfq_monthly_last_year = stock_hfq_monthly_all.loc[
75
+ stock_hfq_monthly_all['date'] < date_handle_util.no_slash_date(now_year_begin_day)]
76
+
77
+ stock_hfq_monthly_now_year = stock_hfq_monthly_all.loc[
78
+ stock_hfq_monthly_all['date'] > date_handle_util.no_slash_date(now_year_begin_day)]
79
+
80
+ # 最近两个月k线
81
+ before_two_month_stock_hfq_monthly = stock_hfq_monthly_now_year.loc[
82
+ stock_hfq_monthly_now_year['date'] > before_two_month_begin_day]
83
+ month_num = before_two_month_stock_hfq_monthly.shape[0]
84
+ k_line_info['month_num'] = month_num
85
+
86
+ if month_num == 0:
87
+ k_line_info['sum_month'] = 0
88
+ k_line_info['month01'] = 0
89
+ k_line_info['month02'] = 0
90
+ k_line_info['month01_date'] = '19890729'
91
+ k_line_info['month02_date'] = '19890729'
92
+ elif month_num == 1:
93
+ k_line_info['month01'] = before_two_month_stock_hfq_monthly.iloc[0].chg
94
+ k_line_info['month02'] = 0
95
+ k_line_info['month01_date'] = before_two_month_stock_hfq_monthly.iloc[0].date
96
+ k_line_info['month02_date'] = '19890729'
97
+ k_line_info['sum_month'] = before_two_month_stock_hfq_monthly.iloc[0].chg
98
+ elif month_num == 2:
99
+ k_line_info['month01'] = before_two_month_stock_hfq_monthly.iloc[0].chg
100
+ k_line_info['month02'] = before_two_month_stock_hfq_monthly.iloc[1].chg
101
+ k_line_info['month01_date'] = before_two_month_stock_hfq_monthly.iloc[0].date
102
+ k_line_info['month02_date'] = before_two_month_stock_hfq_monthly.iloc[1].date
103
+ close_price = before_two_month_stock_hfq_monthly.iloc[0].close
104
+ open_price = before_two_month_stock_hfq_monthly.iloc[1].last_price
105
+ sum_chg = round((close_price - open_price) * 100 / open_price, 2)
106
+ k_line_info['sum_month'] = sum_chg
107
+
108
+ last_year_month_number = stock_hfq_monthly_last_year.shape[0]
109
+ if last_year_month_number == 0:
110
+ k_line_info['last_year_chg'] = 0
111
+ elif last_year_month_number == 1:
112
+ k_line_info['last_year_chg'] = stock_hfq_monthly_last_year.iloc[0].chg
113
+ else:
114
+ close_price = stock_hfq_monthly_last_year.iloc[0].close
115
+ open_price = stock_hfq_monthly_last_year.iloc[last_year_month_number - 1].last_price
116
+ last_year_chg = round((close_price - open_price) * 100 / open_price, 2)
117
+ k_line_info['last_year_chg'] = last_year_chg
118
+
119
+ now_year_month_number = stock_hfq_monthly_now_year.shape[0]
120
+ if now_year_month_number == 0:
121
+ k_line_info['now_year_chg'] = 0
122
+ elif now_year_month_number == 1:
123
+ k_line_info['now_year_chg'] = stock_hfq_monthly_now_year.iloc[0].chg
124
+ else:
125
+ close_price = stock_hfq_monthly_now_year.iloc[0].close
126
+ open_price = stock_hfq_monthly_now_year.iloc[now_year_month_number - 1].last_price
127
+ last_year_chg = round((close_price - open_price) * 100 / open_price, 2)
128
+ k_line_info['now_year_chg'] = last_year_chg
67
129
 
68
130
  return k_line_info
69
131
 
@@ -105,8 +105,9 @@ def create_db_index(db_name):
105
105
 
106
106
 
107
107
  if __name__ == '__main__':
108
- sync_all_daily_data('daily', 'qfq', 'stock_qfq_daily', None, None)
109
- sync_all_daily_data('daily', 'qfq', 'stock_qfq_weekly', None, None)
108
+ sync_all_daily_data('monthly', 'qfq', 'stock_qfq_monthly', None, None)
109
+ # sync_all_daily_data('daily', 'qfq', 'stock_qfq_daily', None, None)
110
+ # sync_all_daily_data('daily', 'qfq', 'stock_qfq_weekly', None, None)
110
111
  # sync_all_daily_data('weekly', 'qfq', 'stock_qfq_weekly', None, None)
111
112
  # sync_all_daily_data('monthly', 'qfq', 'stock_qfq_monthly', None, None)
112
113
 
@@ -13,7 +13,7 @@ mongodb_util = MongodbUtil('27017')
13
13
 
14
14
 
15
15
  def clean_history_data():
16
- query = {"$and": [{"trade_date": {"$gte": '2023-11-06'}}, {"trade_date": {"$lte": '2025-01-23'}}]}
16
+ query = {"$and": [{"trade_date": {"$gte": '2023-11-06'}}, {"trade_date": {"$lte": '2024-12-19'}}]}
17
17
  trade_date_list_df = mongodb_util.find_query_data('trade_date_list', query)
18
18
  trade_date_list_df = trade_date_list_df.sort_values(by=['trade_date'], ascending=False)
19
19
  for trade_data_one in trade_date_list_df.itertuples():
@@ -25,6 +25,9 @@ def clean_history_data():
25
25
 
26
26
 
27
27
  if __name__ == '__main__':
28
+ k_line_info_clean_task.sync_k_line_info('2025-02-14', None)
29
+ k_line_info_clean_task.sync_k_line_info('2024-12-19', ['600992'])
30
+
28
31
  clean_history_data()
29
32
  # 001389 001359
30
33
  k_line_info_clean_task.sync_k_line_info('2025-02-14', None)
@@ -104,6 +104,8 @@ def add_trade_stocks():
104
104
  position_stock_df = mongodb_util.find_query_data(db_name_constant.POSITION_STOCK, query)
105
105
  if data_frame_util.is_not_empty(position_stock_df):
106
106
  stock_list = set(position_stock_df['symbol'])
107
+ else:
108
+ stock_list = set([])
107
109
  trade_stocks_df = mongodb_util.find_query_data(db_name_constant.BUY_STOCK_NAME, query)
108
110
  if data_frame_util.is_not_empty(trade_stocks_df):
109
111
  stock_list = stock_list.union(set(trade_stocks_df['symbol']))
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mns-scheduler
3
- Version: 1.2.6.1
3
+ Version: 1.2.6.2
4
4
 
@@ -69,18 +69,18 @@ mns_scheduler/k_line/clean/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlI
69
69
  mns_scheduler/k_line/clean/k_line_info_clean_impl.py,sha256=2GgRc9Nb9wXMueoZhl9egYzjQP_NPhBCvj-XYcTlG9w,1238
70
70
  mns_scheduler/k_line/clean/k_line_info_clean_task.py,sha256=ey6xTXAxxXh8_8cPzsWmUtVmG8Sd7jXFbpRpTrFrLDo,7622
71
71
  mns_scheduler/k_line/clean/daily/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
72
- mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py,sha256=eNP_nwZMYhLz8GAyFcQUS0p93qgdLurnY4sQdPRxliU,20027
73
- mns_scheduler/k_line/clean/daily/daily_k_line_service.py,sha256=JthnjPjo_h_CnuGw1xsXvFc-bqUL5Zp81BLZb3YhU5A,6904
72
+ mns_scheduler/k_line/clean/daily/daily_k_line_clean_common_service.py,sha256=ZOqaiQuOSFJsKZSW8GEQf1UkveKvg66f-bsHGAybvAM,20447
73
+ mns_scheduler/k_line/clean/daily/daily_k_line_service.py,sha256=AmnswvYlkO0gadMongt089WKWXdd-Cnku5AO0HSgDG0,6906
74
74
  mns_scheduler/k_line/clean/week_month/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
75
- mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py,sha256=4qInTtReDd77Jzb7ngme8yXHRd6INSbSCq84lhS3ScI,4862
75
+ mns_scheduler/k_line/clean/week_month/normal_week_month_k_line_service.py,sha256=bmoJgwfr2A35aWqgszmhck37JEWtg3LQ8QFWVd6DmN8,7994
76
76
  mns_scheduler/k_line/clean/week_month/sub_new_week_month_k_line_service.py,sha256=BS5wouEZhz4WfqubDgjO2CcfmYonCFqRl1BOPnVN3r8,5518
77
77
  mns_scheduler/k_line/hot_stocks/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
78
78
  mns_scheduler/k_line/hot_stocks/recent_hot_stocks_clean_service.py,sha256=whm-pYhAd_7OKurIw2cteBwWse5vVXS88lcrTbbcSaE,2628
79
79
  mns_scheduler/k_line/sync/__init__.py,sha256=ffZXFCLFdIwOsbxnw__u1MbQYh9yz7Bs8UMP6VF0X2M,161
80
80
  mns_scheduler/k_line/sync/bfq_k_line_sync.py,sha256=i2NNdp4uVa-kiqQvOaY6odd8-DmQtlejeMXeVklKOIs,4067
81
- mns_scheduler/k_line/sync/daily_week_month_line_sync.py,sha256=SHAvMkDW-2TKEC4wWkMdiOQWa4Ktc0Umm59OlceK1dg,5795
81
+ mns_scheduler/k_line/sync/daily_week_month_line_sync.py,sha256=4RKH7IpH7-NNGfXl7qM8jfL3in7-f92guW55hQ_k5MY,5875
82
82
  mns_scheduler/k_line/test/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
83
- mns_scheduler/k_line/test/k_line_info_clean_his_data.py,sha256=fbVKZIS9TzXlsWk5C6CdHCSgmeWL-7ppAf1bywUzsnE,1260
83
+ mns_scheduler/k_line/test/k_line_info_clean_his_data.py,sha256=1rvtC_RunMeiT1gwkiyvnLRPkC-wpclUiNjDkX_LV7g,1398
84
84
  mns_scheduler/kpl/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
85
85
  mns_scheduler/kpl/selection/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
86
86
  mns_scheduler/kpl/selection/index/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
@@ -112,7 +112,7 @@ mns_scheduler/risk/test/fix_blask_list.py,sha256=zfUUZl-RrvSCUJPIBdj27cDt3xmz8sx
112
112
  mns_scheduler/risk/transactions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
113
113
  mns_scheduler/risk/transactions/transactions_check_api.py,sha256=AQGPyOUNa-H_lWZ66Avn8nzyh3k1_doGxRm8BZ8EEfg,7261
114
114
  mns_scheduler/self_choose/__init__.py,sha256=wEg73KlZo-dU0yKGwpA1C2y6LZm4IBb94tNda1tqLeg,163
115
- mns_scheduler/self_choose/ths_self_choose_service.py,sha256=IC2FVHr2-IEG2GVo-uZBiheQlOswK-DqB_rCzDM_U2U,6558
115
+ mns_scheduler/self_choose/ths_self_choose_service.py,sha256=QCZ8LMwCV4awOM1wk1yPwzsVJmH1cwjV9o-OjI9n-XQ,6599
116
116
  mns_scheduler/trade/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
117
117
  mns_scheduler/trade/auto_ipo_buy_api.py,sha256=jVe5ZiXwzkDy_j_4X4rUamSzJpmzhV16lNKwbeWgpQw,386
118
118
  mns_scheduler/trade/auto_sell_service_api.py,sha256=b-4xmW6W6cd6dMuLPD7ZJu3tUtchMcUG-p7wOMm_RRY,4640
@@ -152,7 +152,7 @@ mns_scheduler/zt/zt_pool/ths_zt_pool_sync_api.py,sha256=Sy39T-yFwLSIIoSZqQzS-6-W
152
152
  mns_scheduler/zt/zt_pool/update_null_zt_reason_api.py,sha256=1uoiR2Uw46kDfjkvNg2US5rd_4OIkYO3872gIJOufUY,2135
153
153
  mns_scheduler/zz_task/__init__.py,sha256=QWBdZwBCvQw8aS4hnL9_pg3U3ZiNLUXzlImyy9WhUcI,163
154
154
  mns_scheduler/zz_task/data_sync_task.py,sha256=LZqcTIx4X9jNE_rTF3RxDzzD2X_xe7lTM7GtG_hV_fQ,22685
155
- mns_scheduler-1.2.6.1.dist-info/METADATA,sha256=YuqvO_yuF-e8fipv6MMN5twxnMffP65OyImTDuLLVxY,64
156
- mns_scheduler-1.2.6.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
157
- mns_scheduler-1.2.6.1.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
158
- mns_scheduler-1.2.6.1.dist-info/RECORD,,
155
+ mns_scheduler-1.2.6.2.dist-info/METADATA,sha256=3wsDhu546QeonjxQrC8S5FP1AB0Z71avYqawusMn8Aw,64
156
+ mns_scheduler-1.2.6.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
157
+ mns_scheduler-1.2.6.2.dist-info/top_level.txt,sha256=PXQDFBGR1pWmsUbH5yiLAh71P5HZODTRED0zJ8CCgOc,14
158
+ mns_scheduler-1.2.6.2.dist-info/RECORD,,