siat 3.7.28__py3-none-any.whl → 3.8.10__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/holding_risk.py CHANGED
@@ -40,7 +40,8 @@ if czxt in ['linux']: #website Jupyter
40
40
  plt.rcParams['axes.unicode_minus'] = False
41
41
  #==============================================================================
42
42
  #统一设定绘制的图片大小:数值为英寸,1英寸=100像素
43
- plt.rcParams['figure.figsize']=(12.8,7.2)
43
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
44
+ plt.rcParams['figure.figsize']=(12.8,6.4)
44
45
  plt.rcParams['figure.dpi']=300
45
46
  plt.rcParams['font.size'] = 13
46
47
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小
@@ -821,7 +822,8 @@ def portfolio_rets_curve(portfolio,fromdate,todate):
821
822
  import numpy as np
822
823
  x=mu+sigma*np.random.randn(10000)
823
824
 
824
- plt.figure(figsize=(8,4))
825
+ #plt.figure(figsize=(8,4))
826
+ plt.figure(figsize=(12.8,6.4))
825
827
  import seaborn as sns
826
828
  #绘制曲线:股票收益率
827
829
  sns.kdeplot(data=rets,shade=True,color='blue',legend=True,label='投资组合',lw=4)
siat/market_china.py CHANGED
@@ -702,7 +702,10 @@ if __name__=='__main__':
702
702
  df1=market_detail_china(category='price')
703
703
 
