(data leak)RollingRank-7.0,赚钱
This commit is contained in:
@@ -2,58 +2,31 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "500802dc-7a20-48b7-a470-a4bae3ec534b",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:34:34.020485Z",
|
||||
"start_time": "2025-04-06T15:34:33.497731Z"
|
||||
"end_time": "2025-04-08T13:37:12.814092Z",
|
||||
"start_time": "2025-04-08T13:37:11.953133Z"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"end_time": "2025-04-06T15:34:46.227924Z",
|
||||
"start_time": "2025-04-06T15:34:34.042810Z"
|
||||
"end_time": "2025-04-08T13:37:35.724923Z",
|
||||
"start_time": "2025-04-08T13:37:12.820096Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date\n",
|
||||
"4717 600285.SH 20250403\n",
|
||||
"4718 600287.SH 20250403\n",
|
||||
"4719 600288.SH 20250403\n",
|
||||
"4708 600273.SH 20250403\n",
|
||||
"5309 601121.SH 20250403\n",
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"Index: 10301468 entries, 0 to 28272\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: 235.8+ MB\n",
|
||||
"None\n",
|
||||
"20250403\n",
|
||||
"20250407\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
@@ -73,37 +46,45 @@
|
||||
"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": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:34:48.652346Z",
|
||||
"start_time": "2025-04-06T15:34:46.236695Z"
|
||||
},
|
||||
"scrolled": true
|
||||
},
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"任务 20250417 完成\n",
|
||||
"任务 20250418 完成\n",
|
||||
"任务 20250416 完成\n",
|
||||
"任务 20250415 完成\n",
|
||||
"任务 20250414 完成\n",
|
||||
"任务 20250411 完成\n",
|
||||
"任务 20250410 完成\n",
|
||||
"任务 20250409 完成\n",
|
||||
"任务 20250408 完成\n",
|
||||
"任务 20250407 完成\n"
|
||||
" ts_code trade_date\n",
|
||||
"4721 600284.SH 20250408\n",
|
||||
"4722 600285.SH 20250408\n",
|
||||
"4723 600287.SH 20250408\n",
|
||||
"4712 600272.SH 20250408\n",
|
||||
"5 000008.SZ 20250408\n",
|
||||
"<class 'pandas.core.frame.DataFrame'>\n",
|
||||
"Index: 10315620 entries, 0 to 14151\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: 236.1+ MB\n",
|
||||
"None\n",
|
||||
"20250408\n",
|
||||
"20250409\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "bb3191de-27a2-4c89-a3b5-32a0d7b9496f",
|
||||
"metadata": {
|
||||
"scrolled": true,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-08T13:37:36.896959Z",
|
||||
"start_time": "2025-04-08T13:37:35.931558Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"from concurrent.futures import ThreadPoolExecutor, as_completed\n",
|
||||
"\n",
|
||||
@@ -134,58 +115,63 @@
|
||||
" except Exception as e:\n",
|
||||
" print(f\"获取 {trade_date} 数据时出错: {e}\")\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "96a81aa5890ea3c3",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:34:48.680504Z",
|
||||
"start_time": "2025-04-06T15:34:48.665530Z"
|
||||
}
|
||||
},
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[ trade_date ts_code up_limit down_limit\n",
|
||||
"0 20250408 000001.SZ 11.77 9.63\n",
|
||||
"1 20250408 000002.SZ 7.26 5.94\n",
|
||||
"2 20250408 000004.SZ 9.72 7.96\n",
|
||||
"3 20250408 000006.SZ 6.90 5.64\n",
|
||||
"4 20250408 000007.SZ 6.14 5.02\n",
|
||||
"... ... ... ... ...\n",
|
||||
"7072 20250408 920108.BJ 25.33 13.65\n",
|
||||
"7073 20250408 920111.BJ 29.38 15.82\n",
|
||||
"7074 20250408 920116.BJ 96.40 51.92\n",
|
||||
"7075 20250408 920118.BJ 30.16 16.24\n",
|
||||
"7076 20250408 920128.BJ 34.15 18.39\n",
|
||||
"\n",
|
||||
"[7077 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
|
||||
"0 20250407 000001.SZ 12.47 10.21\n",
|
||||
"1 20250407 000002.SZ 7.85 6.43\n",
|
||||
"2 20250407 000004.SZ 10.80 8.84\n",
|
||||
"3 20250407 000006.SZ 7.67 6.27\n",
|
||||
"4 20250407 000007.SZ 6.82 5.58\n",
|
||||
"... ... ... ... ...\n",
|
||||
"7070 20250407 920108.BJ 31.72 17.08\n",
|
||||
"7071 20250407 920111.BJ 36.85 19.85\n",
|
||||
"7072 20250407 920116.BJ 116.05 62.49\n",
|
||||
"7073 20250407 920118.BJ 38.07 20.51\n",
|
||||
"7074 20250407 920128.BJ 43.38 23.36\n",
|
||||
"\n",
|
||||
"[7075 rows x 4 columns]]\n"
|
||||
"任务 20250418 完成\n",
|
||||
"任务 20250417 完成\n",
|
||||
"任务 20250416 完成\n",
|
||||
"任务 20250415 完成\n",
|
||||
"任务 20250414 完成\n",
|
||||
"任务 20250411 完成\n",
|
||||
"任务 20250409 完成\n",
|
||||
"任务 20250410 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "96a81aa5890ea3c3",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-08T13:37:37.699901Z",
|
||||
"start_time": "2025-04-08T13:37:36.909744Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"print(all_daily_data)\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)"
|
||||
]
|
||||
],
|
||||
"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[4], 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 pd\u001B[38;5;241m.\u001B[39mconcat(all_daily_data, ignore_index\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\new_trader\\Lib\\site-packages\\pandas\\core\\reshape\\concat.py:382\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 379\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 380\u001B[0m copy \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mFalse\u001B[39;00m\n\u001B[1;32m--> 382\u001B[0m op \u001B[38;5;241m=\u001B[39m _Concatenator(\n\u001B[0;32m 383\u001B[0m objs,\n\u001B[0;32m 384\u001B[0m axis\u001B[38;5;241m=\u001B[39maxis,\n\u001B[0;32m 385\u001B[0m ignore_index\u001B[38;5;241m=\u001B[39mignore_index,\n\u001B[0;32m 386\u001B[0m join\u001B[38;5;241m=\u001B[39mjoin,\n\u001B[0;32m 387\u001B[0m keys\u001B[38;5;241m=\u001B[39mkeys,\n\u001B[0;32m 388\u001B[0m levels\u001B[38;5;241m=\u001B[39mlevels,\n\u001B[0;32m 389\u001B[0m names\u001B[38;5;241m=\u001B[39mnames,\n\u001B[0;32m 390\u001B[0m verify_integrity\u001B[38;5;241m=\u001B[39mverify_integrity,\n\u001B[0;32m 391\u001B[0m copy\u001B[38;5;241m=\u001B[39mcopy,\n\u001B[0;32m 392\u001B[0m sort\u001B[38;5;241m=\u001B[39msort,\n\u001B[0;32m 393\u001B[0m )\n\u001B[0;32m 395\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\\new_trader\\Lib\\site-packages\\pandas\\core\\reshape\\concat.py:445\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 442\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mverify_integrity \u001B[38;5;241m=\u001B[39m verify_integrity\n\u001B[0;32m 443\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mcopy \u001B[38;5;241m=\u001B[39m copy\n\u001B[1;32m--> 445\u001B[0m objs, keys \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_clean_keys_and_objs(objs, keys)\n\u001B[0;32m 447\u001B[0m \u001B[38;5;66;03m# figure out what our result ndim is going to be\u001B[39;00m\n\u001B[0;32m 448\u001B[0m ndims \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_get_ndims(objs)\n",
|
||||
"File \u001B[1;32mE:\\Python\\anaconda\\envs\\new_trader\\Lib\\site-packages\\pandas\\core\\reshape\\concat.py:507\u001B[0m, in \u001B[0;36m_Concatenator._clean_keys_and_objs\u001B[1;34m(self, objs, keys)\u001B[0m\n\u001B[0;32m 504\u001B[0m objs_list \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlist\u001B[39m(objs)\n\u001B[0;32m 506\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mlen\u001B[39m(objs_list) \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m:\n\u001B[1;32m--> 507\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 509\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 510\u001B[0m objs_list \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_list))\n",
|
||||
"\u001B[1;31mValueError\u001B[0m: No objects to concatenate"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
@@ -193,7 +179,7 @@
|
||||
"id": "ad9733a1-2f42-43ee-a98c-0bf699304c21",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:34:48.966102Z",
|
||||
"end_time": "2025-04-08T13:37:37.748574900Z",
|
||||
"start_time": "2025-04-06T15:34:48.693158Z"
|
||||
}
|
||||
},
|
||||
@@ -221,7 +207,7 @@
|
||||
"id": "7e777f1f-4d54-4a74-b916-691ede6af055",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:34:48.980659Z",
|
||||
"end_time": "2025-04-08T13:37:37.762102Z",
|
||||
"start_time": "2025-04-06T15:34:48.977771Z"
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user