优化金字塔选股结果格式
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -117,3 +117,4 @@ cython_debug/
|
|||||||
# Custom
|
# Custom
|
||||||
temp/
|
temp/
|
||||||
temp/**/*
|
temp/**/*
|
||||||
|
.idea/**/csv-editor.xml
|
||||||
196
材料准备/财报信息.ipynb
196
材料准备/财报信息.ipynb
@@ -4,7 +4,11 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"id": "initial_id",
|
"id": "initial_id",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": true
|
"collapsed": true,
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:30:08.643756Z",
|
||||||
|
"start_time": "2025-01-13T01:30:06.177472Z"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
@@ -13,10 +17,15 @@
|
|||||||
"ts_pro = ts.pro_api(token=\"64ebff4fa679167600b905ee45dd88e76f3963c0ff39157f3f085f0e\")"
|
"ts_pro = ts.pro_api(token=\"64ebff4fa679167600b905ee45dd88e76f3963c0ff39157f3f085f0e\")"
|
||||||
],
|
],
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": null
|
"execution_count": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:30:08.652416Z",
|
||||||
|
"start_time": "2025-01-13T01:30:08.646084Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"def get_balance_sheet_df(start_year, end_year):\n",
|
"def get_balance_sheet_df(start_year, end_year):\n",
|
||||||
@@ -59,10 +68,15 @@
|
|||||||
],
|
],
|
||||||
"id": "14a28ff4952f0df8",
|
"id": "14a28ff4952f0df8",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": null
|
"execution_count": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:30:08.656800Z",
|
||||||
|
"start_time": "2025-01-13T01:30:08.653794Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"start_year = 2014\n",
|
"start_year = 2014\n",
|
||||||
@@ -70,10 +84,15 @@
|
|||||||
],
|
],
|
||||||
"id": "dc68cde196159626",
|
"id": "dc68cde196159626",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": null
|
"execution_count": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:39:39.349170Z",
|
||||||
|
"start_time": "2025-01-13T01:30:08.660347Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"# 财务负债表\n",
|
"# 财务负债表\n",
|
||||||
@@ -81,33 +100,168 @@
|
|||||||
"balance_sheet_df.to_csv(\"../temp/balance_sheet.csv\", index=False)"
|
"balance_sheet_df.to_csv(\"../temp/balance_sheet.csv\", index=False)"
|
||||||
],
|
],
|
||||||
"id": "33cd797a12ad567e",
|
"id": "33cd797a12ad567e",
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
"execution_count": null
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull balance sheet: 2014\n",
|
||||||
|
"Pull balance sheet: 2015\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:8: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull balance sheet: 2016\n",
|
||||||
|
"Pull balance sheet: 2017\n",
|
||||||
|
"Pull balance sheet: 2018\n",
|
||||||
|
"Pull balance sheet: 2019\n",
|
||||||
|
"Pull balance sheet: 2020\n",
|
||||||
|
"Pull balance sheet: 2021\n",
|
||||||
|
"Pull balance sheet: 2022\n",
|
||||||
|
"Pull balance sheet: 2023\n",
|
||||||
|
"Pull balance sheet: 2024\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:8: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:43:28.007135Z",
|
||||||
|
"start_time": "2025-01-13T01:39:39.363037Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"income_df = clean_df(get_income_df(start_year, end_year))\n",
|
"income_df = clean_df(get_income_df(start_year, end_year))\n",
|
||||||
"income_df.to_csv(\"../temp/income.csv\", index=False)"
|
"income_df.to_csv(\"../temp/income.csv\", index=False)"
|
||||||
],
|
],
|
||||||
"id": "17306c1524f5e173",
|
"id": "17306c1524f5e173",
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
"execution_count": null
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull income: 2014\n",
|
||||||
|
"Pull income: 2015\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:19: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull income: 2016\n",
|
||||||
|
"Pull income: 2017\n",
|
||||||
|
"Pull income: 2018\n",
|
||||||
|
"Pull income: 2019\n",
|
||||||
|
"Pull income: 2020\n",
|
||||||
|
"Pull income: 2021\n",
|
||||||
|
"Pull income: 2022\n",
|
||||||
|
"Pull income: 2023\n",
|
||||||
|
"Pull income: 2024\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:19: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 5
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:46:46.375157Z",
|
||||||
|
"start_time": "2025-01-13T01:43:28.011213Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"cash_flow_df = clean_df(get_cash_flow_df(start_year, end_year))\n",
|
"cash_flow_df = clean_df(get_cash_flow_df(start_year, end_year))\n",
|
||||||
"cash_flow_df.to_csv(\"../temp/cash_flow.csv\", index=False)"
|
"cash_flow_df.to_csv(\"../temp/cash_flow.csv\", index=False)"
|
||||||
],
|
],
|
||||||
"id": "334dbe20f2047a1e",
|
"id": "334dbe20f2047a1e",
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
"execution_count": null
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull cash flow: 2014\n",
|
||||||
|
"Pull cash flow: 2015\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:30: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Pull cash flow: 2016\n",
|
||||||
|
"Pull cash flow: 2017\n",
|
||||||
|
"Pull cash flow: 2018\n",
|
||||||
|
"Pull cash flow: 2019\n",
|
||||||
|
"Pull cash flow: 2020\n",
|
||||||
|
"Pull cash flow: 2021\n",
|
||||||
|
"Pull cash flow: 2022\n",
|
||||||
|
"Pull cash flow: 2023\n",
|
||||||
|
"Pull cash flow: 2024\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"/var/folders/7h/w0cmp4zj6mn9br_6nyj310m40000gn/T/ipykernel_50121/709533518.py:30: 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",
|
||||||
|
" result = pd.concat([result, temp], ignore_index=True)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-01-13T01:46:57.717599Z",
|
||||||
|
"start_time": "2025-01-13T01:46:46.377806Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"finance_df = pd.merge(balance_sheet_df, income_df, on=[\"ts_code\", \"end_date\"])\n",
|
"finance_df = pd.merge(balance_sheet_df, income_df, on=[\"ts_code\", \"end_date\"])\n",
|
||||||
@@ -116,13 +270,13 @@
|
|||||||
],
|
],
|
||||||
"id": "f8bea62f377b5e2",
|
"id": "f8bea62f377b5e2",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"execution_count": null
|
"execution_count": 7
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
"end_time": "2025-01-12T12:04:00.424439Z",
|
"end_time": "2025-01-13T01:46:57.814028Z",
|
||||||
"start_time": "2025-01-12T12:04:00.364557Z"
|
"start_time": "2025-01-13T01:46:57.728111Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
@@ -512,12 +666,12 @@
|
|||||||
"</div>"
|
"</div>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 29,
|
"execution_count": 8,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"execution_count": 29
|
"execution_count": 8
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
40816
财报筛选/金字塔选股.ipynb
40816
财报筛选/金字塔选股.ipynb
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user