704
704
  def market_detail_china(category='price',prettytab=True,plttab=False, \
705
- colWidth=0.3,tabScale=2,figsize=(10,6),fontsize=13,cellLoc='center'):
705
+ colWidth=0.3,tabScale=2, \
706
+ #figsize=(10,6), \
707
+ figsize=(12.8,6.4), \
708
+ fontsize=13,cellLoc='center'):
706
709
  """
707
710
  功能:给出中国当前最新的三大股票交易所的更多细节,合成
708
711
  输出:构造表格型数据框df,直接利用Jupyter Notebook格式输出
siat/markowitz.py CHANGED
@@ -30,7 +30,8 @@ import datetime
30
30
  import seaborn as sns
31
31
  import matplotlib.pyplot as plt
32
32
  #统一设定绘制的图片大小:数值为英寸,1英寸=100像素
33
- plt.rcParams['figure.figsize']=(12.8,7.2)
33
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
34
+ plt.rcParams['figure.figsize']=(12.8,6.4)
34
35
  plt.rcParams['figure.dpi']=300
35
36
  plt.rcParams['font.size'] = 13
36
37
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小
@@ -991,7 +992,7 @@ def portfolio_es(pf_info,simulation=50000):
991
992
  pf_volatilities = np.array(RandomPortfolios['Volatility'])
992
993
 
993
994
  #plt.style.use('seaborn-dark') #不支持中文
994
- #plt.figure(figsize=(9, 5))
995
+ #plt.figure(figsize=(12.8,6.4))
995
996
  plt.scatter(pf_volatilities, pf_returns, c=pf_ratio,cmap='RdYlGn', edgecolors='black',marker='o')
996
997
  #plt.grid(True)
997
998
 
@@ -1444,7 +1445,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1444
1445
  pf_returns = np.array(RandomPortfolios['Risk premium'])
1445
1446
  pf_volatilities = np.array(RandomPortfolios['beta'])
1446
1447
 
1447
- plt.figure(figsize=(9, 5))
1448
+ plt.figure(figsize=(12.8,6.4))
1448
1449
  plt.scatter(pf_volatilities, pf_returns, c=pf_ratio,cmap='RdYlGn', edgecolors='black',marker='o')
1449
1450
  plt.colorbar(label='特雷诺比率')
1450
1451
 
@@ -1466,7 +1467,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1466
1467
  pf_returns = np.array(RandomPortfolios[col_y])
1467
1468
  pf_volatilities = np.array(RandomPortfolios[col_x])
1468
1469
 
1469
- #plt.figure(figsize=(9, 5))
1470
+ #plt.figure(figsize=(12.8,6.4))
1470
1471
  plt.scatter(pf_volatilities, pf_returns, c=pf_ratio,cmap='RdYlGn', edgecolors='black',marker='o')
1471
1472
  plt.colorbar(label=colorbartxt)
1472
1473
 
@@ -2204,9 +2205,8 @@ def security_correlation(tickers,start='L5Y',end='today',info_type='Close'):
2204
2205
  df_coor = df.corr()
2205
2206
 
2206
2207
 
2207
- #fig = plt.figure(figsize=(cm2inch(16,12)))
2208
- #fig = plt.figure(figsize=(cm2inch(12,6)))
2209
- fig = plt.figure(figsize=(12.8,7.2))
2208
+ #fig = plt.figure(figsize=(12.8,7.2))
2209
+ fig = plt.figure(figsize=(12.8,6.4))
2210
2210
  ax1 = plt.gca()
2211
2211
 
2212
2212
  #构造mask,去除重复数据显示
siat/markowitz2.py CHANGED
@@ -30,7 +30,8 @@ import datetime
30
30
  import seaborn as sns
31
31
  import matplotlib.pyplot as plt
32
32
  #统一设定绘制的图片大小:数值为英寸,1英寸=100像素
33
- plt.rcParams['figure.figsize']=(12.8,7.2)
33
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
34
+ plt.rcParams['figure.figsize']=(12.8,6.4)
34
35
  plt.rcParams['figure.dpi']=300
35
36
  plt.rcParams['font.size'] = 13
36
37
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小
@@ -1216,7 +1217,7 @@ def portfolio_eset(pf_info,simulation=50000,convex_hull=False,frontier="both",fa
1216
1217
  pf_volatilities = np.array(RandomPortfolios['Volatility'])
1217
1218
 
1218
1219
  #plt.style.use('seaborn-dark') #不支持中文
1219
- #plt.figure(figsize=(9, 5))
1220
+ #plt.figure(figsize=(12.8,6.4))
1220
1221
  plt.scatter(pf_volatilities,pf_returns,c=pf_ratio,cmap='RdYlGn',edgecolors='black',marker='o')
1221
1222
  #plt.grid(True)
1222
1223
 
@@ -1799,7 +1800,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1799
1800
  pf_returns = np.array(RandomPortfolios['Risk premium'])
1800
1801
  pf_volatilities = np.array(RandomPortfolios['beta'])
1801
1802
 
1802
- plt.figure(figsize=(9, 5))
1803
+ plt.figure(figsize=(12.8,6.4))
1803
1804
  plt.scatter(pf_volatilities, pf_returns, c=pf_ratio,cmap='RdYlGn', edgecolors='black',marker='o')
1804
1805
  plt.colorbar(label='特雷诺比率')
1805
1806
 
@@ -1822,7 +1823,7 @@ def RandomPortfolios_plot(RandomPortfolios,col_x,col_y,colorbartxt,title_ext, \
1822
1823
  pf_returns = np.array(RandomPortfolios[col_y])
1823
1824
  pf_volatilities = np.array(RandomPortfolios[col_x])
1824
1825
 
1825
- #plt.figure(figsize=(9, 5))
1826
+ #plt.figure(figsize=(12.8,6.4))
1826
1827
  plt.scatter(pf_volatilities, pf_returns, c=pf_ratio,cmap='RdYlGn', edgecolors='black',marker='o')
1827
1828
  plt.colorbar(label=colorbartxt)
1828
1829
 
@@ -2720,7 +2721,7 @@ def security_correlation(tickers,start='L5Y',end='today',info_type='Close', \
2720
2721
  #fig = plt.figure(figsize=(cm2inch(16,12)))
2721
2722
  #fig = plt.figure(figsize=(cm2inch(12,8)))
2722
2723
  #fig = plt.figure(figsize=(12.8,7.2))
2723
- fig = plt.figure(figsize=(12,6))
2724
+ fig = plt.figure(figsize=(12.8,6.4))
2724
2725
  ax1 = plt.gca()
2725
2726
 
2726
2727
  #构造mask,去除重复数据显示
siat/option_china.py CHANGED
@@ -2273,10 +2273,11 @@ def fin_option_risk_sse2(option,maturity,exercise,trade_date, \
2273
2273
 
2274
2274
  #fig = plt.figure()
2275
2275
  import matplotlib.pyplot as plt
2276
- plt.rcParams['figure.figsize']=(12.8,7.2)
2276
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
2277
+ plt.rcParams['figure.figsize']=(12.8,6.4)
2277
2278
  plt.rcParams['figure.dpi']=300
2278
2279
  """
