You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TslDataFeed/ts-financial-indicator.ipynb

968 lines
35 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8dd1bdcc-05d0-4623-b683-4eec9339a4ae",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "094cfb08-c902-4d37-a8d3-4600dd371140",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('tinysoft-data/44.合并资产负债表/SH600058.csv')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f5605ce4-c5f1-4bf8-afe5-4eb360fcd26c",
"metadata": {},
"outputs": [],
"source": [
"from pprint import pprint"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8b7abc47-accc-47d1-8f16-d5206b410b16",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"range(9900000, 9900028)\n"
]
}
],
"source": [
"pershare_indicator_id_list = range(9900000, 9900028)\n",
"print(pershare_indicator_id_list)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "f86a7c11-2ecb-4d7c-bdc0-29486b2ee86d",
"metadata": {},
"outputs": [],
"source": [
"import pyTSL\n",
"import itertools\n",
"import pandas as pd\n",
"from pprint import pprint\n",
"\n",
"TINYSOFT_HOSTNAME = 'tsl.tinysoft.com.cn'\n",
"TINYSOFT_PORT = 443\n",
"TINYSOFT_USERNAME = 'xunuo2005'\n",
"TINYSOFT_PASSWORD = '20220613'\n",
"\n",
"TINYSOFT_DATA_PATH = 'tinysoft-data'\n",
"\n",
"class tsl():\n",
" \n",
" def __enter__(self):\n",
" self.c = pyTSL.Client(TINYSOFT_USERNAME, TINYSOFT_PASSWORD, TINYSOFT_HOSTNAME, 443)\n",
" status = self.c.login()\n",
" return self\n",
" \n",
" \n",
" def __exit__(self, exc_type, exc_val, exc_tb):\n",
" self.c.logout()\n",
" \n",
" \n",
" def retrieve_stock_report(self, table_id, stock_id, start_date):\n",
" code = \"\"\"\n",
" SetSysParam('ReportMode', -1);\n",
" return Select * \n",
" from infotable {table_id} of '{stock_id}' \n",
" where ['截止日'] >= {start_date}\n",
" end;\n",
" \"\"\".format(table_id=table_id, stock_id=stock_id, start_date=start_date)\n",
" r = self.c.exec(code)\n",
"\n",
" df = pd.DataFrame(r.value())\n",
" return df\n",
" \n",
" \n",
" def retrieve_stock_indicator(self, stock_id, start_year, indicator_config_fname):\n",
" year_list = range(start_year, 2022, 1)\n",
" quarter_list = ['0331', '0630', '0930', '1231']\n",
" report_date_list = [str(t[0]) + t[1] for t in itertools.product(year_list, quarter_list)]\n",
" \n",
" config_df = pd.read_csv(indicator_config_fname)\n",
" config_df['indicator_id'] = config_df['indicator_id'].astype('string')\n",
" indicator_dict = config_df.set_index('indicator_id')['indicator_name'].to_dict()\n",
" indicator_id_list = list(indicator_dict.keys())\n",
" indicator_name_list = [\"'%s'\" % indicator_dict[indicator_id] for indicator_id in indicator_id_list]\n",
" \n",
" code = \"\"\"\n",
" SetSysParam('ReportMode', -1);\n",
" SetSysParam(pn_reportmode(), -1);\n",
" SetSysParam(pn_stock(), '{stock_id}');\n",
"\n",
" date_array := Array({date_list_input});\n",
" indicator_array := Array({indicator_id_list_input});\n",
" indicator_name_array := Array({indicator_name_list_input});\n",
" r := Array();\n",
" \n",
" for i:=0 to length(date_array)-1 do\n",
" begin\n",
" r[i]['StockID'] := 'stock_id';\n",
" r[i]['报告期'] := date_array[i];\n",
" for j:=0 to length(indicator_array)-1 do\n",
" begin\n",
" r[i][indicator_name_array[j]] := ReportOfAll(indicator_array[j], date_array[i]);\n",
" end\n",
" end\n",
" return r;\n",
" \"\"\".format(\n",
" stock_id=stock_id, \n",
" date_list_input=', '.join(report_date_list),\n",
" indicator_id_list_input=', '.join(indicator_id_list),\n",
" indicator_name_list_input=', '.join(indicator_name_list)\n",
" )\n",
" r = self.c.exec(code)\n",
" r = r.value()\n",
" df = pd.DataFrame(r, index=range(len(r)))\n",
" df.set_index(['StockID', '报告期'], inplace=True)\n",
" return df\n",
" \n",
"\n",
" def get_stock_list(self, date, bk_name='A股'):\n",
" code = \"\"\"\n",
" bkName := \"%s\";\n",
" endT := %d;\n",
" return getAbkbydate(bkName,endT);\n",
" \"\"\" % (bk_name, date)\n",
" r = self.c.exec(code)\n",
" \n",
" return r.value()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e11e4a42-1855-4602-95ec-d3ddc3f509e6",
"metadata": {},
"outputs": [],
"source": [
"with tsl() as t:\n",
" #r = t.retrieve_stock_report(46, 'SZ000002', 2012)\n",
" df = t.retrieve_stock_indicator('SZ000002', 2012, TINYSOFT_DATA_PATH + '/indicator-config/每股指标.csv')\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e2719d27-0e15-4b87-9e32-a2241365dcd6",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>每股营业收入(最新摊薄)</th>\n",
" <th>每股营业收入</th>\n",
" <th>每股息税前利润</th>\n",
" <th>每股经营现金流(最新摊薄)</th>\n",
" <th>每股公积金</th>\n",
" <th>每股利润总额</th>\n",
" <th>每股资本公积金</th>\n",
" <th>每股负债</th>\n",
" <th>每股收益(最新摊薄)</th>\n",
" <th>每股短期负债</th>\n",
" <th>...</th>\n",
" <th>每股净资产增长率(%)</th>\n",
" <th>每股净资产</th>\n",
" <th>每股经营活动现金流量净额增长率(%)</th>\n",
" <th>每股筹资现金流量净额</th>\n",
" <th>每股现金及现金等价物</th>\n",
" <th>每股收益增长率(%)</th>\n",
" <th>每股现金净流量</th>\n",
" <th>每股经营活动现金流量净额</th>\n",
" <th>每股营业利润</th>\n",
" <th>每股投资现金流量净额</th>\n",
" </tr>\n",
" <tr>\n",
" <th>StockID</th>\n",
" <th>报告期</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">stock_id</th>\n",
" <th>20120331</th>\n",
" <td>0.889942</td>\n",
" <td>0.940947</td>\n",
" <td>0.197014</td>\n",
" <td>0.110114</td>\n",
" <td>2.048748</td>\n",
" <td>0.187185</td>\n",
" <td>0.807414</td>\n",
" <td>21.947356</td>\n",
" <td>0.120077</td>\n",
" <td>18.494247</td>\n",
" <td>...</td>\n",
" <td>19.382684</td>\n",
" <td>4.943817</td>\n",
" <td>164.809374</td>\n",
" <td>0.329418</td>\n",
" <td>0.000000</td>\n",
" <td>15.832056</td>\n",
" <td>0.430057</td>\n",
" <td>0.116425</td>\n",
" <td>0.185253</td>\n",
" <td>-0.015415</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20120630</th>\n",
" <td>2.642751</td>\n",
" <td>2.794216</td>\n",
" <td>0.585350</td>\n",
" <td>0.242503</td>\n",
" <td>2.037421</td>\n",
" <td>0.550119</td>\n",
" <td>0.796087</td>\n",
" <td>23.698247</td>\n",
" <td>0.320427</td>\n",
" <td>19.745063</td>\n",
" <td>...</td>\n",
" <td>19.251969</td>\n",
" <td>5.011256</td>\n",
" <td>-26.311889</td>\n",
" <td>0.924993</td>\n",
" <td>0.000000</td>\n",
" <td>25.092911</td>\n",
" <td>1.100990</td>\n",
" <td>0.256402</td>\n",
" <td>0.546814</td>\n",
" <td>-0.078620</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20120930</th>\n",
" <td>3.967888</td>\n",
" <td>4.195301</td>\n",
" <td>0.802472</td>\n",
" <td>-0.300253</td>\n",
" <td>2.030278</td>\n",
" <td>0.742686</td>\n",
" <td>0.788945</td>\n",
" <td>25.114003</td>\n",
" <td>0.436965</td>\n",
" <td>21.241522</td>\n",
" <td>...</td>\n",
" <td>20.100036</td>\n",
" <td>5.122391</td>\n",
" <td>-133.422541</td>\n",
" <td>0.368574</td>\n",
" <td>0.000000</td>\n",
" <td>41.741473</td>\n",
" <td>-0.134086</td>\n",
" <td>-0.317461</td>\n",
" <td>0.741498</td>\n",
" <td>-0.183924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20121231</th>\n",
" <td>8.869922</td>\n",
" <td>9.378288</td>\n",
" <td>1.980662</td>\n",
" <td>0.320502</td>\n",
" <td>2.337464</td>\n",
" <td>1.916306</td>\n",
" <td>0.789786</td>\n",
" <td>26.981150</td>\n",
" <td>1.079636</td>\n",
" <td>23.631523</td>\n",
" <td>...</td>\n",
" <td>20.498793</td>\n",
" <td>5.804851</td>\n",
" <td>9.928939</td>\n",
" <td>1.481146</td>\n",
" <td>4.649318</td>\n",
" <td>30.403585</td>\n",
" <td>1.592158</td>\n",
" <td>0.338871</td>\n",
" <td>1.911109</td>\n",
" <td>-0.223138</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20130331</th>\n",
" <td>1.204253</td>\n",
" <td>1.273233</td>\n",
" <td>0.245067</td>\n",
" <td>-0.205005</td>\n",
" <td>2.349401</td>\n",
" <td>0.217805</td>\n",
" <td>0.801771</td>\n",
" <td>30.309328</td>\n",
" <td>0.138826</td>\n",
" <td>27.214376</td>\n",
" <td>...</td>\n",
" <td>20.636496</td>\n",
" <td>5.964048</td>\n",
" <td>-286.168893</td>\n",
" <td>0.266879</td>\n",
" <td>0.000000</td>\n",
" <td>15.610817</td>\n",
" <td>-0.014492</td>\n",
" <td>-0.216748</td>\n",
" <td>0.217828</td>\n",
" <td>-0.063866</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 27 columns</p>\n",
"</div>"
],
"text/plain": [
" 每股营业收入(最新摊薄) 每股营业收入 每股息税前利润 每股经营现金流(最新摊薄) 每股公积金 \\\n",
"StockID 报告期 \n",
"stock_id 20120331 0.889942 0.940947 0.197014 0.110114 2.048748 \n",
" 20120630 2.642751 2.794216 0.585350 0.242503 2.037421 \n",
" 20120930 3.967888 4.195301 0.802472 -0.300253 2.030278 \n",
" 20121231 8.869922 9.378288 1.980662 0.320502 2.337464 \n",
" 20130331 1.204253 1.273233 0.245067 -0.205005 2.349401 \n",
"\n",
" 每股利润总额 每股资本公积金 每股负债 每股收益(最新摊薄) 每股短期负债 ... \\\n",
"StockID 报告期 ... \n",
"stock_id 20120331 0.187185 0.807414 21.947356 0.120077 18.494247 ... \n",
" 20120630 0.550119 0.796087 23.698247 0.320427 19.745063 ... \n",
" 20120930 0.742686 0.788945 25.114003 0.436965 21.241522 ... \n",
" 20121231 1.916306 0.789786 26.981150 1.079636 23.631523 ... \n",
" 20130331 0.217805 0.801771 30.309328 0.138826 27.214376 ... \n",
"\n",
" 每股净资产增长率(%) 每股净资产 每股经营活动现金流量净额增长率(%) 每股筹资现金流量净额 \\\n",
"StockID 报告期 \n",
"stock_id 20120331 19.382684 4.943817 164.809374 0.329418 \n",
" 20120630 19.251969 5.011256 -26.311889 0.924993 \n",
" 20120930 20.100036 5.122391 -133.422541 0.368574 \n",
" 20121231 20.498793 5.804851 9.928939 1.481146 \n",
" 20130331 20.636496 5.964048 -286.168893 0.266879 \n",
"\n",
" 每股现金及现金等价物 每股收益增长率(%) 每股现金净流量 每股经营活动现金流量净额 每股营业利润 \\\n",
"StockID 报告期 \n",
"stock_id 20120331 0.000000 15.832056 0.430057 0.116425 0.185253 \n",
" 20120630 0.000000 25.092911 1.100990 0.256402 0.546814 \n",
" 20120930 0.000000 41.741473 -0.134086 -0.317461 0.741498 \n",
" 20121231 4.649318 30.403585 1.592158 0.338871 1.911109 \n",
" 20130331 0.000000 15.610817 -0.014492 -0.216748 0.217828 \n",
"\n",
" 每股投资现金流量净额 \n",
"StockID 报告期 \n",
"stock_id 20120331 -0.015415 \n",
" 20120630 -0.078620 \n",
" 20120930 -0.183924 \n",
" 20121231 -0.223138 \n",
" 20130331 -0.063866 \n",
"\n",
"[5 rows x 27 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "0f435014-7fc1-4514-ab44-ef6c3430e1ec",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['每股营业收入(最新摊薄)', '每股营业收入', '每股息税前利润', '每股经营现金流(最新摊薄)', '每股公积金', '每股利润总额',\n",
" '每股资本公积金', '每股负债', '每股收益(最新摊薄)', '每股短期负债', '每股未分配利润', '每股收益', '每股股利',\n",
" '每股净资产(最新摊薄)', '每股长期负债', '扣除非经常损益后的每股收益', '每股盈余公积金', '每股净资产增长率(%)',\n",
" '每股净资产', '每股经营活动现金流量净额增长率(%)', '每股筹资现金流量净额', '每股现金及现金等价物', '每股收益增长率(%)',\n",
" '每股现金净流量', '每股经营活动现金流量净额', '每股营业利润', '每股投资现金流量净额'],\n",
" dtype='object')"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fc39372e-5f8a-4043-8758-6102bd026ed8",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 75,
"id": "13369644-5d79-4331-ab4c-582ff1e967dd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['indicator_id', 'indicator_name', 'indicator_function', 'indicator_comment']"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('tinysoft-data/每股指标.csv')\n",
"df.columns.tolist()"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "a3d0b4f2-5ed5-4048-b1f4-6887c915c99b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"indicator_id int64\n",
"indicator_name object\n",
"indicator_function object\n",
"indicator_comment object\n",
"dtype: object"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.dtypes"
]
},
{
"cell_type": "code",
"execution_count": 78,
"id": "2b1dcf5e-820f-4db5-a609-75ac76602424",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'9900000': '每股收益',\n",
" '9900001': '扣除非经常损益后的每股收益',\n",
" '9900002': '每股收益增长率(%)',\n",
" '9900003': '每股净资产',\n",
" '9900004': '每股净资产增长率(%)',\n",
" '9900005': '每股经营活动现金流量净额',\n",
" '9900006': '每股经营活动现金流量净额增长率(%)',\n",
" '9900007': '每股投资现金流量净额',\n",
" '9900008': '每股筹资现金流量净额',\n",
" '9900009': '每股现金及现金等价物',\n",
" '9900010': '每股现金净流量',\n",
" '9900011': '每股营业收入',\n",
" '9900013': '每股营业利润',\n",
" '9900014': '每股息税前利润',\n",
" '9900015': '每股利润总额',\n",
" '9900017': '每股盈余公积金',\n",
" '9900018': '每股资本公积金',\n",
" '9900019': '每股公积金',\n",
" '9900020': '每股股利',\n",
" '9900021': '每股未分配利润',\n",
" '9900022': '每股短期负债',\n",
" '9900023': '每股长期负债',\n",
" '9900024': '每股负债',\n",
" '9900025': '每股收益(最新摊薄)',\n",
" '9900026': '每股净资产(最新摊薄)',\n",
" '9900027': '每股营业收入(最新摊薄)',\n",
" '9900028': '每股经营现金流(最新摊薄)'}"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['indicator_id'] = df['indicator_id'].astype('string')\n",
"df.set_index('indicator_id')['indicator_name'].to_dict()"
]
},
{
"cell_type": "code",
"execution_count": 79,
"id": "156c2f94-95b0-4c6f-99d8-9e5260cecb4d",
"metadata": {},
"outputs": [],
"source": [
"indicator_dict = df.set_index('indicator_id')['indicator_name'].to_dict() \n",
"indicator_id_list = list(indicator_dict.keys())\n",
"indicator_name_list = [\"'%s'\" % indicator_dict[indicator_id] for indicator_id in indicator_id_list]"
]
},
{
"cell_type": "code",
"execution_count": 80,
"id": "1d938e71-fb9e-4d09-9684-bb5db80c96f0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'9900000, 9900001, 9900002, 9900003, 9900004, 9900005, 9900006, 9900007, 9900008, 9900009, 9900010, 9900011, 9900013, 9900014, 9900015, 9900017, 9900018, 9900019, 9900020, 9900021, 9900022, 9900023, 9900024, 9900025, 9900026, 9900027, 9900028'"
]
},
"execution_count": 80,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"', '.join(indicator_id_list)"
]
},
{
"cell_type": "code",
"execution_count": 81,
"id": "cede5b2d-87c6-4809-9262-95a3a18a5577",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"'每股收益', '扣除非经常损益后的每股收益', '每股收益增长率(%)', '每股净资产', '每股净资产增长率(%)', '每股经营活动现金流量净额', '每股经营活动现金流量净额增长率(%)', '每股投资现金流量净额', '每股筹资现金流量净额', '每股现金及现金等价物', '每股现金净流量', '每股营业收入', '每股营业利润', '每股息税前利润', '每股利润总额', '每股盈余公积金', '每股资本公积金', '每股公积金', '每股股利', '每股未分配利润', '每股短期负债', '每股长期负债', '每股负债', '每股收益(最新摊薄)', '每股净资产(最新摊薄)', '每股营业收入(最新摊薄)', '每股经营现金流(最新摊薄)'\""
]
},
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"', '.join(indicator_name_list)"
]
},
{
"cell_type": "code",
"execution_count": 88,
"id": "7d9b9940-9fda-4a3c-8b08-7f6d7cad4119",
"metadata": {},
"outputs": [],
"source": [
"year_list = range(2012, 2022, 1)\n",
"quarter_list = ['0331', '0630', '0930', '1231']"
]
},
{
"cell_type": "code",
"execution_count": 91,
"id": "0055592f-d1db-4328-88ec-1dcbc938a2de",
"metadata": {},
"outputs": [],
"source": [
"import itertools\n",
"\n",
"report_date_list = [str(t[0]) + t[1] for t in itertools.product(year_list, quarter_list)]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7937df2c-62b2-4c2e-8689-095744ceaaf9",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2412ad25-8577-4a4c-84f4-ba7b02d5af15",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('./tinysoft-data/基础报表/40.业绩预测/SH600009.csv')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "37be2152-89bf-465c-ae70-625f714256c0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>StockID</th>\n",
" <th>StockName</th>\n",
" <th>截止日</th>\n",
" <th>公布日</th>\n",
" <th>预警内容</th>\n",
" <th>预警类型</th>\n",
" <th>比上年同期增长数据来源</th>\n",
" <th>预警详情</th>\n",
" <th>备注</th>\n",
" <th>盈利金额上限</th>\n",
" <th>盈利金额单位</th>\n",
" <th>盈利金额下限</th>\n",
" <th>比上年同期增长下限(%)</th>\n",
" <th>比上年同期增长上限(%)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>SH600009</td>\n",
" <td>上海机场</td>\n",
" <td>20200630</td>\n",
" <td>20200429</td>\n",
" <td>此次疫情对公司各项业务开展和客户经营影响较大,公司经营压力持续加大,营业收入预计将有较大幅度...</td>\n",
" <td>预警</td>\n",
" <td>公告中公布</td>\n",
" <td>2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织先后强调...</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>0.0000</td>\n",
" <td>0.0000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>SH600009</td>\n",
" <td>上海机场</td>\n",
" <td>20200930</td>\n",
" <td>20200829</td>\n",
" <td>预测年初至下一报告期期末的累计净利润可能为亏损</td>\n",
" <td>预警</td>\n",
" <td>公告中公布</td>\n",
" <td>2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织\\r\\n...</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>0.0000</td>\n",
" <td>0.0000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>SH600009</td>\n",
" <td>上海机场</td>\n",
" <td>20201231</td>\n",
" <td>20201031</td>\n",
" <td>,营业收入预计将有较大幅度下降</td>\n",
" <td>预减</td>\n",
" <td>公告中公布</td>\n",
" <td>2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织先后强调...</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>0.0000</td>\n",
" <td>0.0000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>SH600009</td>\n",
" <td>上海机场</td>\n",
" <td>20201231</td>\n",
" <td>20210130</td>\n",
" <td>净利润亏损121000万元-129000万元</td>\n",
" <td>预亏</td>\n",
" <td>天软计算</td>\n",
" <td>2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战\\r\\n行业受疫情影响严重、所面临...</td>\n",
" <td>NaN</td>\n",
" <td>-121000.0</td>\n",
" <td>万元</td>\n",
" <td>-129000.0</td>\n",
" <td>-125.6451</td>\n",
" <td>-124.0547</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>SH600009</td>\n",
" <td>上海机场</td>\n",
" <td>20210630</td>\n",
" <td>20210429</td>\n",
" <td>预计业绩仍将亏损</td>\n",
" <td>预警</td>\n",
" <td>公告中公布</td>\n",
" <td>当前,疫情仍是影响行业恢复发展的最大不确定性因素,境外疫情形势依然严峻复杂,本土疫情呈零星散...</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>0.0</td>\n",
" <td>0.0000</td>\n",
" <td>0.0000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" StockID StockName 截止日 公布日 \\\n",
"0 SH600009 上海机场 20200630 20200429 \n",
"1 SH600009 上海机场 20200930 20200829 \n",
"2 SH600009 上海机场 20201231 20201031 \n",
"3 SH600009 上海机场 20201231 20210130 \n",
"4 SH600009 上海机场 20210630 20210429 \n",
"\n",
" 预警内容 预警类型 比上年同期增长数据来源 \\\n",
"0 此次疫情对公司各项业务开展和客户经营影响较大,公司经营压力持续加大,营业收入预计将有较大幅度... 预警 公告中公布 \n",
"1 预测年初至下一报告期期末的累计净利润可能为亏损 预警 公告中公布 \n",
"2 ,营业收入预计将有较大幅度下降 预减 公告中公布 \n",
"3 净利润亏损121000万元-129000万元 预亏 天软计算 \n",
"4 预计业绩仍将亏损 预警 公告中公布 \n",
"\n",
" 预警详情 备注 盈利金额上限 盈利金额单位 \\\n",
"0 2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织先后强调... NaN 0.0 NaN \n",
"1 2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织\\r\\n... NaN 0.0 NaN \n",
"2 2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战国际机场协会和国际民航组织先后强调... NaN 0.0 NaN \n",
"3 2020年以来全球航空业因新冠肺炎疫情爆发面临严峻挑战\\r\\n行业受疫情影响严重、所面临... NaN -121000.0 万元 \n",
"4 当前,疫情仍是影响行业恢复发展的最大不确定性因素,境外疫情形势依然严峻复杂,本土疫情呈零星散... NaN 0.0 NaN \n",
"\n",
" 盈利金额下限 比上年同期增长下限(%) 比上年同期增长上限(%) \n",
"0 0.0 0.0000 0.0000 \n",
"1 0.0 0.0000 0.0000 \n",
"2 0.0 0.0000 0.0000 \n",
"3 -129000.0 -125.6451 -124.0547 \n",
"4 0.0 0.0000 0.0000 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()['']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "45fc86a4-aeda-401f-9fdd-30732e195a3f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['StockID', 'StockName', '截止日', '公布日', '营业总收入', '每股净资产', '归属母公司股东权益合计',\n",
" '营业利润', '股本', '资产总计', '利润总额', '净资产收益率(加权)(%)', '基本每股收益',\n",
" '归属于母公司所有者净利润'],\n",
" dtype='object')"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "25a034a6-495c-4f10-b800-3f34fd7881cd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>报告期</th>\n",
" <th>20200630</th>\n",
" <th>20200930</th>\n",
" <th>20201231</th>\n",
" <th>20210331</th>\n",
" <th>20210630</th>\n",
" <th>20210930</th>\n",
" <th>20211231</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>净资产收益率(%)</th>\n",
" <td>3.892464</td>\n",
" <td>6.242980</td>\n",
" <td>7.944394</td>\n",
" <td>2.719146</td>\n",
" <td>4.661539</td>\n",
" <td>7.492452</td>\n",
" <td>9.188566</td>\n",
" </tr>\n",
" <tr>\n",
" <th>销售净利率(%)</th>\n",
" <td>17.462466</td>\n",
" <td>19.215195</td>\n",
" <td>18.840448</td>\n",
" <td>24.246195</td>\n",
" <td>20.764053</td>\n",
" <td>22.906675</td>\n",
" <td>21.451976</td>\n",
" </tr>\n",
" <tr>\n",
" <th>销售毛利率(%)</th>\n",
" <td>22.544939</td>\n",
" <td>24.812978</td>\n",
" <td>24.038374</td>\n",
" <td>30.939504</td>\n",
" <td>26.470241</td>\n",
" <td>28.955893</td>\n",
" <td>27.148533</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"报告期 20200630 20200930 20201231 20210331 20210630 20210930 \\\n",
"净资产收益率(%) 3.892464 6.242980 7.944394 2.719146 4.661539 7.492452 \n",
"销售净利率(%) 17.462466 19.215195 18.840448 24.246195 20.764053 22.906675 \n",
"销售毛利率(%) 22.544939 24.812978 24.038374 30.939504 26.470241 28.955893 \n",
"\n",
"报告期 20211231 \n",
"净资产收益率(%) 9.188566 \n",
"销售净利率(%) 21.451976 \n",
"销售毛利率(%) 27.148533 "
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.set_index('报告期')[['净资产收益率(%)', '销售净利率(%)', '销售毛利率(%)']].tail(7).T"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e2a7737-f6a2-4990-8f98-e31cfa7ae9e1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}