siat 3.10.125__py3-none-any.whl → 3.10.127__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siat/common.py +106 -2
- siat/exchange_bond_china.pickle +0 -0
- siat/fund_china.pickle +0 -0
- siat/stock.py +10 -2
- siat/stock_info.pickle +0 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/METADATA +235 -226
- siat-3.10.127.dist-info/RECORD +76 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/WHEEL +1 -1
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info/licenses}/LICENSE +0 -0
- {siat-3.10.125.dist-info → siat-3.10.127.dist-info}/top_level.txt +0 -0
- siat/__init__ -20240701.py +0 -65
- siat/__init__.py.backup_20250214.py +0 -73
- siat/alpha_vantage_test.py +0 -24
- siat/assets_liquidity_test.py +0 -44
- siat/barrons_scraping_test.py +0 -276
- siat/beta_adjustment_test.py +0 -77
- siat/bond_test.py +0 -142
- siat/capm_beta_test.py +0 -49
- siat/cmat_commons.py +0 -961
- siat/compare_cross_test.py +0 -117
- siat/concepts_iwencai.py +0 -86
- siat/concepts_kpl.py +0 -93
- siat/cryptocurrency_test.py +0 -71
- siat/derivative.py +0 -1111
- siat/economy-20230125.py +0 -1206
- siat/economy_test.py +0 -360
- siat/esg_test.py +0 -63
- siat/fama_french_test.py +0 -115
- siat/financial_statements_test.py +0 -31
- siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
- siat/financials_china2_test.py +0 -67
- siat/financials_china2_test2.py +0 -88
- siat/financials_china2_test3.py +0 -87
- siat/financials_china_test.py +0 -475
- siat/financials_china_test2.py +0 -197
- siat/financials_china_test2_fin_indicator.py +0 -197
- siat/financials_test.py +0 -713
- siat/fred_test.py +0 -40
- siat/fund_china_test.py +0 -175
- siat/fund_test.py +0 -40
- siat/future_china_test.py +0 -37
- siat/global_index_test.py +0 -66
- siat/grafix_test.py +0 -112
- siat/holding_risk_test.py +0 -13
- siat/local_debug_test.py +0 -100
- siat/markowitz2-20240620.py +0 -2614
- siat/markowitz_ccb_test.py +0 -37
- siat/markowitz_ef_test.py +0 -136
- siat/markowitz_old.py +0 -871
- siat/markowitz_simple-20230709.py +0 -370
- siat/markowitz_test.py +0 -164
- siat/markowitz_test2.py +0 -69
- siat/ml_cases_example1.py +0 -60
- siat/option_china_test.py +0 -447
- siat/option_pricing_test.py +0 -81
- siat/option_sina_api_test.py +0 -112
- siat/proxy_test.py +0 -84
- siat/quandl_test.py +0 -39
- siat/risk_adjusted_return_test.py +0 -81
- siat/risk_evaluation_test.py +0 -96
- siat/risk_free_rate_test.py +0 -127
- siat/sector_china_test.py +0 -203
- siat/security_price.py +0 -831
- siat/security_prices_test.py +0 -310
- siat/security_trend2-20240620.py +0 -493
- siat/setup.py +0 -41
- siat/shenwan index history test.py +0 -41
- siat/stock_china_test.py +0 -38
- siat/stock_info_test.py +0 -189
- siat/stock_list_china_test.py +0 -33
- siat/stock_technical-20240620.py +0 -2736
- siat/stock_test.py +0 -487
- siat/temp.py +0 -36
- siat/test2_graphviz.py +0 -484
- siat/test_graphviz.py +0 -411
- siat/test_markowitz_simple.py +0 -198
- siat/test_markowitz_simple_revised.py +0 -215
- siat/test_markowitz_simple_revised2.py +0 -218
- siat/transaction_test.py +0 -436
- siat/translate-20230125.py +0 -2107
- siat/translate-20230206.py +0 -2109
- siat/translate-20230215.py +0 -2158
- siat/translate_20240606.py +0 -4206
- siat/translate_241003_keep.py +0 -4300
- siat/universal_test.py +0 -100
- siat/valuation_market_china_test.py +0 -36
- siat-3.10.125.dist-info/RECORD +0 -152
siat/test2_graphviz.py
DELETED
@@ -1,484 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir("S:/siat")
|
4
|
-
from siat import *
|
5
|
-
|
6
|
-
#==============================================================================
|
7
|
-
|
8
|
-
def define_dupont_orgchart(company_name,dpdf):
|
9
|
-
"""
|
10
|
-
功能:定义杜邦分解图示的结构框架
|
11
|
-
dpdf:数据框,项目名称,数值
|
12
|
-
"""
|
13
|
-
|
14
|
-
# 定义杜邦分解项目变量
|
15
|
-
roe=company_name+'\n\n'+'净资产收益率'
|
16
|
-
|
17
|
-
roa='总资产净利率'
|
18
|
-
em='权益乘数'
|
19
|
-
|
20
|
-
pm='销售净利率'
|
21
|
-
tat='总资产周转率'
|
22
|
-
debtRatio='资产负债率'
|
23
|
-
|
24
|
-
netProfit='净利润'
|
25
|
-
sales1='销售收入'
|
26
|
-
sales2='销售收入'
|
27
|
-
totalAssets='资产总额'
|
28
|
-
|
29
|
-
totalCosts='成本费用'
|
30
|
-
currentAssets='流动资产'
|
31
|
-
LTAssets='长期资产'
|
32
|
-
|
33
|
-
salesCosts='销售成本'
|
34
|
-
salesExpenses='销售费用'
|
35
|
-
mgmtExpenses='管理费用'
|
36
|
-
financialExpenses='财务费用'
|
37
|
-
incomeTax='所得税费用'
|
38
|
-
otherExpenses='其他支出'
|
39
|
-
|
40
|
-
monetaryFunds='货币资金'
|
41
|
-
securityAssets='有价证券'
|
42
|
-
accountReceivables='应收款项' #含应收张狂和应收票据
|
43
|
-
prepaid='预付款项'
|
44
|
-
inventory='存货'
|
45
|
-
otherCurrentAssets='其他流动资产'
|
46
|
-
|
47
|
-
fixedAssets='固定资产'
|
48
|
-
LTInvestment='长期投资'
|
49
|
-
intangibleAssets='无形资产'
|
50
|
-
deferredAssets='递延资产'
|
51
|
-
goodwill='商誉'
|
52
|
-
|
53
|
-
#合成具体的分解项目
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# 定义杜邦分解框架
|
58
|
-
import pandas as pd
|
59
|
-
df=pd.DataFrame([
|
60
|
-
|
61
|
-
[1,1,roe,roa,''],
|
62
|
-
[1,2,roe,em,''],
|
63
|
-
|
64
|
-
[2,3,em,debtRatio,''],
|
65
|
-
|
66
|
-
[2,1,roa,pm,''],
|
67
|
-
[2,2,roa,tat,''],
|
68
|
-
|
69
|
-
[3,1,pm,netProfit,''],
|
70
|
-
[3,2,pm,sales1,''],
|
71
|
-
|
72
|
-
[3,3,tat,sales1,''],
|
73
|
-
[3,4,tat,totalAssets,''],
|
74
|
-
|
75
|
-
[4,1,netProfit,sales2,''],
|
76
|
-
[4,2,netProfit,totalCosts,''],
|
77
|
-
|
78
|
-
[5,1,totalCosts,salesCosts,''],
|
79
|
-
[5,2,totalCosts,salesExpenses,''],
|
80
|
-
[5,3,totalCosts,mgmtExpenses,''],
|
81
|
-
[5,4,totalCosts,financialExpenses,''],
|
82
|
-
[5,5,totalCosts,incomeTax,''],
|
83
|
-
[5,6,totalCosts,otherExpenses,''],
|
84
|
-
|
85
|
-
[4,3,totalAssets,currentAssets,''],
|
86
|
-
[4,4,totalAssets,LTAssets,''],
|
87
|
-
|
88
|
-
[5,7,currentAssets,monetaryFunds,''],
|
89
|
-
[5,8,currentAssets,securityAssets,''],
|
90
|
-
[5,9,currentAssets,accountReceivables,''],
|
91
|
-
[5,10,currentAssets,prepaid,''],
|
92
|
-
[5,11,currentAssets,inventory,''],
|
93
|
-
[5,12,currentAssets,otherCurrentAssets,''],
|
94
|
-
|
95
|
-
[5,13,LTAssets,fixedAssets,''],
|
96
|
-
[5,14,LTAssets,LTInvestment,''],
|
97
|
-
[5,15,LTAssets,intangibleAssets,''],
|
98
|
-
[5,16,LTAssets,deferredAssets,''],
|
99
|
-
[5,17,LTAssets,goodwill,''],
|
100
|
-
|
101
|
-
[9,1,salesCosts,'',''],
|
102
|
-
[9,2,salesExpenses,'',''],
|
103
|
-
[9,3,mgmtExpenses,'',''],
|
104
|
-
[9,4,financialExpenses,'',''],
|
105
|
-
[9,5,incomeTax,'',''],
|
106
|
-
[9,6,otherExpenses,'',''],
|
107
|
-
|
108
|
-
[9,7,monetaryFunds,'',''],
|
109
|
-
[9,8,securityAssets,'',''],
|
110
|
-
[9,9,accountReceivables,'',''],
|
111
|
-
[9,10,prepaid,'',''],
|
112
|
-
[9,11,inventory,'',''],
|
113
|
-
[9,12,otherCurrentAssets,'',''],
|
114
|
-
|
115
|
-
[9,13,fixedAssets,'',''],
|
116
|
-
[9,14,LTInvestment,'',''],
|
117
|
-
[9,15,intangibleAssets,'',''],
|
118
|
-
[9,16,deferredAssets,'',''],
|
119
|
-
[9,17,goodwill,'',''],
|
120
|
-
|
121
|
-
], columns=['level','seq','mother','child','edge text'])
|
122
|
-
|
123
|
-
df.sort_values(by=['level','seq'],ascending=[True,True],inplace=True)
|
124
|
-
|
125
|
-
return df
|
126
|
-
|
127
|
-
|
128
|
-
def draw_orgchart(df,shape='polygon', \
|
129
|
-
shape_color='black',fontcolor='blue',edge_color='red'):
|
130
|
-
"""
|
131
|
-
功能:基于df的结构绘制杜邦分解图示
|
132
|
-
df的结构字段:
|
133
|
-
mother:上级节点,任意字符串,中间可用'\n'换行
|
134
|
-
child:下级节点
|
135
|
-
edge_text:连线上的文字
|
136
|
-
"""
|
137
|
-
from graphviz import Digraph
|
138
|
-
photo=Digraph('picture',format='svg')
|
139
|
-
nodes={}
|
140
|
-
|
141
|
-
for index,row in df.iterrows():
|
142
|
-
mother_name=row['mother']
|
143
|
-
child_name=row['child']
|
144
|
-
edge_text=row['edge text']
|
145
|
-
|
146
|
-
orientation='0.0'
|
147
|
-
if child_name == '':
|
148
|
-
orientation='90'
|
149
|
-
|
150
|
-
if mother_name not in nodes.keys():
|
151
|
-
photo.node(name=mother_name,shape=shape,color=shape_color, \
|
152
|
-
fontname="Microsoft Yahei",fontcolor=fontcolor,orientation=orientation)
|
153
|
-
if child_name not in nodes.keys():
|
154
|
-
if child_name != '':
|
155
|
-
photo.node(name=child_name,shape=shape,color=shape_color, \
|
156
|
-
fontname="Microsoft Yahei",fontcolor=fontcolor)
|
157
|
-
|
158
|
-
nodes[mother_name]=1
|
159
|
-
nodes[child_name]=1
|
160
|
-
|
161
|
-
if child_name != '':
|
162
|
-
photo.edge(mother_name,child_name,color=edge_color,label=edge_text)
|
163
|
-
|
164
|
-
photo.view()
|
165
|
-
|
166
|
-
return
|
167
|
-
|
168
|
-
|
169
|
-
if __name__ == "__main__":
|
170
|
-
df=define_dupont_orgchart(company_name='',dpdf='')
|
171
|
-
draw_orgchart(df)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
#==============================================================================
|
190
|
-
if __name__=='__main__':
|
191
|
-
ticker="600519.SS"
|
192
|
-
fsdate='2022-12-31'
|
193
|
-
|
194
|
-
g=dupont_decompose_china(ticker,fsdate)
|
195
|
-
|
196
|
-
def dupont_decompose_china(ticker,fsdate):
|
197
|
-
"""
|
198
|
-
功能:杜邦分析分解图
|
199
|
-
ticker: 股票代码
|
200
|
-
fsdate: 财报日期
|
201
|
-
"""
|
202
|
-
#检查日期
|
203
|
-
result,fspd,_=check_period(fsdate,fsdate)
|
204
|
-
if not result:
|
205
|
-
print(" #Error(dupont_decompose_china): invalid date",fsdate)
|
206
|
-
return None
|
207
|
-
|
208
|
-
#获取财报
|
209
|
-
fs=get_fin_stmt_ak(ticker)
|
210
|
-
if fs is None:
|
211
|
-
print(" #Error(dupont_decompose_china): stock not found for",ticker)
|
212
|
-
return None
|
213
|
-
|
214
|
-
fs1=fs[fs.index==fspd]
|
215
|
-
if len(fs1)==0:
|
216
|
-
print(" #Error(dupont_decompose_china): financial statements not found for",ticker,'@',fsdate)
|
217
|
-
return None
|
218
|
-
|
219
|
-
#亿元
|
220
|
-
yi=100000000
|
221
|
-
|
222
|
-
company_name=codetranslate(ticker)
|
223
|
-
# 定义杜邦分解项目变量
|
224
|
-
|
225
|
-
roe=company_name+'\n\n'+'净资产收益率'
|
226
|
-
totalOEValue=round(fs1['所有者权益(或股东权益)合计'].values[0] / yi,1)
|
227
|
-
|
228
|
-
roa='总资产净利率'
|
229
|
-
|
230
|
-
em='权益乘数'
|
231
|
-
|
232
|
-
pm='销售净利率'
|
233
|
-
|
234
|
-
tat='总资产周转率'
|
235
|
-
|
236
|
-
debtRatio='资产负债率'
|
237
|
-
totalLiabValue=round(fs1['负债合计'].values[0] / yi,1)
|
238
|
-
|
239
|
-
netProfit='净利润'
|
240
|
-
netProfitValue=round(fs1['五、净利润'].values[0] / yi,1)
|
241
|
-
roePct=round(netProfitValue / totalOEValue *100,2)
|
242
|
-
|
243
|
-
sales='销售收入'
|
244
|
-
salesValue=round(fs1['一、营业总收入'].values[0] / yi,1)
|
245
|
-
pmPct=round(netProfitValue / salesValue *100,2)
|
246
|
-
|
247
|
-
totalAssets='资产总额'
|
248
|
-
totalAssetsValue=round(fs1['资产总计'].values[0] / yi,1)
|
249
|
-
tatValue=round(salesValue / totalAssetsValue *100,2)
|
250
|
-
emValue=round(totalAssetsValue / totalOEValue,2)
|
251
|
-
debtRatioPct=round(totalLiabValue / totalAssetsValue *100,2)
|
252
|
-
roaPct=round(netProfitValue / totalAssetsValue *100,2)
|
253
|
-
|
254
|
-
totalCosts='成本费用'
|
255
|
-
totalCostsValue=round(fs1['二、营业总成本'].values[0] / yi,1)
|
256
|
-
|
257
|
-
currentAssets='流动资产'
|
258
|
-
currentAssetsValue=round(fs1['流动资产合计'].values[0] / yi,1)
|
259
|
-
|
260
|
-
LTAssets='非流动资产'
|
261
|
-
LTAssetsValue=round(fs1['非流动资产合计'].values[0] / yi,1)
|
262
|
-
|
263
|
-
salesCosts='营业\\n成本'
|
264
|
-
salesCostsValue=round(fs1['营业成本'].values[0] / yi,1)
|
265
|
-
|
266
|
-
periodExpenses='期间\\n费用'
|
267
|
-
salesExpenses='销售\\n费用'
|
268
|
-
salesExpensesValue=round(fs1['销售费用'].values[0] / yi,1)
|
269
|
-
|
270
|
-
mgmtExpenses='管理\\n费用'
|
271
|
-
mgmtExpensesValue=round(fs1['管理费用'].values[0] / yi,1)
|
272
|
-
|
273
|
-
rndExpenses='研发\\n费用'
|
274
|
-
rndExpensesValue=round(fs1['研发费用'].values[0] / yi,1)
|
275
|
-
"""
|
276
|
-
#是否中国股票
|
277
|
-
result,prefix,suffix=split_prefix_suffix(ticker)
|
278
|
-
if not (suffix in STOCK_SUFFIX_CHINA):
|
279
|
-
print(" #Error(dupont_decompose_china): not a stock in China",ticker)
|
280
|
-
return None
|
281
|
-
|
282
|
-
#财务报告摘要
|
283
|
-
try:
|
284
|
-
fsabs = ak.stock_financial_abstract(prefix)
|
285
|
-
except:
|
286
|
-
print(" #Warning(dupont_decompose_china): financial summary not found for",ticker)
|
287
|
-
return None
|
288
|
-
"""
|
289
|
-
financialExpenses='利息\\n费用'
|
290
|
-
financialExpensesValue=round(fs1['应付利息'].values[0] / yi,1)
|
291
|
-
|
292
|
-
taxExpenses='税金'
|
293
|
-
taxExpensesValue=round((fs1['营业税金及附加'].values[0] + fs1['减:所得税费用'].values[0]) / yi,1)
|
294
|
-
|
295
|
-
otherExpenses='其他支出'
|
296
|
-
otherExpensesVaue=round((fs1['开发支出'].values[0] + fs1['减:营业外支出'].values[0]) / yi,1)
|
297
|
-
|
298
|
-
monetaryFunds='货币\\n资金'
|
299
|
-
monetaryFundsValue=round(fs1['货币资金'].values[0] / yi,1)
|
300
|
-
|
301
|
-
securityAssets='金融\\n资产'
|
302
|
-
securityAssetsValue=round((fs1['交易性金融资产'].values[0] + \
|
303
|
-
fs1['衍生金融资产'].values[0] + \
|
304
|
-
fs1['买入返售金融资产'].values[0]) / yi,1)
|
305
|
-
|
306
|
-
ar_prepaid='应收\\n与\\n预付'
|
307
|
-
accountReceivables='应收\\n款项'
|
308
|
-
accountReceivablesValue=round((fs1['应收票据及应收账款'].values[0] + fs1['其他应收款(合计)'].values[0]) / yi,1)
|
309
|
-
|
310
|
-
prepaid='预付\\n款项'
|
311
|
-
prepaidValue=round(fs1['预付款项'].values[0] / yi,1)
|
312
|
-
|
313
|
-
inventory='存货'
|
314
|
-
inventoryValue=round(fs1['存货'].values[0] / yi,1)
|
315
|
-
|
316
|
-
otherCurrentAssets='其他\\n流动\\n资产'
|
317
|
-
otherCurrentAssetsValue=round(fs1['其他流动资产'].values[0] / yi,1)
|
318
|
-
|
319
|
-
fixedAssets='固定\\n资产'
|
320
|
-
fixedAssetsValue=round(fs1['固定资产及清理(合计)'].values[0] / yi,1)
|
321
|
-
|
322
|
-
LTInvestment='长期\\n投资'
|
323
|
-
LTInvestmentValue=round((fs1['发放贷款及垫款'].values[0] + \
|
324
|
-
fs1['可供出售金融资产'].values[0] + \
|
325
|
-
fs1['持有至到期投资'].values[0] + \
|
326
|
-
#fs1['长期应收款'].values[0] + \
|
327
|
-
fs1['长期股权投资'].values[0] + \
|
328
|
-
fs1['投资性房地产'].values[0] + \
|
329
|
-
fs1['在建工程(合计)'].values[0]) / yi,1)
|
330
|
-
|
331
|
-
intangibleAssets='无形\\n资产'
|
332
|
-
intangibleAssetsValue=round(fs1['无形资产'].values[0] / yi,1)
|
333
|
-
|
334
|
-
deferredAssets='递延\\n资产'
|
335
|
-
deferredAssetsValue=round(fs1['递延所得税资产'].values[0] / yi,1)
|
336
|
-
|
337
|
-
goodwill='商誉'
|
338
|
-
goodwillValue=round(fs1['商誉'].values[0] / yi,1)
|
339
|
-
|
340
|
-
#合成具体的分解项目
|
341
|
-
roe=roe+'\n'+str(roePct)+'%'
|
342
|
-
roa=roa+'\n'+str(roaPct)+'%'
|
343
|
-
em=em+'\n'+str(emValue)
|
344
|
-
pm=pm+'\n'+str(pmPct)+'%'
|
345
|
-
tat=tat+'\n'+str(tatValue)
|
346
|
-
|
347
|
-
netProfit=netProfit+'\n'+str(netProfitValue)
|
348
|
-
totalAssets=totalAssets+'\n'+str(totalAssetsValue)
|
349
|
-
totalCosts=totalCosts+'\n'+str(totalCostsValue)
|
350
|
-
sales=sales+'\n'+str(salesValue)
|
351
|
-
currentAssets=currentAssets+'\n'+str(currentAssetsValue)
|
352
|
-
LTAssets=LTAssets+'\n'+str(LTAssetsValue)
|
353
|
-
|
354
|
-
salesCosts=salesCosts+'\n'+str(salesCostsValue)
|
355
|
-
taxExpenses=taxExpenses+'\n'+str(taxExpensesValue)
|
356
|
-
|
357
|
-
salesExpenses=salesExpenses+'\n'+str(salesExpensesValue)
|
358
|
-
mgmtExpenses=mgmtExpenses+'\n'+str(mgmtExpensesValue)
|
359
|
-
financialExpenses=financialExpenses+'\n'+str(financialExpensesValue)
|
360
|
-
rndExpenses=rndExpenses+'\n'+str(rndExpensesValue)
|
361
|
-
|
362
|
-
monetaryFunds=monetaryFunds+'\n'+str(monetaryFundsValue)
|
363
|
-
securityAssets=securityAssets+'\n'+str(securityAssetsValue)
|
364
|
-
accountReceivables=accountReceivables+'\n'+str(accountReceivablesValue)
|
365
|
-
prepaid=prepaid+'\n'+str(prepaidValue)
|
366
|
-
inventory=inventory+'\n'+str(inventoryValue)
|
367
|
-
|
368
|
-
fixedAssets=fixedAssets+'\n'+str(fixedAssetsValue)
|
369
|
-
LTInvestment=LTInvestment+'\n'+str(LTInvestmentValue)
|
370
|
-
intangibleAssets=intangibleAssets+'\n'+str(intangibleAssetsValue)
|
371
|
-
|
372
|
-
#下面字段:“序号”、“父单位”、“父单位层级”、“子单位”、“子单位层级”、“父单位持股比例”
|
373
|
-
#注意:最后面的空格字段为必须,否则显示顺序不受控
|
374
|
-
L=[
|
375
|
-
[1, roe, 1, roa, 2, ' '],
|
376
|
-
[2, roe, 1, em, 2, ' '],
|
377
|
-
[3, roa, 2, pm, 3, ' '],
|
378
|
-
[4, roa, 2, tat, 3, ' '],
|
379
|
-
[5, pm, 3, netProfit, 4, ' '],
|
380
|
-
[6, pm, 3, sales, 4, ' '],
|
381
|
-
[7, netProfit, 4, sales, 5, ' '],
|
382
|
-
[8, netProfit, 4, totalCosts, 5, ' '],
|
383
|
-
[9, totalCosts, 5, salesCosts, 6, ' '],
|
384
|
-
|
385
|
-
[10, totalCosts, 5, periodExpenses, 6, ' '],
|
386
|
-
[11, periodExpenses, 6, salesExpenses, 7, ' '],
|
387
|
-
[12, periodExpenses, 6, mgmtExpenses, 7, ' '],
|
388
|
-
[13, periodExpenses, 6, financialExpenses, 7, ' '],
|
389
|
-
[14, periodExpenses, 6, rndExpenses, 7, ' '],
|
390
|
-
|
391
|
-
[15, totalCosts, 5, taxExpenses, 6, ' '],
|
392
|
-
|
393
|
-
[16, tat, 3, sales, 4, ' '],
|
394
|
-
[17, tat, 3, totalAssets, 4, ' '],
|
395
|
-
[18, totalAssets, 4, currentAssets, 5, ' '],
|
396
|
-
[19, totalAssets, 4, LTAssets, 5, ' '],
|
397
|
-
|
398
|
-
[20, currentAssets, 5, monetaryFunds, 6, ' '],
|
399
|
-
[21, currentAssets, 5, securityAssets, 6, ' '],
|
400
|
-
|
401
|
-
[22, currentAssets, 5, ar_prepaid, 6, ' '],
|
402
|
-
[23, ar_prepaid, 6, accountReceivables, 7, ' '],
|
403
|
-
[24, ar_prepaid, 6, prepaid, 7, ' '],
|
404
|
-
|
405
|
-
[25, currentAssets, 5, inventory, 10, ' '],
|
406
|
-
#[26, currentAssets, 5, otherCurrentAssets, 11, ' '],
|
407
|
-
|
408
|
-
[27, LTAssets, 5, fixedAssets, 6, ' '],
|
409
|
-
[28, LTAssets, 5, LTInvestment, 6, ' '],
|
410
|
-
[29, LTAssets, 5, intangibleAssets, 6, ' '],
|
411
|
-
#[30, LTAssets, 5, deferredAssets, 6, ' '],
|
412
|
-
#[31, LTAssets, 5, goodwill, 6, ' '],
|
413
|
-
|
414
|
-
]
|
415
|
-
|
416
|
-
dic={}
|
417
|
-
father_name_list=[]
|
418
|
-
child_name_list=[]
|
419
|
-
equity_portion_list=[]
|
420
|
-
for i1 in range(len(L)):
|
421
|
-
|
422
|
-
M=L[i1]
|
423
|
-
father_name=M[1]
|
424
|
-
father_name_list.append(M[1])
|
425
|
-
father_layer=M[2]
|
426
|
-
child_name=M[3]
|
427
|
-
child_name_list.append(M[3])
|
428
|
-
child_layer=M[4]
|
429
|
-
equity_portion=M[5]
|
430
|
-
equity_portion_list.append(M[5])
|
431
|
-
|
432
|
-
#debug使用
|
433
|
-
#print(i1,M,father_name,father_layer,child_name,child_layer,equity_portion)
|
434
|
-
|
435
|
-
for x in father_name:
|
436
|
-
dic[father_name]=father_layer #生成父单位名称和对应的层级(用字典考虑去重)
|
437
|
-
|
438
|
-
for y in child_name:
|
439
|
-
dic[child_name]=child_layer #将子单位名称和对应的层级也添加到字典中
|
440
|
-
|
441
|
-
name_layer_list = sorted(dic.items(), key=lambda x: x[1]) #对字典按值(value)进行排序(默认由小到大)
|
442
|
-
|
443
|
-
u=[]
|
444
|
-
for z in name_layer_list:
|
445
|
-
company_name=z[0]
|
446
|
-
layer=z[1]
|
447
|
-
u.append(z[1])
|
448
|
-
number_of_layers=max(u) #计算出层数
|
449
|
-
|
450
|
-
from graphviz import Digraph
|
451
|
-
#按各公司的层数生产分层的节点:
|
452
|
-
g=Digraph(name='DuPont Decompose')
|
453
|
-
|
454
|
-
for key in dic:
|
455
|
-
for n in range(number_of_layers+1):
|
456
|
-
if dic[key]==n:
|
457
|
-
with g.subgraph() as layer_n:
|
458
|
-
layer_n.attr(rank='same')
|
459
|
-
layer_n.node(name=key,color='blue',shape='box',fontname='Microsoft YaHei')
|
460
|
-
|
461
|
-
#生产各节点间的连线:
|
462
|
-
for i2 in range(len(L)):
|
463
|
-
g.edge(father_name_list[i2],child_name_list[i2],label=equity_portion_list[i2],color='red',fontname='Microsoft Yahei')
|
464
|
-
|
465
|
-
g.view()
|
466
|
-
|
467
|
-
#打印信息
|
468
|
-
print("注:",company_name,"\b,金额单位:亿元,财报日期:",fsdate)
|
469
|
-
print("1、应收款项包括应收账款和应收票据")
|
470
|
-
print("2、递延资产为递延所得税资产")
|
471
|
-
print("3、税金包括营业税金及附加以及所得税费用")
|
472
|
-
print("4、此处的金融资产包括交易性金融资产、衍生金融资产和买入返售金融资产")
|
473
|
-
print("5、此处的长期投资包括发放贷款及垫款、可供出售金融资产、持有至到期投资、长期股权投资、投资性房地产以及在建工程")
|
474
|
-
|
475
|
-
return g
|
476
|
-
|
477
|
-
if __name__=='__main__':
|
478
|
-
ticker="600519.SS"
|
479
|
-
fsdate='2022-12-31'
|
480
|
-
|
481
|
-
g=dupont_decompose_china(ticker,fsdate)
|
482
|
-
|
483
|
-
|
484
|
-
#==============================================================================
|