siat 3.0.10__py3-none-any.whl → 3.0.15__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/capm_beta2.py +51 -22
- siat/common.py +22 -8
- siat/financials_china.py +28 -21
- siat/financials_china2.py +199 -106
- siat/grafix.py +109 -45
- siat/markowitz2.py +27 -3
- siat/risk_adjusted_return2.py +136 -62
- siat/security_trend2.py +39 -25
- siat/stock.py +127 -47
- siat/stock_china.py +1 -1
- siat/stock_technical.py +1 -1
- siat/valuation.py +34 -7
- {siat-3.0.10.dist-info → siat-3.0.15.dist-info}/METADATA +1 -1
- {siat-3.0.10.dist-info → siat-3.0.15.dist-info}/RECORD +16 -16
- {siat-3.0.10.dist-info → siat-3.0.15.dist-info}/WHEEL +1 -1
- {siat-3.0.10.dist-info → siat-3.0.15.dist-info}/top_level.txt +0 -0
siat/financials_china2.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
本模块功能:计算财务报表指标,基于东方财富,仅限于中国大陆上市的企业
|
5
5
|
所属工具包:证券投资分析工具SIAT
|
6
6
|
SIAT:Security Investment Analysis Tool
|
7
|
-
创建日期:
|
7
|
+
创建日期:2024年4月21日
|
8
8
|
最新修订日期:2022年5月18日
|
9
9
|
作者:王德宏 (WANG Dehong, Peter)
|
10
10
|
作者单位:北京外国语大学国际商学院
|
@@ -21,6 +21,7 @@ import akshare as ak
|
|
21
21
|
# 这条语句似乎有时失灵!?
|
22
22
|
from siat.stock_china import *
|
23
23
|
from siat.financials_china import *
|
24
|
+
from siat.translate import *
|
24
25
|
#==============================================================================
|
25
26
|
#==============================================================================
|
26
27
|
if __name__=='__main__':
|
@@ -212,7 +213,7 @@ def get_fin_stmt_ak_multi(tickers,fsdates):
|
|
212
213
|
df.rename(columns={'endDate_期初':'endDate_上期'},inplace=True)
|
213
214
|
|
214
215
|
#标注股票简称,去掉其中的(A股)字样
|
215
|
-
df["股票简称"]=df['ticker'].apply(lambda x: ticker_name(x).replace("(A股)",''))
|
216
|
+
df["股票简称"]=df['ticker'].apply(lambda x: ticker_name(x,'stock').replace("(A股)",''))
|
216
217
|
|
217
218
|
"""
|
218
219
|
# 替换nan为-
|
@@ -382,7 +383,9 @@ if __name__=='__main__':
|
|
382
383
|
foot_center=False
|
383
384
|
foot_start=4
|
384
385
|
|
385
|
-
def
|
386
|
+
def df_directprint_original(dfp,title_txt,footnote, \
|
387
|
+
title_break=True,foot_break=True,foot_center=False,foot_start=1, \
|
388
|
+
facecolor='papayawhip'):
|
386
389
|
"""
|
387
390
|
功能:对dfp直接打印,让标题居中,让脚注居中或指定开始位置。
|
388
391
|
"""
|
@@ -417,7 +420,7 @@ def df_directprint(dfp,title_txt,footnote,title_break=True,foot_break=True,foot_
|
|
417
420
|
colalign=['left']+['right']*(len(list(dfp)) - 1)
|
418
421
|
print(dfp.to_markdown(tablefmt='Simple',index=False,colalign=colalign))
|
419
422
|
|
420
|
-
|
423
|
+
#解析脚注各行并打印
|
421
424
|
if foot_break: print('')
|
422
425
|
footnote1=footnote+'\n'
|
423
426
|
pos,pos_new=0,0
|
@@ -440,8 +443,98 @@ def df_directprint(dfp,title_txt,footnote,title_break=True,foot_break=True,foot_
|
|
440
443
|
|
441
444
|
return
|
442
445
|
|
443
|
-
|
444
|
-
|
446
|
+
#==============================================================================
|
447
|
+
"""
|
448
|
+
def df_directprint(dfp,title_txt,footnote, \
|
449
|
+
title_break=True,foot_break=True,foot_center=False,foot_start=1, \
|
450
|
+
decimals=2,facecolor='papayawhip'):
|
451
|
+
"""
|
452
|
+
def df_directprint(dfp,title_txt,footnote,decimals=2,facecolor='papayawhip'):
|
453
|
+
"""
|
454
|
+
功能:对dfp直接打印,使用pandas style打印
|
455
|
+
"""
|
456
|
+
#替换nan和inf
|
457
|
+
import pandas as pd
|
458
|
+
import numpy as np
|
459
|
+
dfp.replace([np.inf, -np.inf],'-', inplace=True)
|
460
|
+
dfp.replace([np.nan],'-', inplace=True)
|
461
|
+
|
462
|
+
print('') #空一行
|
463
|
+
|
464
|
+
"""
|
465
|
+
#解析标题各行并居中打印
|
466
|
+
title_txt1=title_txt+'\n'
|
467
|
+
pos,pos_new=0,0
|
468
|
+
while pos_new != -1:
|
469
|
+
pos_new=title_txt1.find('\n',pos)
|
470
|
+
linetxt=title_txt1[pos:pos_new]
|
471
|
+
#print(linetxt)
|
472
|
+
|
473
|
+
blanknum=title_position(linetxt,dfp)
|
474
|
+
|
475
|
+
if linetxt != '\n':
|
476
|
+
print(' '*blanknum,linetxt)
|
477
|
+
|
478
|
+
pos=pos_new+1
|
479
|
+
"""
|
480
|
+
disph=dfp.style.hide() #不显示索引列
|
481
|
+
dispp=disph.format(precision=decimals) #设置带有小数点的列精度调整为小数点后2位
|
482
|
+
|
483
|
+
#设置标题/列名
|
484
|
+
dispt=dispp.set_caption(title_txt).set_table_styles(
|
485
|
+
[{'selector':'caption', #设置标题对齐
|
486
|
+
'props':[('color','black'),('font-size','18px'),('font-weight','bold')]}, \
|
487
|
+
{'selector':'th.col_heading', #设置列名对齐
|
488
|
+
'props':[('color','black'),('background-color',facecolor), \
|
489
|
+
('font-size','17px'),('text-align','center'),('margin','auto')]}])
|
490
|
+
|
491
|
+
#设置数据对齐
|
492
|
+
dispt1=dispt.set_properties(**{'font-size':'17px'})
|
493
|
+
dispf=dispt1.set_properties(**{'text-align':'center'})
|
494
|
+
|
495
|
+
#设置前景背景颜色
|
496
|
+
try:
|
497
|
+
dispf2=dispf.set_properties(**{'background-color':facecolor,'color':'black'})
|
498
|
+
except:
|
499
|
+
print(" #Warning(df_directprint): unknown color",facecolor,"\b, changed to default one")
|
500
|
+
dispf2=dispf.set_properties(**{'background-color':'papayawhip','color':'black'})
|
501
|
+
|
502
|
+
#打印数据框本身
|
503
|
+
from IPython.display import display
|
504
|
+
display(dispf2)
|
505
|
+
|
506
|
+
"""
|
507
|
+
#print(dfp.to_string(index=False))
|
508
|
+
colalign=['left']+['right']*(len(list(dfp)) - 1)
|
509
|
+
print(dfp.to_markdown(tablefmt='Simple',index=False,colalign=colalign))
|
510
|
+
"""
|
511
|
+
|
512
|
+
#解析脚注各行并打印
|
513
|
+
"""
|
514
|
+
if foot_break: print('')
|
515
|
+
footnote1=footnote+'\n'
|
516
|
+
pos,pos_new=0,0
|
517
|
+
while pos_new != -1:
|
518
|
+
pos_new=footnote1.find('\n',pos)
|
519
|
+
linetxt=footnote1[pos:pos_new]
|
520
|
+
#print(linetxt)
|
521
|
+
if foot_center:
|
522
|
+
blanknum=title_position(linetxt,dfp)
|
523
|
+
else:
|
524
|
+
blanknum=foot_start-1
|
525
|
+
|
526
|
+
if linetxt != '\n':
|
527
|
+
if blanknum >2:
|
528
|
+
print(' '*blanknum,linetxt)
|
529
|
+
else:
|
530
|
+
print(linetxt)
|
531
|
+
|
532
|
+
pos=pos_new+1
|
533
|
+
"""
|
534
|
+
#print('') #空一行
|
535
|
+
print(footnote,'\n')
|
536
|
+
|
537
|
+
return
|
445
538
|
#==============================================================================
|
446
539
|
|
447
540
|
if __name__=='__main__':
|
@@ -458,7 +551,7 @@ if __name__=='__main__':
|
|
458
551
|
items=["货币资金","应收票据","应收账款"]
|
459
552
|
dfp=fs_item_analysis_1(df,ticker,fsdate,items)
|
460
553
|
|
461
|
-
def fs_item_analysis_1(df,ticker,fsdate,items,title_txt='',notes=''):
|
554
|
+
def fs_item_analysis_1(df,ticker,fsdate,items,title_txt='',notes='',facecolor='papayawhip'):
|
462
555
|
"""
|
463
556
|
功能:比较给定财报日期的资产项目、期初数、期末数、变动额和变动幅度%
|
464
557
|
"""
|
@@ -504,8 +597,8 @@ def fs_item_analysis_1(df,ticker,fsdate,items,title_txt='',notes=''):
|
|
504
597
|
|
505
598
|
#无序号打印
|
506
599
|
if title_txt=='':
|
507
|
-
|
508
|
-
title_txt=
|
600
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
601
|
+
title_txt=tname+"财报分析:重要项目的变动情况\n(截至"+fsdate+")"
|
509
602
|
import datetime; today=datetime.date.today()
|
510
603
|
#footnote="*单位:亿元,数据来源:新浪财经,"+str(today)
|
511
604
|
footnote="*单位:亿元,本期报表日期:"+fsdate+',数据来源:新浪财经'
|
@@ -515,7 +608,7 @@ def fs_item_analysis_1(df,ticker,fsdate,items,title_txt='',notes=''):
|
|
515
608
|
else:
|
516
609
|
foottext=notes+'\n'+footnote
|
517
610
|
|
518
|
-
df_directprint(dfp,title_txt,foottext)
|
611
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
519
612
|
|
520
613
|
return dfp
|
521
614
|
|
@@ -534,7 +627,7 @@ if __name__=='__main__':
|
|
534
627
|
|
535
628
|
dfp=fs_item_analysis_2(df,ticker,fsdates,items)
|
536
629
|
|
537
|
-
def fs_item_analysis_2(df,ticker,fsdates,items,title_txt='',notes=''):
|
630
|
+
def fs_item_analysis_2(df,ticker,fsdates,items,title_txt='',notes='',facecolor='papayawhip'):
|
538
631
|
"""
|
539
632
|
功能:比较给定财报日期的报表项目、最近几年fsdates、占比%
|
540
633
|
"""
|
@@ -565,8 +658,8 @@ def fs_item_analysis_2(df,ticker,fsdates,items,title_txt='',notes=''):
|
|
565
658
|
|
566
659
|
#无序号打印
|
567
660
|
if title_txt=='':
|
568
|
-
|
569
|
-
title_txt=
|
661
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
662
|
+
title_txt=tname+"财报分析:重要项目占比的变动趋势"
|
570
663
|
import datetime; today=datetime.date.today()
|
571
664
|
footnote="*数据来源:新浪财经,"+str(today)
|
572
665
|
|
@@ -575,7 +668,7 @@ def fs_item_analysis_2(df,ticker,fsdates,items,title_txt='',notes=''):
|
|
575
668
|
else:
|
576
669
|
foottext=notes+'\n'+footnote
|
577
670
|
|
578
|
-
df_directprint(dfp,title_txt,foottext)
|
671
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
579
672
|
|
580
673
|
return dfp
|
581
674
|
|
@@ -590,7 +683,7 @@ if __name__=='__main__':
|
|
590
683
|
|
591
684
|
dfp=fs_item_analysis_3(df,ticker,fsdates)
|
592
685
|
|
593
|
-
def fs_item_analysis_3(df,ticker,fsdates,title_txt='',notes=''):
|
686
|
+
def fs_item_analysis_3(df,ticker,fsdates,title_txt='',notes='',facecolor='papayawhip'):
|
594
687
|
"""
|
595
688
|
功能:比较给定财报日期的流动比率、最近几年fsdates
|
596
689
|
"""
|
@@ -620,8 +713,8 @@ def fs_item_analysis_3(df,ticker,fsdates,title_txt='',notes=''):
|
|
620
713
|
|
621
714
|
#无序号打印
|
622
715
|
if title_txt=='':
|
623
|
-
|
624
|
-
title_txt=
|
716
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
717
|
+
title_txt=tname+"财报分析:流动比率的变动趋势"
|
625
718
|
import datetime; today=datetime.date.today()
|
626
719
|
footnote="*数据来源:新浪财经,"+str(today)
|
627
720
|
|
@@ -630,7 +723,7 @@ def fs_item_analysis_3(df,ticker,fsdates,title_txt='',notes=''):
|
|
630
723
|
else:
|
631
724
|
foottext=notes+'\n'+footnote
|
632
725
|
|
633
|
-
df_directprint(dfp,title_txt,foottext)
|
726
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
634
727
|
|
635
728
|
return dfp
|
636
729
|
|
@@ -645,7 +738,7 @@ if __name__=='__main__':
|
|
645
738
|
|
646
739
|
dfp=fs_item_analysis_4(df,ticker,fsdates)
|
647
740
|
|
648
|
-
def fs_item_analysis_4(df,ticker,fsdates,title_txt='',notes=''):
|
741
|
+
def fs_item_analysis_4(df,ticker,fsdates,title_txt='',notes='',facecolor='papayawhip'):
|
649
742
|
"""
|
650
743
|
功能:比较给定财报日期的流动比率、最近几年fsdates
|
651
744
|
"""
|
@@ -695,8 +788,8 @@ def fs_item_analysis_4(df,ticker,fsdates,title_txt='',notes=''):
|
|
695
788
|
|
696
789
|
#无序号打印
|
697
790
|
if title_txt=='':
|
698
|
-
|
699
|
-
title_txt=
|
791
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
792
|
+
title_txt=tname+"财报分析:速动比率的变动趋势"
|
700
793
|
import datetime; today=datetime.date.today()
|
701
794
|
footnote="*数据来源:新浪财经,"+str(today)
|
702
795
|
|
@@ -705,7 +798,7 @@ def fs_item_analysis_4(df,ticker,fsdates,title_txt='',notes=''):
|
|
705
798
|
else:
|
706
799
|
foottext=notes+'\n'+footnote
|
707
800
|
|
708
|
-
df_directprint(dfp,title_txt,foottext)
|
801
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
709
802
|
|
710
803
|
return dfp
|
711
804
|
|
@@ -720,7 +813,7 @@ if __name__=='__main__':
|
|
720
813
|
|
721
814
|
dfp=fs_item_analysis_5(df,ticker,fsdates)
|
722
815
|
|
723
|
-
def fs_item_analysis_5(df,ticker,fsdates,title_txt='',notes=''):
|
816
|
+
def fs_item_analysis_5(df,ticker,fsdates,title_txt='',notes='',facecolor='papayawhip'):
|
724
817
|
"""
|
725
818
|
功能:比较给定财报日期的流动比率、最近几年fsdates
|
726
819
|
"""
|
@@ -750,8 +843,8 @@ def fs_item_analysis_5(df,ticker,fsdates,title_txt='',notes=''):
|
|
750
843
|
|
751
844
|
#无序号打印
|
752
845
|
if title_txt=='':
|
753
|
-
|
754
|
-
title_txt=
|
846
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
847
|
+
title_txt=tname+"财报分析:资产负债率的变动趋势"
|
755
848
|
import datetime; today=datetime.date.today()
|
756
849
|
footnote="*数据来源:新浪财经,"+str(today)
|
757
850
|
|
@@ -760,7 +853,7 @@ def fs_item_analysis_5(df,ticker,fsdates,title_txt='',notes=''):
|
|
760
853
|
else:
|
761
854
|
foottext=notes+'\n'+footnote
|
762
855
|
|
763
|
-
df_directprint(dfp,title_txt,foottext)
|
856
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
764
857
|
|
765
858
|
return dfp
|
766
859
|
|
@@ -811,8 +904,8 @@ def fs_item_analysis_6_original(df,ticker,fsdates,items,title_txt='',notes=''):
|
|
811
904
|
|
812
905
|
#无序号打印
|
813
906
|
if title_txt=='':
|
814
|
-
|
815
|
-
title_txt=
|
907
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
908
|
+
title_txt=tname+"财报分析:重要关联项目的增幅对比"
|
816
909
|
import datetime; today=datetime.date.today()
|
817
910
|
footnote="*数据来源:新浪财经,"+str(today)
|
818
911
|
|
@@ -836,7 +929,7 @@ if __name__=='__main__':
|
|
836
929
|
|
837
930
|
dfp=fs_item_analysis_6(df,ticker,fsdates,items)
|
838
931
|
|
839
|
-
def fs_item_analysis_6(df,ticker,fsdates,items,title_txt='',notes=''):
|
932
|
+
def fs_item_analysis_6(df,ticker,fsdates,items,title_txt='',notes='',facecolor='papayawhip'):
|
840
933
|
"""
|
841
934
|
功能:比较给定财报日期的应收账款与营业收入增幅、最近几年fsdates
|
842
935
|
"""
|
@@ -870,8 +963,8 @@ def fs_item_analysis_6(df,ticker,fsdates,items,title_txt='',notes=''):
|
|
870
963
|
|
871
964
|
#无序号打印
|
872
965
|
if title_txt=='':
|
873
|
-
|
874
|
-
title_txt=
|
966
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
967
|
+
title_txt=tname+"财报分析:重要关联项目的增幅对比"
|
875
968
|
import datetime; today=datetime.date.today()
|
876
969
|
if yiyuan_foot:
|
877
970
|
footnote="*单位:亿元,数据来源:新浪财经,"+str(today)
|
@@ -883,7 +976,7 @@ def fs_item_analysis_6(df,ticker,fsdates,items,title_txt='',notes=''):
|
|
883
976
|
else:
|
884
977
|
foottext=notes+'\n'+footnote
|
885
978
|
|
886
|
-
df_directprint(dfp,title_txt,foottext)
|
979
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
887
980
|
|
888
981
|
return dfp
|
889
982
|
|
@@ -919,7 +1012,7 @@ def fs_item_analysis_7_original(df,tickers,fsdate,items,title_txt=''):
|
|
919
1012
|
yiyuan_foot=False
|
920
1013
|
|
921
1014
|
for t in tickers:
|
922
|
-
tname=ticker_name(t).replace("(A股)",'')
|
1015
|
+
tname=ticker_name(t,'stock').replace("(A股)",'')
|
923
1016
|
row_list=[tname]
|
924
1017
|
for i in items:
|
925
1018
|
i_value,_,_=select_item(df,t,fsdate,i)
|
@@ -939,8 +1032,8 @@ def fs_item_analysis_7_original(df,tickers,fsdate,items,title_txt=''):
|
|
939
1032
|
if title_txt=='':
|
940
1033
|
title_txt="=== 重要指标的同行业对比 ==="
|
941
1034
|
ticker=tickers[0]
|
942
|
-
|
943
|
-
title_txt=
|
1035
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
1036
|
+
title_txt=tname+"财报分析:重要指标的同行业对比\n(截至"+fsdate+")"
|
944
1037
|
import datetime; today=datetime.date.today()
|
945
1038
|
if yiyuan_foot:
|
946
1039
|
footnote="*单位:亿元,数据来源:新浪财经,"+str(today)
|
@@ -961,7 +1054,7 @@ if __name__=='__main__':
|
|
961
1054
|
|
962
1055
|
dfp=fs_item_analysis_7(df,tickers,fsdate,items)
|
963
1056
|
|
964
|
-
def fs_item_analysis_7(df,tickers,fsdate,items,title_txt='',notes=''):
|
1057
|
+
def fs_item_analysis_7(df,tickers,fsdate,items,title_txt='',notes='',facecolor='papayawhip'):
|
965
1058
|
"""
|
966
1059
|
功能:比较给定财报日期fsdate的项目和指标,与同业相比
|
967
1060
|
"""
|
@@ -972,7 +1065,7 @@ def fs_item_analysis_7(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
972
1065
|
yiyuan_foot=False
|
973
1066
|
|
974
1067
|
for t in tickers:
|
975
|
-
tname=ticker_name(t).replace("(A股)",'')
|
1068
|
+
tname=ticker_name(t,'stock').replace("(A股)",'')
|
976
1069
|
row_list=[tname]
|
977
1070
|
for i in items:
|
978
1071
|
i_value,_,_=select_item(df,t,fsdate,i)
|
@@ -1009,8 +1102,8 @@ def fs_item_analysis_7(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
1009
1102
|
if title_txt=='':
|
1010
1103
|
title_txt="=== 重要指标的同行业对比 ==="
|
1011
1104
|
ticker=tickers[0]
|
1012
|
-
|
1013
|
-
title_txt=
|
1105
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
1106
|
+
title_txt=tname+"财报分析:重要指标的同行业对比\n(截至"+fsdate+")"
|
1014
1107
|
import datetime; today=datetime.date.today()
|
1015
1108
|
if yiyuan_foot:
|
1016
1109
|
#footnote="*单位:亿元,数据来源:新浪财经,"+str(today)
|
@@ -1024,7 +1117,7 @@ def fs_item_analysis_7(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
1024
1117
|
else:
|
1025
1118
|
foottext=notes+'\n'+footnote
|
1026
1119
|
|
1027
|
-
df_directprint(dfp,title_txt,foottext)
|
1120
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
1028
1121
|
|
1029
1122
|
return dfp
|
1030
1123
|
|
@@ -1039,7 +1132,7 @@ if __name__=='__main__':
|
|
1039
1132
|
items=['资产总计','资产负债率%','流动比率%','速动比率%']
|
1040
1133
|
dfp=fs_item_analysis_8(df,tickers,fsdate,items)
|
1041
1134
|
|
1042
|
-
def fs_item_analysis_8(df,tickers,fsdate,items,title_txt='',notes=''):
|
1135
|
+
def fs_item_analysis_8(df,tickers,fsdate,items,title_txt='',notes='',facecolor='papayawhip'):
|
1043
1136
|
"""
|
1044
1137
|
功能:比较给定财报日期fsdate的项目和指标,与同业相比
|
1045
1138
|
区别:项目不带‘(亿元)’字样,避免行过长
|
@@ -1052,7 +1145,7 @@ def fs_item_analysis_8(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
1052
1145
|
yiyuan_foot=False
|
1053
1146
|
|
1054
1147
|
for t in tickers:
|
1055
|
-
tname=ticker_name(t).replace("(A股)",'')
|
1148
|
+
tname=ticker_name(t,'stock').replace("(A股)",'')
|
1056
1149
|
row_list=[tname]
|
1057
1150
|
for i in items:
|
1058
1151
|
i_value,_,_=select_item(df,t,fsdate,i)
|
@@ -1088,8 +1181,8 @@ def fs_item_analysis_8(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
1088
1181
|
#无序号打印
|
1089
1182
|
if title_txt=='':
|
1090
1183
|
ticker=tickers[0]
|
1091
|
-
|
1092
|
-
title_txt=
|
1184
|
+
tname=ticker_name(ticker,'stock').replace("(A股)",'')
|
1185
|
+
title_txt=tname+"财报分析:重要指标的同行业对比\n(截至"+fsdate+")"
|
1093
1186
|
|
1094
1187
|
import datetime; today=datetime.date.today()
|
1095
1188
|
if yiyuan_foot:
|
@@ -1104,7 +1197,7 @@ def fs_item_analysis_8(df,tickers,fsdate,items,title_txt='',notes=''):
|
|
1104
1197
|
else:
|
1105
1198
|
foottext=notes+'\n'+footnote
|
1106
1199
|
|
1107
|
-
df_directprint(dfp,title_txt,foottext)
|
1200
|
+
df_directprint(dfp,title_txt,foottext,facecolor=facecolor)
|
1108
1201
|
|
1109
1202
|
return dfp
|
1110
1203
|
|
@@ -1114,16 +1207,16 @@ if __name__=='__main__':
|
|
1114
1207
|
fsdates=['2022-12-31','2021-12-31','2020-12-31','2019-12-31']
|
1115
1208
|
asset_liab_structure_china(tickers,fsdates)
|
1116
1209
|
|
1117
|
-
def asset_liab_china(tickers,fsdates):
|
1210
|
+
def asset_liab_china(tickers,fsdates,facecolor='papayawhip'):
|
1118
1211
|
"""
|
1119
1212
|
套壳函数asset_liab_structure_china
|
1120
1213
|
"""
|
1121
|
-
asset_liab_structure_china(tickers,fsdates)
|
1214
|
+
asset_liab_structure_china(tickers,fsdates,facecolor=facecolor)
|
1122
1215
|
|
1123
1216
|
return
|
1124
1217
|
|
1125
1218
|
|
1126
|
-
def asset_liab_structure_china(tickers,fsdates):
|
1219
|
+
def asset_liab_structure_china(tickers,fsdates,facecolor='papayawhip'):
|
1127
1220
|
"""
|
1128
1221
|
功能:分析上市公司的资产负债基本结构,并与同业公司对比。
|
1129
1222
|
注意1:分析近三期情况,fsdates要给出四个报表日期,以便获得期初数。
|
@@ -1156,11 +1249,11 @@ def asset_liab_structure_china(tickers,fsdates):
|
|
1156
1249
|
comparator=tickers[0]
|
1157
1250
|
comparee=tickers[1:]
|
1158
1251
|
print(" Conducting asset-liability analysis ...")
|
1159
|
-
print(" Comparator:",ticker_name(comparator))
|
1252
|
+
print(" Comparator:",ticker_name(comparator,'stock'))
|
1160
1253
|
#print(" Comparee :",ticker_name(comparee))
|
1161
1254
|
print(" Comparee :",end='')
|
1162
1255
|
if comparee != []:
|
1163
|
-
print_list(ticker_name(comparee))
|
1256
|
+
print_list(ticker_name(comparee,'stock'))
|
1164
1257
|
else:
|
1165
1258
|
print(" N/A")
|
1166
1259
|
|
@@ -1196,7 +1289,7 @@ def asset_liab_structure_china(tickers,fsdates):
|
|
1196
1289
|
print(" Solution: check ticker spelling and try at least 10 minutes later")
|
1197
1290
|
return
|
1198
1291
|
|
1199
|
-
title_head=ticker_name(comparator)+"资产负债分析:"
|
1292
|
+
title_head=ticker_name(comparator,'stock')+"资产负债分析:"
|
1200
1293
|
|
1201
1294
|
### 资产负债表的主要项目
|
1202
1295
|
#资产变动趋势2
|
@@ -1243,30 +1336,30 @@ def asset_liab_structure_china(tickers,fsdates):
|
|
1243
1336
|
#资产变动趋势1:"货币资金","应收票据","应收账款"
|
1244
1337
|
title_txt=title_head+"货币资金与应收项目"
|
1245
1338
|
items1=["货币资金","应收票据","应收账款"]
|
1246
|
-
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt)
|
1339
|
+
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt,facecolor=facecolor)
|
1247
1340
|
|
1248
1341
|
#应收账款占比变动分析
|
1249
1342
|
fsdates1=fsdates[:3]
|
1250
1343
|
items5=["应收账款","资产总计"]
|
1251
1344
|
title_txt=title_head+"应收账款占比变动情况"
|
1252
|
-
dfp5=fs_item_analysis_2(df,ticker,fsdates1,items5,title_txt)
|
1345
|
+
dfp5=fs_item_analysis_2(df,ticker,fsdates1,items5,title_txt,facecolor=facecolor)
|
1253
1346
|
|
1254
1347
|
#应收与营业收入增幅对比
|
1255
1348
|
fsdates2=fsdates[:2]
|
1256
1349
|
items6=['应收账款',"应收票据",'营业总收入']
|
1257
1350
|
title_txt=title_head+"应收项目与营业收入增幅对比"
|
1258
|
-
dfp6=fs_item_analysis_6(df,ticker,fsdates2,items6,title_txt)
|
1351
|
+
dfp6=fs_item_analysis_6(df,ticker,fsdates2,items6,title_txt,facecolor=facecolor)
|
1259
1352
|
|
1260
1353
|
#应收账款占比同行对比
|
1261
1354
|
items7=['应收账款','资产总计','应收账款占比%']
|
1262
1355
|
title_txt=title_head+"应收账款占比同行对比"
|
1263
|
-
dfp7=fs_item_analysis_7(df,tickers,fsdate,items7,title_txt)
|
1356
|
+
dfp7=fs_item_analysis_7(df,tickers,fsdate,items7,title_txt,facecolor=facecolor)
|
1264
1357
|
|
1265
1358
|
### 存货
|
1266
1359
|
#存货占比变动分析
|
1267
1360
|
items8=["存货","资产总计"]
|
1268
1361
|
title_txt=title_head+"存货占比变动情况"
|
1269
|
-
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items8,title_txt)
|
1362
|
+
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items8,title_txt,facecolor=facecolor)
|
1270
1363
|
"""
|
1271
1364
|
items9=["存货","营业总收入"]
|
1272
1365
|
dfp9=fs_item_analysis_6(df,ticker,fsdates2,items9)
|
@@ -1274,30 +1367,30 @@ def asset_liab_structure_china(tickers,fsdates):
|
|
1274
1367
|
#存货与营业收入增幅对比分析
|
1275
1368
|
items10=['存货','流动资产合计',"速动资产合计","资产总计"]
|
1276
1369
|
title_txt=title_head+"存货与资产项目增幅对比"
|
1277
|
-
dfp10=fs_item_analysis_6(df,ticker,fsdates2,items10,title_txt)
|
1370
|
+
dfp10=fs_item_analysis_6(df,ticker,fsdates2,items10,title_txt,facecolor=facecolor)
|
1278
1371
|
|
1279
1372
|
#存货占比与行业对比
|
1280
1373
|
items11=['存货','资产总计','存货占比%']
|
1281
1374
|
title_txt=title_head+"存货占比情况同行对比"
|
1282
|
-
dfp11=fs_item_analysis_7(df,tickers,fsdate,items11,title_txt)
|
1375
|
+
dfp11=fs_item_analysis_7(df,tickers,fsdate,items11,title_txt,facecolor=facecolor)
|
1283
1376
|
|
1284
1377
|
### 偿债能力
|
1285
1378
|
#流动比率变动分析
|
1286
1379
|
title_txt=title_head+"流动比率变动情况"
|
1287
|
-
dfp12=fs_item_analysis_3(df,ticker,fsdates1,title_txt)
|
1380
|
+
dfp12=fs_item_analysis_3(df,ticker,fsdates1,title_txt,facecolor=facecolor)
|
1288
1381
|
|
1289
1382
|
#速动比率变动分析
|
1290
1383
|
title_txt=title_head+"速动比率变动情况"
|
1291
|
-
dfp13=fs_item_analysis_4(df,ticker,fsdates1,title_txt)
|
1384
|
+
dfp13=fs_item_analysis_4(df,ticker,fsdates1,title_txt,facecolor=facecolor)
|
1292
1385
|
|
1293
1386
|
#资产负债率变动分析
|
1294
1387
|
title_txt=title_head+"资产负债率变动情况"
|
1295
|
-
dfp14=fs_item_analysis_5(df,ticker,fsdates1,title_txt)
|
1388
|
+
dfp14=fs_item_analysis_5(df,ticker,fsdates1,title_txt,facecolor=facecolor)
|
1296
1389
|
|
1297
1390
|
#资产负债率同行比较
|
1298
1391
|
title_txt=title_head+"资产负债率同行比较"
|
1299
1392
|
items15=['资产总计','资产负债率%','流动比率%','速动比率%']
|
1300
|
-
dfp15=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt)
|
1393
|
+
dfp15=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt,facecolor=facecolor)
|
1301
1394
|
|
1302
1395
|
return
|
1303
1396
|
|
@@ -1307,15 +1400,15 @@ if __name__=='__main__':
|
|
1307
1400
|
fsdates=['2021-12-31','2020-12-31','2019-12-31','2018-12-31']
|
1308
1401
|
income_cost_structure_china(tickers,fsdates)
|
1309
1402
|
|
1310
|
-
def income_cost_china(tickers,fsdates):
|
1403
|
+
def income_cost_china(tickers,fsdates,facecolor='papayawhip'):
|
1311
1404
|
"""
|
1312
1405
|
套壳函数income_cost_structure_china
|
1313
1406
|
"""
|
1314
|
-
income_cost_structure_china(tickers,fsdates)
|
1407
|
+
income_cost_structure_china(tickers,fsdates,facecolor=facecolor)
|
1315
1408
|
|
1316
1409
|
return
|
1317
1410
|
|
1318
|
-
def income_cost_structure_china(tickers,fsdates):
|
1411
|
+
def income_cost_structure_china(tickers,fsdates,facecolor='papayawhip'):
|
1319
1412
|
"""
|
1320
1413
|
功能:分析上市公司的收入成本基本结构,并与同业公司对比。
|
1321
1414
|
注意1:分析近三期情况,fsdates要给出四个报表日期,以便获得期初数。
|
@@ -1357,11 +1450,11 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1357
1450
|
comparator=tickers[0]
|
1358
1451
|
comparee=tickers[1:]
|
1359
1452
|
print(" Conducting income-cost analysis ...")
|
1360
|
-
print(" Comparator:",ticker_name(comparator))
|
1453
|
+
print(" Comparator:",ticker_name(comparator,'stock'))
|
1361
1454
|
#print(" Comparee :",ticker_name(comparee))
|
1362
1455
|
print(" Comparee :",end='')
|
1363
1456
|
if comparee != []:
|
1364
|
-
print_list(ticker_name(comparee))
|
1457
|
+
print_list(ticker_name(comparee,'stock'))
|
1365
1458
|
else:
|
1366
1459
|
print(" N/A")
|
1367
1460
|
|
@@ -1378,12 +1471,12 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1378
1471
|
#print(" Possible reasons: no access to data source or invalid tickers")
|
1379
1472
|
return
|
1380
1473
|
|
1381
|
-
title_head=ticker_name(comparator)+"收入成本分析:"
|
1474
|
+
title_head=ticker_name(comparator,'stock')+"收入成本分析:"
|
1382
1475
|
|
1383
1476
|
#收入成本总体变动趋势
|
1384
1477
|
title_txt=title_head+"主要项目及其变动趋势"
|
1385
1478
|
items1=["营业总收入","营业总成本","营业成本","毛利润","营业利润","营业外收支","税前利润","所得税费用","净利润","归母净利润"]
|
1386
|
-
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt)
|
1479
|
+
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt,facecolor=facecolor)
|
1387
1480
|
|
1388
1481
|
#成本变动趋势
|
1389
1482
|
title_txt=title_head+"主要成本费用及其变动趋势"
|
@@ -1396,7 +1489,7 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1396
1489
|
items2=["营业总成本","营业成本","营业税金及附加","销售费用","管理费用","研发费用",
|
1397
1490
|
"应付利息","非流动资产处置损失",
|
1398
1491
|
"资产减值损失","营业外支出"]
|
1399
|
-
dfp2=fs_item_analysis_1(df,ticker,'2021-12-31',items2,title_txt)
|
1492
|
+
dfp2=fs_item_analysis_1(df,ticker,'2021-12-31',items2,title_txt,facecolor=facecolor)
|
1400
1493
|
|
1401
1494
|
#占比变动分析:近三年
|
1402
1495
|
title_txt=title_head+"营业总成本占营业总收入比例情况"
|
@@ -1407,7 +1500,7 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1407
1500
|
notes2="注2:营业收入=主营业务收入和其他非主营业务收入"
|
1408
1501
|
notes3="注3:营业总收入=营业收入+非营业收入(投资收益、营业外收入等)"
|
1409
1502
|
notes=notes1+'\n'+notes2+'\n'+notes3
|
1410
|
-
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items3,title_txt,notes)
|
1503
|
+
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items3,title_txt,notes,facecolor=facecolor)
|
1411
1504
|
#====================================================================
|
1412
1505
|
title_txt=title_head+"营业成本占营业总成本比例情况"
|
1413
1506
|
items4=["营业成本","营业总成本"]
|
@@ -1415,29 +1508,29 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1415
1508
|
notes1="注1:营业成本是经营活动中发生的可归属于产品/劳务成本等的费用"
|
1416
1509
|
notes2="注2:营业总成本包括营业成本、营业税金及附加、三大费用和资产减值损失"
|
1417
1510
|
notes=notes1+'\n'+notes2
|
1418
|
-
dfp4=fs_item_analysis_2(df,ticker,fsdates1,items4,title_txt,notes)
|
1511
|
+
dfp4=fs_item_analysis_2(df,ticker,fsdates1,items4,title_txt,notes,facecolor=facecolor)
|
1419
1512
|
|
1420
1513
|
title_txt=title_head+"营业成本占营业总收入比例情况"
|
1421
1514
|
items5=["营业成本","营业总收入"]
|
1422
|
-
dfp5=fs_item_analysis_2(df,ticker,fsdates1,items5,title_txt)
|
1515
|
+
dfp5=fs_item_analysis_2(df,ticker,fsdates1,items5,title_txt,facecolor=facecolor)
|
1423
1516
|
|
1424
1517
|
title_txt=title_head+"营业成本增幅分析"
|
1425
1518
|
fsdates2=fsdates[:2]
|
1426
1519
|
items12=['营业成本','营业总成本','营业总收入']
|
1427
|
-
dfp12=fs_item_analysis_6(df,ticker,fsdates2,items12,title_txt)
|
1520
|
+
dfp12=fs_item_analysis_6(df,ticker,fsdates2,items12,title_txt,facecolor=facecolor)
|
1428
1521
|
|
1429
1522
|
#====================================================================
|
1430
1523
|
title_txt=title_head+"销售费用占营业总收入比例情况"
|
1431
1524
|
items6=["销售费用","营业总收入"]
|
1432
1525
|
|
1433
1526
|
notes="注:销售费用是企业销售过程中发生的各种费用"
|
1434
|
-
dfp6=fs_item_analysis_2(df,ticker,fsdates1,items6,title_txt,notes)
|
1527
|
+
dfp6=fs_item_analysis_2(df,ticker,fsdates1,items6,title_txt,notes,facecolor=facecolor)
|
1435
1528
|
#====================================================================
|
1436
1529
|
title_txt=title_head+"管理费用占营业总收入比例情况"
|
1437
1530
|
items7=["管理费用","营业总收入"]
|
1438
1531
|
|
1439
1532
|
notes="注:管理费用是行政管理部门为组织生产/经营活动发生的各种费用"
|
1440
|
-
dfp7=fs_item_analysis_2(df,ticker,fsdates1,items7,title_txt,notes)
|
1533
|
+
dfp7=fs_item_analysis_2(df,ticker,fsdates1,items7,title_txt,notes,facecolor=facecolor)
|
1441
1534
|
|
1442
1535
|
title_txt=title_head+"三项费用率同行对比"
|
1443
1536
|
items14=['营业总收入','销售费用率%','管理费用率%','研发费用率%']
|
@@ -1447,35 +1540,35 @@ def income_cost_structure_china(tickers,fsdates):
|
|
1447
1540
|
notes3="注3:研发费用率 = 研发费用 / 营业总收入"
|
1448
1541
|
notes=notes1+'\n'+notes2+'\n'+notes3
|
1449
1542
|
|
1450
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items14,title_txt,notes)
|
1543
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items14,title_txt,notes,facecolor=facecolor)
|
1451
1544
|
#====================================================================
|
1452
1545
|
title_txt=title_head+"毛利润占营业总收入比例情况"
|
1453
1546
|
items8=["毛利润","营业总收入"]
|
1454
|
-
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items8,title_txt)
|
1547
|
+
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items8,title_txt,facecolor=facecolor)
|
1455
1548
|
#====================================================================
|
1456
1549
|
title_txt=title_head+"营业利润占营业总收入比例情况"
|
1457
1550
|
items9=["营业利润","营业总收入"]
|
1458
|
-
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items9,title_txt)
|
1551
|
+
dfp8=fs_item_analysis_2(df,ticker,fsdates1,items9,title_txt,facecolor=facecolor)
|
1459
1552
|
#====================================================================
|
1460
1553
|
title_txt=title_head+"税前利润占营业总收入比例情况"
|
1461
1554
|
items10=["税前利润","营业总收入"]
|
1462
|
-
dfp9=fs_item_analysis_2(df,ticker,fsdates1,items10,title_txt)
|
1555
|
+
dfp9=fs_item_analysis_2(df,ticker,fsdates1,items10,title_txt,facecolor=facecolor)
|
1463
1556
|
#====================================================================
|
1464
1557
|
title_txt=title_head+"净利润占营业总收入比例情况"
|
1465
1558
|
items11=["净利润","营业总收入"]
|
1466
|
-
dfp9=fs_item_analysis_2(df,ticker,fsdates1,items11,title_txt)
|
1559
|
+
dfp9=fs_item_analysis_2(df,ticker,fsdates1,items11,title_txt,facecolor=facecolor)
|
1467
1560
|
|
1468
1561
|
#增幅分析:近两年
|
1469
1562
|
title_txt=title_head+"四种利润对比"
|
1470
1563
|
items13=['毛利润','营业利润','税前利润','净利润']
|
1471
|
-
dfp11=fs_item_analysis_6(df,ticker,fsdates2,items13,title_txt)
|
1564
|
+
dfp11=fs_item_analysis_6(df,ticker,fsdates2,items13,title_txt,facecolor=facecolor)
|
1472
1565
|
|
1473
1566
|
#同行比较
|
1474
1567
|
title_txt=title_head+"利润率同行对比"
|
1475
1568
|
#items15=['营业利润','营业利润率%','税前利润率%','实际所得税率%','净利润','净利润率%']
|
1476
1569
|
#items15=['毛利润率%','营业利润率%','税前利润率%','净利润率%']
|
1477
1570
|
items15=['净利润率%','税前利润率%','营业利润率%','毛利润率%']
|
1478
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt)
|
1571
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt,facecolor=facecolor)
|
1479
1572
|
|
1480
1573
|
return
|
1481
1574
|
|
@@ -1485,16 +1578,16 @@ if __name__=='__main__':
|
|
1485
1578
|
fsdates=['2021-12-31','2020-12-31','2019-12-31','2018-12-31']
|
1486
1579
|
cash_flow_structure_china(tickers,fsdates)
|
1487
1580
|
|
1488
|
-
def cash_flow_china(tickers,fsdates):
|
1581
|
+
def cash_flow_china(tickers,fsdates,facecolor='papayawhip'):
|
1489
1582
|
"""
|
1490
1583
|
套壳函数cash_flow_structure_china
|
1491
1584
|
"""
|
1492
|
-
cash_flow_structure_china(tickers,fsdates)
|
1585
|
+
cash_flow_structure_china(tickers,fsdates,facecolor=facecolor)
|
1493
1586
|
|
1494
1587
|
return
|
1495
1588
|
|
1496
1589
|
|
1497
|
-
def cash_flow_structure_china(tickers,fsdates):
|
1590
|
+
def cash_flow_structure_china(tickers,fsdates,facecolor='papayawhip'):
|
1498
1591
|
"""
|
1499
1592
|
功能:分析上市公司的现金流量基本结构,并与同业公司对比。
|
1500
1593
|
注意1:分析近三期情况,fsdates要给出四个报表日期,以便获得期初数。
|
@@ -1535,10 +1628,10 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1535
1628
|
comparator=tickers[0]
|
1536
1629
|
comparee=tickers[1:]
|
1537
1630
|
print(" Conducting cash flow analysis ...")
|
1538
|
-
print(" Comparator:",ticker_name(comparator))
|
1631
|
+
print(" Comparator:",ticker_name(comparator,'stock'))
|
1539
1632
|
print(" Comparee :",end='')
|
1540
1633
|
if comparee != []:
|
1541
|
-
print_list(ticker_name(comparee))
|
1634
|
+
print_list(ticker_name(comparee,'stock'))
|
1542
1635
|
else:
|
1543
1636
|
print(" N/A")
|
1544
1637
|
|
@@ -1555,7 +1648,7 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1555
1648
|
#print(" Possible reasons: no access to data source or invalid tickers")
|
1556
1649
|
return
|
1557
1650
|
|
1558
|
-
title_head=ticker_name(comparator)+"现金流分析:"
|
1651
|
+
title_head=ticker_name(comparator,'stock')+"现金流分析:"
|
1559
1652
|
|
1560
1653
|
#总体变动趋势
|
1561
1654
|
title_txt=title_head+"主要项目及其变动趋势"
|
@@ -1563,23 +1656,23 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1563
1656
|
"投资活动现金流净额","投资活动现金流入","投资活动现金流出",
|
1564
1657
|
"筹资活动现金流净额","筹资活动现金流入","筹资活动现金流出",
|
1565
1658
|
"汇率对现金流的影响","现金流量净增加额"]
|
1566
|
-
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt)
|
1659
|
+
dfp1=fs_item_analysis_1(df,ticker,fsdate,items1,title_txt,facecolor=facecolor)
|
1567
1660
|
|
1568
1661
|
#占比变动分析:近三年
|
1569
1662
|
title_txt=title_head+"经营活动现金流入占比情况"
|
1570
1663
|
fsdates1=fsdates[:3]
|
1571
1664
|
items3=["经营活动现金流入","营业总收入"]
|
1572
|
-
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items3,title_txt)
|
1665
|
+
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items3,title_txt,facecolor=facecolor)
|
1573
1666
|
|
1574
1667
|
title_txt=title_head+"经营活动现金流净额占比情况"
|
1575
1668
|
items4=["经营活动现金流净额","营业利润"]
|
1576
|
-
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items4,title_txt)
|
1669
|
+
dfp3=fs_item_analysis_2(df,ticker,fsdates1,items4,title_txt,facecolor=facecolor)
|
1577
1670
|
|
1578
1671
|
#增幅分析:近两年
|
1579
1672
|
title_txt=title_head+"经营活动现金流增幅情况"
|
1580
1673
|
fsdates2=fsdates[:2]
|
1581
1674
|
items12=['经营活动现金流入','经营活动现金流出','经营活动现金流净额']
|
1582
|
-
dfp12=fs_item_analysis_6(df,ticker,fsdates2,items12,title_txt)
|
1675
|
+
dfp12=fs_item_analysis_6(df,ticker,fsdates2,items12,title_txt,facecolor=facecolor)
|
1583
1676
|
|
1584
1677
|
#同行比较
|
1585
1678
|
title_txt=title_head+"现金收入能力同行比较"
|
@@ -1589,7 +1682,7 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1589
1682
|
notes2="注2:现金购销比率 = 经营活动现金流出 / 经营活动现金流入"
|
1590
1683
|
notes3="注3:营业现金回笼率 = 经营活动现金流入 / 营业总收入"
|
1591
1684
|
notes=notes1+'\n'+notes2+'\n'+notes3
|
1592
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items16,title_txt,notes)
|
1685
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items16,title_txt,notes,facecolor=facecolor)
|
1593
1686
|
|
1594
1687
|
title_txt=title_head+"现金偿债能力同行比较"
|
1595
1688
|
items14=['短期现金偿债能力%','长期现金偿债能力%']
|
@@ -1597,7 +1690,7 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1597
1690
|
notes1="注1:短期现金偿债能力 = 经营活动现金流净额 / 流动负债合计"
|
1598
1691
|
notes2="注2:长期现金偿债能力 = 经营活动现金流净额 / 负债合计"
|
1599
1692
|
notes=notes1+'\n'+notes2
|
1600
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items14,title_txt,notes)
|
1693
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items14,title_txt,notes,facecolor=facecolor)
|
1601
1694
|
|
1602
1695
|
title_txt=title_head+"现金支付能力同行比较"
|
1603
1696
|
items15=['现金支付股利能力(元)','现金综合支付能力%','支付给职工的现金比率%']
|
@@ -1606,7 +1699,7 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1606
1699
|
notes2="注2:现金综合支付能力 = 经营活动现金流净额 / 所有者权益合计"
|
1607
1700
|
notes3="注3:支付给职工的现金比率 = 支付给(为)职工支付的现金 / 经营活动现金流入"
|
1608
1701
|
notes=notes1+'\n'+notes2+'\n'+notes3
|
1609
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt,notes)
|
1702
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items15,title_txt,notes,facecolor=facecolor)
|
1610
1703
|
|
1611
1704
|
title_txt=title_head+"财务指标含金量同行比较"
|
1612
1705
|
items17=['盈利现金比率%','现金流入流出比率%','资产现金回收率%']
|
@@ -1615,7 +1708,7 @@ def cash_flow_structure_china(tickers,fsdates):
|
|
1615
1708
|
notes2="注2:现金流入流出比率 = 经营活动现金流入 / 经营活动现金流出"
|
1616
1709
|
notes3="注3:资产现金回收率 = 经营活动现金流净额 / 资产总计"
|
1617
1710
|
notes=notes1+'\n'+notes2+'\n'+notes3
|
1618
|
-
dfp12=fs_item_analysis_8(df,tickers,fsdate,items17,title_txt,notes)
|
1711
|
+
dfp12=fs_item_analysis_8(df,tickers,fsdate,items17,title_txt,notes,facecolor=facecolor)
|
1619
1712
|
|
1620
1713
|
return
|
1621
1714
|
|
@@ -1674,7 +1767,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1674
1767
|
category='profile',business_period='recent', \
|
1675
1768
|
printout=False,gview=False, \
|
1676
1769
|
loc1='upper left',loc2='upper right', \
|
1677
|
-
):
|
1770
|
+
facecolor='papayawhip'):
|
1678
1771
|
"""
|
1679
1772
|
套壳函数1:tickers为股票列表,fsdates为财报日期,可为单个日期或日期列表
|
1680
1773
|
asset_liab_china, income_cost_china, cash_flow_china
|
@@ -1704,7 +1797,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1704
1797
|
fsdates=gen_yoy_dates(fsdates,num=4)
|
1705
1798
|
|
1706
1799
|
# 分析资产负债表
|
1707
|
-
asset_liab_china(tickers,fsdates)
|
1800
|
+
asset_liab_china(tickers,fsdates,facecolor=facecolor)
|
1708
1801
|
return
|
1709
1802
|
|
1710
1803
|
elif ('income' in analysis_type1) or ('cost' in analysis_type1) \
|
@@ -1717,7 +1810,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1717
1810
|
fsdates=gen_yoy_dates(fsdates,num=4)
|
1718
1811
|
|
1719
1812
|
# 分析利润表
|
1720
|
-
income_cost_china(tickers,fsdates)
|
1813
|
+
income_cost_china(tickers,fsdates,facecolor=facecolor)
|
1721
1814
|
return
|
1722
1815
|
|
1723
1816
|
elif ('cash' in analysis_type1) or ('flow' in analysis_type1):
|
@@ -1729,7 +1822,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1729
1822
|
fsdates=gen_yoy_dates(fsdates,num=4)
|
1730
1823
|
|
1731
1824
|
# 分析现金流量表
|
1732
|
-
cash_flow_china(tickers,fsdates)
|
1825
|
+
cash_flow_china(tickers,fsdates,facecolor=facecolor)
|
1733
1826
|
return
|
1734
1827
|
|
1735
1828
|
elif ('summary' in analysis_type1):
|
@@ -1754,7 +1847,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1754
1847
|
|
1755
1848
|
# 分析财报摘要
|
1756
1849
|
from siat.financials_china import compare_fin_summary_china
|
1757
|
-
df_summary=compare_fin_summary_china(tickers,fsdates)
|
1850
|
+
df_summary=compare_fin_summary_china(tickers,fsdates,facecolor=facecolor)
|
1758
1851
|
return
|
1759
1852
|
|
1760
1853
|
elif ('indicator' in analysis_type1):
|
@@ -1779,7 +1872,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1779
1872
|
|
1780
1873
|
# 分析主要财务指标和比率
|
1781
1874
|
from siat.financials_china import compare_fin_indicator_china
|
1782
|
-
df_ind=compare_fin_indicator_china(tickers,fsdates)
|
1875
|
+
df_ind=compare_fin_indicator_china(tickers,fsdates,facecolor=facecolor)
|
1783
1876
|
return
|
1784
1877
|
|
1785
1878
|
elif ('profile' in analysis_type1):
|
@@ -1789,7 +1882,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1789
1882
|
return
|
1790
1883
|
|
1791
1884
|
# 分析单只股票的全方位概况
|
1792
|
-
stock_profile_china(tickers,category,business_period,loc1=loc1,loc2=loc2)
|
1885
|
+
stock_profile_china(tickers,category,business_period,loc1=loc1,loc2=loc2,facecolor=facecolor)
|
1793
1886
|
return
|
1794
1887
|
|
1795
1888
|
elif ('dupont' in analysis_type1) and (('identity' in analysis_type1) or ('analysis' in analysis_type1)):
|
@@ -1807,7 +1900,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1807
1900
|
|
1808
1901
|
# 多只股票的杜邦分析对比
|
1809
1902
|
from siat.financials_china import compare_dupont_china
|
1810
|
-
df_db=compare_dupont_china(tickers,fsdate=fsdates,printout=printout)
|
1903
|
+
df_db=compare_dupont_china(tickers,fsdate=fsdates,printout=printout,facecolor=facecolor)
|
1811
1904
|
return
|
1812
1905
|
|
1813
1906
|
elif ('dupont' in analysis_type1) and ('decompose' in analysis_type1):
|
@@ -1825,7 +1918,7 @@ def fs_analysis_china(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1825
1918
|
|
1826
1919
|
# 单只股票的多层杜邦分解
|
1827
1920
|
from siat.financials_china import dupont_decompose_china
|
1828
|
-
df_dbd=dupont_decompose_china(ticker=tickers,fsdate=fsdates,gview=gview)
|
1921
|
+
df_dbd=dupont_decompose_china(ticker=tickers,fsdate=fsdates,gview=gview,facecolor=facecolor)
|
1829
1922
|
return
|
1830
1923
|
|
1831
1924
|
else:
|