多线程rank6.0,赚钱,回撤略微减小

This commit is contained in:
liaozhaorun
2025-04-08 20:32:51 +08:00
parent e0087aa6e1
commit dc1e62c77c
9 changed files with 3737 additions and 4668 deletions

View File

@@ -2,13 +2,15 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-30T16:42:23.864275Z",
"start_time": "2025-03-30T16:42:22.963221Z"
"end_time": "2025-04-06T15:33:29.087509Z",
"start_time": "2025-04-06T15:33:28.293879Z"
}
},
"outputs": [],
"source": [
"from operator import index\n",
"\n",
@@ -18,19 +20,35 @@
"\n",
"ts.set_token('3a0741c702ee7e5e5f2bf1f0846bafaafe4e320833240b2a7e4a685f')\n",
"pro = ts.pro_api()"
],
"outputs": [],
"execution_count": 1
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f448da220816bf98",
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-30T16:42:25.559047Z",
"start_time": "2025-03-30T16:42:23.868783Z"
"end_time": "2025-04-06T15:33:32.756495Z",
"start_time": "2025-04-06T15:33:29.097180Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"数据已经成功存储到index_data.h5文件中\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\liaozhaorun\\AppData\\Local\\Temp\\ipykernel_26824\\1832869062.py:13: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" final_df = pd.concat(all_data, ignore_index=True)\n"
]
}
],
"source": [
"# 定义四个指数\n",
"index_list = ['399300.SH', '000905.SH', '000852.SH', '399006.SZ']\n",
@@ -50,78 +68,60 @@
"final_df.to_hdf('../../data/index_data.h5', key='index_data', mode='w')\n",
"\n",
"print(\"数据已经成功存储到index_data.h5文件中\")"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"数据已经成功存储到index_data.h5文件中\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\liaozhaorun\\AppData\\Local\\Temp\\ipykernel_6192\\3209233630.py:13: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" final_df = pd.concat(all_data, ignore_index=True)\n"
]
}
],
"execution_count": 2
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "907f732d3c397bf",
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-30T16:42:25.802535Z",
"start_time": "2025-03-30T16:42:25.766399Z"
"end_time": "2025-04-06T15:33:32.795003Z",
"start_time": "2025-04-06T15:33:32.758127Z"
}
},
"source": [
"h5_filename = '../../data/index_data.h5'\n",
"key = '/index_data'\n",
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
" df = store[key]\n",
" print(df)\n"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" ts_code trade_date close open high low \\\n",
"0 000905.SH 20250328 5916.0314 5954.7297 5973.8015 5904.9159 \n",
"1 000905.SH 20250327 5957.6017 5932.5165 6000.6615 5891.7664 \n",
"2 000905.SH 20250326 5948.4986 5935.8537 5983.4739 5935.8537 \n",
"3 000905.SH 20250325 5946.9510 5969.4164 5993.9312 5929.6734 \n",
"4 000905.SH 20250324 5969.0789 5973.0466 5987.0606 5882.8780 \n",
"0 000905.SH 20250407 5287.0333 5523.9636 5587.8502 5212.6773 \n",
"1 000905.SH 20250403 5845.5045 5842.6167 5906.7057 5817.9662 \n",
"2 000905.SH 20250402 5899.0865 5884.8925 5936.6467 5884.1126 \n",
"3 000905.SH 20250401 5892.8502 5870.9424 5931.5038 5867.8480 \n",
"4 000905.SH 20250331 5857.7721 5886.9560 5908.3026 5802.4187 \n",
"... ... ... ... ... ... ... \n",
"13423 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
"13424 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
"13425 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
"13426 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
"13427 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
"13438 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
"13439 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
"13440 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
"13441 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
"13442 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
"\n",
" pre_close change pct_chg vol amount \n",
"0 5957.6017 -41.5703 -0.6978 1.342619e+08 1.688995e+08 \n",
"1 5948.4986 9.1031 0.1530 1.347089e+08 1.765905e+08 \n",
"2 5946.9510 1.5476 0.0260 1.367021e+08 1.716958e+08 \n",
"3 5969.0789 -22.1279 -0.3707 1.474839e+08 1.922270e+08 \n",
"4 5971.9302 -2.8513 -0.0477 1.691924e+08 2.200943e+08 \n",
"... ... ... ... ... ... \n",
"13423 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
"13424 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
"13425 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
"13426 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
"13427 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
" pre_close change pct_chg vol amount \n",
"0 5845.5045 -558.4712 -9.5539 2.365227e+08 2.673974e+08 \n",
"1 5899.0865 -53.5820 -0.9083 1.349386e+08 1.736621e+08 \n",
"2 5892.8502 6.2363 0.1058 1.121600e+08 1.406421e+08 \n",
"3 5857.7721 35.0781 0.5988 1.364486e+08 1.793280e+08 \n",
"4 5916.0314 -58.2593 -0.9848 1.542561e+08 1.895634e+08 \n",
"... ... ... ... ... ... \n",
"13438 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
"13439 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
"13440 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
"13441 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
"13442 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
"\n",
"[13428 rows x 11 columns]\n"
"[13443 rows x 11 columns]\n"
]
}
],
"execution_count": 3
"source": [
"h5_filename = '../../data/index_data.h5'\n",
"key = '/index_data'\n",
"with pd.HDFStore(h5_filename, mode='r') as store:\n",
" df = store[key]\n",
" print(df)\n"
]
}
],
"metadata": {