siat 3.8.2__py3-none-any.whl → 3.8.20__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/beta_adjustment.py +1 -1
- siat/beta_adjustment_china.py +1 -1
- siat/bond.py +4 -2
- siat/bond_base.py +2 -1
- siat/bond_china.py +2 -1
- siat/capm_beta2.py +57 -14
- siat/common.py +38 -11
- siat/cryptocurrency.py +6 -3
- siat/economy2.py +3 -2
- siat/financials.py +4 -2
- siat/financials2.py +4 -2
- siat/financials_china.py +2 -1
- siat/fund.py +12 -12
- siat/fund_china.py +561 -2
- siat/grafix.py +66 -24
- siat/holding_risk.py +4 -2
- siat/market_china.py +4 -1
- siat/markowitz.py +7 -7
- siat/markowitz2.py +6 -5
- siat/option_china.py +3 -2
- siat/risk_adjusted_return.py +2 -2
- siat/risk_adjusted_return2.py +52 -8
- siat/risk_evaluation.py +10 -6
- siat/sector_china.py +2 -1
- siat/security_trend2.py +12 -2
- siat/stock.py +17 -4
- siat/stock_profile.py +2 -1
- siat/stock_technical.py +2 -1
- siat/translate.py +1 -1
- siat/valuation.py +25 -0
- {siat-3.8.2.dist-info → siat-3.8.20.dist-info}/METADATA +2 -10
- {siat-3.8.2.dist-info → siat-3.8.20.dist-info}/RECORD +35 -35
- {siat-3.8.2.dist-info → siat-3.8.20.dist-info}/WHEEL +1 -1
- {siat-3.8.2.dist-info → siat-3.8.20.dist-info}/LICENSE +0 -0
- {siat-3.8.2.dist-info → siat-3.8.20.dist-info}/top_level.txt +0 -0
siat/beta_adjustment.py
CHANGED
@@ -727,7 +727,7 @@ def draw_hamada_factors(stkcd,mktidx,betas):
|
|
727
727
|
#计算资产负债率:由 D/E到 D/(A=D+E)
|
728
728
|
betas['Debt/Assets%']=1/(1+1/(betas['Debt Ratio%']/100))*100
|
729
729
|
|
730
|
-
#fig=plt.figure(figsize=(8,6))
|
730
|
+
#fig=plt.figure(figsize=(12.8,6.4))
|
731
731
|
fig=plt.figure()
|
732
732
|
ax1=fig.add_subplot(111)
|
733
733
|
ax1.plot(betas['CFLB%'],marker='o',color='green',lw=3,label='CFLB%')
|
siat/beta_adjustment_china.py
CHANGED
@@ -345,7 +345,7 @@ def draw_hamada_factors_china(stkcd,mktidx,betas):
|
|
345
345
|
#计算资产负债率:由 D/E到 D/(A=D+E)
|
346
346
|
betas['Debt/Assets%']=1/(1+1/(betas['lev ratio']/100))*100
|
347
347
|
|
348
|
-
#fig=plt.figure(figsize=(8,6))
|
348
|
+
#fig=plt.figure(figsize=(12.8,6.4))
|
349
349
|
fig=plt.figure()
|
350
350
|
ax1=fig.add_subplot(111)
|
351
351
|
ax1.plot(betas['CFLB%'],marker='o',color='green',lw=3,label='CFLB%')
|
siat/bond.py
CHANGED
@@ -22,7 +22,8 @@ from siat.bond_base import *
|
|
22
22
|
|
23
23
|
#==============================================================================
|
24
24
|
import matplotlib.pyplot as plt
|
25
|
-
plt.rcParams['figure.figsize']=(12.8,7.2)
|
25
|
+
#plt.rcParams['figure.figsize']=(12.8,7.2)
|
26
|
+
plt.rcParams['figure.figsize']=(12.8,6.4)
|
26
27
|
plt.rcParams['figure.dpi']=300
|
27
28
|
plt.rcParams['font.size'] = 13
|
28
29
|
plt.rcParams['xtick.labelsize']=11 #横轴字体大小
|
@@ -2357,7 +2358,8 @@ def kpmg_rnpm1_rrd(k1,theta,i1, \
|
|
2357
2358
|
df.reset_index(drop=True,inplace=True)
|
2358
2359
|
|
2359
2360
|
#绘图
|
2360
|
-
fig = plt.figure(figsize=(12.8,7.2),dpi=300)
|
2361
|
+
#fig = plt.figure(figsize=(12.8,7.2),dpi=300)
|
2362
|
+
fig = plt.figure(figsize=(12.8,6.4),dpi=300)
|
2361
2363
|
#plt.rcParams['figure.dpi']=300
|
2362
2364
|
|
2363
2365
|
ax = fig.add_subplot(111)
|
siat/bond_base.py
CHANGED
@@ -19,7 +19,8 @@ from siat.common import *
|
|
19
19
|
from siat.translate import *
|
20
20
|
#==============================================================================
|
21
21
|
import matplotlib.pyplot as plt
|
22
|
-
plt.rcParams['figure.figsize']=(12.8,7.2)
|
22
|
+
#plt.rcParams['figure.figsize']=(12.8,7.2)
|
23
|
+
plt.rcParams['figure.figsize']=(12.8,6.4)
|
23
24
|
plt.rcParams['figure.dpi']=300
|
24
25
|
plt.rcParams['font.size'] = 13
|
25
26
|
plt.rcParams['xtick.labelsize']=11 #横轴字体大小
|
siat/bond_china.py
CHANGED
@@ -28,7 +28,8 @@ from siat.security_prices import *
|
|
28
28
|
from siat.security_price2 import *
|
29
29
|
#==============================================================================
|
30
30
|
import matplotlib.pyplot as plt
|
31
|
-
plt.rcParams['figure.figsize']=(12.8,7.2)
|
31
|
+
#plt.rcParams['figure.figsize']=(12.8,7.2)
|
32
|
+
plt.rcParams['figure.figsize']=(12.8,6.4)
|
32
33
|
plt.rcParams['figure.dpi']=300
|
33
34
|
plt.rcParams['font.size'] = 13
|
34
35
|
plt.rcParams['xtick.labelsize']=11 #横轴字体大小
|
siat/capm_beta2.py
CHANGED
@@ -86,7 +86,7 @@ if __name__=='__main__':
|
|
86
86
|
reg_result,dretdf3=regression_capm(ticker,start2,end,RF,regtrddays)
|
87
87
|
|
88
88
|
def regression_capm(ticker,start2,end, \
|
89
|
-
adjust='', \
|
89
|
+
adjust='qfq', \
|
90
90
|
RF=0,regtrddays=252, \
|
91
91
|
mktidx='auto',source='auto',ticker_type='auto'):
|
92
92
|
"""
|
@@ -203,7 +203,7 @@ def regression_capm(ticker,start2,end, \
|
|
203
203
|
return reg_result,dretdf3
|
204
204
|
|
205
205
|
|
206
|
-
def regression_capm_df(marketdf,pricedf,mktidx,adjust='',RF=0,regtrddays=252):
|
206
|
+
def regression_capm_df(marketdf,pricedf,mktidx,adjust='qfq',RF=0,regtrddays=252):
|
207
207
|
"""
|
208
208
|
功能:进行CAPM回归,R-Rf=beta*(Rm-Rf),无截距项回归
|
209
209
|
x为(Rm-Rf),y为R-Rf,均为日收益率,默认回归样本长度一年(365日历日或252交易日)
|
@@ -289,7 +289,7 @@ if __name__=='__main__':
|
|
289
289
|
beta1=get_capm_beta(ticker,start,end,RF,regtrddays)
|
290
290
|
beta1.plot()
|
291
291
|
|
292
|
-
def get_capm_beta(ticker,start,end,adjust='',RF=0,regtrddays=252,mktidx='auto', \
|
292
|
+
def get_capm_beta(ticker,start,end,adjust='qfq',RF=0,regtrddays=252,mktidx='auto', \
|
293
293
|
source='auto',ticker_type='auto'):
|
294
294
|
"""
|
295
295
|
功能:套壳函数regression_capm,仅返回滚动的贝塔系数,基于日收益率
|
@@ -306,7 +306,11 @@ def get_capm_beta(ticker,start,end,adjust='',RF=0,regtrddays=252,mktidx='auto',
|
|
306
306
|
|
307
307
|
startpd=pd.to_datetime(date_adjust(start,adjust=-7))
|
308
308
|
endpd=pd.to_datetime(end)
|
309
|
-
|
309
|
+
|
310
|
+
try:
|
311
|
+
reg_result2=reg_result[(reg_result.index >= startpd) & (reg_result.index <= endpd)]
|
312
|
+
except:
|
313
|
+
print(" #Error(get_capm_beta): none obtained from capm regression")
|
310
314
|
|
311
315
|
return reg_result2
|
312
316
|
|
@@ -335,7 +339,8 @@ def compare_mticker_1beta(ticker,start,end, \
|
|
335
339
|
RF=0,regression_period=365, \
|
336
340
|
attention_value='',attention_value_area='', \
|
337
341
|
attention_point='',attention_point_area='', \
|
338
|
-
axhline_value=1,axhline_label='', \
|
342
|
+
axhline_value=1,axhline_label='零线', \
|
343
|
+
band_area='', \
|
339
344
|
graph=True,facecolor='whitesmoke',loc='best', \
|
340
345
|
annotate=False,annotate_value=False, \
|
341
346
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
@@ -361,7 +366,7 @@ def compare_mticker_1beta(ticker,start,end, \
|
|
361
366
|
RF=RF[0]
|
362
367
|
if isinstance(regression_period,list):
|
363
368
|
regression_period=regression_period[0]
|
364
|
-
print("
|
369
|
+
print(" Working on capm beta, please wait ......")
|
365
370
|
|
366
371
|
#计算日历日regression_period对应的交易日数
|
367
372
|
regtrddays=int(252 / 365 * regression_period)
|
@@ -382,8 +387,17 @@ def compare_mticker_1beta(ticker,start,end, \
|
|
382
387
|
break
|
383
388
|
else:
|
384
389
|
dft=df_tmp[['beta']]
|
385
|
-
|
390
|
+
|
391
|
+
tname=ticker_name(t,tt)
|
392
|
+
dft.rename(columns={'beta':tname},inplace=True)
|
386
393
|
mktidx_name=ticker_name(df_tmp['mktidx'].values[0])
|
394
|
+
|
395
|
+
# 将band_area中的ticker替换为tname
|
396
|
+
if band_area != '':
|
397
|
+
for index, item in enumerate(band_area):
|
398
|
+
if item == t:
|
399
|
+
band_area[index] = tname
|
400
|
+
|
387
401
|
if len(df)==0: #第一个
|
388
402
|
df=dft
|
389
403
|
else:
|
@@ -432,6 +446,7 @@ def compare_mticker_1beta(ticker,start,end, \
|
|
432
446
|
title_txt=title_txt,data_label=False, \
|
433
447
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
434
448
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
449
|
+
band_area=band_area, \
|
435
450
|
annotate=annotate,annotate_value=annotate, \
|
436
451
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,
|
437
452
|
facecolor=facecolor,loc=loc)
|
@@ -463,7 +478,8 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
463
478
|
regression_period=365, \
|
464
479
|
attention_value='',attention_value_area='', \
|
465
480
|
attention_point='',attention_point_area='', \
|
466
|
-
axhline_value=1,axhline_label='', \
|
481
|
+
axhline_value=1,axhline_label='零线', \
|
482
|
+
band_area='', \
|
467
483
|
graph=True,facecolor='whitesmoke',loc='best', \
|
468
484
|
annotate=False,annotate_value=False, \
|
469
485
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
@@ -490,7 +506,7 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
490
506
|
RF=[RF]
|
491
507
|
if isinstance(regression_period,list):
|
492
508
|
regression_period=regression_period[0]
|
493
|
-
print("
|
509
|
+
print(" Working on capm beta with different RFs, please wait ......")
|
494
510
|
|
495
511
|
#计算日历日regression_period对应的交易日数
|
496
512
|
regtrddays=int(252 / 365 * regression_period)
|
@@ -508,8 +524,17 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
508
524
|
break
|
509
525
|
else:
|
510
526
|
dft=df_tmp[['beta']]
|
511
|
-
|
527
|
+
|
528
|
+
#tname="基于无风险利率"+str(round(t*100,4))+'%'
|
529
|
+
tname="RF="+str(round(t*100,4))+'%'
|
530
|
+
dft.rename(columns={'beta':tname},inplace=True)
|
512
531
|
mktidx_name=ticker_name(df_tmp['mktidx'].values[0])
|
532
|
+
|
533
|
+
# 将band_area中的ticker替换为tname
|
534
|
+
if band_area != '':
|
535
|
+
for index, item in enumerate(band_area):
|
536
|
+
if item == t:
|
537
|
+
band_area[index] = tname
|
513
538
|
|
514
539
|
if len(df)==0: #第一个
|
515
540
|
df=dft
|
@@ -558,6 +583,7 @@ def compare_1ticker_mRF(ticker,start,end, \
|
|
558
583
|
title_txt=title_txt,data_label=False, \
|
559
584
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
560
585
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
586
|
+
band_area=band_area, \
|
561
587
|
annotate=annotate,annotate_value=annotate, \
|
562
588
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
563
589
|
facecolor=facecolor,loc=loc)
|
@@ -587,7 +613,8 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
587
613
|
regression_period=[183,365,730], \
|
588
614
|
attention_value='',attention_value_area='', \
|
589
615
|
attention_point='',attention_point_area='', \
|
590
|
-
axhline_value=1,axhline_label='', \
|
616
|
+
axhline_value=1,axhline_label='零线', \
|
617
|
+
band_area='', \
|
591
618
|
graph=True,facecolor='whitesmoke',loc='best', \
|
592
619
|
annotate=False,annotate_value=False, \
|
593
620
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
@@ -614,7 +641,7 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
614
641
|
RF=RF[0]
|
615
642
|
if isinstance(regression_period,int):
|
616
643
|
regression_period=[regression_period]
|
617
|
-
print("
|
644
|
+
print(" Working on capm beta with different regression periods ......")
|
618
645
|
|
619
646
|
#预处理ticker_type
|
620
647
|
ticker_type=ticker_type_preprocess_mticker_mixed(ticker,ticker_type)
|
@@ -632,8 +659,18 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
632
659
|
break
|
633
660
|
else:
|
634
661
|
dft=df_tmp[['beta']]
|
635
|
-
|
662
|
+
|
663
|
+
#tname="基于"+str(t)+"自然日回归"
|
664
|
+
tname="基于"+str(t)+"自然日回归"
|
665
|
+
dft.rename(columns={'beta':tname},inplace=True)
|
636
666
|
mktidx_name=ticker_name(df_tmp['mktidx'].values[0])
|
667
|
+
|
668
|
+
# 将band_area中的ticker替换为tname
|
669
|
+
if band_area != '':
|
670
|
+
for index, item in enumerate(band_area):
|
671
|
+
if item == t:
|
672
|
+
band_area[index] = tname
|
673
|
+
|
637
674
|
if len(df)==0: #第一个
|
638
675
|
df=dft
|
639
676
|
else:
|
@@ -677,6 +714,7 @@ def compare_1ticker_mregression_period(ticker,start,end, \
|
|
677
714
|
title_txt=title_txt,data_label=False, \
|
678
715
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
679
716
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
717
|
+
band_area=band_area, \
|
680
718
|
annotate=annotate,annotate_value=annotate, \
|
681
719
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
682
720
|
facecolor=facecolor,loc=loc)
|
@@ -706,10 +744,11 @@ if __name__=='__main__':
|
|
706
744
|
betas=compare_beta_security(ticker,start,end,RF)
|
707
745
|
|
708
746
|
def compare_beta_security(ticker,start,end, \
|
709
|
-
adjust='', \
|
747
|
+
adjust='qfq', \
|
710
748
|
RF=0,regression_period=365, \
|
711
749
|
attention_value='',attention_value_area='', \
|
712
750
|
attention_point='',attention_point_area='', \
|
751
|
+
band_area='', \
|
713
752
|
graph=True,facecolor='whitesmoke', \
|
714
753
|
annotate=False,annotate_value=False, \
|
715
754
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
@@ -731,6 +770,7 @@ def compare_beta_security(ticker,start,end, \
|
|
731
770
|
RF=RF,regression_period=regression_period, \
|
732
771
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
733
772
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
773
|
+
band_area=band_area, \
|
734
774
|
graph=graph,facecolor=facecolor,loc=loc, \
|
735
775
|
annotate=annotate,annotate_value=annotate, \
|
736
776
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
@@ -749,6 +789,7 @@ def compare_beta_security(ticker,start,end, \
|
|
749
789
|
RF=RF,regression_period=regression_period, \
|
750
790
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
751
791
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
792
|
+
band_area=band_area, \
|
752
793
|
graph=graph,facecolor=facecolor,loc=loc, \
|
753
794
|
annotate=annotate,annotate_value=annotate, \
|
754
795
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
@@ -767,6 +808,7 @@ def compare_beta_security(ticker,start,end, \
|
|
767
808
|
RF=RF,regression_period=regression_period, \
|
768
809
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
769
810
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
811
|
+
band_area=band_area, \
|
770
812
|
graph=graph,facecolor=facecolor,loc=loc, \
|
771
813
|
annotate=annotate,annotate_value=annotate, \
|
772
814
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
@@ -783,6 +825,7 @@ def compare_beta_security(ticker,start,end, \
|
|
783
825
|
RF=RF,regression_period=regression_period, \
|
784
826
|
attention_value=attention_value,attention_value_area=attention_value_area, \
|
785
827
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
828
|
+
band_area=band_area, \
|
786
829
|
graph=graph,facecolor=facecolor,loc=loc, \
|
787
830
|
annotate=annotate,annotate_value=annotate, \
|
788
831
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
siat/common.py
CHANGED
@@ -3125,29 +3125,29 @@ def df_preprocess(dfs,measure,axhline_label,x_label,y_label, \
|
|
3125
3125
|
measure_suffix='(change %)'
|
3126
3126
|
else:
|
3127
3127
|
if preprocess1 == 'standardize':
|
3128
|
-
std_notes="
|
3128
|
+
std_notes="注意:为突出变化趋势,对数据进行了标准化处理,非原值"
|
3129
3129
|
measure_suffix='(标准化处理后)'
|
3130
3130
|
if preprocess1 == 'normalize':
|
3131
|
-
std_notes="
|
3131
|
+
std_notes="注意:为突出变化趋势,对数据进行了归一化处理,非原值"
|
3132
3132
|
measure_suffix='(归一化处理后)'
|
3133
3133
|
if preprocess1 == 'logarithm':
|
3134
|
-
std_notes="
|
3134
|
+
std_notes="注意:为突出变化趋势,对数据进行了对数处理,非原值"
|
3135
3135
|
measure_suffix='(对数处理后)'
|
3136
3136
|
if preprocess1 == 'scaling':
|
3137
3137
|
if scaling_option == 'mean':
|
3138
|
-
std_notes="
|
3139
|
-
measure_suffix='(
|
3138
|
+
std_notes="注意:为突出变化趋势,按均值对原始数据进行了比例缩放,非原值"
|
3139
|
+
measure_suffix='(按均值比例缩放后)'
|
3140
3140
|
elif scaling_option == 'min':
|
3141
|
-
std_notes="
|
3142
|
-
measure_suffix='(
|
3141
|
+
std_notes="注意:为突出变化趋势,按最小值对原始数据进行了比例缩放,非原值"
|
3142
|
+
measure_suffix='(按最小值比例缩放后)'
|
3143
3143
|
elif scaling_option == 'start':
|
3144
|
-
std_notes="
|
3145
|
-
measure_suffix='(
|
3144
|
+
std_notes="注意:为突出变化趋势,按起点值对原始数据进行了比例缩放,非原值"
|
3145
|
+
measure_suffix='(按起点值比例缩放后)'
|
3146
3146
|
elif scaling_option == 'percentage':
|
3147
|
-
std_notes="注释:为突出变化趋势,期间起点数值=100
|
3147
|
+
std_notes="注释:为突出变化趋势,期间起点数值=100%,其他数值为相对百分比,非原值"
|
3148
3148
|
measure_suffix='(相对百分数%)'
|
3149
3149
|
elif scaling_option == 'change%':
|
3150
|
-
std_notes="
|
3150
|
+
std_notes="注释:为突出变化趋势,图中数值为相对期间起点的增减百分比,非原值"
|
3151
3151
|
#measure_suffix='(增/减%)'
|
3152
3152
|
measure_suffix='(涨跌幅度%)'
|
3153
3153
|
axhline_label='零线' #可以在security_trend中使用critical_value选项指定水平线位置,默认0
|
@@ -4972,6 +4972,33 @@ if __name__ == '__main__':
|
|
4972
4972
|
#await jupyter2pdf2(notebook_dir, notebook_file)
|
4973
4973
|
# 注意:上面的await命令会导致编译失败,测试后要注释掉
|
4974
4974
|
#==============================================================================
|
4975
|
+
if __name__ == '__main__':
|
4976
|
+
df=security_trend("600519.SS",indicator=['Close','Open','High','Low'],graph=False)
|
4977
|
+
col_name='持股总数'; position=3
|
4978
|
+
|
4979
|
+
df=shift_column_position(df,col_name='Low',position=0)
|
4980
|
+
|
4981
|
+
def shift_column_position(df,col_name,position=1):
|
4982
|
+
"""
|
4983
|
+
功能:将df中的字段col_name挪动到位置position,其余字段不动。
|
4984
|
+
注意:位置顺序从0开始。
|
4985
|
+
"""
|
4986
|
+
# 获取所有列名
|
4987
|
+
columns = df.columns.tolist()
|
4988
|
+
if col_name not in columns:
|
4989
|
+
raise ValueError(f" #Warning: column '{col_name}' does not exist in the DataFrame.")
|
4990
|
+
return df
|
4991
|
+
|
4992
|
+
# 移除要移动的列
|
4993
|
+
columns.remove(col_name)
|
4994
|
+
|
4995
|
+
# 插入到指定位置
|
4996
|
+
columns.insert(position, col_name)
|
4997
|
+
|
4998
|
+
# 重新排列 DataFrame
|
4999
|
+
df = df[columns]
|
5000
|
+
|
5001
|
+
return df
|
4975
5002
|
#==============================================================================
|
4976
5003
|
#==============================================================================
|
4977
5004
|
#==============================================================================
|
siat/cryptocurrency.py
CHANGED
@@ -385,7 +385,8 @@ def evalSpread_in2Markets(fsym,tsym,market1,market2,begdate,enddate):
|
|
385
385
|
df12=pd.merge(df1,df2,how='inner',left_index=True,right_index=True)
|
386
386
|
df12['spread']=df12['close_x'] - df12['close_y']
|
387
387
|
|
388
|
-
plt.figure(figsize=(12,6))
|
388
|
+
#plt.figure(figsize=(12,6))
|
389
|
+
plt.figure(figsize=(12.8,6.4))
|
389
390
|
labeltxt=market1+"与"+market2+"的价差"
|
390
391
|
plt.plot(df12.spread, '.-', label=labeltxt)
|
391
392
|
#plt.plot(df2.close, '.-', label=market2)
|
@@ -531,7 +532,8 @@ def eval_Position(market1,market2,investment,ac1,ac2,money):
|
|
531
532
|
|
532
533
|
|
533
534
|
ymax=(round(max(money)/1000)+1)*1000
|
534
|
-
plt.figure(figsize=(18,9))
|
535
|
+
#plt.figure(figsize=(18,9))
|
536
|
+
plt.figure(figsize=(12.8,6.4))
|
535
537
|
# market1的账户ac1变化图
|
536
538
|
plt.subplot(2,3,1)
|
537
539
|
plt.plot(ac1)
|
@@ -564,7 +566,8 @@ def eval_Roi(fsym,tsym,market1,market2,roi,begdate,enddate):
|
|
564
566
|
ymax=round(10*roi[-1])*10+10
|
565
567
|
product=fsym+"/"+tsym+":"
|
566
568
|
mktpair="市场配对("+market1+","+market2+")"
|
567
|
-
plt.figure(figsize=(8,5))
|
569
|
+
#plt.figure(figsize=(8,5))
|
570
|
+
plt.figure(figsize=(12.8,6.4))
|
568
571
|
plt.plot(np.array(roi)*100, 'r')
|
569
572
|
|
570
573
|
footnote1="交易序列(总计"+str(ttltrdnum)+"次)"
|
siat/economy2.py
CHANGED
@@ -769,7 +769,7 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
769
769
|
axhline_value=0
|
770
770
|
axhline_label="零线"
|
771
771
|
else:
|
772
|
-
if one_unit and unit != '':
|
772
|
+
if one_unit and unit != '' and preprocess == 'none':
|
773
773
|
titletxt=titletxt+', '+unit
|
774
774
|
|
775
775
|
# 为避免出错,对空值进行插值
|
@@ -808,7 +808,8 @@ def economy_mtickers_wb(ticker=['CN','US','JP'],indicator='NY.GDP.MKTP.PP.CD', \
|
|
808
808
|
attention_point=attention_point,attention_point_area=attention_point_area, \
|
809
809
|
annotate=annotate,annotate_value=annotate_value,plus_sign=plus_sign, \
|
810
810
|
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor, \
|
811
|
-
maxticks=
|
811
|
+
maxticks_enable=False,maxticks=10, \
|
812
|
+
translate=translate)
|
812
813
|
|
813
814
|
return dfs2
|
814
815
|
|
siat/financials.py
CHANGED
@@ -24,7 +24,8 @@ from siat.grafix import *
|
|
24
24
|
#==============================================================================
|
25
25
|
import matplotlib.pyplot as plt
|
26
26
|
|
27
|
-
plt.rcParams['figure.figsize']=(12.8,7.2)
|
27
|
+
#plt.rcParams['figure.figsize']=(12.8,7.2)
|
28
|
+
plt.rcParams['figure.figsize']=(12.8,6.4)
|
28
29
|
plt.rcParams['figure.dpi']=300
|
29
30
|
plt.rcParams['font.size'] = 13
|
30
31
|
plt.rcParams['xtick.labelsize']=11 #横轴字体大小
|
@@ -1936,7 +1937,8 @@ def compare_dupont(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10,hatchlist=
|
|
1936
1937
|
code=df.loc[i,'公司']
|
1937
1938
|
df.loc[i,'公司']=ticker_name(code)
|
1938
1939
|
|
1939
|
-
f,ax1 = plt.subplots(1,figsize=(10,5))
|
1940
|
+
#f,ax1 = plt.subplots(1,figsize=(10,5))
|
1941
|
+
f,ax1 = plt.subplots(1,figsize=(12.8,6.4))
|
1940
1942
|
w = 0.75
|
1941
1943
|
x = [i+1 for i in range(len(df[name1]))]
|
1942
1944
|
#tick_pos = [i+(w/2.) for i in x]
|
siat/financials2.py
CHANGED
@@ -26,7 +26,8 @@ from siat.grafix import *
|
|
26
26
|
#==============================================================================
|
27
27
|
import matplotlib.pyplot as plt
|
28
28
|
|
29
|
-
plt.rcParams['figure.figsize']=(12.8,7.2)
|
29
|
+
#plt.rcParams['figure.figsize']=(12.8,7.2)
|
30
|
+
plt.rcParams['figure.figsize']=(12.8,6.4)
|
30
31
|
plt.rcParams['figure.dpi']=300
|
31
32
|
plt.rcParams['font.size'] = 13
|
32
33
|
plt.rcParams['xtick.labelsize']=11 #横轴字体大小
|
@@ -1009,7 +1010,8 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
1009
1010
|
|
1010
1011
|
fin_period=df2['endDate'].values[0]
|
1011
1012
|
|
1012
|
-
f,ax1 = plt.subplots(1,figsize=(10,5))
|
1013
|
+
#f,ax1 = plt.subplots(1,figsize=(10,5))
|
1014
|
+
f,ax1 = plt.subplots(1,figsize=(12.8,6.4))
|
1013
1015
|
w = 0.75
|
1014
1016
|
x = [i+1 for i in range(len(df2[name1]))]
|
1015
1017
|
tick_pos = [i for i in x]
|
siat/financials_china.py
CHANGED
@@ -770,7 +770,8 @@ def compare_dupont_china(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10, \
|
|
770
770
|
code=df.loc[i,'公司']
|
771
771
|
df.loc[i,'公司']=ticker_name(code,'stock').replace("(A股)",'')
|
772
772
|
|
773
|
-
f,ax1 = plt.subplots(1,figsize=(10,5))
|
773
|
+
#f,ax1 = plt.subplots(1,figsize=(10,5))
|
774
|
+
f,ax1 = plt.subplots(1,figsize=(12.8,6.4))
|
774
775
|
w = 0.75
|
775
776
|
x = [i+1 for i in range(len(df[name1]))]
|
776
777
|
#tick_pos = [i+(w/2.) for i in x]
|
siat/fund.py
CHANGED
@@ -129,8 +129,8 @@ def pof_list_china(fund_type='全部类型',printout=True):
|
|
129
129
|
print(prefix,"{:,}".format(n),"\b,",round(n/num*100,2),'\b%')
|
130
130
|
|
131
131
|
import datetime
|
132
|
-
|
133
|
-
print("来源:东方财富/天天基金,",
|
132
|
+
todaydt = datetime.date.today()
|
133
|
+
print("来源:东方财富/天天基金,",todaydt)
|
134
134
|
|
135
135
|
return df3
|
136
136
|
|
@@ -215,8 +215,8 @@ def oef_rank_china(info_type='单位净值',fund_type='全部类型'):
|
|
215
215
|
|
216
216
|
print(" 净值日期:",nvdate,'\b. ',end='')
|
217
217
|
import datetime
|
218
|
-
|
219
|
-
print(" 来源:东方财富/天天基金,",
|
218
|
+
todaydt = datetime.date.today()
|
219
|
+
print(" 来源:东方财富/天天基金,",todaydt)
|
220
220
|
|
221
221
|
return df
|
222
222
|
|
@@ -261,7 +261,7 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值',power=0):
|
|
261
261
|
import akshare as ak
|
262
262
|
|
263
263
|
#开放式基金-历史数据
|
264
|
-
import datetime;
|
264
|
+
import datetime; todaydt = datetime.date.today()
|
265
265
|
source="来源:东方财富/天天基金"
|
266
266
|
import siat.grafix as grf
|
267
267
|
|
@@ -288,7 +288,7 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值',power=0):
|
|
288
288
|
ylabeltxt='人民币元'
|
289
289
|
titletxt="开放式基金的净值趋势:"+fund
|
290
290
|
|
291
|
-
footnote=source+', '+str(
|
291
|
+
footnote=source+', '+str(todaydt)
|
292
292
|
grf.plot_line2(dfp,ticker1,colname1,label1, \
|
293
293
|
dfp,ticker2,colname2,label2, \
|
294
294
|
ylabeltxt,titletxt,footnote,power=power)
|
@@ -306,7 +306,7 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值',power=0):
|
|
306
306
|
colname='累计收益率'; collabel='累计收益率%'
|
307
307
|
ylabeltxt=''
|
308
308
|
titletxt="开放式基金的累计收益率趋势:"+fund
|
309
|
-
footnote=source+', '+str(
|
309
|
+
footnote=source+', '+str(todaydt)
|
310
310
|
grf.plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
|
311
311
|
return df
|
312
312
|
|
@@ -332,7 +332,7 @@ def oef_trend_china(fund,fromdate,todate,trend_type='净值',power=0):
|
|
332
332
|
ticker2=fund; colname2='同类排名百分比';label2='同类排名百分比'
|
333
333
|
ylabeltxt=''
|
334
334
|
titletxt="开放式基金的近三个月收益率排名趋势:"+fund
|
335
|
-
footnote=source+', '+str(
|
335
|
+
footnote=source+', '+str(todaydt)
|
336
336
|
grf.plot_line2(dfp,ticker1,colname1,label1, \
|
337
337
|
dfp,ticker2,colname2,label2, \
|
338
338
|
ylabeltxt,titletxt,footnote,power=power,twinx=True)
|
@@ -388,8 +388,8 @@ def mmf_rank_china():
|
|
388
388
|
|
389
389
|
print("收益率日期:",nvdate,'\b. ',end='')
|
390
390
|
import datetime
|
391
|
-
|
392
|
-
print("来源:东方财富/天天基金,",
|
391
|
+
todaydt = datetime.date.today()
|
392
|
+
print("来源:东方财富/天天基金,",todaydt)
|
393
393
|
|
394
394
|
return df
|
395
395
|
|
@@ -421,7 +421,7 @@ def mmf_trend_china(fund,fromdate,todate,power=0):
|
|
421
421
|
import akshare as ak
|
422
422
|
|
423
423
|
#基金历史数据
|
424
|
-
import datetime;
|
424
|
+
import datetime; dt = datetime.date.today()
|
425
425
|
source="来源:东方财富/天天基金"
|
426
426
|
import siat.grafix as grf
|
427
427
|
|
@@ -440,7 +440,7 @@ def mmf_trend_china(fund,fromdate,todate,power=0):
|
|
440
440
|
colname='7日年化%'; collabel='7日年化%'
|
441
441
|
ylabeltxt=''
|
442
442
|
titletxt="货币型基金的7日年化收益率趋势:"+fund
|
443
|
-
footnote=source+', '+str(
|
443
|
+
footnote=source+', '+str(todaydt)
|
444
444
|
grf.plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
|
445
445
|
|
446
446
|
return df
|