siat 3.0.30__py3-none-any.whl → 3.0.38__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 +11 -6
- siat/financials2.py +105 -66
- siat/financials_china.py +150 -124
- siat/financials_china2.py +296 -127
- siat/sector_china.py +1 -1
- siat/stock_china.py +35 -13
- {siat-3.0.30.dist-info → siat-3.0.38.dist-info}/METADATA +1 -1
- {siat-3.0.30.dist-info → siat-3.0.38.dist-info}/RECORD +10 -10
- {siat-3.0.30.dist-info → siat-3.0.38.dist-info}/WHEEL +0 -0
- {siat-3.0.30.dist-info → siat-3.0.38.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -1704,7 +1704,7 @@ if __name__ == '__main__':
|
|
1704
1704
|
'26', '27', '28']
|
1705
1705
|
printInLine_md(aList,numberPerLine=8,colalign='center')
|
1706
1706
|
|
1707
|
-
def printInLine_md(aList,numberPerLine=5,colalign='left'):
|
1707
|
+
def printInLine_md(aList,numberPerLine=5,colalign='left',font_size='16px'):
|
1708
1708
|
"""
|
1709
1709
|
功能:将一个长列表等行分组打印,使用df.to_markdown方式打印,实现自动对齐
|
1710
1710
|
aList:用于打印的数据列表
|
@@ -1739,11 +1739,16 @@ def printInLine_md(aList,numberPerLine=5,colalign='left'):
|
|
1739
1739
|
alignlist=[colalign]*numberPerLine
|
1740
1740
|
print(df.to_markdown(index=False,tablefmt='plain',colalign=alignlist))
|
1741
1741
|
"""
|
1742
|
+
|
1743
|
+
#确定表格字体大小
|
1744
|
+
titile_font_size=font_size
|
1745
|
+
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
|
1746
|
+
|
1742
1747
|
df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2, \
|
1743
1748
|
first_col_align='left',second_col_align='left', \
|
1744
1749
|
last_col_align='left',other_col_align='left', \
|
1745
|
-
titile_font_size=
|
1746
|
-
data_font_size=
|
1750
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
1751
|
+
data_font_size=data_font_size)
|
1747
1752
|
|
1748
1753
|
return
|
1749
1754
|
|
@@ -3695,8 +3700,8 @@ if __name__=='__main__':
|
|
3695
3700
|
def df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2, \
|
3696
3701
|
first_col_align='left',second_col_align='right', \
|
3697
3702
|
last_col_align='right',other_col_align='right', \
|
3698
|
-
titile_font_size='
|
3699
|
-
data_font_size='
|
3703
|
+
titile_font_size='16px',heading_font_size='15px', \
|
3704
|
+
data_font_size='15px'):
|
3700
3705
|
"""
|
3701
3706
|
功能:采样CSS式样显示df,适用于Jupyter环境,整齐紧凑,不挑浏览器
|
3702
3707
|
注意:若facecolor不被支持,则自动改为papayawhip
|
@@ -3769,7 +3774,7 @@ if __name__=='__main__':
|
|
3769
3774
|
upgrade_siat()
|
3770
3775
|
|
3771
3776
|
def upgrade_siat(module_list=['siat','akshare','pandas','pandas_datareader', \
|
3772
|
-
'yfinance','yahooquery','urllib3','twine','mplfinance'], \
|
3777
|
+
'yfinance','yahooquery','urllib3','tabulate','twine','mplfinance'], \
|
3773
3778
|
pipcmd="pip install --upgrade"):
|
3774
3779
|
"""
|
3775
3780
|
功能:一次性升级siat及其相关插件
|
siat/financials2.py
CHANGED
@@ -93,7 +93,7 @@ if __name__=='__main__':
|
|
93
93
|
def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
94
94
|
category='profile',business_period='annual', \
|
95
95
|
scale1=10,scale2=10,sort='PM',
|
96
|
-
printout=True,
|
96
|
+
printout=True,facecolor='papayawhip',font_size='16px'
|
97
97
|
):
|
98
98
|
"""
|
99
99
|
功能:tickers为股票列表,fsdates为财报日期,可为单个日期或日期列表
|
@@ -128,6 +128,10 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
128
128
|
million=1000000
|
129
129
|
billion=million * 1000
|
130
130
|
|
131
|
+
#确定表格字体大小
|
132
|
+
titile_font_size=font_size
|
133
|
+
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-1)+'px'
|
134
|
+
|
131
135
|
# 基于analysis_type1的类型分别处理
|
132
136
|
if ('profile' in analysis_type1):
|
133
137
|
# 股票需为单只股票,若为列表则仅取第一个
|
@@ -210,8 +214,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
210
214
|
|
211
215
|
fsdf4.replace(0,'---',inplace=True)
|
212
216
|
|
213
|
-
titletxt="\n***** "+ticker_name(tickers)+": BALANCE SHEET"+' *****\n'
|
214
|
-
|
217
|
+
#titletxt="\n***** "+ticker_name(tickers)+": BALANCE SHEET"+' *****\n'
|
218
|
+
titletxt=ticker_name(tickers,'stock')+": BALANCE SHEET"
|
219
|
+
#print(titletxt)
|
215
220
|
"""
|
216
221
|
tablefmt_list=["plain","simple","github","grid","simple_grid","rounded_grid", \
|
217
222
|
"heavy_grid","mixed_grid","double_grid","fancy_grid","outline", \
|
@@ -239,13 +244,18 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
239
244
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
240
245
|
|
241
246
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType'],ascending=True)
|
242
|
-
|
247
|
+
"""
|
243
248
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
244
249
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
250
|
+
"""
|
245
251
|
|
246
|
-
footnote1="
|
247
|
-
footnote2="
|
248
|
-
|
252
|
+
footnote1="Amount unit: "+currency+" billion, exchange's local accounting standards"
|
253
|
+
footnote2="Data source: Yahoo Finance, "+str(todaydt)
|
254
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2
|
255
|
+
#print('\n',footnote1,'\n',footnote2)
|
256
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
257
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
258
|
+
data_font_size=data_font_size)
|
249
259
|
|
250
260
|
return fsdf6
|
251
261
|
|
@@ -307,8 +317,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
307
317
|
|
308
318
|
fsdf4.replace(0,'---',inplace=True)
|
309
319
|
|
310
|
-
titletxt="\n***** "+ticker_name(tickers)+": INCOME STATEMENTS"+' *****\n'
|
311
|
-
|
320
|
+
#titletxt="\n***** "+ticker_name(tickers)+": INCOME STATEMENTS"+' *****\n'
|
321
|
+
titletxt=ticker_name(tickers,'stock')+": INCOME STATEMENTS"
|
322
|
+
#print(titletxt)
|
312
323
|
|
313
324
|
collist=list(fsdf4)
|
314
325
|
fsdf4['Item']=fsdf4.index
|
@@ -316,13 +327,17 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
316
327
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
317
328
|
|
318
329
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType'],ascending=True)
|
319
|
-
|
330
|
+
"""
|
320
331
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
321
332
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
322
|
-
|
323
|
-
footnote1="
|
324
|
-
footnote2="
|
325
|
-
|
333
|
+
"""
|
334
|
+
footnote1="Amount unit: "+currency+" billion, exchange's local accounting standards"
|
335
|
+
footnote2="Data source: Yahoo Finance, "+str(todaydt)
|
336
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2
|
337
|
+
#print('\n',footnote1,'\n',footnote2)
|
338
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
339
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
340
|
+
data_font_size=data_font_size)
|
326
341
|
|
327
342
|
return fsdf6
|
328
343
|
|
@@ -382,8 +397,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
382
397
|
|
383
398
|
fsdf4.replace(0,'---',inplace=True)
|
384
399
|
|
385
|
-
titletxt="\n***** "+ticker_name(tickers)+": CASHFLOW STATEMENTS"+' *****\n'
|
386
|
-
|
400
|
+
#titletxt="\n***** "+ticker_name(tickers)+": CASHFLOW STATEMENTS"+' *****\n'
|
401
|
+
titletxt=ticker_name(tickers,'stock')+": CASHFLOW STATEMENTS"
|
402
|
+
#print(titletxt)
|
387
403
|
|
388
404
|
collist=list(fsdf4)
|
389
405
|
fsdf4['Item']=fsdf4.index
|
@@ -391,14 +407,17 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
391
407
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
392
408
|
|
393
409
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType'],ascending=True)
|
394
|
-
|
410
|
+
"""
|
395
411
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
396
412
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
397
|
-
|
398
|
-
footnote1="
|
399
|
-
footnote2="
|
400
|
-
|
401
|
-
|
413
|
+
"""
|
414
|
+
footnote1="Amount unit: "+currency+" billion, exchange's local accounting standards"
|
415
|
+
footnote2="Data source: Yahoo Finance, "+str(todaydt)
|
416
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2
|
417
|
+
#print('\n',footnote1,'\n',footnote2)
|
418
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
419
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
420
|
+
data_font_size=data_font_size)
|
402
421
|
return fsdf6
|
403
422
|
|
404
423
|
return fsdf2
|
@@ -488,8 +507,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
488
507
|
|
489
508
|
fsdf4.replace(0,'---',inplace=True)
|
490
509
|
|
491
|
-
titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL STATEMENT SUMMARY"+' *****\n'
|
492
|
-
|
510
|
+
#titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL STATEMENT SUMMARY"+' *****\n'
|
511
|
+
titletxt=ticker_name(tickers,'stock')+": FINANCIAL STATEMENT SUMMARY"
|
512
|
+
#print(titletxt)
|
493
513
|
|
494
514
|
collist=list(fsdf4)
|
495
515
|
fsdf4['Item']=fsdf4.index
|
@@ -497,15 +517,18 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
497
517
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
498
518
|
|
499
519
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType'],ascending=True)
|
500
|
-
|
520
|
+
"""
|
501
521
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
502
522
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
503
|
-
|
504
|
-
footnote1="
|
505
|
-
footnote2="
|
506
|
-
footnote3="
|
507
|
-
|
508
|
-
|
523
|
+
"""
|
524
|
+
footnote1="Amount unit: "+currency+" billion, exchange's local accounting standards"
|
525
|
+
footnote2="ROx/EM/turnover rates are based on periodic mean, others on end-term"
|
526
|
+
footnote3="Data source: Yahoo Finance, "+todaydt
|
527
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2+'\n'+footnote3
|
528
|
+
#print('\n',footnote1,'\n',footnote2,'\n',footnote3)
|
529
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
530
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
531
|
+
data_font_size=data_font_size)
|
509
532
|
return fsdf6
|
510
533
|
|
511
534
|
return fsdf2
|
@@ -586,8 +609,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
586
609
|
|
587
610
|
fsdf4.replace(0,'---',inplace=True)
|
588
611
|
|
589
|
-
titletxt="\n***** PEER COMPARISON OF FINANCIAL STATEMENT SUMMARY *****\n"
|
590
|
-
|
612
|
+
#titletxt="\n***** PEER COMPARISON OF FINANCIAL STATEMENT SUMMARY *****\n"
|
613
|
+
titletxt="FINANCIAL STATEMENT SUMMARY: PEER COMPARISON"
|
614
|
+
#print(titletxt)
|
591
615
|
|
592
616
|
collist=list(fsdf4)
|
593
617
|
fsdf4['Item']=fsdf4.index
|
@@ -595,15 +619,18 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
595
619
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
596
620
|
|
597
621
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType','reportDate','currencyCode'],ascending=True)
|
598
|
-
|
622
|
+
"""
|
599
623
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
600
624
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
601
|
-
|
602
|
-
footnote1="
|
603
|
-
footnote2="
|
604
|
-
footnote3="
|
605
|
-
|
606
|
-
|
625
|
+
"""
|
626
|
+
footnote1="Amount unit: billion, based on exchange's local accounting standards"
|
627
|
+
footnote2="ROx/EM/turnover rates are based on periodic mean, others on end-term"
|
628
|
+
footnote3="Data source: Yahoo Finance, "+str(todaydt)
|
629
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2+'\n'+footnote3
|
630
|
+
#print('\n',footnote1,'\n',footnote2,'\n',footnote3)
|
631
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
632
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
633
|
+
data_font_size=data_font_size)
|
607
634
|
return fsdf6
|
608
635
|
|
609
636
|
return fsdf2
|
@@ -691,8 +718,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
691
718
|
|
692
719
|
fsdf4.replace(0,'---',inplace=True)
|
693
720
|
|
694
|
-
titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL INDICATORS"+' *****\n'
|
695
|
-
|
721
|
+
#titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL INDICATORS"+' *****\n'
|
722
|
+
titletxt=ticker_name(tickers,'stock')+": FINANCIAL INDICATORS"
|
723
|
+
#print(titletxt)
|
696
724
|
|
697
725
|
collist=list(fsdf4)
|
698
726
|
fsdf4['Item']=fsdf4.index
|
@@ -700,15 +728,18 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
700
728
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
701
729
|
|
702
730
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType'],ascending=True)
|
703
|
-
|
731
|
+
"""
|
704
732
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
705
733
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
706
|
-
|
707
|
-
footnote1="
|
708
|
-
footnote2="
|
709
|
-
footnote3="
|
710
|
-
|
711
|
-
|
734
|
+
"""
|
735
|
+
footnote1="Amount unit: "+currency+" billion, exchange's local accounting standards"
|
736
|
+
footnote2="ROx/EM/turnover rates are based on periodic mean, others on end-term"
|
737
|
+
footnote3="Data source: Yahoo Finance, "+str(todaydt)
|
738
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2+'\n'+footnote3
|
739
|
+
#print('\n',footnote1,'\n',footnote2,'\n',footnote3)
|
740
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
741
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
742
|
+
data_font_size=data_font_size)
|
712
743
|
return fsdf6
|
713
744
|
|
714
745
|
return fsdf2
|
@@ -790,8 +821,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
790
821
|
|
791
822
|
fsdf4.replace(0,'---',inplace=True)
|
792
823
|
|
793
|
-
titletxt="\n***** PEER COMPARISON OF FINANCIAL INDICATORS *****\n"
|
794
|
-
|
824
|
+
#titletxt="\n***** PEER COMPARISON OF FINANCIAL INDICATORS *****\n"
|
825
|
+
titletxt="FINANCIAL INDICATORS: PEER COMPARISON"
|
826
|
+
#print(titletxt)
|
795
827
|
|
796
828
|
collist=list(fsdf4)
|
797
829
|
fsdf4['Item']=fsdf4.index
|
@@ -799,15 +831,18 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
799
831
|
fsdf6=df_filter_row(fsdf5,exclude_collist=['Item'],symbol='---')
|
800
832
|
|
801
833
|
fsdf6=df_sort_priority_list(fsdf6,sort_column='Item',priorityList=['periodType','reportDate','currencyCode'],ascending=True)
|
802
|
-
|
834
|
+
"""
|
803
835
|
alignlist=['left']+['right']*(len(list(fsdf5))-1)
|
804
836
|
print(fsdf6.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
805
|
-
|
806
|
-
footnote1="
|
807
|
-
footnote2="
|
808
|
-
footnote3="
|
809
|
-
|
810
|
-
|
837
|
+
"""
|
838
|
+
footnote1="Amount unit: billion, based on exchange's local accounting standards"
|
839
|
+
footnote2="ROx/EM/turnover rates are based on periodic mean, others on end-term"
|
840
|
+
footnote3="Data source: Yahoo Finance, "+str(todaydt)
|
841
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2+'\n'+footnote3
|
842
|
+
#print('\n',footnote1,'\n',footnote2,'\n',footnote3)
|
843
|
+
df_display_CSS(fsdf6,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
844
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
845
|
+
data_font_size=data_font_size)
|
811
846
|
return fsdf6
|
812
847
|
|
813
848
|
return fsdf2
|
@@ -914,8 +949,9 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
914
949
|
plt.show()
|
915
950
|
|
916
951
|
if printout:
|
917
|
-
title_txt="\n***** Dupont Identity Fact Sheet *****\n"
|
918
|
-
|
952
|
+
#title_txt="\n***** Dupont Identity Fact Sheet *****\n"
|
953
|
+
titletxt="Dupont Identity Fact Sheet"
|
954
|
+
#print(titletxt)
|
919
955
|
|
920
956
|
# 保留四位小数
|
921
957
|
collist=list(df)
|
@@ -927,14 +963,17 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
927
963
|
|
928
964
|
for d in list(df):
|
929
965
|
df[d]=df[d].apply(lambda x: round(x,5) if isinstance(x,float) else x)
|
930
|
-
|
966
|
+
"""
|
931
967
|
alignlist=['left']+['right']*(len(list(df))-1)
|
932
968
|
print(df.to_markdown(tablefmt='plain',index=False,colalign=alignlist))
|
933
|
-
|
934
|
-
footnote1="
|
935
|
-
footnote2="Data source: Yahoo Finance, "+todaydt
|
936
|
-
|
937
|
-
|
969
|
+
"""
|
970
|
+
footnote1="Based on exchange's local accounting standards, EM/TAT are on periodic mean"
|
971
|
+
footnote2="Data source: Yahoo Finance, "+str(todaydt)
|
972
|
+
footnote='Note:\n'+footnote1+'\n'+footnote2
|
973
|
+
#print('\n',footnote1,'\b.',footnote2)
|
974
|
+
df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
975
|
+
titile_font_size=titile_font_size,heading_font_size=heading_font_size, \
|
976
|
+
data_font_size=data_font_size)
|
938
977
|
return df2
|
939
978
|
|
940
979
|
else: # analysis_type1
|