2279
- c=dfg.plot(kind='bar', y=['看涨期权','看跌期权'],figsize=(16, 8),width=0.8,
2280
+ c=dfg.plot(kind='bar', y=['看涨期权','看跌期权'],figsize=(12.8,6.4),width=0.8,
2280
2281
  color=['green','red'],fontsize=16)
2281
2282
  """
2282
2283
  #柱状图填充图案
@@ -476,7 +476,7 @@ def draw_rar_ratio(rars,portfolio,ratio_name):
476
476
  rars2=rars1.interpolate(method='cubic')
477
477
  """
478
478
 
479
- #plt.figure(figsize=(8,5))
479
+ #plt.figure(figsize=(12.8,6.4))
480
480
 
481
481
  labeltxt=ratio_name.capitalize()+'指标'
482
482
  plt.plot(rars['RAR'],label=labeltxt,color='red',lw=1)
@@ -510,7 +510,7 @@ def draw_rar_ratio(rars,portfolio,ratio_name):
510
510
  """
511
511
  import seaborn as sns
512
512
  with sns.axes_style("whitegrid"):
513
- fig, ax = plt.subplots(figsize=(8,5))
513
+ fig, ax = plt.subplots(figsize=(12.8,6.4))
514
514
  ax.plot(rars['RAR'],label=labeltxt,color='red',lw=3)
515
515
  #ax.plot(rars['Mean(Ret)'],label='Stock(s) return(%)',color='blue',lw=1)
516
516
  plt.axhline(y=0.0,label='Zero return',color='black',linestyle=':')
siat/risk_evaluation.py CHANGED
@@ -40,7 +40,8 @@ if czxt in ['linux']: #website Jupyter
40
40
  plt.rcParams['axes.unicode_minus'] = False
41
41
  #==============================================================================
42
42
  #统一设定绘制的图片大小:数值为英寸,1英寸=100像素
43
- plt.rcParams['figure.figsize']=(12.8,7.2)
43
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
44
+ plt.rcParams['figure.figsize']=(12.8,6.4)
44
45
  plt.rcParams['figure.dpi']=300
45
46
  plt.rcParams['font.size'] = 13
46
47
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小
@@ -742,7 +743,8 @@ def plot_rets_histogram(ticker,start,end,num_bins=20):
742
743
  sigma=rets.std()
743
744
 
744
745
  #绘制股票收益率直方图
745
- plt.figure(figsize=(8,4))
746
+ #plt.figure(figsize=(8,4))
747
+ plt.figure(figsize=(12.8,6.4))
746
748
  n,bins,patches=plt.hist(rets,num_bins,facecolor='blue',alpha=0.5,label=ticker_name(ticker))
747
749
 
748
750
  #生成与直方图柱子对应的正态分布概率密度
@@ -789,7 +791,7 @@ def plot_rets_curve(ticker,start,end):
789
791
  import numpy as np
790
792
  x=mu+sigma*np.random.randn(1000000)
791
793
 
792
- #plt.figure(figsize=(8,4))
794
+ #plt.figure(figsize=(12.8,6.4))
793
795
  import seaborn as sns
794
796
  #绘制曲线:股票收益率
795
797
  sns.kdeplot(data=rets,shade=True,color='blue',legend=True,label=ticker_name(ticker),lw=2)
@@ -1435,7 +1437,7 @@ def series_VaR_tlcp(tickerlist,today,alpha=0.99,pastyears=1,model="montecarlo"):
1435
1437
  #tlcpdf.reset_index(drop=True)
1436
1438
  tlcpdf.set_index('Ticker',drop=True,inplace=True)
1437
1439
  """
1438
- #ax=plt.figure(figsize=(8,4))
1440
+ #ax=plt.figure(figsize=(12.8,6.4))
1439
1441
  tlcpdf.plot.barh(x='Ticker',y='TLCP',color='r',grid=True)
1440
1442
  plt.ylabel('股票')
1441
1443
  titlel1="VaR全损临界点(TLCP)"
@@ -1516,7 +1518,8 @@ def plot_VaR_days_changes(ticker,shares,today,dayslist,alpha=0.99, \
1516
1518
 
1517
1519
  #绘图
1518
1520
  if printout == True:
1519
- plt.figure(figsize=(8,4))
1521
+ #plt.figure(figsize=(8,4))
1522
+ plt.figure(figsize=(12.8,6.4))
1520
1523
  #绘制曲线:ratio
1521
1524
  plt.plot(vardf['ratio%'],color='red',lw=2,label=ticker_name(ticker),marker=markertype)
1522
1525
  #设置标题、图例、坐标轴标签
@@ -1564,7 +1567,8 @@ def compare_VaR_days_changes(tickerlist,shares,today,dayslist,alpha=0.99, \
1564
1567
  return
1565
1568
 
1566
1569
  #依次绘图tickerlist中的各个股票
1567
- plt.figure(figsize=(8,4))
1570
+ #plt.figure(figsize=(8,4))
1571
+ plt.figure(figsize=(12.8,6.4))
1568
1572
 
1569
1573
  markerlist=['.','o','s','*','+','x','1','2']
1570
1574
  for t in tickerlist:
siat/sector_china.py CHANGED
@@ -889,9 +889,17 @@ def display_industry_sw(sw_level='1',numberPerLine=4,colalign='left'):
889
889
  """
890
890
  按照类别打印申万行业列表,名称(代码),每行5个, 套壳函数
891
891
  """
892
- itype_list=['1','2','3','F','S','B','C']
893
- sw_level_list=['1','2','3','F','S','B','C']
894
- pos=sw_level_list.index(sw_level)
892
+ #itype_list=['1','2','3','F','S','B','C']
893
+ itype_list=['1','2','3','F','S','B']
894
+ #sw_level_list=['1','2','3','F','S','B','C']
895
+ sw_level_list=['1','2','3','F','S','B']
896
+
897
+ try:
898
+ pos=sw_level_list.index(sw_level)
899
+ except:
900
+ print(f" #Warning(display_industry_sw): no such level in Shenwan system {sw_level}")
901
+ print(f" Supported Shenwan system: {sw_level_list}")
902
+
895
903
  itype=itype_list[pos]
896
904
 
897
905
  print_industry_sw(itype=itype,numberPerLine=numberPerLine,colalign=colalign)
@@ -2721,7 +2729,8 @@ def industry_correlation_sw(df,tickers,start,end, \
2721
2729
  import seaborn as sns
2722
2730
  sns.set(font='SimHei') # 解决Seaborn中文显示问题
2723
2731
 
2724
- fig = plt.figure(figsize=(cm2inch(12,8)))
2732
+ #fig = plt.figure(figsize=(cm2inch(12,8)))
2733
+ fig = plt.figure(figsize=(12.8,6.4))
2725
2734
  ax1 = plt.gca()
2726
2735
 
2727
2736
  #构造mask,去除重复数据显示
@@ -2884,6 +2893,7 @@ if __name__=='__main__':
2884
2893
 
2885
2894
  def find_peers_china(industry='',top=20,rank=20,sw_level='2'):
2886
2895
  """
2896
+ ===========================================================================
2887
2897
  功能:找出一个申万行业的上市公司排名
2888
2898
  主要参数:
2889
2899
  industry:申万行业名称。当industry = '',显示的内容由sw_level控制。申万二级行业分类
@@ -3480,18 +3490,22 @@ def contains_chinese(text):
3480
3490
  #==============================================================================
3481
3491
  if __name__=='__main__':
3482
3492
  ticker='600791.SS'
3493
+ ticker='689009.SS'
3483
3494
 
3484
3495
  ticker=['600791.SS','东阿阿胶']
3485
3496
  level='1'
3486
3497
 
3487
- find_industry_sw(ticker)
3498
+ find_industry_sw(ticker,level='1')
3488
3499
 
3489
3500
  def find_industry_sw(ticker,level='1',ticker_order=True,max_sleep=30):
3490
3501
  """
3502
+ ===========================================================================
3491
3503
  功能:寻找一只或一组股票所属的申万行业,支持股票代码和股票名称。
3492
- level='1':默认只查找申万1级行业,以便节省时间
3493
- ticker_order=True:默认输出结果按照ticker中的顺序,而非按照所属行业排序
3494
- max_sleep:为防止反爬虫,默认每次爬虫后睡眠最多几秒钟
3504
+ level='1':默认只查找申万1级行业;查找2/3级行业时间较久,可能触发反爬虫机制。
3505
+ ticker_order=True:默认输出结果按照ticker中的顺序,而非按照所属行业排序。
3506
+ max_sleep:为防止触发反爬虫机制,默认每次爬虫后睡眠最多30秒钟。
3507
+
3508
+ 返回值:查找结果df。
3495
3509
  """
3496
3510
  print(" Searching shenwan industries for securities ... ...")
3497
3511
 
@@ -3620,21 +3634,24 @@ if __name__=='__main__':
3620
3634
 
3621
3635
  peers=stock_industry_peer_em(ticker,indicator="市盈率",rank=10)
3622
3636
 
3623
- def stock_peers_em(ticker='',indicator='',rank=10, \
3624
- force_show_stock=False, \
3637
+ def stock_peers_em(ticker='',indicator='市盈率',rank=10, \
3638
+ force_show_stock=True, \
3625
3639
  font_size="16px",facecolor="papayawhip", \
3626
3640
  numberPerLine=5):
3627
3641
  """
3628
- 功能:基于东方财富行业分类,查找股票所属的行业板块以及主要同行排名
3629
- 特点:行业分类较粗糙,略胜于无
3642
+ ===========================================================================
3643
+ 功能:基于东方财富行业分类,查找股票所属的行业板块以及主要同行排名。
3644
+ 特点:行业分类较粗糙,略胜于无。
3630
3645
  主要参数:
3631
- ticker:股票代码,默认''显示所有板块名称
3632
- indicator:排名指标,默认''。例如:"股价"、"流动性"、"市净率"、"市盈率"
3633
- rank:排名数量,默认10前十名
3634
- force_show_stock:是否显示股票信息,默认False
3635
- font_size:表格字体大小,默认"16px"
3636
- facecolor:输出表格的背景颜色,默认"papayawhip",
3637
- numberPerLine:输出表格中的每行显示个数,默认5
3646
+ ticker:股票代码,默认''显示所有板块名称。
3647
+ indicator:排名指标,默认''。例如:"股价"、"流动性"、"市净率"、"市盈率"
3648
+ rank:排名数量,默认10前十名。
3649
+ force_show_stock:是否显示股票信息,默认False
3650
+ font_size:表格字体大小,默认"16px"
3651
+ facecolor:输出表格的背景颜色,默认"papayawhip"
3652
+ numberPerLine:输出表格中的每行显示个数,默认5
3653
+
3654
+ 注意:若结果异常,可尝试升级插件akshare。
3638
3655
 
3639
3656
  示例:
3640
3657
  industries=stock_peers_em() # 显示东方财富所有行业板块分类
@@ -3662,6 +3679,7 @@ def stock_peers_em(ticker='',indicator='',rank=10, \
3662
3679
  except:
3663
3680
  if not ticker=='':
3664
3681
  print(" #Warning(stock_peer_em): stock info not found for",ticker)
3682
+ print(" Solution: if stock code is correct, upgrade akshare and try again")
3665
3683
 
3666
3684
  df_em=ak.stock_board_industry_name_em()
3667
3685
  #df_em.sort_values(by="板块名称",ascending=True,inplace=True)
@@ -3724,6 +3742,7 @@ def stock_peers_em(ticker='',indicator='',rank=10, \
3724
3742
  df_disp=cfg[collist].tail(abs(rank))
3725
3743
 
3726
3744
  #强制显示所选股票
3745
+ #if force_show_stock and rank != 10:
3727
3746
  if force_show_stock:
3728
3747
  #所选股票是否在其中?
3729
3748
  if not ticker[:6] in list(df_disp["代码"]):
@@ -3779,8 +3798,22 @@ def concept_stocks_em(concept='',ticker='',indicator="市盈率",rank=10, \
3779
3798
  force_show_stock=False, \
3780
3799
  font_size="16px",facecolor="papayawhip",numberPerLine=5):
3781
3800
  """
3782
- 功能:基于东方财富概念板块,查找关键字相关概念以及股票业绩
3783
- 特点:概念板块划分细致,同一股票可能分属多个板块,与行业分类不同
3801
+ ===========================================================================
3802
+ 功能:基于东方财富概念板块,查找关键字相关概念以及股票业绩。
3803
+ 特点:概念板块划分细致,同一股票可能分属多个板块,与行业分类不同。
3804
+ 参数:
3805
+ concept:概念板块名称,或名称中的关键字,默认''输出所有概念板块名称;
3806
+ 若查找到多个名称,则优先输出查找到的名称;
3807
+ 若仅仅找到一个板块,则按indicator输出该板块的股票排行。
3808
+ ticker:股票代码,默认''
3809
+ indicator:指标名称,默认"市盈率",还支持:股价,市净率,涨跌幅,流动性,换手率。
3810
+ rank:排名,支持正负数,默认10。
3811
+ force_show_stock:若ticker不为空,且不在rank范围内,是否强制显示该股票,默认False。
3812
+ font_size:显示字体大小,默认"16px"。
3813
+ facecolor:表格背景颜色,默认"papayawhip"。
3814
+ numberPerLine:当显示板块名称时,每行显示个数,默认5。
3815
+
3816
+ 返回值:df
3784
3817
  """
3785
3818
  if indicator in ["股价","股票价格","价格","收盘价","价位"]:
3786
3819
  indicator="最新价"
@@ -4020,9 +4053,10 @@ def stock_peers_sw(ticker):
4020
4053
  print("\n #Warning(stock_peers_sw): failed to search peers for",ticker)
4021
4054
  print(" Possible solutions:")
4022
4055
  print(" Try first: upgrade akshare, restart Jupyter and try again")
4023
- print(" If not working, uninstall anaconda and reinstall a newer version")
4056
+ #print(" If not working, uninstall anaconda and reinstall a newer version")
4024
4057
 
4025
4058
  #查找股票在行业板块中的位置
4059
+ ticker_item=''
4026
4060
  if not ilist=='':
4027
4061
  ticker6=ticker[:6]
4028
4062
  for i in ilist:
@@ -4030,12 +4064,12 @@ def stock_peers_sw(ticker):
4030
4064
  ticker_item=i
4031
4065
  ticker_pos=ilist.index(i)+1
4032
4066
  break
4033
-
4034
- footnote0="注:"
4035
- footnote1=ticker_item+"在申万行业"+hangye_final+"指数中的权重排名为"+str(ticker_pos)+'/'+str(len(ilist))
4036
- footnote2="该指数的权重排名依据主要包括公司的市值规模、流动性以及市场代表性"
4037
- footnote=footnote0+'\n'+footnote1+'\n'+footnote2
4038
- print(footnote)
4067
+ if ticker_item != '':
4068
+ footnote0="注:"
4069
+ footnote1=ticker_item+"在申万行业"+hangye_final+"指数中的权重排名为"+str(ticker_pos)+'/'+str(len(ilist))
4070
+ footnote2="该指数的权重排名依据主要包括公司的市值规模、流动性以及市场代表性"
4071
+ footnote=footnote0+'\n'+footnote1+'\n'+footnote2
4072
+ print(footnote)
4039
4073
  return
4040
4074
 
4041
4075
  #==============================================================================
siat/security_trend2.py CHANGED
@@ -198,7 +198,7 @@ def security_trend(ticker,indicator='Close',adjust='', \
198
198
  注意:本参数需要特殊访问获取数据。
199
199
 
200
200
  ret_type、RF、regression_period和market_index:仅用于计算RAR指标和CAPM贝塔系数。
201
- ret_type:指定计算RAR的收益率类型,支持滚动和扩展收益率,但不建议混合使用。
201
+ ret_type:指定计算RAR的收益率类型,支持滚动和扩展收益率,不同种类的计算结果之间不可比。
202
202
  RF:指定年化无风险利率,非百分比数值。
203
203
  regression_period:指定CAPM回归时的日期期间跨度,为日历日(自然日),默认一年。
204
204
  market_index:用于计算CAPM回归贝塔系数时的市场收益率。
@@ -523,6 +523,7 @@ def security_trend(ticker,indicator='Close',adjust='', \
523
523
  axhline_value=axhline_value,axhline_label=axhline_label, \
524
524
  preprocess=preprocess,linewidth=linewidth, \
525
525
  scaling_option=scaling_option, \
526
+ band_area=band_area, \
526
527
  graph=graph,loc=loc1, \
527
528
  annotate=annotate,annotate_value=annotate_value, \
528
529
  smooth=smooth, \
@@ -539,7 +540,8 @@ def security_trend(ticker,indicator='Close',adjust='', \
539
540
  print("Scenario 6: indicator_group2 RAR")
540
541
  print("attention_value=",attention_value)
541
542
  print("attention_point=",attention_point)
542
-
543
+
544
+ # ret_type要使用复权价
543
545
  df=compare_rar_security(ticker=tickers,start=fromdate,end=todate,rar=measures, \
544
546
  ret_type=ret_type,RF=RF,regression_period=regression_period, \
545
547
  attention_value=attention_value,attention_value_area=attention_value_area, \
@@ -556,11 +558,17 @@ def security_trend(ticker,indicator='Close',adjust='', \
556
558
 
557
559
  # 情形7:单个或多个证券,CAPM贝塔系数=========================================
558
560
  if indicator_group4:
561
+ #if 'adj' in ret_type.lower() and adjust == '':
562
+ if adjust == '':
563
+ # 使用前复权价
564
+ adjust='qfq'
565
+
559
566
  df=compare_beta_security(ticker=tickers,start=fromdate,end=todate, \
560
567
  adjust=adjust, \
561
568
  RF=RF,regression_period=regression_period, \
562
569
  attention_value=attention_value,attention_value_area=attention_value_area, \
563
570
  attention_point=attention_point,attention_point_area=attention_point_area, \
571
+ band_area=band_area, \
564
572
  graph=graph,facecolor=facecolor,loc=loc1, \
565
573
  annotate=annotate,annotate_value=annotate_value, \
566
574
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
siat/stock.py CHANGED
@@ -24,7 +24,8 @@ from siat.security_price2 import *
24
24
 
25
25
  #==============================================================================
26
26
  import matplotlib.pyplot as plt
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 #横轴字体大小
@@ -71,7 +72,8 @@ def reset_plt():
71
72
 
72
73
  #尝试恢复绘图尺寸
73
74
  #统一设定绘制的图片大小:数值为英寸,1英寸=100像素
74
- plt.rcParams['figure.figsize']=(12.8,7.2)
75
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
76
+ plt.rcParams['figure.figsize']=(12.8,6.4)
75
77
  plt.rcParams['figure.dpi']=300
76
78
  plt.rcParams['font.size'] = 13
77
79
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小
@@ -987,7 +989,7 @@ def security_mindicators(ticker,measures,
987
989
  titletxt=text_lang("证券趋势分析:","Security Trend: ")+ticker_name(ticker,ticker_type=ticker_type)
988
990
 
989
991
  draw_lines2(df,y_label,x_label,axhline_value,axhline_label,titletxt, \
990
- data_label=False,resample_freq='6H',smooth=smooth, \
992
+ data_label=False,resample_freq='1D',smooth=smooth, \
991
993
  date_range=date_range,date_freq=date_freq,date_fmt='%Y-%m-%d', \
992
994
  attention_value=attention_value,attention_value_area=attention_value_area, \
993
995
  attention_point=attention_point,attention_point_area=attention_point_area, \
@@ -1963,6 +1965,7 @@ def compare_msecurity(tickers,measure,start,end, \
1963
1965
  preprocess='none',linewidth=1.5, \
1964
1966
  scaling_option='start', \
1965
1967
  plus_sign=False, \
1968
+ band_area='', \
1966
1969
  graph=True,loc='best',facecolor='whitesmoke', \
1967
1970
  annotate=False,annotate_value=False, \
1968
1971
  smooth=True, \
@@ -2046,7 +2049,16 @@ def compare_msecurity(tickers,measure,start,end, \
2046
2049
  continue
2047
2050
 
2048
2051
  df_tmp1=pd.DataFrame(df_tmp[measure])
2049
- df_tmp1.rename(columns={measure:ticker_name(t,tt)},inplace=True)
2052
+
2053
+ tname=ticker_name(t,tt)
2054
+ df_tmp1.rename(columns={measure:tname},inplace=True)
2055
+
2056
+ # 将band_area中的ticker替换为tname
2057
+ if band_area != '':
2058
+ for index, item in enumerate(band_area):
2059
+ if item == t:
2060
+ band_area[index] = tname
2061
+
2050
2062
  if len(dfs)==0:
2051
2063
  dfs=df_tmp1
2052
2064
  else:
@@ -2139,6 +2151,7 @@ def compare_msecurity(tickers,measure,start,end, \
2139
2151
  data_label=False,resample_freq='H',smooth=smooth,linewidth=linewidth,loc=loc, \
2140
2152
  attention_value=attention_value,attention_value_area=attention_value_area, \
2141
2153
  attention_point=attention_point,attention_point_area=attention_point_area, \
2154
+ band_area=band_area, \
2142
2155
  annotate=annotate,annotate_value=annotate_value,plus_sign=plus_sign, \
2143
2156
  mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor)
2144
2157
 
@@ -2573,7 +2586,7 @@ def candlestick_demo(stkcd,fromdate,todate, \
2573
2586
 
2574
2587
  print('')
2575
2588
  #specify the size of the graph
2576
- #fig,ax=plt.subplots(figsize=(10,6))
2589
+ #fig,ax=plt.subplots(figsize=(12.8,6.4))
2577
2590
  fig,ax=plt.subplots()
2578
2591
 
2579
2592
  #绘制各个价格的折线图
siat/stock_profile.py CHANGED
@@ -515,7 +515,8 @@ def plot_sustainability(sustainability,option="ESG"):
515
515
  else: width=round(2.9/l,2)
516
516
  #print("Firms:",s.index,", Width:",width)
517
517
 
518
- fig,ax=plt.subplots(figsize=(10,6))
518
+ #fig,ax=plt.subplots(figsize=(10,6))
519
+ fig,ax=plt.subplots(figsize=(12.8,6.4))
519
520
 
520
521
  #绘制分数和分位数图
521
522
  if option=="ESG":
siat/stock_technical.py CHANGED
@@ -25,7 +25,8 @@ from siat.stock import *
25
25
  from siat.valuation import *
26
26
  #==============================================================================
27
27
  import matplotlib.pyplot as plt
28
- plt.rcParams['figure.figsize']=(12.8,7.2)
28
+ #plt.rcParams['figure.figsize']=(12.8,7.2)
29
+ plt.rcParams['figure.figsize']=(12.8,6.4)
29
30
  plt.rcParams['figure.dpi']=300
30
31
  plt.rcParams['font.size'] = 13
31
32
  plt.rcParams['xtick.labelsize']=11 #横轴字体大小