Classify2
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -9,6 +10,7 @@
|
||||
"start_time": "2025-04-09T14:57:26.124592Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from operator import index\n",
|
||||
"\n",
|
||||
@@ -18,12 +20,11 @@
|
||||
"\n",
|
||||
"ts.set_token('3a0741c702ee7e5e5f2bf1f0846bafaafe4e320833240b2a7e4a685f')\n",
|
||||
"pro = ts.pro_api()"
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "f448da220816bf98",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -31,6 +32,23 @@
|
||||
"start_time": "2025-04-09T14:57:27.392846Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"数据已经成功存储到index_data.h5文件中\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\liaozhaorun\\AppData\\Local\\Temp\\ipykernel_28220\\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,28 +68,11 @@
|
||||
"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_15500\\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": {
|
||||
@@ -79,54 +80,53 @@
|
||||
"start_time": "2025-04-09T14:57:37.695917Z"
|
||||
}
|
||||
},
|
||||
"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 20250409 5439.7716 5249.6841 5465.1449 5135.9655 \n",
|
||||
"1 000905.SH 20250408 5326.9140 5279.7566 5371.1834 5249.2318 \n",
|
||||
"2 000905.SH 20250407 5287.0333 5523.9636 5587.8502 5212.6773 \n",
|
||||
"3 000905.SH 20250403 5845.5045 5842.6167 5906.7057 5817.9662 \n",
|
||||
"4 000905.SH 20250402 5899.0865 5884.8925 5936.6467 5884.1126 \n",
|
||||
"0 000905.SH 20250506 5740.3338 5668.8762 5740.3338 5666.4698 \n",
|
||||
"1 000905.SH 20250430 5631.8249 5604.6537 5647.7821 5603.1718 \n",
|
||||
"2 000905.SH 20250429 5604.9057 5583.7186 5622.0220 5571.2363 \n",
|
||||
"3 000905.SH 20250428 5598.2951 5624.4166 5628.0778 5587.7857 \n",
|
||||
"4 000905.SH 20250425 5627.1804 5613.1407 5661.5869 5596.5266 \n",
|
||||
"... ... ... ... ... ... ... \n",
|
||||
"13444 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
|
||||
"13445 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
|
||||
"13446 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
|
||||
"13447 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
|
||||
"13448 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
|
||||
"13492 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
|
||||
"13493 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
|
||||
"13494 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
|
||||
"13495 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
|
||||
"13496 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
|
||||
"\n",
|
||||
" pre_close change pct_chg vol amount \n",
|
||||
"0 5326.9140 112.8576 2.1186 2.451180e+08 2.882574e+08 \n",
|
||||
"1 5287.0333 39.8807 0.7543 2.238407e+08 2.618753e+08 \n",
|
||||
"2 5845.5045 -558.4712 -9.5539 2.365227e+08 2.673974e+08 \n",
|
||||
"3 5899.0865 -53.5820 -0.9083 1.349386e+08 1.736621e+08 \n",
|
||||
"4 5892.8502 6.2363 0.1058 1.121600e+08 1.406421e+08 \n",
|
||||
"0 5631.8249 108.5089 1.9267 1.627736e+08 2.170600e+08 \n",
|
||||
"1 5604.9057 26.9192 0.4803 1.383866e+08 1.816166e+08 \n",
|
||||
"2 5598.2951 6.6106 0.1181 1.267429e+08 1.580330e+08 \n",
|
||||
"3 5627.1804 -28.8853 -0.5133 1.362181e+08 1.676163e+08 \n",
|
||||
"4 5605.8796 21.3008 0.3800 1.400008e+08 1.719338e+08 \n",
|
||||
"... ... ... ... ... ... \n",
|
||||
"13444 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
|
||||
"13445 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
|
||||
"13446 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
|
||||
"13447 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
|
||||
"13448 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
|
||||
"13492 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
|
||||
"13493 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
|
||||
"13494 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
|
||||
"13495 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
|
||||
"13496 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
|
||||
"\n",
|
||||
"[13449 rows x 11 columns]\n"
|
||||
"[13497 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": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": "new_trader",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user