siat 3.5.11__py3-none-any.whl → 3.6.1__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 +39 -11
- siat/common.py +14 -7
- siat/grafix.py +285 -29
- siat/option_china.py +1 -1
- siat/risk_adjusted_return2.py +55 -7
- siat/security_prices.py +2 -0
- siat/security_trend2.py +70 -14
- siat/stock.py +94 -18
- siat/stooq.py +2 -1
- siat/translate.py +5 -3
- siat/valuation.py +29 -12
- siat/yf_name.py +127 -3
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/METADATA +1 -1
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/RECORD +17 -17
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/LICENSE +0 -0
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/WHEEL +0 -0
- {siat-3.5.11.dist-info → siat-3.6.1.dist-info}/top_level.txt +0 -0
siat/capm_beta2.py
CHANGED
@@ -333,7 +333,10 @@ if __name__=='__main__':
|
|
333
333
|
def compare_mticker_1beta(ticker,start,end, \
|
334
334
|
adjust='', \
|
335
335
|
RF=0,regression_period=365, \
|
336
|
-
|
336
|
+
attention_value='', \
|
337
|
+
attention_point='', \
|
338
|
+
axhline_value=1,axhline_label='', \
|
339
|
+
graph=True,facecolor='whitesmoke',loc='best', \
|
337
340
|
annotate=False,annotate_value=False, \
|
338
341
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
339
342
|
mktidx='auto',source='auto',ticker_type='auto'):
|
@@ -427,9 +430,11 @@ def compare_mticker_1beta(ticker,start,end, \
|
|
427
430
|
draw_lines(df1,y_label,x_label=footnotex, \
|
428
431
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
429
432
|
title_txt=title_txt,data_label=False, \
|
433
|
+
attention_value=attention_value, \
|
434
|
+
attention_point=attention_point, \
|
430
435
|
annotate=annotate,annotate_value=annotate, \
|
431
436
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,
|
432
|
-
facecolor=facecolor)
|
437
|
+
facecolor=facecolor,loc=loc)
|
433
438
|
|
434
439
|
return df
|
435
440
|
|
@@ -456,7 +461,10 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
456
461
|
adjust='', \
|
457
462
|
RF=[0,0.02,0.05], \
|
458
463
|
regression_period=365, \
|
459
|
-
|
464
|
+
attention_value='', \
|
465
|
+
attention_point='', \
|
466
|
+
axhline_value=1,axhline_label='', \
|
467
|
+
graph=True,facecolor='whitesmoke',loc='best', \
|
460
468
|
annotate=False,annotate_value=False, \
|
461
469
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
462
470
|
mktidx='auto',source='auto', \
|
@@ -548,9 +556,11 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
548
556
|
draw_lines(df1,y_label,x_label=footnotex, \
|
549
557
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
550
558
|
title_txt=title_txt,data_label=False, \
|
559
|
+
attention_value=attention_value, \
|
560
|
+
attention_point=attention_point, \
|
551
561
|
annotate=annotate,annotate_value=annotate, \
|
552
562
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
553
|
-
facecolor=facecolor)
|
563
|
+
facecolor=facecolor,loc=loc)
|
554
564
|
|
555
565
|
return df
|
556
566
|
|
@@ -575,7 +585,10 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
575
585
|
adjust='', \
|
576
586
|
RF=0, \
|
577
587
|
regression_period=[183,365,730], \
|
578
|
-
|
588
|
+
attention_value='', \
|
589
|
+
attention_point='', \
|
590
|
+
axhline_value=1,axhline_label='', \
|
591
|
+
graph=True,facecolor='whitesmoke',loc='best', \
|
579
592
|
annotate=False,annotate_value=False, \
|
580
593
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
581
594
|
mktidx='auto',source='auto', \
|
@@ -662,9 +675,11 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
662
675
|
draw_lines(df1,y_label,x_label=footnotex, \
|
663
676
|
axhline_value=axhline_value,axhline_label=axhline_label, \
|
664
677
|
title_txt=title_txt,data_label=False, \
|
678
|
+
attention_value=attention_value, \
|
679
|
+
attention_point=attention_point, \
|
665
680
|
annotate=annotate,annotate_value=annotate, \
|
666
681
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
667
|
-
facecolor=facecolor)
|
682
|
+
facecolor=facecolor,loc=loc)
|
668
683
|
|
669
684
|
return df
|
670
685
|
|
@@ -693,11 +708,13 @@ if __name__=='__main__':
|
|
693
708
|
def compare_beta_security(ticker,start,end, \
|
694
709
|
adjust='', \
|
695
710
|
RF=0,regression_period=365, \
|
711
|
+
attention_value='', \
|
712
|
+
attention_point='', \
|
696
713
|
graph=True,facecolor='whitesmoke', \
|
697
714
|
annotate=False,annotate_value=False, \
|
698
715
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
699
716
|
mktidx='auto',source='auto', \
|
700
|
-
ticker_type='auto'):
|
717
|
+
ticker_type='auto',loc="best"):
|
701
718
|
"""
|
702
719
|
功能:组合情况,可能多只股票、多个投资组合或投资组合与股票的混合,多个无风险收益率
|
703
720
|
|
@@ -712,7 +729,9 @@ def compare_beta_security(ticker,start,end, \
|
|
712
729
|
df=compare_mticker_1beta(ticker,start,end, \
|
713
730
|
adjust=adjust, \
|
714
731
|
RF=RF,regression_period=regression_period, \
|
715
|
-
|
732
|
+
attention_value=attention_value, \
|
733
|
+
attention_point=attention_point, \
|
734
|
+
graph=graph,facecolor=facecolor,loc=loc, \
|
716
735
|
annotate=annotate,annotate_value=annotate, \
|
717
736
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
718
737
|
mktidx=mktidx,source=source, \
|
@@ -728,7 +747,10 @@ def compare_beta_security(ticker,start,end, \
|
|
728
747
|
df=compare_1ticker_mRF(ticker,start,end, \
|
729
748
|
adjust=adjust, \
|
730
749
|
RF=RF,regression_period=regression_period, \
|
731
|
-
|
750
|
+
attention_value=attention_value, \
|
751
|
+
attention_point=attention_point, \
|
752
|
+
|
753
|
+
graph=graph,facecolor=facecolor,loc=loc, \
|
732
754
|
annotate=annotate,annotate_value=annotate, \
|
733
755
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
734
756
|
mktidx=mktidx,source=source, \
|
@@ -744,7 +766,10 @@ def compare_beta_security(ticker,start,end, \
|
|
744
766
|
df=compare_1ticker_mregression_period(ticker,start,end, \
|
745
767
|
adjust=adjust, \
|
746
768
|
RF=RF,regression_period=regression_period, \
|
747
|
-
|
769
|
+
attention_value=attention_value, \
|
770
|
+
attention_point=attention_point, \
|
771
|
+
|
772
|
+
graph=graph,facecolor=facecolor,loc=loc, \
|
748
773
|
annotate=annotate,annotate_value=annotate, \
|
749
774
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
750
775
|
mktidx=mktidx,source=source, \
|
@@ -758,7 +783,10 @@ def compare_beta_security(ticker,start,end, \
|
|
758
783
|
df=compare_mticker_1beta(ticker,start,end, \
|
759
784
|
adjust=adjust, \
|
760
785
|
RF=RF,regression_period=regression_period, \
|
761
|
-
|
786
|
+
attention_value=attention_value, \
|
787
|
+
attention_point=attention_point, \
|
788
|
+
|
789
|
+
graph=graph,facecolor=facecolor,loc=loc, \
|
762
790
|
annotate=annotate,annotate_value=annotate, \
|
763
791
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
764
792
|
mktidx=mktidx,source=source, \
|
siat/common.py
CHANGED
@@ -2916,15 +2916,15 @@ def fix_package(file='stooq.py',package='pandas_datareader'):
|
|
2916
2916
|
result=copyfile(srcfile,objfile)
|
2917
2917
|
except IOError as e:
|
2918
2918
|
print(" #Error(fix_package): Unable to copy file. %s" % e)
|
2919
|
-
print(" Program failed most likely becos of incorrect source/target directories.")
|
2919
|
+
print(" Program failed, most likely becos of incorrect source/target directories.")
|
2920
2920
|
print(" Solution: manually copy the file",srcfile,"to the folder",objpath1)
|
2921
2921
|
#exit(1)
|
2922
2922
|
except:
|
2923
2923
|
print(" #Error(fix_package): Unexpected error:", sys.exc_info())
|
2924
2924
|
#exit(1)
|
2925
2925
|
else:
|
2926
|
-
print("
|
2927
|
-
print(" Please RESTART
|
2926
|
+
print(" Overrided",file,"in",package)
|
2927
|
+
print(" Please RESTART Python kernel before using siat")
|
2928
2928
|
|
2929
2929
|
return
|
2930
2930
|
|
@@ -3737,7 +3737,7 @@ def df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2,
|
|
3737
3737
|
first_col_align='left',second_col_align='right', \
|
3738
3738
|
last_col_align='right',other_col_align='right', \
|
3739
3739
|
titile_font_size='16px',heading_font_size='15px', \
|
3740
|
-
data_font_size='
|
3740
|
+
data_font_size='14px',footnote_font_size='13px'):
|
3741
3741
|
"""
|
3742
3742
|
功能:采样CSS式样显示df,适用于Jupyter环境,整齐紧凑,不挑浏览器
|
3743
3743
|
注意:若facecolor不被支持,则自动改为papayawhip
|
@@ -3808,7 +3808,14 @@ def df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2,
|
|
3808
3808
|
display(style6)
|
3809
3809
|
|
3810
3810
|
if not footnote=='':
|
3811
|
-
print(footnote)
|
3811
|
+
#print(footnote)
|
3812
|
+
|
3813
|
+
from IPython.display import display, HTML
|
3814
|
+
ft_list=footnote.split('\n') #分行显示,因下列显示方式无法识别换行
|
3815
|
+
for ft in ft_list:
|
3816
|
+
# 使用HTML和CSS设置字体大小
|
3817
|
+
html_code = f'<p style="font-size:{footnote_font_size};">{ft}</p>'
|
3818
|
+
display(HTML(html_code))
|
3812
3819
|
#print('') #空一行
|
3813
3820
|
|
3814
3821
|
return
|
@@ -4394,11 +4401,11 @@ def annual_compound_growth(df,column="Close"):
|
|
4394
4401
|
years=days / 365
|
4395
4402
|
|
4396
4403
|
import numpy as np
|
4397
|
-
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,
|
4404
|
+
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,3)
|
4398
4405
|
rate_str=str(growth_rate)+'%'
|
4399
4406
|
|
4400
4407
|
day1str=day1.strftime("%Y-%m-%d"); day2str=day2.strftime("%Y-%m-%d")
|
4401
|
-
print("
|
4408
|
+
print("Annualized compound growth",rate_str,"from",day1str,"to",day2str)
|
4402
4409
|
|
4403
4410
|
return
|
4404
4411
|
#==============================================================================
|