|
|
|
|
@@ -18,10 +18,10 @@
|
|
|
|
|
"Please upgrade to Gymnasium, the maintained drop-in replacement of Gym, or contact the authors of your software and request that they upgrade.\n",
|
|
|
|
|
"Users of this version of Gym should be able to simply replace 'import gym' with 'import gymnasium as gym' in the vast majority of cases.\n",
|
|
|
|
|
"See the migration guide at https://gymnasium.farama.org/introduction/migration_guide/ for additional information.\n",
|
|
|
|
|
"[177513:MainThread](2026-02-25 22:33:43,460) INFO - qlib.Initialization - [config.py:452] - default_conf: client.\n",
|
|
|
|
|
"[177513:MainThread](2026-02-25 22:33:43,461) WARNING - qlib.Initialization - [config.py:459] - Unrecognized config freq\n",
|
|
|
|
|
"[177513:MainThread](2026-02-25 22:33:43,467) INFO - qlib.Initialization - [__init__.py:75] - qlib successfully initialized based on client settings.\n",
|
|
|
|
|
"[177513:MainThread](2026-02-25 22:33:43,469) INFO - qlib.Initialization - [__init__.py:77] - data_path={'__DEFAULT_FREQ': PosixPath('/mnt/d/PyProject/NewStock/data/qlib')}\n"
|
|
|
|
|
"[65879:MainThread](2026-03-01 22:39:22,291) INFO - qlib.Initialization - [config.py:452] - default_conf: client.\n",
|
|
|
|
|
"[65879:MainThread](2026-03-01 22:39:22,291) WARNING - qlib.Initialization - [config.py:459] - Unrecognized config freq\n",
|
|
|
|
|
"[65879:MainThread](2026-03-01 22:39:22,297) INFO - qlib.Initialization - [__init__.py:75] - qlib successfully initialized based on client settings.\n",
|
|
|
|
|
"[65879:MainThread](2026-03-01 22:39:22,298) INFO - qlib.Initialization - [__init__.py:77] - data_path={'__DEFAULT_FREQ': PosixPath('/mnt/d/PyProject/NewStock/data/qlib')}\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -96,7 +96,7 @@
|
|
|
|
|
"cyq perf\n",
|
|
|
|
|
"left merge on ['ts_code', 'trade_date']\n",
|
|
|
|
|
"<class 'pandas.core.frame.DataFrame'>\n",
|
|
|
|
|
"RangeIndex: 9436343 entries, 0 to 9436342\n",
|
|
|
|
|
"RangeIndex: 9456764 entries, 0 to 9456763\n",
|
|
|
|
|
"Data columns (total 33 columns):\n",
|
|
|
|
|
" # Column Dtype \n",
|
|
|
|
|
"--- ------ ----- \n",
|
|
|
|
|
@@ -174,7 +174,7 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 10,
|
|
|
|
|
"execution_count": 7,
|
|
|
|
|
"id": "5f3847ec",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
@@ -182,15 +182,17 @@
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
" trade_date return_5_rank\n",
|
|
|
|
|
"6527870 2024-06-03 0.523969\n",
|
|
|
|
|
" trade_date ma5 ma10 close\n",
|
|
|
|
|
"6527870 2024-06-03 10.526 10.216 10.37\n"
|
|
|
|
|
" trade_date ma5 ma10 return_5 close\n",
|
|
|
|
|
"6527953 2024-01-23 7.358 7.500 -0.043364 7.28\n",
|
|
|
|
|
"6527952 2024-01-24 7.412 7.507 0.036339 7.70\n",
|
|
|
|
|
"6527951 2024-01-25 7.552 7.556 0.094213 8.13\n",
|
|
|
|
|
"6527950 2024-01-26 7.692 7.609 0.093583 8.18\n",
|
|
|
|
|
"6527949 2024-01-29 7.910 7.667 0.152022 8.26\n"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"df = df.sort_values(by=['trade_date'])\n",
|
|
|
|
|
"df['return_5'] = df.groupby('ts_code')['close'].pct_change(periods=5)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"df['return_5_rank'] = df.groupby('trade_date')['return_5'].transform(\n",
|
|
|
|
|
@@ -198,10 +200,19 @@
|
|
|
|
|
" )\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"df['ma5'] = df.groupby('ts_code')['close'].transform(lambda x: x.rolling(window=5, min_periods=1).mean())\n",
|
|
|
|
|
"df['ma10'] = df.groupby('ts_code')['close'].transform(lambda x: x.rolling(window=10, min_periods=1).mean())\n",
|
|
|
|
|
"df['ma10'] = df.groupby('ts_code')['close'].transform(lambda x: x.rolling(window=10, min_periods=1).mean())\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "e6de3c12",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"\n",
|
|
|
|
|
"print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] == '2024-06-03')][['trade_date', 'return_5_rank']])\n",
|
|
|
|
|
"print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] == '2024-06-03')][['trade_date', 'ma5', 'ma10', 'close']])"
|
|
|
|
|
"# print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] >= '2024-01-23')][['trade_date', 'return_5_rank']])\n",
|
|
|
|
|
"print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] >= '2024-01-23') & (df['trade_date'] <= '2024-01-29')][['trade_date', 'ma5', 'ma10', 'return_5', 'close']])"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -9370,7 +9381,7 @@
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
|
"version": "3.13.2"
|
|
|
|
|
"version": "3.12.11"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"nbformat": 4,
|
|
|
|
|
|