多线程rank6.0,赚钱,回撤略微减小
This commit is contained in:
@@ -2,30 +2,55 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "f74ce078-f7e8-4733-a14c-14d8815a3626",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-30T16:42:32.996500Z",
|
||||
"start_time": "2025-03-30T16:42:32.209631Z"
|
||||
"end_time": "2025-04-06T15:33:36.424263Z",
|
||||
"start_time": "2025-04-06T15:33:36.048334Z"
|
||||
}
|
||||
},
|
||||
"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": "44dd8d87-e60b-49e5-aed9-efaa7f92d4fe",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-30T16:42:34.591433Z",
|
||||
"start_time": "2025-03-30T16:42:32.996500Z"
|
||||
"end_time": "2025-04-06T15:33:37.871314Z",
|
||||
"start_time": "2025-04-06T15:33:36.424263Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date\n",
|
||||
"0 801001.SI 20250221\n",
|
||||
"1 801002.SI 20250221\n",
|
||||
"2 801003.SI 20250221\n",
|
||||
"3 801005.SI 20250221\n",
|
||||
"4 801010.SI 20250221\n",
|
||||
"... ... ...\n",
|
||||
"1751 859811.SI 20250401\n",
|
||||
"1752 859821.SI 20250401\n",
|
||||
"1753 859822.SI 20250401\n",
|
||||
"1754 859852.SI 20250401\n",
|
||||
"1755 859951.SI 20250401\n",
|
||||
"\n",
|
||||
"[1057124 rows x 2 columns]\n",
|
||||
"20250403\n",
|
||||
"start_date: 20250407\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import time\n",
|
||||
@@ -44,42 +69,36 @@
|
||||
"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": "747acc47-0884-4f76-90fb-276f6494e31d",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-04-06T15:33:40.123037Z",
|
||||
"start_time": "2025-04-06T15:33:37.881433Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" ts_code trade_date\n",
|
||||
"0 801001.SI 20250221\n",
|
||||
"1 801002.SI 20250221\n",
|
||||
"2 801003.SI 20250221\n",
|
||||
"3 801005.SI 20250221\n",
|
||||
"4 801010.SI 20250221\n",
|
||||
"... ... ...\n",
|
||||
"2629 859811.SI 20250314\n",
|
||||
"2630 859821.SI 20250314\n",
|
||||
"2631 859822.SI 20250314\n",
|
||||
"2632 859852.SI 20250314\n",
|
||||
"2633 859951.SI 20250314\n",
|
||||
"\n",
|
||||
"[1053173 rows x 2 columns]\n",
|
||||
"20250321\n",
|
||||
"start_date: 20250324\n"
|
||||
"任务 20250417 完成\n",
|
||||
"任务 20250418 完成\n",
|
||||
"任务 20250416 完成\n",
|
||||
"任务 20250415 完成\n",
|
||||
"任务 20250414 完成\n",
|
||||
"任务 20250411 完成\n",
|
||||
"任务 20250409 完成\n",
|
||||
"任务 20250410 完成\n",
|
||||
"任务 20250408 完成\n",
|
||||
"任务 20250407 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "747acc47-0884-4f76-90fb-276f6494e31d",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-30T16:42:37.718270Z",
|
||||
"start_time": "2025-03-30T16:42:34.817305Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"from concurrent.futures import ThreadPoolExecutor, as_completed\n",
|
||||
"\n",
|
||||
@@ -109,55 +128,18 @@
|
||||
" except Exception as e:\n",
|
||||
" print(f\"获取 {trade_date} 数据时出错: {e}\")\n",
|
||||
"\n"
|
||||
],
|
||||
"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",
|
||||
"任务 20250403 完成\n",
|
||||
"任务 20250402 完成\n",
|
||||
"任务 20250401 完成\n",
|
||||
"任务 20250331 完成\n",
|
||||
"任务 20250328 完成\n",
|
||||
"任务 20250327 完成\n",
|
||||
"任务 20250326 完成\n",
|
||||
"任务 20250325 完成\n",
|
||||
"任务 20250324 完成\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 3
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "c6765638-481f-40d8-a259-2e7b25362618",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-30T16:42:37.922827Z",
|
||||
"start_time": "2025-03-30T16:42:37.739040Z"
|
||||
"end_time": "2025-04-06T15:33:40.286614Z",
|
||||
"start_time": "2025-04-06T15:33:40.138227Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n",
|
||||
"\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"\n",
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key=key, mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -167,7 +149,16 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 4
|
||||
"source": [
|
||||
"all_daily_data_df = pd.concat(all_daily_data, ignore_index=True)\n",
|
||||
"\n",
|
||||
"# 将所有数据合并为一个 DataFrame\n",
|
||||
"\n",
|
||||
"# 将数据保存为 HDF5 文件(table 格式)\n",
|
||||
"all_daily_data_df.to_hdf(h5_filename, key=key, mode='a', format='table', append=True, data_columns=True)\n",
|
||||
"\n",
|
||||
"print(\"所有每日基础数据获取并保存完毕!\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user