2.15
This commit is contained in:
@@ -8,3 +8,4 @@ import time
|
||||
# 读取本地保存的股票列表 CSV 文件(假设文件名为 stocks_data.csv)
|
||||
df = ts.pro_bar(ts_code='000001.SZ', adj='hfq', start_date='20180101')
|
||||
print(df)
|
||||
|
||||
|
||||
@@ -73,13 +73,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"is st...\n",
|
||||
" ts_code trade_date is_st\n",
|
||||
"0 688283.SH 20250207 False\n",
|
||||
"1 002635.SZ 20250207 False\n",
|
||||
"2 002463.SZ 20250207 False\n",
|
||||
"3 603959.SH 20250207 False\n",
|
||||
"4 688361.SH 20250207 False\n"
|
||||
"is st...\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -100,11 +94,8 @@
|
||||
" for i in range(len(df)):\n",
|
||||
" sds = df.iloc[i, 2]\n",
|
||||
" eds = df.iloc[i, 3]\n",
|
||||
" # sd = datetime.strptime(sds, '%Y%m%d')\n",
|
||||
" if eds == None:\n",
|
||||
" ed = datetime.now()\n",
|
||||
" # else:\n",
|
||||
" # ed = datetime.strptime(eds, '%Y%m%d')\n",
|
||||
" if eds is None or eds is pd.NaT:\n",
|
||||
" eds = datetime.now()\n",
|
||||
" if (target_date - sds).days >= 0 and (target_date - eds).days <= 0:\n",
|
||||
" return True\n",
|
||||
" return False\n",
|
||||
@@ -116,11 +107,54 @@
|
||||
" lambda row: is_st(name_change_dict, row['ts_code'], row['trade_date']), axis=1\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "c74bc633-fc73-48c2-bb44-0a798d2cf070",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Empty DataFrame\n",
|
||||
"Columns: [ts_code, trade_date, close, turnover_rate, turnover_rate_f, volume_ratio, pe, pe_ttm, pb, ps, ps_ttm, dv_ratio, dv_ttm, total_share, float_share, free_share, total_mv, circ_mv, is_st]\n",
|
||||
"Index: []\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(daily_basic[(daily_basic['is_st'] != True) & (daily_basic['is_st'] != False)])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "0464ce15-320c-40d4-b499-2e18bac5910f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date is_st\n",
|
||||
"0 002512.SZ 20250211 False\n",
|
||||
"1 600966.SH 20250211 False\n",
|
||||
"2 600358.SH 20250211 True\n",
|
||||
"3 002893.SZ 20250211 False\n",
|
||||
"4 300648.SZ 20250211 False\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# 保存结果到新的 HDF5 文件\n",
|
||||
"daily_basic.to_hdf('../../data/daily_basic.h5', key='daily_basic', mode='w', format='table')\n",
|
||||
"\n",
|
||||
"# 输出部分结果\n",
|
||||
"print(daily_basic[['ts_code', 'trade_date', 'is_st']].head())\n"
|
||||
"print(daily_basic[['ts_code', 'trade_date', 'is_st']].head())"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "18d1d622-b083-4cc4-a6f8-7c1ed2d0edd2",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -9,22 +10,24 @@
|
||||
"start_time": "2025-02-11T15:43:53.837662Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import tushare as ts\n",
|
||||
"ts.set_token('3a0741c702ee7e5e5f2bf1f0846bafaafe4e320833240b2a7e4a685f')\n",
|
||||
"pro = ts.pro_api()"
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "14671a7f72de2564",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:08.235573Z",
|
||||
"start_time": "2025-02-11T15:53:07.753701Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from datetime import datetime\n",
|
||||
"import pandas as pd\n",
|
||||
@@ -56,19 +59,38 @@
|
||||
" st_data = group[(group['change_reason'] == 'ST') | (group['change_reason'] == '*ST')]\n",
|
||||
" if not st_data.empty:\n",
|
||||
" name_change_dict[ts_code] = st_data"
|
||||
],
|
||||
"id": "14671a7f72de2564",
|
||||
"outputs": [],
|
||||
"execution_count": 31
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "e7f8cce2f80e2f20",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:19.812860Z",
|
||||
"start_time": "2025-02-11T15:53:09.614377Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"Index: 8291970 entries, 0 to 8291969\n",
|
||||
"Data columns (total 2 columns):\n",
|
||||
" # Column Dtype \n",
|
||||
"--- ------ ----- \n",
|
||||
" 0 ts_code object\n",
|
||||
" 1 trade_date object\n",
|
||||
"dtypes: object(2)\n",
|
||||
"memory usage: 189.8+ MB\n",
|
||||
"None\n",
|
||||
"20250211\n",
|
||||
"20250212\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import time\n",
|
||||
"from concurrent.futures import ThreadPoolExecutor, as_completed\n",
|
||||
@@ -87,40 +109,34 @@
|
||||
"trade_dates = trade_cal[trade_cal['cal_date'] > max_date]['cal_date'].tolist()\n",
|
||||
"start_date = min(trade_dates)\n",
|
||||
"print(start_date)"
|
||||
],
|
||||
"id": "e7f8cce2f80e2f20",
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "553cfb36-f560-4cc4-b2bc-68323ccc5072",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:24.100612Z",
|
||||
"start_time": "2025-02-11T15:53:22.361257Z"
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"Index: 8295494 entries, 0 to 8295493\n",
|
||||
"Data columns (total 2 columns):\n",
|
||||
" # Column Dtype \n",
|
||||
"--- ------ ----- \n",
|
||||
" 0 ts_code object\n",
|
||||
" 1 trade_date object\n",
|
||||
"dtypes: object(2)\n",
|
||||
"memory usage: 189.9+ MB\n",
|
||||
"None\n",
|
||||
"20250210\n",
|
||||
"20250211\n"
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250212 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 32
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "553cfb36-f560-4cc4-b2bc-68323ccc5072",
|
||||
"metadata": {
|
||||
"scrolled": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:24.100612Z",
|
||||
"start_time": "2025-02-11T15:53:22.361257Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -170,189 +186,169 @@
|
||||
" # 重置批次起始时间\n",
|
||||
" batch_start_time = time.time()\n",
|
||||
"\n"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250212 完成\n",
|
||||
"任务 20250211 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 33
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "919023c693d7a47a",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:25.913933Z",
|
||||
"start_time": "2025-02-11T15:53:25.902629Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n",
|
||||
"print(all_daily_data_df)"
|
||||
],
|
||||
"id": "919023c693d7a47a",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date close turnover_rate turnover_rate_f \\\n",
|
||||
"0 002512.SZ 20250211 5.03 5.9759 7.8713 \n",
|
||||
"1 600966.SH 20250211 4.83 0.6904 1.3494 \n",
|
||||
"2 600358.SH 20250211 3.68 8.5826 11.3780 \n",
|
||||
"3 002893.SZ 20250211 9.73 1.9217 2.6415 \n",
|
||||
"4 300648.SZ 20250211 22.90 1.7775 2.3188 \n",
|
||||
"0 601162.SH 20250212 4.77 7.3760 9.7054 \n",
|
||||
"1 603216.SH 20250212 11.42 8.8711 8.8711 \n",
|
||||
"2 872808.BJ 20250212 74.36 4.1219 15.3296 \n",
|
||||
"3 601881.SH 20250212 14.43 0.5617 1.9533 \n",
|
||||
"4 002837.SZ 20250212 42.25 3.8199 5.7136 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5380 300886.SZ 20250211 21.80 8.9341 13.4176 \n",
|
||||
"5381 600050.SH 20250211 5.48 2.3899 5.6722 \n",
|
||||
"5382 300149.SZ 20250211 6.73 3.5271 5.3077 \n",
|
||||
"5383 002197.SZ 20250211 4.42 4.0058 4.6595 \n",
|
||||
"5384 688270.SH 20250211 37.34 2.9212 2.9212 \n",
|
||||
"5380 603931.SH 20250212 23.83 1.4692 4.6843 \n",
|
||||
"5381 688567.SH 20250212 12.35 1.3091 2.1970 \n",
|
||||
"5382 688530.SH 20250212 19.30 6.6093 6.6093 \n",
|
||||
"5383 301363.SZ 20250212 31.99 2.1990 2.1990 \n",
|
||||
"5384 833533.BJ 20250212 46.02 27.7269 27.7597 \n",
|
||||
"\n",
|
||||
" volume_ratio pe pe_ttm pb ps ps_ttm dv_ratio \\\n",
|
||||
"0 0.87 NaN NaN 12.8888 2.9340 3.0625 0.0000 \n",
|
||||
"1 1.16 35.5101 15.2315 0.9534 0.3454 0.3402 0.5633 \n",
|
||||
"2 1.38 NaN NaN 15.2661 3.4220 4.2041 0.0000 \n",
|
||||
"3 0.85 48.9883 41.5405 2.2074 2.3641 2.3637 0.8222 \n",
|
||||
"4 0.69 NaN NaN 4.1442 3.7325 3.3186 0.0000 \n",
|
||||
"0 2.00 134.5633 NaN 1.7935 12.0634 19.0461 0.0000 \n",
|
||||
"1 2.09 26.5657 27.5224 1.4454 1.9304 1.9996 2.6270 \n",
|
||||
"2 1.20 142.3485 196.0315 22.9124 22.8711 25.8281 NaN \n",
|
||||
"3 0.84 20.0264 15.5707 1.4245 4.6898 4.4609 2.1067 \n",
|
||||
"4 0.65 91.3544 64.5935 11.2259 8.9056 7.2600 0.3621 \n",
|
||||
"... ... ... ... ... ... ... ... \n",
|
||||
"5380 3.00 NaN 111.0678 2.9043 6.0326 4.9204 0.0000 \n",
|
||||
"5381 1.15 21.3231 19.5079 1.0668 0.4677 0.4574 2.6625 \n",
|
||||
"5382 1.34 NaN NaN 2.5009 2.9440 3.3158 0.0000 \n",
|
||||
"5383 1.41 NaN NaN 1.1195 2.0851 2.5837 0.0000 \n",
|
||||
"5384 0.75 110.2738 170.0477 3.7594 28.4642 27.3030 NaN \n",
|
||||
"5380 1.16 27.1631 29.0662 3.0982 6.8392 6.9124 1.1120 \n",
|
||||
"5381 1.01 NaN NaN 1.4955 0.9183 1.0469 NaN \n",
|
||||
"5382 0.99 62.5995 198.4906 3.6879 6.4857 7.9319 NaN \n",
|
||||
"5383 0.98 41.5226 47.9900 3.8396 9.7258 8.9664 0.4982 \n",
|
||||
"5384 0.84 52.3997 62.1858 13.3582 6.6261 5.9638 NaN \n",
|
||||
"\n",
|
||||
" dv_ttm total_share float_share free_share total_mv \\\n",
|
||||
"0 NaN 1.147095e+05 1.048455e+05 7.959795e+04 5.769885e+05 \n",
|
||||
"1 0.5633 1.336844e+05 1.336844e+05 6.839785e+04 6.456958e+05 \n",
|
||||
"2 NaN 5.049367e+04 5.049367e+04 3.808829e+04 1.858167e+05 \n",
|
||||
"3 0.8222 2.636400e+04 2.027786e+04 1.475173e+04 2.565217e+05 \n",
|
||||
"4 NaN 1.477839e+04 1.061894e+04 8.140048e+03 3.384251e+05 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5380 NaN 7.455500e+03 4.346405e+03 2.894040e+03 1.625299e+05 \n",
|
||||
"5381 2.6625 3.180058e+06 3.128014e+06 1.317969e+06 1.742672e+07 \n",
|
||||
"5382 NaN 4.979640e+04 4.970844e+04 3.303210e+04 3.351298e+05 \n",
|
||||
"5383 NaN 6.143629e+04 5.340007e+04 4.590857e+04 2.715484e+05 \n",
|
||||
"5384 NaN 2.140516e+04 1.442317e+04 1.442317e+04 7.992687e+05 \n",
|
||||
" dv_ttm total_share float_share free_share total_mv \\\n",
|
||||
"0 NaN 8.665757e+05 866575.7464 658594.7570 4.133566e+06 \n",
|
||||
"1 2.6270 2.226900e+04 5669.0000 5669.0000 2.543120e+05 \n",
|
||||
"2 NaN 2.000000e+04 19461.9464 5233.0650 1.487200e+06 \n",
|
||||
"3 2.1067 1.093440e+06 724341.7623 208280.6759 1.577834e+07 \n",
|
||||
"4 0.3621 7.438227e+04 64662.2002 43230.4691 3.142651e+06 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5380 1.1120 1.995584e+04 19955.8380 6258.8392 4.755476e+05 \n",
|
||||
"5381 NaN 1.222104e+05 122210.3885 72818.9706 1.509298e+06 \n",
|
||||
"5382 NaN 1.600448e+04 3200.8966 3200.8966 3.088865e+05 \n",
|
||||
"5383 0.4982 4.066600e+04 11215.9100 11215.9100 1.300905e+06 \n",
|
||||
"5384 NaN 1.005826e+04 3796.0235 3791.5280 4.628809e+05 \n",
|
||||
"\n",
|
||||
" circ_mv is_st \n",
|
||||
"0 5.273728e+05 False \n",
|
||||
"1 6.456958e+05 False \n",
|
||||
"2 1.858167e+05 True \n",
|
||||
"3 1.973036e+05 False \n",
|
||||
"4 2.431738e+05 False \n",
|
||||
"0 4.133566e+06 False \n",
|
||||
"1 6.473998e+04 False \n",
|
||||
"2 1.447190e+06 False \n",
|
||||
"3 1.045225e+07 False \n",
|
||||
"4 2.731978e+06 False \n",
|
||||
"... ... ... \n",
|
||||
"5380 9.475163e+04 False \n",
|
||||
"5381 1.714152e+07 False \n",
|
||||
"5382 3.345378e+05 False \n",
|
||||
"5383 2.360283e+05 True \n",
|
||||
"5384 5.385612e+05 False \n",
|
||||
"5380 4.755476e+05 False \n",
|
||||
"5381 1.509298e+06 False \n",
|
||||
"5382 6.177730e+04 False \n",
|
||||
"5383 3.587970e+05 False \n",
|
||||
"5384 1.746930e+05 False \n",
|
||||
"\n",
|
||||
"[5385 rows x 19 columns]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 34
|
||||
"source": [
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n",
|
||||
"print(all_daily_data_df)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "28cb78d032671b20",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:42.062142Z",
|
||||
"start_time": "2025-02-11T15:53:42.044324Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": "print(all_daily_data_df[all_daily_data_df['is_st']])",
|
||||
"id": "28cb78d032671b20",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date close turnover_rate turnover_rate_f \\\n",
|
||||
"2 600358.SH 20250211 3.68 8.5826 11.3780 \n",
|
||||
"20 000889.SZ 20250211 2.48 2.0846 2.8167 \n",
|
||||
"50 603879.SH 20250211 3.58 1.7126 2.7285 \n",
|
||||
"62 002024.SZ 20250211 1.99 0.2997 0.8575 \n",
|
||||
"65 600078.SH 20250211 5.77 1.0536 1.8102 \n",
|
||||
"10 002366.SZ 20250212 5.10 3.8029 4.1742 \n",
|
||||
"48 002124.SZ 20250212 2.80 1.8388 1.9195 \n",
|
||||
"57 000504.SZ 20250212 9.32 0.9666 1.5370 \n",
|
||||
"63 603007.SH 20250212 10.03 2.0477 2.7581 \n",
|
||||
"91 300201.SZ 20250212 5.33 2.3317 3.1604 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5327 688309.SH 20250211 13.80 0.5594 1.0928 \n",
|
||||
"5328 002800.SZ 20250211 10.57 2.0449 3.9025 \n",
|
||||
"5342 300368.SZ 20250211 4.50 1.5755 2.2505 \n",
|
||||
"5375 600515.SH 20250211 3.64 0.4111 0.6804 \n",
|
||||
"5383 002197.SZ 20250211 4.42 4.0058 4.6595 \n",
|
||||
"5303 002316.SZ 20250212 3.52 3.1023 3.3580 \n",
|
||||
"5335 600568.SH 20250212 1.30 0.3996 0.6514 \n",
|
||||
"5364 002168.SZ 20250212 2.48 0.8869 1.0824 \n",
|
||||
"5367 300600.SZ 20250212 7.19 0.7517 1.4024 \n",
|
||||
"5369 000972.SZ 20250212 3.38 4.6979 7.2993 \n",
|
||||
"\n",
|
||||
" volume_ratio pe pe_ttm pb ps ps_ttm dv_ratio \\\n",
|
||||
"2 1.38 NaN NaN 15.2661 3.4220 4.2041 0.0000 \n",
|
||||
"20 1.08 NaN NaN 20.6126 1.6250 1.6047 0.0000 \n",
|
||||
"50 1.08 NaN NaN 3.4116 3.8093 3.5391 0.0000 \n",
|
||||
"62 1.01 NaN NaN 1.5246 0.2944 0.3546 0.0000 \n",
|
||||
"65 0.97 NaN NaN 2.1866 1.2329 1.2311 0.5373 \n",
|
||||
"... ... ... ... ... ... ... ... \n",
|
||||
"5327 0.73 60.8452 186.0174 1.5353 6.7361 13.4432 NaN \n",
|
||||
"5328 0.72 NaN NaN 3.0468 1.6938 1.3629 0.0000 \n",
|
||||
"5342 0.99 NaN NaN 7.1301 6.7544 11.8519 0.0000 \n",
|
||||
"5375 0.91 43.6494 110.6536 1.7765 6.1506 7.8214 0.0000 \n",
|
||||
"5383 1.41 NaN NaN 1.1195 2.0851 2.5837 0.0000 \n",
|
||||
" volume_ratio pe pe_ttm pb ps ps_ttm dv_ratio \\\n",
|
||||
"10 0.92 52.0324 56.8856 2.2889 14.2486 11.9214 0.0000 \n",
|
||||
"48 0.97 NaN 260.7218 1.7484 0.6080 0.6154 0.0000 \n",
|
||||
"57 0.83 NaN NaN 12.3702 22.4855 24.7156 0.0000 \n",
|
||||
"63 0.86 NaN NaN 24.6750 55.2244 76.4853 0.0000 \n",
|
||||
"91 0.75 26.1255 26.1088 4.2311 3.9774 4.2028 0.6431 \n",
|
||||
"... ... ... ... ... ... ... ... \n",
|
||||
"5303 0.95 NaN NaN 19.4146 2.2930 2.3153 0.0000 \n",
|
||||
"5335 0.76 NaN NaN 1.1378 4.0571 4.0379 0.0000 \n",
|
||||
"5364 0.88 1024.9794 NaN NaN 7.6515 7.4299 0.0000 \n",
|
||||
"5367 1.18 NaN NaN 2.2914 10.7845 8.9952 0.0000 \n",
|
||||
"5369 0.77 24.0853 120.2360 16.2931 4.5277 4.9137 0.0000 \n",
|
||||
"\n",
|
||||
" dv_ttm total_share float_share free_share total_mv \\\n",
|
||||
"2 NaN 5.049367e+04 50493.6660 38088.2934 1.858167e+05 \n",
|
||||
"20 NaN 9.362911e+04 86984.9676 64375.7658 2.322002e+05 \n",
|
||||
"50 NaN 3.593444e+04 35934.4440 22555.6496 1.286453e+05 \n",
|
||||
"62 NaN 9.264768e+05 919834.5068 321453.1001 1.843689e+06 \n",
|
||||
"65 0.5373 6.625729e+04 66257.2861 38563.8247 3.823045e+05 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5327 NaN 8.001073e+03 8001.0733 4095.6641 1.104148e+05 \n",
|
||||
"5328 NaN 1.522531e+04 14165.4100 7422.5200 1.609315e+05 \n",
|
||||
"5342 NaN 5.289435e+04 52894.3475 37030.2475 2.380246e+05 \n",
|
||||
"5375 NaN 1.142531e+06 917601.2508 554411.0843 4.158813e+06 \n",
|
||||
"5383 NaN 6.143629e+04 53400.0687 45908.5733 2.715484e+05 \n",
|
||||
" dv_ttm total_share float_share free_share total_mv \\\n",
|
||||
"10 NaN 208093.7640 125646.4390 114472.2056 1.061278e+06 \n",
|
||||
"48 NaN 222193.3832 197428.3498 189130.4452 6.221415e+05 \n",
|
||||
"57 NaN 33002.3098 31066.8701 19536.7046 3.075815e+05 \n",
|
||||
"63 NaN 87689.6101 49983.0778 37108.5778 8.795268e+05 \n",
|
||||
"91 0.6431 100904.3607 100450.7422 74110.3317 5.378202e+05 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"5303 NaN 39312.0000 31500.7500 29101.6694 1.383782e+05 \n",
|
||||
"5335 NaN 199286.9681 166906.7279 102374.4773 2.590731e+05 \n",
|
||||
"5364 NaN 78416.3368 78416.3368 64258.0991 1.944725e+05 \n",
|
||||
"5367 NaN 29423.4480 24616.3436 13195.4382 2.115546e+05 \n",
|
||||
"5369 NaN 77128.3579 77128.3579 49641.0760 2.606938e+05 \n",
|
||||
"\n",
|
||||
" circ_mv is_st \n",
|
||||
"2 1.858167e+05 True \n",
|
||||
"20 2.157227e+05 True \n",
|
||||
"50 1.286453e+05 True \n",
|
||||
"62 1.830471e+06 True \n",
|
||||
"65 3.823045e+05 True \n",
|
||||
"... ... ... \n",
|
||||
"5327 1.104148e+05 True \n",
|
||||
"5328 1.497284e+05 True \n",
|
||||
"5342 2.380246e+05 True \n",
|
||||
"5375 3.340069e+06 True \n",
|
||||
"5383 2.360283e+05 True \n",
|
||||
" circ_mv is_st \n",
|
||||
"10 640796.8389 True \n",
|
||||
"48 552799.3794 True \n",
|
||||
"57 289543.2293 True \n",
|
||||
"63 501330.2703 True \n",
|
||||
"91 535402.4559 True \n",
|
||||
"... ... ... \n",
|
||||
"5303 110882.6400 True \n",
|
||||
"5335 216978.7463 True \n",
|
||||
"5364 194472.5153 True \n",
|
||||
"5367 176991.5105 True \n",
|
||||
"5369 260693.8497 True \n",
|
||||
"\n",
|
||||
"[318 rows x 19 columns]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 37
|
||||
"source": [
|
||||
"print(all_daily_data_df[all_daily_data_df['is_st']])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "692b58674b7462c9",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:53:33.693894Z",
|
||||
"start_time": "2025-02-11T15:53:33.609884Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key='daily_basic', mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")\n"
|
||||
],
|
||||
"id": "692b58674b7462c9",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -362,29 +358,30 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 36
|
||||
"source": [
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key='daily_basic', mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "d7a773fc20293477",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:54:27.868021Z",
|
||||
"start_time": "2025-02-11T15:54:18.853803Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date', 'is_st']]\n",
|
||||
" print(df.info())"
|
||||
],
|
||||
"id": "d7a773fc20293477",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"Index: 8300879 entries, 0 to 5384\n",
|
||||
"Index: 8297355 entries, 0 to 5384\n",
|
||||
"Data columns (total 3 columns):\n",
|
||||
" # Column Dtype \n",
|
||||
"--- ------ ----- \n",
|
||||
@@ -392,12 +389,16 @@
|
||||
" 1 trade_date object\n",
|
||||
" 2 is_st bool \n",
|
||||
"dtypes: bool(1), object(2)\n",
|
||||
"memory usage: 197.9+ MB\n",
|
||||
"memory usage: 197.8+ MB\n",
|
||||
"None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 39
|
||||
"source": [
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date', 'is_st']]\n",
|
||||
" print(df.info())"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "b94bb1f2-5332-485e-ae1b-eea01f938106",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -9,43 +10,24 @@
|
||||
"start_time": "2025-02-11T15:21:54.050569Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import tushare as ts\n",
|
||||
"\n",
|
||||
"ts.set_token('3a0741c702ee7e5e5f2bf1f0846bafaafe4e320833240b2a7e4a685f')\n",
|
||||
"pro = ts.pro_api()"
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "742c29d453b9bb38",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:22:32.726905Z",
|
||||
"start_time": "2025-02-11T15:22:25.018135Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"h5_filename = '../../../data/money_flow.h5'\n",
|
||||
"key = '/money_flow'\n",
|
||||
"max_date = None\n",
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date']]\n",
|
||||
" print(df.info())\n",
|
||||
" max_date = df['trade_date'].max()\n",
|
||||
"\n",
|
||||
"print(max_date)\n",
|
||||
"trade_cal = pro.trade_cal(exchange='', start_date='20170101', end_date='20250220')\n",
|
||||
"trade_cal = trade_cal[trade_cal['is_open'] == 1] # 只保留交易日\n",
|
||||
"trade_dates = trade_cal[trade_cal['cal_date'] > max_date]['cal_date'].tolist()\n",
|
||||
"start_date = min(trade_dates)\n",
|
||||
"print(f'start_date: {start_date}')"
|
||||
],
|
||||
"id": "742c29d453b9bb38",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -66,18 +48,52 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 6
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"h5_filename = '../../../data/money_flow.h5'\n",
|
||||
"key = '/money_flow'\n",
|
||||
"max_date = None\n",
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date']]\n",
|
||||
" print(df.info())\n",
|
||||
" max_date = df['trade_date'].max()\n",
|
||||
"\n",
|
||||
"print(max_date)\n",
|
||||
"trade_cal = pro.trade_cal(exchange='', start_date='20170101', end_date='20250220')\n",
|
||||
"trade_cal = trade_cal[trade_cal['is_open'] == 1] # 只保留交易日\n",
|
||||
"trade_dates = trade_cal[trade_cal['cal_date'] > max_date]['cal_date'].tolist()\n",
|
||||
"start_date = min(trade_dates)\n",
|
||||
"print(f'start_date: {start_date}')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "679ce40e-8d62-4887-970c-e1d8cbdeee6b",
|
||||
"metadata": {
|
||||
"scrolled": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:22:14.513527Z",
|
||||
"start_time": "2025-02-11T15:22:12.973331Z"
|
||||
}
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250212 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from concurrent.futures import ThreadPoolExecutor, as_completed\n",
|
||||
"\n",
|
||||
@@ -107,40 +123,26 @@
|
||||
" except Exception as e:\n",
|
||||
" print(f\"获取 {trade_date} 数据时出错: {e}\")\n",
|
||||
"\n"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250212 完成\n",
|
||||
"任务 20250211 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 3
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "9af80516849d4e80",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:22:16.656650Z",
|
||||
"start_time": "2025-02-11T15:22:16.639271Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": "all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n",
|
||||
"id": "9af80516849d4e80",
|
||||
"outputs": [],
|
||||
"execution_count": 4
|
||||
"source": [
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "a2b05187-437f-4053-bc43-bd80d4cf8b0e",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -148,15 +150,6 @@
|
||||
"start_time": "2025-02-11T15:22:19.145561Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"\n",
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key='money_flow', mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -166,7 +159,15 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 5
|
||||
"source": [
|
||||
"\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"\n",
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key='money_flow', mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "500802dc-7a20-48b7-a470-a4bae3ec534b",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -9,17 +10,17 @@
|
||||
"start_time": "2025-02-11T15:18:36.020822Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import tushare as ts\n",
|
||||
"\n",
|
||||
"ts.set_token('3a0741c702ee7e5e5f2bf1f0846bafaafe4e320833240b2a7e4a685f')\n",
|
||||
"pro = ts.pro_api()"
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "5a84bc9da6d54868",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -27,26 +28,6 @@
|
||||
"start_time": "2025-02-11T15:20:00.110127Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"h5_filename = '../../../data/stk_limit.h5'\n",
|
||||
"key = '/stk_limit'\n",
|
||||
"max_date = None\n",
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date']]\n",
|
||||
" print(df.sort_values(by='trade_date', ascending=True).tail())\n",
|
||||
" print(df.info())\n",
|
||||
" max_date = df['trade_date'].max()\n",
|
||||
"\n",
|
||||
"print(max_date)\n",
|
||||
"trade_cal = pro.trade_cal(exchange='', start_date='20170101', end_date='20250220')\n",
|
||||
"trade_cal = trade_cal[trade_cal['is_open'] == 1] # 只保留交易日\n",
|
||||
"trade_dates = trade_cal[trade_cal['cal_date'] > max_date]['cal_date'].tolist()\n",
|
||||
"start_date = min(trade_dates)\n",
|
||||
"print(start_date)"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -73,18 +54,53 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 5
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"h5_filename = '../../../data/stk_limit.h5'\n",
|
||||
"key = '/stk_limit'\n",
|
||||
"max_date = None\n",
|
||||
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
|
||||
" df = store[key][['ts_code', 'trade_date']]\n",
|
||||
" print(df.sort_values(by='trade_date', ascending=True).tail())\n",
|
||||
" print(df.info())\n",
|
||||
" max_date = df['trade_date'].max()\n",
|
||||
"\n",
|
||||
"print(max_date)\n",
|
||||
"trade_cal = pro.trade_cal(exchange='', start_date='20170101', end_date='20250220')\n",
|
||||
"trade_cal = trade_cal[trade_cal['is_open'] == 1] # 只保留交易日\n",
|
||||
"trade_dates = trade_cal[trade_cal['cal_date'] > max_date]['cal_date'].tolist()\n",
|
||||
"start_date = min(trade_dates)\n",
|
||||
"print(start_date)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "bb3191de-27a2-4c89-a3b5-32a0d7b9496f",
|
||||
"metadata": {
|
||||
"scrolled": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:21:27.831699Z",
|
||||
"start_time": "2025-02-11T15:21:26.665039Z"
|
||||
}
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250212 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from concurrent.futures import ThreadPoolExecutor, as_completed\n",
|
||||
"\n",
|
||||
@@ -115,64 +131,62 @@
|
||||
" except Exception as e:\n",
|
||||
" print(f\"获取 {trade_date} 数据时出错: {e}\")\n",
|
||||
"\n"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250220 完成\n",
|
||||
"任务 20250219 完成\n",
|
||||
"任务 20250217 完成\n",
|
||||
"任务 20250218 完成\n",
|
||||
"任务 20250214 完成\n",
|
||||
"任务 20250213 完成\n",
|
||||
"任务 20250212 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 10
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "96a81aa5890ea3c3",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-11T15:21:29.294283Z",
|
||||
"start_time": "2025-02-11T15:21:29.247112Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"print(all_daily_data)\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)"
|
||||
],
|
||||
"id": "96a81aa5890ea3c3",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "No objects to concatenate",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
|
||||
"\u001B[1;31mValueError\u001B[0m Traceback (most recent call last)",
|
||||
"Cell \u001B[1;32mIn[11], line 3\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;28mprint\u001B[39m(all_daily_data)\n\u001B[0;32m 2\u001B[0m \u001B[38;5;66;03m# 将所有数据合并为一个 DataFrame\u001B[39;00m\n\u001B[1;32m----> 3\u001B[0m all_daily_data_df \u001B[38;5;241m=\u001B[39m \u001B[43mpd\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mconcat\u001B[49m\u001B[43m(\u001B[49m\u001B[43mall_daily_data\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mignore_index\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mTrue\u001B[39;49;00m\u001B[43m)\u001B[49m\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\try_trader\\lib\\site-packages\\pandas\\core\\reshape\\concat.py:372\u001B[0m, in \u001B[0;36mconcat\u001B[1;34m(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)\u001B[0m\n\u001B[0;32m 369\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m copy \u001B[38;5;129;01mand\u001B[39;00m using_copy_on_write():\n\u001B[0;32m 370\u001B[0m copy \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mFalse\u001B[39;00m\n\u001B[1;32m--> 372\u001B[0m op \u001B[38;5;241m=\u001B[39m \u001B[43m_Concatenator\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 373\u001B[0m \u001B[43m \u001B[49m\u001B[43mobjs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 374\u001B[0m \u001B[43m \u001B[49m\u001B[43maxis\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43maxis\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 375\u001B[0m \u001B[43m \u001B[49m\u001B[43mignore_index\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mignore_index\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 376\u001B[0m \u001B[43m \u001B[49m\u001B[43mjoin\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mjoin\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 377\u001B[0m \u001B[43m \u001B[49m\u001B[43mkeys\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mkeys\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 378\u001B[0m \u001B[43m \u001B[49m\u001B[43mlevels\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mlevels\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 379\u001B[0m \u001B[43m \u001B[49m\u001B[43mnames\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnames\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 380\u001B[0m \u001B[43m \u001B[49m\u001B[43mverify_integrity\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mverify_integrity\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 381\u001B[0m \u001B[43m \u001B[49m\u001B[43mcopy\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mcopy\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 382\u001B[0m \u001B[43m \u001B[49m\u001B[43msort\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msort\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 383\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 385\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m op\u001B[38;5;241m.\u001B[39mget_result()\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\try_trader\\lib\\site-packages\\pandas\\core\\reshape\\concat.py:429\u001B[0m, in \u001B[0;36m_Concatenator.__init__\u001B[1;34m(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)\u001B[0m\n\u001B[0;32m 426\u001B[0m objs \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlist\u001B[39m(objs)\n\u001B[0;32m 428\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mlen\u001B[39m(objs) \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m:\n\u001B[1;32m--> 429\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mNo objects to concatenate\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 431\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m keys \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[0;32m 432\u001B[0m objs \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlist\u001B[39m(com\u001B[38;5;241m.\u001B[39mnot_none(\u001B[38;5;241m*\u001B[39mobjs))\n",
|
||||
"\u001B[1;31mValueError\u001B[0m: No objects to concatenate"
|
||||
"[ trade_date ts_code up_limit down_limit\n",
|
||||
"0 20250213 000001.SZ 12.56 10.28\n",
|
||||
"1 20250213 000002.SZ 8.76 7.16\n",
|
||||
"2 20250213 000004.SZ 15.40 12.60\n",
|
||||
"3 20250213 000006.SZ 7.92 6.48\n",
|
||||
"4 20250213 000007.SZ 7.39 6.05\n",
|
||||
"... ... ... ... ...\n",
|
||||
"7014 20250213 920108.BJ 27.22 14.66\n",
|
||||
"7015 20250213 920111.BJ 35.98 19.38\n",
|
||||
"7016 20250213 920116.BJ 80.44 43.32\n",
|
||||
"7017 20250213 920118.BJ 34.46 18.56\n",
|
||||
"7018 20250213 920128.BJ 39.84 21.46\n",
|
||||
"\n",
|
||||
"[7019 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
|
||||
"0 20250212 000001.SZ 12.56 10.28\n",
|
||||
"1 20250212 000002.SZ 7.96 6.52\n",
|
||||
"2 20250212 000004.SZ 15.07 12.33\n",
|
||||
"3 20250212 000006.SZ 7.74 6.34\n",
|
||||
"4 20250212 000007.SZ 7.40 6.06\n",
|
||||
"... ... ... ... ...\n",
|
||||
"7014 20250212 920108.BJ 27.41 14.77\n",
|
||||
"7015 20250212 920111.BJ 34.51 18.59\n",
|
||||
"7016 20250212 920116.BJ 79.66 42.90\n",
|
||||
"7017 20250212 920118.BJ 34.81 18.75\n",
|
||||
"7018 20250212 920128.BJ 38.98 21.00\n",
|
||||
"\n",
|
||||
"[7019 rows x 4 columns]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 11
|
||||
"source": [
|
||||
"print(all_daily_data)\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "ad9733a1-2f42-43ee-a98c-0bf699304c21",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -180,6 +194,15 @@
|
||||
"start_time": "2025-02-11T15:20:37.375220Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"所有每日基础数据获取并保存完毕!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -187,23 +210,7 @@
|
||||
"all_daily_data_df.to_hdf(h5_filename, key='stk_limit', mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "All objects passed were None",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
|
||||
"\u001B[1;31mValueError\u001B[0m Traceback (most recent call last)",
|
||||
"Cell \u001B[1;32mIn[7], line 2\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;66;03m# 将所有数据合并为一个 DataFrame\u001B[39;00m\n\u001B[1;32m----> 2\u001B[0m all_daily_data_df \u001B[38;5;241m=\u001B[39m \u001B[43mpd\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mconcat\u001B[49m\u001B[43m(\u001B[49m\u001B[43mall_daily_data\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mignore_index\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mTrue\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[0;32m 4\u001B[0m \u001B[38;5;66;03m# 将数据保存为 HDF5 文件(table 格式)\u001B[39;00m\n\u001B[0;32m 5\u001B[0m all_daily_data_df\u001B[38;5;241m.\u001B[39mto_hdf(h5_filename, key\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstk_limit\u001B[39m\u001B[38;5;124m'\u001B[39m, mode\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124ma\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;28mformat\u001B[39m\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtable\u001B[39m\u001B[38;5;124m'\u001B[39m, append\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, data_columns\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\try_trader\\lib\\site-packages\\pandas\\core\\reshape\\concat.py:372\u001B[0m, in \u001B[0;36mconcat\u001B[1;34m(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)\u001B[0m\n\u001B[0;32m 369\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m copy \u001B[38;5;129;01mand\u001B[39;00m using_copy_on_write():\n\u001B[0;32m 370\u001B[0m copy \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mFalse\u001B[39;00m\n\u001B[1;32m--> 372\u001B[0m op \u001B[38;5;241m=\u001B[39m \u001B[43m_Concatenator\u001B[49m\u001B[43m(\u001B[49m\n\u001B[0;32m 373\u001B[0m \u001B[43m \u001B[49m\u001B[43mobjs\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 374\u001B[0m \u001B[43m \u001B[49m\u001B[43maxis\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43maxis\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 375\u001B[0m \u001B[43m \u001B[49m\u001B[43mignore_index\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mignore_index\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 376\u001B[0m \u001B[43m \u001B[49m\u001B[43mjoin\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mjoin\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 377\u001B[0m \u001B[43m \u001B[49m\u001B[43mkeys\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mkeys\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 378\u001B[0m \u001B[43m \u001B[49m\u001B[43mlevels\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mlevels\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 379\u001B[0m \u001B[43m \u001B[49m\u001B[43mnames\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mnames\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 380\u001B[0m \u001B[43m \u001B[49m\u001B[43mverify_integrity\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mverify_integrity\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 381\u001B[0m \u001B[43m \u001B[49m\u001B[43mcopy\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mcopy\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 382\u001B[0m \u001B[43m \u001B[49m\u001B[43msort\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msort\u001B[49m\u001B[43m,\u001B[49m\n\u001B[0;32m 383\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 385\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m op\u001B[38;5;241m.\u001B[39mget_result()\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\try_trader\\lib\\site-packages\\pandas\\core\\reshape\\concat.py:452\u001B[0m, in \u001B[0;36m_Concatenator.__init__\u001B[1;34m(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)\u001B[0m\n\u001B[0;32m 449\u001B[0m keys \u001B[38;5;241m=\u001B[39m Index(clean_keys, name\u001B[38;5;241m=\u001B[39mname, dtype\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mgetattr\u001B[39m(keys, \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdtype\u001B[39m\u001B[38;5;124m\"\u001B[39m, \u001B[38;5;28;01mNone\u001B[39;00m))\n\u001B[0;32m 451\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mlen\u001B[39m(objs) \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m:\n\u001B[1;32m--> 452\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mAll objects passed were None\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 454\u001B[0m \u001B[38;5;66;03m# figure out what our result ndim is going to be\u001B[39;00m\n\u001B[0;32m 455\u001B[0m ndims \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mset\u001B[39m()\n",
|
||||
"\u001B[1;31mValueError\u001B[0m: All objects passed were None"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 7
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -3,8 +3,8 @@
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:52:54.170824Z",
|
||||
"start_time": "2025-02-09T14:52:53.544850Z"
|
||||
"end_time": "2025-02-11T16:39:38.576665Z",
|
||||
"start_time": "2025-02-11T16:39:38.019824Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -12,28 +12,38 @@
|
||||
"%load_ext autoreload\n",
|
||||
"%autoreload 2\n",
|
||||
"\n",
|
||||
"from utils.utils import read_and_merge_h5_data"
|
||||
"from utils.utils import read_and_merge_h5_data\n"
|
||||
],
|
||||
"id": "79a7758178bafdd3",
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"The autoreload extension is already loaded. To reload it, use:\n",
|
||||
" %reload_ext autoreload\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 8
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:53:36.873700Z",
|
||||
"start_time": "2025-02-09T14:52:54.170824Z"
|
||||
"end_time": "2025-02-11T16:40:45.842510Z",
|
||||
"start_time": "2025-02-11T16:39:54.757326Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"\n",
|
||||
"print('daily data')\n",
|
||||
"df = read_and_merge_h5_data('../../data/daily_data.h5', key='daily_data',\n",
|
||||
" columns=['ts_code', 'trade_date', 'open', 'close', 'high', 'low', 'vol'],\n",
|
||||
" df=None)\n",
|
||||
"\n",
|
||||
"print('daily basic')\n",
|
||||
"df = read_and_merge_h5_data('../../data/daily_basic.h5', key='daily_basic_with_st',\n",
|
||||
"df = read_and_merge_h5_data('../../data/daily_basic.h5', key='daily_basic',\n",
|
||||
" columns=['ts_code', 'trade_date', 'turnover_rate', 'pe_ttm', 'circ_mv', 'volume_ratio',\n",
|
||||
" 'is_st'], df=df)\n",
|
||||
"\n",
|
||||
@@ -60,26 +70,26 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 2
|
||||
"execution_count": 10
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:53:37.426404Z",
|
||||
"start_time": "2025-02-09T14:53:36.955552Z"
|
||||
"end_time": "2025-02-11T16:40:45.905077Z",
|
||||
"start_time": "2025-02-11T16:40:45.848510Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": "origin_columns = df.columns.tolist()",
|
||||
"id": "c4e9e1d31da6dba6",
|
||||
"outputs": [],
|
||||
"execution_count": 3
|
||||
"execution_count": 11
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:53:38.164112Z",
|
||||
"start_time": "2025-02-09T14:53:38.070007Z"
|
||||
"end_time": "2025-02-11T16:40:46.016229Z",
|
||||
"start_time": "2025-02-11T16:40:45.938587Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -221,13 +231,13 @@
|
||||
],
|
||||
"id": "a735bc02ceb4d872",
|
||||
"outputs": [],
|
||||
"execution_count": 4
|
||||
"execution_count": 12
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:53:49.153376Z",
|
||||
"start_time": "2025-02-09T14:53:38.164112Z"
|
||||
"end_time": "2025-02-11T16:40:56.805530Z",
|
||||
"start_time": "2025-02-11T16:40:46.048312Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -247,8 +257,8 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"RangeIndex: 8364308 entries, 0 to 8364307\n",
|
||||
"Data columns (total 83 columns):\n",
|
||||
"RangeIndex: 8375079 entries, 0 to 8375078\n",
|
||||
"Data columns (total 87 columns):\n",
|
||||
" # Column Dtype \n",
|
||||
"--- ------ ----- \n",
|
||||
" 0 ts_code object \n",
|
||||
@@ -258,103 +268,106 @@
|
||||
" 4 high float64 \n",
|
||||
" 5 low float64 \n",
|
||||
" 6 vol float64 \n",
|
||||
" 7 is_st object \n",
|
||||
" 8 up_limit float64 \n",
|
||||
" 9 down_limit float64 \n",
|
||||
" 10 buy_sm_vol float64 \n",
|
||||
" 11 sell_sm_vol float64 \n",
|
||||
" 12 buy_lg_vol float64 \n",
|
||||
" 13 sell_lg_vol float64 \n",
|
||||
" 14 buy_elg_vol float64 \n",
|
||||
" 15 sell_elg_vol float64 \n",
|
||||
" 16 net_mf_vol float64 \n",
|
||||
" 17 up float64 \n",
|
||||
" 18 down float64 \n",
|
||||
" 19 atr_14 float64 \n",
|
||||
" 20 atr_6 float64 \n",
|
||||
" 21 obv float64 \n",
|
||||
" 22 maobv_6 float64 \n",
|
||||
" 23 obv-maobv_6 float64 \n",
|
||||
" 24 rsi_3 float64 \n",
|
||||
" 25 rsi_6 float64 \n",
|
||||
" 26 rsi_9 float64 \n",
|
||||
" 27 return_10 float64 \n",
|
||||
" 28 return_20 float64 \n",
|
||||
" 29 avg_close_5 float64 \n",
|
||||
" 30 std_return_5 float64 \n",
|
||||
" 31 std_return_15 float64 \n",
|
||||
" 32 std_return_25 float64 \n",
|
||||
" 33 std_return_90 float64 \n",
|
||||
" 34 std_return_90_2 float64 \n",
|
||||
" 35 std_return_5 / std_return_90 float64 \n",
|
||||
" 36 std_return_5 / std_return_25 float64 \n",
|
||||
" 37 std_return_90 - std_return_90_2 float64 \n",
|
||||
" 38 ema_5 float64 \n",
|
||||
" 39 ema_13 float64 \n",
|
||||
" 40 ema_20 float64 \n",
|
||||
" 41 ema_60 float64 \n",
|
||||
" 42 act_factor1 float64 \n",
|
||||
" 43 act_factor2 float64 \n",
|
||||
" 44 act_factor3 float64 \n",
|
||||
" 45 act_factor4 float64 \n",
|
||||
" 46 act_factor5 float64 \n",
|
||||
" 47 act_factor6 float64 \n",
|
||||
" 48 rank_act_factor1 float64 \n",
|
||||
" 49 rank_act_factor2 float64 \n",
|
||||
" 50 rank_act_factor3 float64 \n",
|
||||
" 51 active_buy_volume_large float64 \n",
|
||||
" 52 active_buy_volume_big float64 \n",
|
||||
" 53 active_buy_volume_small float64 \n",
|
||||
" 54 buy_lg_vol - sell_lg_vol float64 \n",
|
||||
" 55 buy_elg_vol - sell_elg_vol float64 \n",
|
||||
" 56 future_return1 float64 \n",
|
||||
" 57 future_return2 float64 \n",
|
||||
" 58 future_return3 float64 \n",
|
||||
" 59 future_return4 float64 \n",
|
||||
" 60 future_return5 float64 \n",
|
||||
" 61 future_return6 float64 \n",
|
||||
" 62 future_return7 float64 \n",
|
||||
" 63 future_close1 float64 \n",
|
||||
" 64 future_close2 float64 \n",
|
||||
" 65 future_close3 float64 \n",
|
||||
" 66 future_close4 float64 \n",
|
||||
" 67 future_close5 float64 \n",
|
||||
" 68 future_af11 float64 \n",
|
||||
" 69 future_af12 float64 \n",
|
||||
" 70 future_af13 float64 \n",
|
||||
" 71 future_af14 float64 \n",
|
||||
" 72 future_af15 float64 \n",
|
||||
" 73 future_af21 float64 \n",
|
||||
" 74 future_af22 float64 \n",
|
||||
" 75 future_af23 float64 \n",
|
||||
" 76 future_af24 float64 \n",
|
||||
" 77 future_af25 float64 \n",
|
||||
" 78 future_af31 float64 \n",
|
||||
" 79 future_af32 float64 \n",
|
||||
" 80 future_af33 float64 \n",
|
||||
" 81 future_af34 float64 \n",
|
||||
" 82 future_af35 float64 \n",
|
||||
"dtypes: datetime64[ns](1), float64(80), object(2)\n",
|
||||
"memory usage: 5.2+ GB\n",
|
||||
" 7 turnover_rate float64 \n",
|
||||
" 8 pe_ttm float64 \n",
|
||||
" 9 circ_mv float64 \n",
|
||||
" 10 volume_ratio float64 \n",
|
||||
" 11 is_st object \n",
|
||||
" 12 up_limit float64 \n",
|
||||
" 13 down_limit float64 \n",
|
||||
" 14 buy_sm_vol float64 \n",
|
||||
" 15 sell_sm_vol float64 \n",
|
||||
" 16 buy_lg_vol float64 \n",
|
||||
" 17 sell_lg_vol float64 \n",
|
||||
" 18 buy_elg_vol float64 \n",
|
||||
" 19 sell_elg_vol float64 \n",
|
||||
" 20 net_mf_vol float64 \n",
|
||||
" 21 up float64 \n",
|
||||
" 22 down float64 \n",
|
||||
" 23 atr_14 float64 \n",
|
||||
" 24 atr_6 float64 \n",
|
||||
" 25 obv float64 \n",
|
||||
" 26 maobv_6 float64 \n",
|
||||
" 27 obv-maobv_6 float64 \n",
|
||||
" 28 rsi_3 float64 \n",
|
||||
" 29 rsi_6 float64 \n",
|
||||
" 30 rsi_9 float64 \n",
|
||||
" 31 return_10 float64 \n",
|
||||
" 32 return_20 float64 \n",
|
||||
" 33 avg_close_5 float64 \n",
|
||||
" 34 std_return_5 float64 \n",
|
||||
" 35 std_return_15 float64 \n",
|
||||
" 36 std_return_25 float64 \n",
|
||||
" 37 std_return_90 float64 \n",
|
||||
" 38 std_return_90_2 float64 \n",
|
||||
" 39 std_return_5 / std_return_90 float64 \n",
|
||||
" 40 std_return_5 / std_return_25 float64 \n",
|
||||
" 41 std_return_90 - std_return_90_2 float64 \n",
|
||||
" 42 ema_5 float64 \n",
|
||||
" 43 ema_13 float64 \n",
|
||||
" 44 ema_20 float64 \n",
|
||||
" 45 ema_60 float64 \n",
|
||||
" 46 act_factor1 float64 \n",
|
||||
" 47 act_factor2 float64 \n",
|
||||
" 48 act_factor3 float64 \n",
|
||||
" 49 act_factor4 float64 \n",
|
||||
" 50 act_factor5 float64 \n",
|
||||
" 51 act_factor6 float64 \n",
|
||||
" 52 rank_act_factor1 float64 \n",
|
||||
" 53 rank_act_factor2 float64 \n",
|
||||
" 54 rank_act_factor3 float64 \n",
|
||||
" 55 active_buy_volume_large float64 \n",
|
||||
" 56 active_buy_volume_big float64 \n",
|
||||
" 57 active_buy_volume_small float64 \n",
|
||||
" 58 buy_lg_vol - sell_lg_vol float64 \n",
|
||||
" 59 buy_elg_vol - sell_elg_vol float64 \n",
|
||||
" 60 future_return1 float64 \n",
|
||||
" 61 future_return2 float64 \n",
|
||||
" 62 future_return3 float64 \n",
|
||||
" 63 future_return4 float64 \n",
|
||||
" 64 future_return5 float64 \n",
|
||||
" 65 future_return6 float64 \n",
|
||||
" 66 future_return7 float64 \n",
|
||||
" 67 future_close1 float64 \n",
|
||||
" 68 future_close2 float64 \n",
|
||||
" 69 future_close3 float64 \n",
|
||||
" 70 future_close4 float64 \n",
|
||||
" 71 future_close5 float64 \n",
|
||||
" 72 future_af11 float64 \n",
|
||||
" 73 future_af12 float64 \n",
|
||||
" 74 future_af13 float64 \n",
|
||||
" 75 future_af14 float64 \n",
|
||||
" 76 future_af15 float64 \n",
|
||||
" 77 future_af21 float64 \n",
|
||||
" 78 future_af22 float64 \n",
|
||||
" 79 future_af23 float64 \n",
|
||||
" 80 future_af24 float64 \n",
|
||||
" 81 future_af25 float64 \n",
|
||||
" 82 future_af31 float64 \n",
|
||||
" 83 future_af32 float64 \n",
|
||||
" 84 future_af33 float64 \n",
|
||||
" 85 future_af34 float64 \n",
|
||||
" 86 future_af35 float64 \n",
|
||||
"dtypes: datetime64[ns](1), float64(84), object(2)\n",
|
||||
"memory usage: 5.4+ GB\n",
|
||||
"None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 5
|
||||
"execution_count": 13
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:55:28.712343Z",
|
||||
"start_time": "2025-02-09T14:53:49.279168Z"
|
||||
"end_time": "2025-02-11T16:42:03.707721Z",
|
||||
"start_time": "2025-02-11T16:40:56.889317Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"def filter_data(df):\n",
|
||||
" df = df.groupby('trade_date').apply(lambda x: x.nlargest(1000, 'act_factor3'))\n",
|
||||
" df = df[df['is_st'] == False]\n",
|
||||
" df = df[df['is_st'] == False]\n",
|
||||
" df = df[~df['is_st']]\n",
|
||||
" df = df[~df['ts_code'].str.startswith('30')]\n",
|
||||
" df = df[~df['ts_code'].str.startswith('68')]\n",
|
||||
" df = df[~df['ts_code'].str.startswith('8')]\n",
|
||||
@@ -372,106 +385,110 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"RangeIndex: 1136157 entries, 0 to 1136156\n",
|
||||
"Data columns (total 83 columns):\n",
|
||||
"RangeIndex: 1101560 entries, 0 to 1101559\n",
|
||||
"Data columns (total 87 columns):\n",
|
||||
" # Column Non-Null Count Dtype \n",
|
||||
"--- ------ -------------- ----- \n",
|
||||
" 0 ts_code 1136157 non-null object \n",
|
||||
" 1 trade_date 1136157 non-null datetime64[ns]\n",
|
||||
" 2 open 1136157 non-null float64 \n",
|
||||
" 3 close 1136157 non-null float64 \n",
|
||||
" 4 high 1136157 non-null float64 \n",
|
||||
" 5 low 1136157 non-null float64 \n",
|
||||
" 6 vol 1136157 non-null float64 \n",
|
||||
" 7 is_st 1136157 non-null object \n",
|
||||
" 8 up_limit 1135878 non-null float64 \n",
|
||||
" 9 down_limit 1135878 non-null float64 \n",
|
||||
" 10 buy_sm_vol 1135663 non-null float64 \n",
|
||||
" 11 sell_sm_vol 1135663 non-null float64 \n",
|
||||
" 12 buy_lg_vol 1135663 non-null float64 \n",
|
||||
" 13 sell_lg_vol 1135663 non-null float64 \n",
|
||||
" 14 buy_elg_vol 1135663 non-null float64 \n",
|
||||
" 15 sell_elg_vol 1135663 non-null float64 \n",
|
||||
" 16 net_mf_vol 1135663 non-null float64 \n",
|
||||
" 17 up 1136157 non-null float64 \n",
|
||||
" 18 down 1136157 non-null float64 \n",
|
||||
" 19 atr_14 1136157 non-null float64 \n",
|
||||
" 20 atr_6 1136157 non-null float64 \n",
|
||||
" 21 obv 1136157 non-null float64 \n",
|
||||
" 22 maobv_6 1136157 non-null float64 \n",
|
||||
" 23 obv-maobv_6 1136157 non-null float64 \n",
|
||||
" 24 rsi_3 1136157 non-null float64 \n",
|
||||
" 25 rsi_6 1136157 non-null float64 \n",
|
||||
" 26 rsi_9 1136157 non-null float64 \n",
|
||||
" 27 return_10 1136157 non-null float64 \n",
|
||||
" 28 return_20 1136157 non-null float64 \n",
|
||||
" 29 avg_close_5 1136157 non-null float64 \n",
|
||||
" 30 std_return_5 1136157 non-null float64 \n",
|
||||
" 31 std_return_15 1136157 non-null float64 \n",
|
||||
" 32 std_return_25 1136157 non-null float64 \n",
|
||||
" 33 std_return_90 1136131 non-null float64 \n",
|
||||
" 34 std_return_90_2 1136129 non-null float64 \n",
|
||||
" 35 std_return_5 / std_return_90 1136131 non-null float64 \n",
|
||||
" 36 std_return_5 / std_return_25 1136157 non-null float64 \n",
|
||||
" 37 std_return_90 - std_return_90_2 1136129 non-null float64 \n",
|
||||
" 38 ema_5 1136157 non-null float64 \n",
|
||||
" 39 ema_13 1136157 non-null float64 \n",
|
||||
" 40 ema_20 1136157 non-null float64 \n",
|
||||
" 41 ema_60 1136153 non-null float64 \n",
|
||||
" 42 act_factor1 1136157 non-null float64 \n",
|
||||
" 43 act_factor2 1136157 non-null float64 \n",
|
||||
" 44 act_factor3 1136157 non-null float64 \n",
|
||||
" 45 act_factor4 1136152 non-null float64 \n",
|
||||
" 46 act_factor5 1136152 non-null float64 \n",
|
||||
" 47 act_factor6 1136157 non-null float64 \n",
|
||||
" 48 rank_act_factor1 1136157 non-null float64 \n",
|
||||
" 49 rank_act_factor2 1136157 non-null float64 \n",
|
||||
" 50 rank_act_factor3 1136157 non-null float64 \n",
|
||||
" 51 active_buy_volume_large 1135659 non-null float64 \n",
|
||||
" 52 active_buy_volume_big 1135636 non-null float64 \n",
|
||||
" 53 active_buy_volume_small 1135663 non-null float64 \n",
|
||||
" 54 buy_lg_vol - sell_lg_vol 1135660 non-null float64 \n",
|
||||
" 55 buy_elg_vol - sell_elg_vol 1135640 non-null float64 \n",
|
||||
" 56 future_return1 1136157 non-null float64 \n",
|
||||
" 57 future_return2 1136157 non-null float64 \n",
|
||||
" 58 future_return3 1136157 non-null float64 \n",
|
||||
" 59 future_return4 1136157 non-null float64 \n",
|
||||
" 60 future_return5 1136157 non-null float64 \n",
|
||||
" 61 future_return6 1136157 non-null float64 \n",
|
||||
" 62 future_return7 1136157 non-null float64 \n",
|
||||
" 63 future_close1 1136157 non-null float64 \n",
|
||||
" 64 future_close2 1136157 non-null float64 \n",
|
||||
" 65 future_close3 1136157 non-null float64 \n",
|
||||
" 66 future_close4 1136157 non-null float64 \n",
|
||||
" 67 future_close5 1136157 non-null float64 \n",
|
||||
" 68 future_af11 1136157 non-null float64 \n",
|
||||
" 69 future_af12 1136157 non-null float64 \n",
|
||||
" 70 future_af13 1136157 non-null float64 \n",
|
||||
" 71 future_af14 1136157 non-null float64 \n",
|
||||
" 72 future_af15 1136157 non-null float64 \n",
|
||||
" 73 future_af21 1136157 non-null float64 \n",
|
||||
" 74 future_af22 1136157 non-null float64 \n",
|
||||
" 75 future_af23 1136157 non-null float64 \n",
|
||||
" 76 future_af24 1136157 non-null float64 \n",
|
||||
" 77 future_af25 1136157 non-null float64 \n",
|
||||
" 78 future_af31 1136157 non-null float64 \n",
|
||||
" 79 future_af32 1136157 non-null float64 \n",
|
||||
" 80 future_af33 1136157 non-null float64 \n",
|
||||
" 81 future_af34 1136157 non-null float64 \n",
|
||||
" 82 future_af35 1136157 non-null float64 \n",
|
||||
"dtypes: datetime64[ns](1), float64(80), object(2)\n",
|
||||
"memory usage: 719.5+ MB\n",
|
||||
" 0 ts_code 1101560 non-null object \n",
|
||||
" 1 trade_date 1101560 non-null datetime64[ns]\n",
|
||||
" 2 open 1101560 non-null float64 \n",
|
||||
" 3 close 1101560 non-null float64 \n",
|
||||
" 4 high 1101560 non-null float64 \n",
|
||||
" 5 low 1101560 non-null float64 \n",
|
||||
" 6 vol 1101560 non-null float64 \n",
|
||||
" 7 turnover_rate 1101560 non-null float64 \n",
|
||||
" 8 pe_ttm 932908 non-null float64 \n",
|
||||
" 9 circ_mv 1101560 non-null float64 \n",
|
||||
" 10 volume_ratio 1101096 non-null float64 \n",
|
||||
" 11 is_st 1101560 non-null object \n",
|
||||
" 12 up_limit 1101282 non-null float64 \n",
|
||||
" 13 down_limit 1101282 non-null float64 \n",
|
||||
" 14 buy_sm_vol 1101069 non-null float64 \n",
|
||||
" 15 sell_sm_vol 1101069 non-null float64 \n",
|
||||
" 16 buy_lg_vol 1101069 non-null float64 \n",
|
||||
" 17 sell_lg_vol 1101069 non-null float64 \n",
|
||||
" 18 buy_elg_vol 1101069 non-null float64 \n",
|
||||
" 19 sell_elg_vol 1101069 non-null float64 \n",
|
||||
" 20 net_mf_vol 1101069 non-null float64 \n",
|
||||
" 21 up 1101560 non-null float64 \n",
|
||||
" 22 down 1101560 non-null float64 \n",
|
||||
" 23 atr_14 1100687 non-null float64 \n",
|
||||
" 24 atr_6 1100687 non-null float64 \n",
|
||||
" 25 obv 1101560 non-null float64 \n",
|
||||
" 26 maobv_6 1101560 non-null float64 \n",
|
||||
" 27 obv-maobv_6 1101560 non-null float64 \n",
|
||||
" 28 rsi_3 1100687 non-null float64 \n",
|
||||
" 29 rsi_6 1100687 non-null float64 \n",
|
||||
" 30 rsi_9 1100687 non-null float64 \n",
|
||||
" 31 return_10 1101560 non-null float64 \n",
|
||||
" 32 return_20 1101560 non-null float64 \n",
|
||||
" 33 avg_close_5 1101560 non-null float64 \n",
|
||||
" 34 std_return_5 1101560 non-null float64 \n",
|
||||
" 35 std_return_15 1101560 non-null float64 \n",
|
||||
" 36 std_return_25 1101559 non-null float64 \n",
|
||||
" 37 std_return_90 1101533 non-null float64 \n",
|
||||
" 38 std_return_90_2 1101531 non-null float64 \n",
|
||||
" 39 std_return_5 / std_return_90 1101533 non-null float64 \n",
|
||||
" 40 std_return_5 / std_return_25 1101559 non-null float64 \n",
|
||||
" 41 std_return_90 - std_return_90_2 1101531 non-null float64 \n",
|
||||
" 42 ema_5 1100687 non-null float64 \n",
|
||||
" 43 ema_13 1100687 non-null float64 \n",
|
||||
" 44 ema_20 1100687 non-null float64 \n",
|
||||
" 45 ema_60 1100682 non-null float64 \n",
|
||||
" 46 act_factor1 1100687 non-null float64 \n",
|
||||
" 47 act_factor2 1100687 non-null float64 \n",
|
||||
" 48 act_factor3 1100687 non-null float64 \n",
|
||||
" 49 act_factor4 1100682 non-null float64 \n",
|
||||
" 50 act_factor5 1100682 non-null float64 \n",
|
||||
" 51 act_factor6 1100687 non-null float64 \n",
|
||||
" 52 rank_act_factor1 1100687 non-null float64 \n",
|
||||
" 53 rank_act_factor2 1100687 non-null float64 \n",
|
||||
" 54 rank_act_factor3 1100687 non-null float64 \n",
|
||||
" 55 active_buy_volume_large 1101065 non-null float64 \n",
|
||||
" 56 active_buy_volume_big 1101042 non-null float64 \n",
|
||||
" 57 active_buy_volume_small 1101069 non-null float64 \n",
|
||||
" 58 buy_lg_vol - sell_lg_vol 1101066 non-null float64 \n",
|
||||
" 59 buy_elg_vol - sell_elg_vol 1101046 non-null float64 \n",
|
||||
" 60 future_return1 1101560 non-null float64 \n",
|
||||
" 61 future_return2 1101560 non-null float64 \n",
|
||||
" 62 future_return3 1101560 non-null float64 \n",
|
||||
" 63 future_return4 1101560 non-null float64 \n",
|
||||
" 64 future_return5 1101560 non-null float64 \n",
|
||||
" 65 future_return6 1101560 non-null float64 \n",
|
||||
" 66 future_return7 1101560 non-null float64 \n",
|
||||
" 67 future_close1 1101560 non-null float64 \n",
|
||||
" 68 future_close2 1101560 non-null float64 \n",
|
||||
" 69 future_close3 1101560 non-null float64 \n",
|
||||
" 70 future_close4 1101560 non-null float64 \n",
|
||||
" 71 future_close5 1101560 non-null float64 \n",
|
||||
" 72 future_af11 1100687 non-null float64 \n",
|
||||
" 73 future_af12 1100687 non-null float64 \n",
|
||||
" 74 future_af13 1100687 non-null float64 \n",
|
||||
" 75 future_af14 1100687 non-null float64 \n",
|
||||
" 76 future_af15 1100687 non-null float64 \n",
|
||||
" 77 future_af21 1100687 non-null float64 \n",
|
||||
" 78 future_af22 1100687 non-null float64 \n",
|
||||
" 79 future_af23 1100687 non-null float64 \n",
|
||||
" 80 future_af24 1100687 non-null float64 \n",
|
||||
" 81 future_af25 1100687 non-null float64 \n",
|
||||
" 82 future_af31 1100687 non-null float64 \n",
|
||||
" 83 future_af32 1100687 non-null float64 \n",
|
||||
" 84 future_af33 1100687 non-null float64 \n",
|
||||
" 85 future_af34 1100687 non-null float64 \n",
|
||||
" 86 future_af35 1100687 non-null float64 \n",
|
||||
"dtypes: datetime64[ns](1), float64(84), object(2)\n",
|
||||
"memory usage: 731.2+ MB\n",
|
||||
"None\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 6
|
||||
"execution_count": 14
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T15:00:45.828404Z",
|
||||
"start_time": "2025-02-09T15:00:45.294830Z"
|
||||
"end_time": "2025-02-11T16:42:04.317134Z",
|
||||
"start_time": "2025-02-11T16:42:03.969288Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -516,17 +533,18 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['up', 'down', 'atr_14', 'atr_6', 'obv', 'maobv_6', 'obv-maobv_6', 'rsi_3', 'rsi_6', 'rsi_9', 'return_10', 'return_20', 'avg_close_5', 'std_return_5', 'std_return_15', 'std_return_25', 'std_return_90', 'std_return_90_2', 'std_return_5 / std_return_90', 'std_return_5 / std_return_25', 'std_return_90 - std_return_90_2', 'ema_5', 'ema_13', 'ema_20', 'ema_60', 'act_factor1', 'act_factor2', 'act_factor3', 'act_factor4', 'act_factor5', 'act_factor6', 'rank_act_factor1', 'rank_act_factor2', 'rank_act_factor3', 'active_buy_volume_large', 'active_buy_volume_big', 'active_buy_volume_small', 'buy_lg_vol - sell_lg_vol', 'buy_elg_vol - sell_elg_vol']\n"
|
||||
"860933\n",
|
||||
"240627\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 19
|
||||
"execution_count": 15
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:56:05.319915Z",
|
||||
"start_time": "2025-02-09T14:56:03.355725Z"
|
||||
"end_time": "2025-02-11T16:42:06.417436Z",
|
||||
"start_time": "2025-02-11T16:42:04.322121Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -558,26 +576,40 @@
|
||||
],
|
||||
"id": "f4f16d63ad18d1bc",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\liaozhaorun\\AppData\\Local\\Temp\\ipykernel_88940\\2181928612.py:16: SettingWithCopyWarning: \n",
|
||||
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
||||
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
||||
"\n",
|
||||
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
||||
" train_data['label'], test_data['label'] = get_label(train_data), get_label(test_data)\n",
|
||||
"C:\\Users\\liaozhaorun\\AppData\\Local\\Temp\\ipykernel_88940\\2181928612.py:16: SettingWithCopyWarning: \n",
|
||||
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
||||
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
||||
"\n",
|
||||
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
||||
" train_data['label'], test_data['label'] = get_label(train_data), get_label(test_data)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"875004\n",
|
||||
"最小日期: 2017-01-03\n",
|
||||
"最大日期: 2022-12-30\n",
|
||||
"260581\n",
|
||||
"最小日期: 2023-01-03\n",
|
||||
"最大日期: 2025-01-27\n"
|
||||
"747134\n",
|
||||
"184095\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 13
|
||||
"execution_count": 16
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:56:05.480695Z",
|
||||
"start_time": "2025-02-09T14:56:05.367238Z"
|
||||
"end_time": "2025-02-11T16:42:08.032246Z",
|
||||
"start_time": "2025-02-11T16:42:06.481439Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -771,13 +803,13 @@
|
||||
],
|
||||
"id": "8f134d435f71e9e2",
|
||||
"outputs": [],
|
||||
"execution_count": 14
|
||||
"execution_count": 17
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:56:05.576927Z",
|
||||
"start_time": "2025-02-09T14:56:05.480695Z"
|
||||
"end_time": "2025-02-11T16:42:08.126033Z",
|
||||
"start_time": "2025-02-11T16:42:08.047878Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -802,13 +834,13 @@
|
||||
],
|
||||
"id": "4a4542e1ed6afe7d",
|
||||
"outputs": [],
|
||||
"execution_count": 15
|
||||
"execution_count": 18
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:57:25.341222Z",
|
||||
"start_time": "2025-02-09T14:56:05.640256Z"
|
||||
"end_time": "2025-02-11T16:43:30.267422Z",
|
||||
"start_time": "2025-02-11T16:42:08.363141Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -831,22 +863,23 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"train data size: 875004\n",
|
||||
"train data size: 747134\n",
|
||||
"未发现缓存模型,开始训练新模型。\n",
|
||||
"Training until validation scores don't improve for 50 rounds\n",
|
||||
"[500]\ttrain's l2: 0.415226\tvalid's l2: 0.57674\n",
|
||||
"Early stopping, best iteration is:\n",
|
||||
"[378]\ttrain's l2: 0.435049\tvalid's l2: 0.589178\n",
|
||||
"[477]\ttrain's l2: 0.417575\tvalid's l2: 0.576627\n",
|
||||
"Evaluated only: l2\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 16
|
||||
"execution_count": 19
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:57:27.394697Z",
|
||||
"start_time": "2025-02-09T14:57:25.373274Z"
|
||||
"end_time": "2025-02-11T16:43:32.102494Z",
|
||||
"start_time": "2025-02-11T16:43:30.315429Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
@@ -856,20 +889,20 @@
|
||||
],
|
||||
"id": "5bb96ca8492e74d",
|
||||
"outputs": [],
|
||||
"execution_count": 17
|
||||
"execution_count": 20
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-09T14:57:27.489570Z",
|
||||
"start_time": "2025-02-09T14:57:27.397368Z"
|
||||
"end_time": "2025-02-11T16:43:32.197091Z",
|
||||
"start_time": "2025-02-11T16:43:32.107477Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": "predictions[['trade_date', 'score', 'ts_code']].to_csv('predictions.csv', index=False)",
|
||||
"id": "5d1522a7538db91b",
|
||||
"outputs": [],
|
||||
"execution_count": 18
|
||||
"execution_count": 21
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -1,486 +0,0 @@
|
||||
trade_date,score,ts_code
|
||||
2023-01-03,0.6847274162535452,600965.SH
|
||||
2023-01-04,0.7414192412896188,000615.SZ
|
||||
2023-01-05,0.5542654290126795,000430.SZ
|
||||
2023-01-06,0.6959513776962396,002640.SZ
|
||||
2023-01-09,0.7412055912703203,600785.SH
|
||||
2023-01-10,0.6855907318251123,002762.SZ
|
||||
2023-01-11,0.7292345443148791,002719.SZ
|
||||
2023-01-12,0.7309633018913224,600996.SH
|
||||
2023-01-13,0.8190324397886146,002279.SZ
|
||||
2023-01-16,0.784606092607123,000850.SZ
|
||||
2023-01-17,0.7241262895910806,002441.SZ
|
||||
2023-01-18,0.7040191348893544,002467.SZ
|
||||
2023-01-19,1.4428906481799044,002195.SZ
|
||||
2023-01-20,0.8043769403690574,000561.SZ
|
||||
2023-01-30,0.8713260866140435,000913.SZ
|
||||
2023-01-31,0.7091214216170246,002560.SZ
|
||||
2023-02-01,0.8674507984004312,002576.SZ
|
||||
2023-02-02,0.8435316672358789,002576.SZ
|
||||
2023-02-03,0.3637794960484866,603698.SH
|
||||
2023-02-06,0.8498784343039595,002401.SZ
|
||||
2023-02-07,0.5210597972482388,002767.SZ
|
||||
2023-02-08,0.9567872514253289,002368.SZ
|
||||
2023-02-09,0.5267235816880836,002155.SZ
|
||||
2023-02-10,0.8402723790587989,002348.SZ
|
||||
2023-02-13,0.4846072502710197,002348.SZ
|
||||
2023-02-14,0.7626025684565886,002877.SZ
|
||||
2023-02-15,0.697045569808066,600225.SH
|
||||
2023-02-16,0.8282986278708487,002748.SZ
|
||||
2023-02-17,1.8315250204409614,601020.SH
|
||||
2023-02-20,0.9746443150927466,003021.SZ
|
||||
2023-02-21,1.33028636760986,002339.SZ
|
||||
2023-02-22,0.7778102046341324,002167.SZ
|
||||
2023-02-23,1.1313865958453686,600100.SH
|
||||
2023-02-24,0.5636940136703907,000716.SZ
|
||||
2023-02-27,1.1864163478203489,600557.SH
|
||||
2023-02-28,1.0001756905854564,603129.SH
|
||||
2023-03-01,0.859829916936714,603025.SH
|
||||
2023-03-02,0.7059826582301507,603186.SH
|
||||
2023-03-03,0.6713484518505006,002942.SZ
|
||||
2023-03-06,0.7514650334919161,002362.SZ
|
||||
2023-03-07,0.9199279895136431,002350.SZ
|
||||
2023-03-08,0.7172896853160168,601872.SH
|
||||
2023-03-09,1.2558830649002728,002808.SZ
|
||||
2023-03-10,1.2172505980712502,003020.SZ
|
||||
2023-03-13,0.5215320654292881,600363.SH
|
||||
2023-03-14,1.0463998807907229,601872.SH
|
||||
2023-03-15,0.583641209552904,603966.SH
|
||||
2023-03-16,0.9789347178467226,603803.SH
|
||||
2023-03-17,0.6572400306835567,600780.SH
|
||||
2023-03-20,0.9514948440683256,601003.SH
|
||||
2023-03-21,0.842214622933076,002439.SZ
|
||||
2023-03-22,1.1462525936633026,601698.SH
|
||||
2023-03-23,0.48812639918095935,601199.SH
|
||||
2023-03-24,0.4727906220196696,601698.SH
|
||||
2023-03-27,0.7956407883949915,000810.SZ
|
||||
2023-03-28,0.9780023176799034,601698.SH
|
||||
2023-03-29,0.7581739222176508,002558.SZ
|
||||
2023-03-30,1.2088597249444364,002425.SZ
|
||||
2023-03-31,1.0383208709472522,000938.SZ
|
||||
2023-04-03,0.7742369597473725,001872.SZ
|
||||
2023-04-04,0.8024470755073208,002858.SZ
|
||||
2023-04-06,0.7607284837753079,002261.SZ
|
||||
2023-04-07,0.9927088245634893,002261.SZ
|
||||
2023-04-10,0.8693657271995023,603019.SH
|
||||
2023-04-11,1.3756495540495381,600228.SH
|
||||
2023-04-12,0.6041603413288005,002222.SZ
|
||||
2023-04-13,0.7744980911161148,002777.SZ
|
||||
2023-04-14,0.8672190988257731,600633.SH
|
||||
2023-04-17,1.4449313652608706,603083.SH
|
||||
2023-04-18,0.6773096694945689,002517.SZ
|
||||
2023-04-19,2.078581022345213,002908.SZ
|
||||
2023-04-20,0.9806780152085147,600203.SH
|
||||
2023-04-21,0.8344159521107176,000686.SZ
|
||||
2023-04-24,1.210049105329498,600749.SH
|
||||
2023-04-25,1.4048193576090038,603699.SH
|
||||
2023-04-26,1.4845584717530398,600750.SH
|
||||
2023-04-27,1.7290167418990006,002351.SZ
|
||||
2023-04-28,0.6169128309035838,002343.SZ
|
||||
2023-05-04,0.406077908055111,603019.SH
|
||||
2023-05-05,0.9080152593104391,603258.SH
|
||||
2023-05-08,0.796876165601434,603083.SH
|
||||
2023-05-09,0.9700970682165659,002291.SZ
|
||||
2023-05-10,1.3258832446428042,002291.SZ
|
||||
2023-05-11,0.8900850443360986,600750.SH
|
||||
2023-05-12,1.0650432251092237,601318.SH
|
||||
2023-05-15,0.6787099027648815,002760.SZ
|
||||
2023-05-16,0.722076527194143,603357.SH
|
||||
2023-05-17,1.053645140729648,603357.SH
|
||||
2023-05-18,0.6034913204660662,601518.SH
|
||||
2023-05-19,0.5868824391890941,000600.SZ
|
||||
2023-05-22,0.7653788907870708,002315.SZ
|
||||
2023-05-23,0.8498831870683509,003021.SZ
|
||||
2023-05-24,0.8222394685174235,600337.SH
|
||||
2023-05-25,0.9415393784400905,600587.SH
|
||||
2023-05-26,0.520220425480583,000600.SZ
|
||||
2023-05-29,0.6595697603731597,002334.SZ
|
||||
2023-05-30,0.606477318736669,603790.SH
|
||||
2023-05-31,0.694237121673502,603662.SH
|
||||
2023-06-01,0.5921959927449983,603196.SH
|
||||
2023-06-02,0.6895081721399422,603019.SH
|
||||
2023-06-05,0.5566382152721012,001309.SZ
|
||||
2023-06-06,1.892873809852157,002587.SZ
|
||||
2023-06-07,0.7678242983656595,605011.SH
|
||||
2023-06-08,1.0539866095101476,000938.SZ
|
||||
2023-06-09,0.8147649527362582,002292.SZ
|
||||
2023-06-12,0.7188933998461803,002173.SZ
|
||||
2023-06-13,0.681977313547429,603097.SH
|
||||
2023-06-14,0.8733642333159071,002865.SZ
|
||||
2023-06-15,0.8968643954524321,603108.SH
|
||||
2023-06-16,0.7840028396319321,002897.SZ
|
||||
2023-06-19,0.8775653925608153,603319.SH
|
||||
2023-06-20,1.0844187891842454,002902.SZ
|
||||
2023-06-21,1.2927896026027148,603629.SH
|
||||
2023-06-26,1.2292848291237288,002261.SZ
|
||||
2023-06-27,1.3781866321602365,000938.SZ
|
||||
2023-06-28,0.8540277846763247,601138.SH
|
||||
2023-06-29,0.8523211757782663,603779.SH
|
||||
2023-06-30,1.1754329601349267,601127.SH
|
||||
2023-07-03,1.2249906293712542,603015.SH
|
||||
2023-07-04,1.1084820336750372,000936.SZ
|
||||
2023-07-05,1.2710980206868936,000936.SZ
|
||||
2023-07-06,0.747949676257483,603728.SH
|
||||
2023-07-07,0.9061602512086774,002835.SZ
|
||||
2023-07-10,0.9551342600022579,002126.SZ
|
||||
2023-07-11,0.966971776030953,603767.SH
|
||||
2023-07-12,0.9443518376543841,601886.SH
|
||||
2023-07-13,0.6769606633633086,603085.SH
|
||||
2023-07-14,0.918333951173531,002036.SZ
|
||||
2023-07-17,0.6569232106980998,603045.SH
|
||||
2023-07-18,0.7121594789903711,002409.SZ
|
||||
2023-07-19,0.7294037039105077,002548.SZ
|
||||
2023-07-20,0.7381883846308512,002703.SZ
|
||||
2023-07-21,0.7652204062690017,002997.SZ
|
||||
2023-07-24,0.9003480376547147,000550.SZ
|
||||
2023-07-25,0.6357345607310146,605020.SH
|
||||
2023-07-26,0.5810885924302148,605020.SH
|
||||
2023-07-27,0.8761890730266239,002316.SZ
|
||||
2023-07-28,0.9028509127260252,000716.SZ
|
||||
2023-07-31,0.4708956316796065,601777.SH
|
||||
2023-08-01,0.5561891737811866,600763.SH
|
||||
2023-08-02,0.8760196470112966,002719.SZ
|
||||
2023-08-03,0.7648464404493108,002400.SZ
|
||||
2023-08-04,0.7791782042380738,601799.SH
|
||||
2023-08-07,0.8061135186567487,000797.SZ
|
||||
2023-08-08,1.1666879365515435,600322.SH
|
||||
2023-08-09,1.4355955291322207,000006.SZ
|
||||
2023-08-10,1.2886157376213954,000656.SZ
|
||||
2023-08-11,1.3479230675318692,002941.SZ
|
||||
2023-08-14,1.0490220109983646,601377.SH
|
||||
2023-08-15,1.0632174359473308,600376.SH
|
||||
2023-08-16,1.050421116938835,002126.SZ
|
||||
2023-08-17,0.6717173215978612,000948.SZ
|
||||
2023-08-18,0.9668301556287141,002907.SZ
|
||||
2023-08-21,1.1746853792925736,003005.SZ
|
||||
2023-08-22,0.9584954141170795,600838.SH
|
||||
2023-08-23,1.2457408517312187,001234.SZ
|
||||
2023-08-24,1.0823923917882998,002999.SZ
|
||||
2023-08-25,0.9378153059525566,603918.SH
|
||||
2023-08-28,1.2421433405918902,603767.SH
|
||||
2023-08-29,0.616127073238452,002696.SZ
|
||||
2023-08-30,0.9031479500764501,000010.SZ
|
||||
2023-08-31,0.8845829289455852,000010.SZ
|
||||
2023-09-01,0.6016754849643945,600272.SH
|
||||
2023-09-04,0.7558571185023197,600272.SH
|
||||
2023-09-05,0.4028980705656072,000678.SZ
|
||||
2023-09-06,0.659374499556469,603080.SH
|
||||
2023-09-07,0.6245495405404559,000609.SZ
|
||||
2023-09-08,0.6710722697700532,603919.SH
|
||||
2023-09-11,0.6278048802992457,600546.SH
|
||||
2023-09-12,0.8256329238016435,600546.SH
|
||||
2023-09-13,0.9974851537103986,601127.SH
|
||||
2023-09-14,1.2529240943908486,603005.SH
|
||||
2023-09-15,0.6551278623697204,603306.SH
|
||||
2023-09-18,0.62491397271537,000851.SZ
|
||||
2023-09-19,0.9590430560641906,600293.SH
|
||||
2023-09-20,0.9192992329949209,600895.SH
|
||||
2023-09-21,1.303323539412371,603667.SH
|
||||
2023-09-22,0.6392556165728372,002406.SZ
|
||||
2023-09-25,0.550363061204975,603933.SH
|
||||
2023-09-26,0.8885810012289143,000766.SZ
|
||||
2023-09-27,1.3119504188158804,605588.SH
|
||||
2023-09-28,0.6383963467007131,002885.SZ
|
||||
2023-10-09,0.5559833174181884,603277.SH
|
||||
2023-10-10,0.6746335129218759,002855.SZ
|
||||
2023-10-11,0.48076279797688554,001319.SZ
|
||||
2023-10-12,0.4648032423789084,002953.SZ
|
||||
2023-10-13,0.7973569102606312,605588.SH
|
||||
2023-10-16,0.6753500013003589,603929.SH
|
||||
2023-10-17,0.939032197442827,002786.SZ
|
||||
2023-10-18,1.3316765134484991,603005.SH
|
||||
2023-10-19,1.5107094655109568,002728.SZ
|
||||
2023-10-20,1.8033472200834302,603890.SH
|
||||
2023-10-23,2.0156758075487904,000526.SZ
|
||||
2023-10-24,1.733095955568728,600186.SH
|
||||
2023-10-25,1.0763644734039597,002456.SZ
|
||||
2023-10-26,0.6254989123134431,600155.SH
|
||||
2023-10-27,0.9189894086467906,000712.SZ
|
||||
2023-10-30,0.82608918468284,600839.SH
|
||||
2023-10-31,0.7212314254570089,001319.SZ
|
||||
2023-11-01,0.7217175319235539,002657.SZ
|
||||
2023-11-02,0.7778599932153227,002456.SZ
|
||||
2023-11-03,1.3422820103526423,603985.SH
|
||||
2023-11-06,0.5239681122691597,600595.SH
|
||||
2023-11-07,0.5067988914432168,000520.SZ
|
||||
2023-11-08,0.8068628626883659,603009.SH
|
||||
2023-11-09,0.795444145270753,601127.SH
|
||||
2023-11-10,0.7853290033363176,600630.SH
|
||||
2023-11-13,0.6675304106579922,601595.SH
|
||||
2023-11-14,0.2361369659661822,000828.SZ
|
||||
2023-11-15,1.3945937102768664,603598.SH
|
||||
2023-11-16,0.9576360953800751,000628.SZ
|
||||
2023-11-17,0.6890730621251102,603108.SH
|
||||
2023-11-20,0.7909511281469108,000628.SZ
|
||||
2023-11-21,0.8142228770378246,000925.SZ
|
||||
2023-11-22,0.797507102177366,000550.SZ
|
||||
2023-11-23,0.7063630358338048,000676.SZ
|
||||
2023-11-24,1.036008941153352,002181.SZ
|
||||
2023-11-27,1.0291531391754778,000503.SZ
|
||||
2023-11-28,0.9076486100273481,600775.SH
|
||||
2023-11-29,0.7882491062137358,000669.SZ
|
||||
2023-11-30,1.0967518981113826,000669.SZ
|
||||
2023-12-01,0.7311870736612255,000625.SZ
|
||||
2023-12-04,1.0691371238894785,603286.SH
|
||||
2023-12-05,1.3131270390024472,605188.SH
|
||||
2023-12-06,0.7752257820655966,000628.SZ
|
||||
2023-12-07,0.8197027217611897,600107.SH
|
||||
2023-12-08,1.3967047074635028,603488.SH
|
||||
2023-12-11,0.687045285463665,002277.SZ
|
||||
2023-12-12,0.665884682887716,600593.SH
|
||||
2023-12-13,0.654047737248992,600476.SH
|
||||
2023-12-14,1.0532572750390772,603106.SH
|
||||
2023-12-15,1.0658083351666034,603358.SH
|
||||
2023-12-18,0.962400311858336,000766.SZ
|
||||
2023-12-19,0.7287547482546808,603103.SH
|
||||
2023-12-20,1.2148728495986132,002647.SZ
|
||||
2023-12-21,0.7541763251442525,002858.SZ
|
||||
2023-12-22,0.8726322448001688,600178.SH
|
||||
2023-12-25,0.8241484608574933,605011.SH
|
||||
2023-12-26,0.9109440061301425,603992.SH
|
||||
2023-12-27,0.8418823218408088,002660.SZ
|
||||
2023-12-28,0.6918104133614209,002238.SZ
|
||||
2023-12-29,0.587505902687491,002495.SZ
|
||||
2024-01-02,0.9211111544777676,002587.SZ
|
||||
2024-01-03,0.7226235020970133,000691.SZ
|
||||
2024-01-04,0.9569550769001772,002962.SZ
|
||||
2024-01-05,1.1926365483735857,605117.SH
|
||||
2024-01-08,1.2688927804343633,603032.SH
|
||||
2024-01-09,0.658120719671456,002862.SZ
|
||||
2024-01-10,1.0753659753822198,000698.SZ
|
||||
2024-01-11,0.8894494773121738,603097.SH
|
||||
2024-01-12,0.9087175987157813,600593.SH
|
||||
2024-01-15,0.5892323752732013,603212.SH
|
||||
2024-01-16,0.7839193778147607,000698.SZ
|
||||
2024-01-17,1.0625258983405035,603172.SH
|
||||
2024-01-18,1.2631347573071583,002033.SZ
|
||||
2024-01-19,1.178331671274573,603579.SH
|
||||
2024-01-22,1.6352965224693876,605268.SH
|
||||
2024-01-23,1.4266068895392103,605117.SH
|
||||
2024-01-24,0.8002314972730927,600138.SH
|
||||
2024-01-25,0.6269522471780932,603099.SH
|
||||
2024-01-26,1.1309900405971738,605111.SH
|
||||
2024-01-29,1.125066361142788,002253.SZ
|
||||
2024-01-30,1.351423375727843,003007.SZ
|
||||
2024-01-31,1.5739771441257069,601138.SH
|
||||
2024-02-01,1.499054147286471,002033.SZ
|
||||
2024-02-02,1.5167645269468597,601038.SH
|
||||
2024-02-05,1.903436398968963,000998.SZ
|
||||
2024-02-06,0.8212170920332696,600705.SH
|
||||
2024-02-07,0.8351364611756162,603199.SH
|
||||
2024-02-08,0.6822013314565247,601998.SH
|
||||
2024-02-19,0.5444839345994206,000999.SZ
|
||||
2024-02-20,0.5734873097155654,603369.SH
|
||||
2024-02-21,0.43260992475178217,600023.SH
|
||||
2024-02-22,0.4837658423417254,000526.SZ
|
||||
2024-02-23,0.25932845682914313,000157.SZ
|
||||
2024-02-26,0.37391625217883473,000983.SZ
|
||||
2024-02-27,0.06249364085384111,002039.SZ
|
||||
2024-02-28,1.038623993098607,000680.SZ
|
||||
2024-02-29,0.11792404338777529,603871.SH
|
||||
2024-03-01,0.30810066963043975,603605.SH
|
||||
2024-03-04,0.17622933681947947,600375.SH
|
||||
2024-03-05,1.0199617166369774,002009.SZ
|
||||
2024-03-06,0.7025950679251926,002209.SZ
|
||||
2024-03-07,0.8130361341508562,002317.SZ
|
||||
2024-03-08,0.6714948117029352,603960.SH
|
||||
2024-03-11,0.7527103580484402,603960.SH
|
||||
2024-03-12,0.773794092704635,603960.SH
|
||||
2024-03-13,0.6395980350337678,603499.SH
|
||||
2024-03-14,0.6983134888804106,603660.SH
|
||||
2024-03-15,0.990357376475744,601138.SH
|
||||
2024-03-18,0.4182273803259301,002075.SZ
|
||||
2024-03-19,0.8116021296004745,603050.SH
|
||||
2024-03-20,0.6916582321872963,605580.SH
|
||||
2024-03-21,0.7126108686308776,002698.SZ
|
||||
2024-03-22,0.795964501966808,603190.SH
|
||||
2024-03-25,1.0652068531193497,603286.SH
|
||||
2024-03-26,1.2060727717193194,002331.SZ
|
||||
2024-03-27,1.8308956146424886,001696.SZ
|
||||
2024-03-28,1.5762953683649072,002645.SZ
|
||||
2024-03-29,0.8133804882766478,002055.SZ
|
||||
2024-04-01,0.6881987381521469,002735.SZ
|
||||
2024-04-02,0.9728619403924941,002085.SZ
|
||||
2024-04-03,0.9735850429701983,002625.SZ
|
||||
2024-04-08,0.9464502611855133,002805.SZ
|
||||
2024-04-09,1.10422053943107,002085.SZ
|
||||
2024-04-10,0.699553803327553,603822.SH
|
||||
2024-04-11,1.2813227488155954,002544.SZ
|
||||
2024-04-12,0.9677010248477915,605198.SH
|
||||
2024-04-15,1.2722648770139777,002290.SZ
|
||||
2024-04-16,2.1135975645782725,002521.SZ
|
||||
2024-04-17,1.0448007042761251,000737.SZ
|
||||
2024-04-18,1.3682438721410928,603619.SH
|
||||
2024-04-19,0.6510347025537216,000933.SZ
|
||||
2024-04-22,1.1007294592332375,600529.SH
|
||||
2024-04-23,1.0096847778899667,002078.SZ
|
||||
2024-04-24,0.5132039397179469,000949.SZ
|
||||
2024-04-25,1.7289140437217827,600066.SH
|
||||
2024-04-26,1.048178737250126,603556.SH
|
||||
2024-04-29,0.28151131629200876,000949.SZ
|
||||
2024-04-30,0.5902959535550075,605098.SH
|
||||
2024-05-06,0.8659440618533316,001696.SZ
|
||||
2024-05-07,0.4125483888931327,002225.SZ
|
||||
2024-05-08,0.49991019731911135,002597.SZ
|
||||
2024-05-09,0.8523675809088074,002590.SZ
|
||||
2024-05-10,0.6072304373378594,001696.SZ
|
||||
2024-05-13,0.9449133844307348,600326.SH
|
||||
2024-05-14,0.756524501371889,002025.SZ
|
||||
2024-05-15,0.7974348512463216,600682.SH
|
||||
2024-05-16,0.9752446361705888,600644.SH
|
||||
2024-05-17,1.1846986232709233,000702.SZ
|
||||
2024-05-20,0.7167728676668204,002851.SZ
|
||||
2024-05-21,1.071890852713521,603683.SH
|
||||
2024-05-22,0.7124540930368298,600463.SH
|
||||
2024-05-23,1.5016154741945653,002225.SZ
|
||||
2024-05-24,1.2198831133459211,002968.SZ
|
||||
2024-05-27,0.9536299254414154,000656.SZ
|
||||
2024-05-28,0.8425457543469408,002761.SZ
|
||||
2024-05-29,0.652762060180136,600979.SH
|
||||
2024-05-30,0.9000889953940735,002455.SZ
|
||||
2024-05-31,0.9330771253458983,601825.SH
|
||||
2024-06-03,1.2914669574335471,001267.SZ
|
||||
2024-06-04,0.829699499403838,600530.SH
|
||||
2024-06-05,1.0758350766018299,002922.SZ
|
||||
2024-06-06,0.8595311066455215,603360.SH
|
||||
2024-06-07,1.0888503051113,002889.SZ
|
||||
2024-06-11,1.0628038633716435,002475.SZ
|
||||
2024-06-12,1.1159013979424315,603009.SH
|
||||
2024-06-13,1.1812561799680747,600996.SH
|
||||
2024-06-14,0.8256170648299659,600039.SH
|
||||
2024-06-17,0.8645410455127762,000528.SZ
|
||||
2024-06-18,0.6063406599939511,600996.SH
|
||||
2024-06-19,0.7166446473651414,600192.SH
|
||||
2024-06-20,0.932110291603618,605598.SH
|
||||
2024-06-21,0.9558209107020993,603936.SH
|
||||
2024-06-24,1.119014534304907,600992.SH
|
||||
2024-06-25,1.3527294398026957,600584.SH
|
||||
2024-06-26,0.7188166389093542,000504.SZ
|
||||
2024-06-27,1.9515093336713365,002452.SZ
|
||||
2024-06-28,0.8843544096493936,600889.SH
|
||||
2024-07-01,0.6545882280229176,003004.SZ
|
||||
2024-07-02,0.6762487770835988,600584.SH
|
||||
2024-07-03,0.9128444390874889,601179.SH
|
||||
2024-07-04,1.1423863246899275,603225.SH
|
||||
2024-07-05,0.9324658736527716,603936.SH
|
||||
2024-07-08,1.780537827812583,603328.SH
|
||||
2024-07-09,0.7579237257512456,000679.SZ
|
||||
2024-07-10,0.6704021737995826,605117.SH
|
||||
2024-07-11,0.6117132499929072,000622.SZ
|
||||
2024-07-12,1.0566477568456074,002452.SZ
|
||||
2024-07-15,0.6602660923500289,605081.SH
|
||||
2024-07-16,0.5502090318853736,002420.SZ
|
||||
2024-07-17,0.6837622842594867,002355.SZ
|
||||
2024-07-18,0.8242173773899442,002384.SZ
|
||||
2024-07-19,0.9979238076969816,002384.SZ
|
||||
2024-07-22,0.4982073979858695,000421.SZ
|
||||
2024-07-23,1.1543952284060066,002428.SZ
|
||||
2024-07-24,1.2334918071766405,605111.SH
|
||||
2024-07-25,0.8987252044027945,002496.SZ
|
||||
2024-07-26,0.8562640506752258,600171.SH
|
||||
2024-07-29,0.5774106541432314,002750.SZ
|
||||
2024-07-30,0.5406184547635255,600563.SH
|
||||
2024-07-31,0.5575394015591096,002700.SZ
|
||||
2024-08-01,0.3836358457058139,600099.SH
|
||||
2024-08-02,0.670543769867587,605081.SH
|
||||
2024-08-05,1.2561423052432321,605117.SH
|
||||
2024-08-06,0.9373802633817199,000584.SZ
|
||||
2024-08-07,0.8074459777954732,603032.SH
|
||||
2024-08-08,0.8017404350976902,600611.SH
|
||||
2024-08-09,0.9444750578832374,000659.SZ
|
||||
2024-08-12,0.8308531709022774,000880.SZ
|
||||
2024-08-13,0.6345130236563948,600266.SH
|
||||
2024-08-14,0.7618996741024034,000159.SZ
|
||||
2024-08-15,0.7957196976564392,000880.SZ
|
||||
2024-08-16,0.8007104277247147,603050.SH
|
||||
2024-08-19,0.8488617680848443,603444.SH
|
||||
2024-08-20,1.049247341754445,002488.SZ
|
||||
2024-08-21,1.2543709456137933,002488.SZ
|
||||
2024-08-22,1.0702026523317902,002208.SZ
|
||||
2024-08-23,1.0790725273037058,002369.SZ
|
||||
2024-08-26,0.8933596937509765,000532.SZ
|
||||
2024-08-27,0.9555026539273229,605318.SH
|
||||
2024-08-28,0.8517730333686951,002547.SZ
|
||||
2024-08-29,0.8787028549560587,003001.SZ
|
||||
2024-08-30,0.5949301031458588,601898.SH
|
||||
2024-09-02,1.0927036539101782,603826.SH
|
||||
2024-09-03,0.5011518255679451,000810.SZ
|
||||
2024-09-04,0.913670019713004,001298.SZ
|
||||
2024-09-05,0.5722903163709645,600375.SH
|
||||
2024-09-06,1.054280211341685,002622.SZ
|
||||
2024-09-09,1.1145869455283224,600375.SH
|
||||
2024-09-10,0.6071645644461853,600804.SH
|
||||
2024-09-11,0.8120257237744295,002808.SZ
|
||||
2024-09-12,0.7226510652354332,600148.SH
|
||||
2024-09-13,1.4358476935516946,603615.SH
|
||||
2024-09-18,0.8351081061832145,002946.SZ
|
||||
2024-09-19,0.605865384829211,600898.SH
|
||||
2024-09-20,0.9533885243905273,603398.SH
|
||||
2024-09-23,1.046054385469168,601162.SH
|
||||
2024-09-24,0.3758184358111333,603559.SH
|
||||
2024-09-25,0.8156363720747627,600756.SH
|
||||
2024-09-26,0.5051488053045387,600550.SH
|
||||
2024-09-27,0.16901120016969293,002016.SZ
|
||||
2024-09-30,0.03361915273177237,603106.SH
|
||||
2024-10-08,0.02829952163781644,603106.SH
|
||||
2024-10-09,0.15132702693149014,601336.SH
|
||||
2024-10-10,0.5264407322666304,000402.SZ
|
||||
2024-10-11,1.0343311919140215,600657.SH
|
||||
2024-10-14,0.47180187869811324,603383.SH
|
||||
2024-10-15,0.8703255693900985,603106.SH
|
||||
2024-10-16,0.8602575981884926,002987.SZ
|
||||
2024-10-17,0.8415090474760394,000567.SZ
|
||||
2024-10-18,0.15292428350076237,002542.SZ
|
||||
2024-10-21,0.4922089945140812,002457.SZ
|
||||
2024-10-22,0.4176771447393169,002423.SZ
|
||||
2024-10-23,0.8519606263347589,000158.SZ
|
||||
2024-10-24,0.5430046541942165,000935.SZ
|
||||
2024-10-25,0.18041199007445233,603016.SH
|
||||
2024-10-28,0.5571845419116188,000503.SZ
|
||||
2024-10-29,0.4049481417593221,002851.SZ
|
||||
2024-10-30,0.7134818524722009,600463.SH
|
||||
2024-10-31,0.5829203522209173,603117.SH
|
||||
2024-11-01,1.2246655429458404,002851.SZ
|
||||
2024-11-04,0.8176452500049061,600843.SH
|
||||
2024-11-05,0.896531400955133,002514.SZ
|
||||
2024-11-06,0.8080466337179094,600292.SH
|
||||
2024-11-07,0.8536978345761432,600481.SH
|
||||
2024-11-08,0.735404763610977,002047.SZ
|
||||
2024-11-11,0.7749352489908305,002428.SZ
|
||||
2024-11-12,0.8967548353595826,002428.SZ
|
||||
2024-11-13,1.0199850479686239,603859.SH
|
||||
2024-11-14,0.9361081815051415,603559.SH
|
||||
2024-11-15,1.5997213068383358,002086.SZ
|
||||
2024-11-18,1.5789594007558525,002709.SZ
|
||||
2024-11-19,1.5249787983366927,603825.SH
|
||||
2024-11-20,0.736292965730012,002808.SZ
|
||||
2024-11-21,0.7544341372210354,603859.SH
|
||||
2024-11-22,1.2744170240551567,600593.SH
|
||||
2024-11-25,0.8324187454861728,600787.SH
|
||||
2024-11-26,1.0752006153991913,600736.SH
|
||||
2024-11-27,0.6500606694243171,002245.SZ
|
||||
2024-11-28,0.8456761058883665,000833.SZ
|
||||
2024-11-29,0.8489157795122361,002354.SZ
|
||||
2024-12-02,0.6832024025795977,002611.SZ
|
||||
2024-12-03,0.8939114413301544,603366.SH
|
||||
2024-12-04,1.0277665925094743,002822.SZ
|
||||
2024-12-05,0.9103466279163851,002175.SZ
|
||||
2024-12-06,0.7686238693084577,002467.SZ
|
||||
2024-12-09,1.0846053237578963,601933.SH
|
||||
2024-12-10,1.0700371757624498,600193.SH
|
||||
2024-12-11,0.7673727634361369,002520.SZ
|
||||
2024-12-12,0.8497906144901559,002362.SZ
|
||||
2024-12-13,1.254346634364545,603429.SH
|
||||
2024-12-16,1.0386293779387827,000727.SZ
|
||||
2024-12-17,1.2458109349303497,600157.SH
|
||||
2024-12-18,1.3409657396440136,003002.SZ
|
||||
2024-12-19,1.1408332938187322,600593.SH
|
||||
2024-12-20,0.8248161307709121,002512.SZ
|
||||
2024-12-23,1.1576027817247634,002336.SZ
|
||||
2024-12-24,0.8652560164174093,603610.SH
|
||||
2024-12-25,0.8928903216570524,002045.SZ
|
||||
2024-12-26,0.7436802683703838,603214.SH
|
||||
2024-12-27,0.8278524197563604,002945.SZ
|
||||
2024-12-30,0.6846259683364331,600223.SH
|
||||
2024-12-31,1.0514482797503029,001309.SZ
|
||||
2025-01-02,1.4104671874229635,603668.SH
|
||||
|
@@ -1,265 +0,0 @@
|
||||
trade_date,score,ts_code
|
||||
2024-01-02,0.8906433047229376,002587.SZ
|
||||
2024-01-03,0.800255773815545,000691.SZ
|
||||
2024-01-04,0.918203870395468,002962.SZ
|
||||
2024-01-05,1.1734063865615825,605117.SH
|
||||
2024-01-08,1.2784720379037475,600761.SH
|
||||
2024-01-09,0.5936470874291284,002862.SZ
|
||||
2024-01-10,0.9080905815108482,000698.SZ
|
||||
2024-01-11,0.827458720223193,603097.SH
|
||||
2024-01-12,0.994883205877543,600593.SH
|
||||
2024-01-15,0.6804254263110727,603212.SH
|
||||
2024-01-16,0.7194593431343859,000698.SZ
|
||||
2024-01-17,1.0860069907228742,603172.SH
|
||||
2024-01-18,1.3749235527137786,603828.SH
|
||||
2024-01-19,1.2391308950507334,603579.SH
|
||||
2024-01-22,1.7603168299560354,605268.SH
|
||||
2024-01-23,1.5656552549163458,605117.SH
|
||||
2024-01-24,0.7379915949457881,600138.SH
|
||||
2024-01-25,0.7346719736914655,603099.SH
|
||||
2024-01-26,1.0310897640701377,605111.SH
|
||||
2024-01-29,1.1768938262108766,603398.SH
|
||||
2024-01-30,1.235487562255028,003007.SZ
|
||||
2024-01-31,1.5371910050217372,601138.SH
|
||||
2024-02-01,1.3629464247750829,600551.SH
|
||||
2024-02-02,1.52270944692793,601038.SH
|
||||
2024-02-05,1.847344110860692,000550.SZ
|
||||
2024-02-06,0.8127749986671006,600705.SH
|
||||
2024-02-07,0.7565034143929377,603199.SH
|
||||
2024-02-08,0.7247153170440155,600188.SH
|
||||
2024-02-19,0.41560847492124364,002032.SZ
|
||||
2024-02-20,0.5419618315007714,603369.SH
|
||||
2024-02-21,0.44193316268825533,600023.SH
|
||||
2024-02-22,0.45382033625301066,000526.SZ
|
||||
2024-02-23,0.25689917770287357,000157.SZ
|
||||
2024-02-26,0.4253231714991775,000983.SZ
|
||||
2024-02-27,0.03172161439110529,605151.SH
|
||||
2024-02-28,1.074800376390378,000680.SZ
|
||||
2024-02-29,0.11241663388214615,002467.SZ
|
||||
2024-03-01,0.317478967758629,603605.SH
|
||||
2024-03-04,0.17878811429242739,600860.SH
|
||||
2024-03-05,1.0151694508153393,002009.SZ
|
||||
2024-03-06,0.8229010452846762,002209.SZ
|
||||
2024-03-07,0.8017175629386889,600584.SH
|
||||
2024-03-08,0.6810433978551881,603960.SH
|
||||
2024-03-11,0.9532104338812376,603960.SH
|
||||
2024-03-12,0.7055297835013503,603960.SH
|
||||
2024-03-13,0.5920124881579221,603499.SH
|
||||
2024-03-14,0.661232064922907,603660.SH
|
||||
2024-03-15,0.8778620305552904,601138.SH
|
||||
2024-03-18,0.42042942845890563,002075.SZ
|
||||
2024-03-19,0.7527868193603998,603050.SH
|
||||
2024-03-20,0.5531908723666995,605580.SH
|
||||
2024-03-21,0.7900117288163369,002698.SZ
|
||||
2024-03-22,0.8285381778407641,603190.SH
|
||||
2024-03-25,1.0749381159867608,603286.SH
|
||||
2024-03-26,1.2654734266422276,002331.SZ
|
||||
2024-03-27,1.8684480159293833,001696.SZ
|
||||
2024-03-28,1.6075301389782366,002645.SZ
|
||||
2024-03-29,0.8465441903404123,002055.SZ
|
||||
2024-04-01,0.7568317810951942,002735.SZ
|
||||
2024-04-02,1.0341346018053856,002085.SZ
|
||||
2024-04-03,1.0122022102013215,002130.SZ
|
||||
2024-04-08,0.8881305473937254,002805.SZ
|
||||
2024-04-09,1.0559556356983075,002085.SZ
|
||||
2024-04-10,0.6554344664442165,603822.SH
|
||||
2024-04-11,1.2760784980841757,002544.SZ
|
||||
2024-04-12,1.0181838249663664,605198.SH
|
||||
2024-04-15,1.221720496054648,002290.SZ
|
||||
2024-04-16,2.0663546208214703,002521.SZ
|
||||
2024-04-17,1.1065962300439527,000737.SZ
|
||||
2024-04-18,1.34853784445544,603619.SH
|
||||
2024-04-19,0.6639505828915956,000933.SZ
|
||||
2024-04-22,1.1652613644520093,600529.SH
|
||||
2024-04-23,1.0507483721309534,002078.SZ
|
||||
2024-04-24,0.7225763953314781,000949.SZ
|
||||
2024-04-25,1.9430192587586146,600066.SH
|
||||
2024-04-26,1.0817360300030114,603556.SH
|
||||
2024-04-29,0.21577435079395113,600480.SH
|
||||
2024-04-30,0.5290265764148879,605098.SH
|
||||
2024-05-06,0.7885258258967485,001696.SZ
|
||||
2024-05-07,0.415812996822765,002225.SZ
|
||||
2024-05-08,0.5596574674012184,603232.SH
|
||||
2024-05-09,0.8548632655231382,002590.SZ
|
||||
2024-05-10,0.5787850519196119,001696.SZ
|
||||
2024-05-13,0.9751906596140552,000952.SZ
|
||||
2024-05-14,0.7644462578838344,600645.SH
|
||||
2024-05-15,0.8589488842170756,600682.SH
|
||||
2024-05-16,1.049953727857974,600644.SH
|
||||
2024-05-17,1.1220964730505885,000702.SZ
|
||||
2024-05-20,0.8027292772970297,002851.SZ
|
||||
2024-05-21,1.1153910838352858,603683.SH
|
||||
2024-05-22,0.6413250933571519,002922.SZ
|
||||
2024-05-23,1.570388967019694,002225.SZ
|
||||
2024-05-24,1.2444795042063028,002968.SZ
|
||||
2024-05-27,0.9627736773164858,600675.SH
|
||||
2024-05-28,0.9448048863120843,002761.SZ
|
||||
2024-05-29,0.6810520099963742,600979.SH
|
||||
2024-05-30,0.842272857355848,600530.SH
|
||||
2024-05-31,1.0001129400930693,600101.SH
|
||||
2024-06-03,1.3637566909343166,001267.SZ
|
||||
2024-06-04,0.9588694721783405,600530.SH
|
||||
2024-06-05,1.0953534292665954,002922.SZ
|
||||
2024-06-06,0.8110235687535462,603360.SH
|
||||
2024-06-07,1.2134023901747366,002889.SZ
|
||||
2024-06-11,1.0772961141495465,002655.SZ
|
||||
2024-06-12,1.1183914831029496,603009.SH
|
||||
2024-06-13,1.0362186103086477,600996.SH
|
||||
2024-06-14,0.7480333968482387,600039.SH
|
||||
2024-06-17,1.0007287301926653,000528.SZ
|
||||
2024-06-18,0.5381156056733658,600996.SH
|
||||
2024-06-19,0.7036814608094294,600830.SH
|
||||
2024-06-20,0.8499910179916197,605598.SH
|
||||
2024-06-21,1.2150720829980681,603936.SH
|
||||
2024-06-24,1.0311244474924908,600992.SH
|
||||
2024-06-25,1.2484419002632245,600584.SH
|
||||
2024-06-26,0.7320854040096385,000819.SZ
|
||||
2024-06-27,1.9029808384109885,002452.SZ
|
||||
2024-06-28,0.8803270724492669,600889.SH
|
||||
2024-07-01,0.6059109111833119,000622.SZ
|
||||
2024-07-02,0.656778781716391,600584.SH
|
||||
2024-07-03,0.8605418473204086,601179.SH
|
||||
2024-07-04,1.073683249192727,603225.SH
|
||||
2024-07-05,0.8800051248743536,603936.SH
|
||||
2024-07-08,1.8061114289786495,603328.SH
|
||||
2024-07-09,0.5826571385994789,000679.SZ
|
||||
2024-07-10,0.8413277231762297,605117.SH
|
||||
2024-07-11,0.6665748975268276,000622.SZ
|
||||
2024-07-12,1.0278922272860618,002452.SZ
|
||||
2024-07-15,0.6403011305936952,605081.SH
|
||||
2024-07-16,0.592445020815451,002420.SZ
|
||||
2024-07-17,0.5442518053370551,002355.SZ
|
||||
2024-07-18,0.8022024783282671,002384.SZ
|
||||
2024-07-19,0.9433013682690108,002384.SZ
|
||||
2024-07-22,0.6240394772580439,000421.SZ
|
||||
2024-07-23,1.237721650844904,002428.SZ
|
||||
2024-07-24,1.186379759584258,605111.SH
|
||||
2024-07-25,0.8926351872925693,002496.SZ
|
||||
2024-07-26,0.8499067690354271,600171.SH
|
||||
2024-07-29,0.7013969819645556,002750.SZ
|
||||
2024-07-30,0.615258963090716,600563.SH
|
||||
2024-07-31,0.5799237504937365,002700.SZ
|
||||
2024-08-01,0.5070284832062075,600834.SH
|
||||
2024-08-02,0.6485822834772664,600604.SH
|
||||
2024-08-05,1.3222325162798954,605117.SH
|
||||
2024-08-06,0.9935887583155018,000584.SZ
|
||||
2024-08-07,0.7440148514526516,603032.SH
|
||||
2024-08-08,0.8934326068252262,600611.SH
|
||||
2024-08-09,0.9907610203863012,000659.SZ
|
||||
2024-08-12,0.7143811940598249,000880.SZ
|
||||
2024-08-13,0.5948683342786406,600266.SH
|
||||
2024-08-14,0.7780755309120447,000159.SZ
|
||||
2024-08-15,0.8738359592762805,000880.SZ
|
||||
2024-08-16,0.7460601727356423,603050.SH
|
||||
2024-08-19,0.8904872743308099,603444.SH
|
||||
2024-08-20,1.077089845741329,002488.SZ
|
||||
2024-08-21,1.330096420372438,002488.SZ
|
||||
2024-08-22,1.04117609681098,002208.SZ
|
||||
2024-08-23,1.2634267858516914,002369.SZ
|
||||
2024-08-26,0.8745811905917017,000532.SZ
|
||||
2024-08-27,0.836754154047108,002760.SZ
|
||||
2024-08-28,0.7231326607988842,002547.SZ
|
||||
2024-08-29,0.8735120215139563,003001.SZ
|
||||
2024-08-30,0.6615140980616735,601898.SH
|
||||
2024-09-02,1.093224090711538,603826.SH
|
||||
2024-09-03,0.41407989346203866,002309.SZ
|
||||
2024-09-04,0.7919233491318468,001298.SZ
|
||||
2024-09-05,0.6449753890047838,000908.SZ
|
||||
2024-09-06,1.17109797325565,002622.SZ
|
||||
2024-09-09,1.2278175192855338,000999.SZ
|
||||
2024-09-10,0.7463596223821397,600804.SH
|
||||
2024-09-11,0.7470176349514708,002808.SZ
|
||||
2024-09-12,0.7243651180373872,603559.SH
|
||||
2024-09-13,1.474732794777432,603615.SH
|
||||
2024-09-18,0.883126816576788,000659.SZ
|
||||
2024-09-19,0.640225572474989,600898.SH
|
||||
2024-09-20,1.051164703847969,603398.SH
|
||||
2024-09-23,0.9312327237656652,601162.SH
|
||||
2024-09-24,0.47774549082415085,603559.SH
|
||||
2024-09-25,0.9563618822865794,600756.SH
|
||||
2024-09-26,0.5275946326737218,002686.SZ
|
||||
2024-09-27,0.18984202360702415,002016.SZ
|
||||
2024-09-30,0.035786009050673036,603106.SH
|
||||
2024-10-08,0.032889649456072596,603106.SH
|
||||
2024-10-09,0.12465071252054723,601336.SH
|
||||
2024-10-10,0.6969210259884471,000402.SZ
|
||||
2024-10-11,1.0531806211526256,600099.SH
|
||||
2024-10-14,0.46171010596010975,601162.SH
|
||||
2024-10-15,1.050584350922452,000402.SZ
|
||||
2024-10-16,0.9133292498947153,002987.SZ
|
||||
2024-10-17,0.7700882254413255,000567.SZ
|
||||
2024-10-18,0.1201641254984537,600895.SH
|
||||
2024-10-21,0.6976186419462845,002457.SZ
|
||||
2024-10-22,0.29432613116032685,002423.SZ
|
||||
2024-10-23,0.7806425787966057,000158.SZ
|
||||
2024-10-24,0.6036172569478745,002199.SZ
|
||||
2024-10-25,0.12282827583399647,603016.SH
|
||||
2024-10-28,0.5245178749249334,000503.SZ
|
||||
2024-10-29,0.5076972792469883,002851.SZ
|
||||
2024-10-30,0.7895092176015108,600463.SH
|
||||
2024-10-31,0.6192784720087864,603117.SH
|
||||
2024-11-01,1.204091078793982,002134.SZ
|
||||
2024-11-04,0.8093625376363384,002570.SZ
|
||||
2024-11-05,0.8638488115176264,600172.SH
|
||||
2024-11-06,0.8186577511607894,600292.SH
|
||||
2024-11-07,0.8635644200307799,600481.SH
|
||||
2024-11-08,0.747868586080844,002047.SZ
|
||||
2024-11-11,0.8396084711761063,002428.SZ
|
||||
2024-11-12,0.7919805059954543,603859.SH
|
||||
2024-11-13,0.9060991217118458,603859.SH
|
||||
2024-11-14,0.9421847563274262,600966.SH
|
||||
2024-11-15,1.5178035825387006,002086.SZ
|
||||
2024-11-18,1.5376931721833804,600212.SH
|
||||
2024-11-19,1.4060097628439219,603825.SH
|
||||
2024-11-20,0.8890834002457785,002808.SZ
|
||||
2024-11-21,0.8855345297456824,603859.SH
|
||||
2024-11-22,1.119413451276471,600593.SH
|
||||
2024-11-25,0.7785122491322624,600787.SH
|
||||
2024-11-26,1.0000210964516405,600736.SH
|
||||
2024-11-27,0.8847088850937169,002245.SZ
|
||||
2024-11-28,0.8621169938483969,601360.SH
|
||||
2024-11-29,0.7042168573520408,002354.SZ
|
||||
2024-12-02,0.6426744321671465,002611.SZ
|
||||
2024-12-03,0.9021248369663103,603366.SH
|
||||
2024-12-04,0.9942733603597254,002822.SZ
|
||||
2024-12-05,0.8594169937974554,002175.SZ
|
||||
2024-12-06,0.6985253068214117,603366.SH
|
||||
2024-12-09,0.9476416369172441,601933.SH
|
||||
2024-12-10,1.053999067291189,600193.SH
|
||||
2024-12-11,0.6996323878339654,002193.SZ
|
||||
2024-12-12,0.9535599508119768,002362.SZ
|
||||
2024-12-13,1.3279717542253164,603429.SH
|
||||
2024-12-16,1.0260681164941636,000727.SZ
|
||||
2024-12-17,1.3063049942413876,600157.SH
|
||||
2024-12-18,1.3121814535335503,002878.SZ
|
||||
2024-12-19,1.219098477203033,600593.SH
|
||||
2024-12-20,0.8480675770196239,002512.SZ
|
||||
2024-12-23,1.1806404660060321,600724.SH
|
||||
2024-12-24,0.8537658533885591,603610.SH
|
||||
2024-12-25,0.8752079792242901,002965.SZ
|
||||
2024-12-26,0.720498836899636,603214.SH
|
||||
2024-12-27,0.8552518755027023,002945.SZ
|
||||
2024-12-30,0.7853260336927593,600223.SH
|
||||
2024-12-31,1.0774196590782728,600183.SH
|
||||
2025-01-02,1.345874429894366,603225.SH
|
||||
2025-01-03,1.4595000226870254,603379.SH
|
||||
2025-01-06,1.8567194520891437,002130.SZ
|
||||
2025-01-07,1.327995034218316,002881.SZ
|
||||
2025-01-08,0.7854520495476546,600126.SH
|
||||
2025-01-09,0.8656051617404842,000756.SZ
|
||||
2025-01-10,1.1141535494224937,605016.SH
|
||||
2025-01-13,2.0375745364278695,605080.SH
|
||||
2025-01-14,0.6228152667370752,603269.SH
|
||||
2025-01-15,0.7099046974063614,600673.SH
|
||||
2025-01-16,0.7230959774435842,600381.SH
|
||||
2025-01-17,0.8735560458074921,603007.SH
|
||||
2025-01-20,0.6265446536616674,002164.SZ
|
||||
2025-01-21,1.4687297319348953,000534.SZ
|
||||
2025-01-22,0.7347201431708319,000408.SZ
|
||||
2025-01-23,0.7698608009850573,603121.SH
|
||||
2025-01-24,0.6733337270251429,603360.SH
|
||||
2025-01-27,1.3722279750234074,002484.SZ
|
||||
2025-02-05,1.0995625926629562,603667.SH
|
||||
2025-02-06,0.9540560778289151,603308.SH
|
||||
2025-02-07,0.8152925075270021,000856.SZ
|
||||
2025-02-10,0.4527649047879118,603166.SH
|
||||
|
87
code/train/utils/utils.py
Normal file
87
code/train/utils/utils.py
Normal file
@@ -0,0 +1,87 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
def read_and_merge_h5_data(h5_filename, key, columns, df=None):
|
||||
"""
|
||||
读取 HDF5 文件中的数据,根据指定的 columns 筛选数据,
|
||||
如果传入 df 参数,则将其与读取的数据根据 ts_code 和 trade_date 合并。
|
||||
|
||||
参数:
|
||||
- h5_filename: HDF5 文件名
|
||||
- key: 数据存储在 HDF5 文件中的 key
|
||||
- columns: 要读取的列名列表
|
||||
- df: 需要合并的 DataFrame(如果为空,则不进行合并)
|
||||
|
||||
返回:
|
||||
- 合并后的 DataFrame
|
||||
"""
|
||||
# 处理 _ 开头的列名
|
||||
processed_columns = []
|
||||
for col in columns:
|
||||
if col.startswith('_'):
|
||||
processed_columns.append(col[1:]) # 去掉下划线
|
||||
else:
|
||||
processed_columns.append(col)
|
||||
|
||||
# 从 HDF5 文件读取数据,选择需要的列
|
||||
data = pd.read_hdf(h5_filename, key=key, columns=processed_columns)
|
||||
|
||||
# 修改列名,如果列名以前有 _,加上 _
|
||||
for col in data.columns:
|
||||
if col not in columns: # 只有不在 columns 中的列才需要加下划线
|
||||
new_col = f'_{col}'
|
||||
data.rename(columns={col: new_col}, inplace=True)
|
||||
|
||||
# 如果传入的 df 不为空,则进行合并
|
||||
if df is not None and not df.empty:
|
||||
# 确保两个 DataFrame 都有 ts_code 和 trade_date 列
|
||||
df['trade_date'] = pd.to_datetime(df['trade_date'], format='%Y%m%d')
|
||||
data['trade_date'] = pd.to_datetime(data['trade_date'], format='%Y%m%d')
|
||||
|
||||
# 根据 ts_code 和 trade_date 合并
|
||||
merged_df = pd.merge(df, data, on=['ts_code', 'trade_date'], how='left')
|
||||
else:
|
||||
# 如果 df 为空,则直接返回读取的数据
|
||||
merged_df = data
|
||||
|
||||
return merged_df
|
||||
|
||||
|
||||
def calculate_risk_adjusted_return(df, days=1, method='ratio', lambda_=0.5, eps=1e-8):
|
||||
"""
|
||||
计算单只股票的风险调整收益。
|
||||
|
||||
参数:
|
||||
- df: DataFrame,包含 'ts_code' 和 'close' 列,按日期排序(假设 'trade_date' 已排序)。
|
||||
- days: 预测未来多少天的收益,默认1天。
|
||||
- method: 'ratio'(收益/波动率) 或 'difference'(收益 - λ * 波动率)。
|
||||
- lambda_: 风险惩罚系数,仅当 method='difference' 时有效。
|
||||
- eps: 防止除零的小常数。
|
||||
|
||||
返回:
|
||||
- df:添加 'risk_adj_return' 列的 DataFrame,表示风险调整后的收益。
|
||||
"""
|
||||
# 确保数据按 ts_code 和 trade_date 排序
|
||||
df = df.sort_values(by=['ts_code', 'trade_date'])
|
||||
|
||||
# 计算未来的对数收益率
|
||||
df['future_return'] = np.log(df.groupby('ts_code')['close'].shift(-days) / df['close'])
|
||||
|
||||
# 计算历史收益(对数收益率)
|
||||
df['historical_return'] = np.log(df.groupby('ts_code')['close'].shift(1) / df['close'])
|
||||
|
||||
# 计算波动率(历史收益的标准差)
|
||||
df['volatility'] = df.groupby('ts_code')['historical_return'].rolling(window=days).std().reset_index(level=0,
|
||||
drop=True)
|
||||
|
||||
# 根据选择的 method 计算风险调整收益
|
||||
if method == 'ratio':
|
||||
# 收益/波动率(防止除零)
|
||||
df['risk_adj_return'] = df['future_return'] / (df['volatility'] + eps)
|
||||
elif method == 'difference':
|
||||
# 收益 - λ * 波动率
|
||||
df['risk_adj_return'] = df['future_return'] - lambda_ * df['volatility']
|
||||
else:
|
||||
raise ValueError("Invalid method. Use 'ratio' or 'difference'.")
|
||||
|
||||
return df
|
||||
@@ -1,50 +0,0 @@
|
||||
import pandas as pd
|
||||
|
||||
|
||||
import pandas as pd
|
||||
|
||||
def read_and_merge_h5_data(h5_filename, key, columns, df=None):
|
||||
"""
|
||||
读取 HDF5 文件中的数据,根据指定的 columns 筛选数据,
|
||||
如果传入 df 参数,则将其与读取的数据根据 ts_code 和 trade_date 合并。
|
||||
|
||||
参数:
|
||||
- h5_filename: HDF5 文件名
|
||||
- key: 数据存储在 HDF5 文件中的 key
|
||||
- columns: 要读取的列名列表
|
||||
- df: 需要合并的 DataFrame(如果为空,则不进行合并)
|
||||
|
||||
返回:
|
||||
- 合并后的 DataFrame
|
||||
"""
|
||||
# 处理 _ 开头的列名
|
||||
processed_columns = []
|
||||
for col in columns:
|
||||
if col.startswith('_'):
|
||||
processed_columns.append(col[1:]) # 去掉下划线
|
||||
else:
|
||||
processed_columns.append(col)
|
||||
|
||||
# 从 HDF5 文件读取数据,选择需要的列
|
||||
data = pd.read_hdf(h5_filename, key=key, columns=processed_columns)
|
||||
|
||||
# 修改列名,如果列名以前有 _,加上 _
|
||||
for col in data.columns:
|
||||
if col not in columns: # 只有不在 columns 中的列才需要加下划线
|
||||
new_col = f'_{col}'
|
||||
data.rename(columns={col: new_col}, inplace=True)
|
||||
|
||||
# 如果传入的 df 不为空,则进行合并
|
||||
if df is not None and not df.empty:
|
||||
# 确保两个 DataFrame 都有 ts_code 和 trade_date 列
|
||||
df['trade_date'] = pd.to_datetime(df['trade_date'], format='%Y%m%d')
|
||||
data['trade_date'] = pd.to_datetime(data['trade_date'], format='%Y%m%d')
|
||||
|
||||
# 根据 ts_code 和 trade_date 合并
|
||||
merged_df = pd.merge(df, data, on=['ts_code', 'trade_date'], how='left')
|
||||
else:
|
||||
# 如果 df 为空,则直接返回读取的数据
|
||||
merged_df = data
|
||||
|
||||
return merged_df
|
||||
|
||||
Reference in New Issue
Block a user