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/grafix.py CHANGED
@@ -30,7 +30,8 @@ plt.rcParams['xtick.direction'] = 'inout' # 将x轴的刻度线方向设置向
30
30
  plt.rcParams['ytick.direction'] = 'inout' # 将y轴的刻度方向设置向内内
31
31
 
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 #横轴字体大小
@@ -124,7 +125,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
124
125
  resample_freq='H',loc='best', \
125
126
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
126
127
  mark_top=True,mark_bottom=True,mark_end=True, \
127
- facecolor='whitesmoke',maxticks=10,translate=False):
128
+ facecolor='whitesmoke',maxticks=15,translate=False):
128
129
  """
129
130
  功能:绘制折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
130
131
  假定:数据表有索引,且已经按照索引排序
@@ -421,7 +422,8 @@ def plot_line2(df1,ticker1,colname1,label1, \
421
422
  yline=999,attention_value_area='', \
422
423
  xline=999,attention_point_area='', \
423
424
  resample_freq='H',loc1='best',loc2='best', \
424
- color1='red',color2='blue',facecolor='whitesmoke'):
425
+ color1='red',color2='blue',facecolor='whitesmoke', \
426
+ maxticks=20):
425
427
  """
426
428
  功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
427
429
  假定:数据表有索引,且已经按照索引排序
@@ -456,7 +458,8 @@ def plot_line2(df1,ticker1,colname1,label1, \
456
458
  xline=xline,attention_point_area=attention_point_area, \
457
459
  resample_freq=resample_freq, \
458
460
  loc1=loc1,loc2=loc2, \
459
- color1=color1,color2=color2,facecolor=facecolor)
461
+ color1=color1,color2=color2,facecolor=facecolor, \
462
+ maxticks=maxticks)
460
463
  else:
461
464
  plot_line2_twinx(df1,ticker1,colname1,label1, \
462
465
  df2,ticker2,colname2,label2, \
@@ -464,7 +467,8 @@ def plot_line2(df1,ticker1,colname1,label1, \
464
467
  resample_freq=resample_freq, \
465
468
  xline=xline,attention_point_area=attention_point_area, \
466
469
  loc1=loc1,loc2=loc2, \
467
- color1=color1,color2=color2,facecolor=facecolor)
470
+ color1=color1,color2=color2,facecolor=facecolor, \
471
+ maxticks=maxticks)
468
472
  return
469
473
 
470
474
 
@@ -478,7 +482,8 @@ def plot2_line2(df1,ticker1,colname1,label1, \
478
482
  xline=999,attention_point_area='', \
479
483
  resample_freq='H',loc1='best',loc2='best', \
480
484
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
481
- color1='red',color2='blue',facecolor='whitesmoke'):
485
+ color1='red',color2='blue',facecolor='whitesmoke', \
486
+ maxticks=20):
482
487
  """
483
488
  注意:可能有bug,twinx=True时左纵坐标轴和横坐标轴标记可能发生重叠!!!暂不建议使用
484
489
  facecolor不起作用
@@ -517,7 +522,8 @@ def plot2_line2(df1,ticker1,colname1,label1, \
517
522
  resample_freq=resample_freq, \
518
523
  loc1=loc1,loc2=loc2, \
519
524
  date_range=date_range,date_freq=date_freq,date_fmt=date_fmt, \
520
- color1=color1,color2=color2,facecolor=facecolor)
525
+ color1=color1,color2=color2,facecolor=facecolor, \
526
+ maxticks=maxticks)
521
527
  else:
522
528
  plot_line2_twinx2(df1,ticker1,colname1,label1, \
523
529
  df2,ticker2,colname2,label2, \
@@ -526,7 +532,9 @@ def plot2_line2(df1,ticker1,colname1,label1, \
526
532
  resample_freq=resample_freq, \
527
533
  loc1=loc1,loc2=loc2, \
528
534
  date_range=date_range,date_freq=date_freq,date_fmt=date_fmt, \
529
- color1=color1,color2=color2,facecolor=facecolor)
535
+ color1=color1,color2=color2,facecolor=facecolor, \
536
+ maxticks=maxticks)
537
+
530
538
  return
531
539
 
532
540
 
@@ -542,7 +550,7 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
542
550
  resample_freq='H', \
543
551
  loc1='best',loc2='best', \
544
552
  color1='red',color2='blue',facecolor='whitesmoke', \
545
- ticker_type='auto'):
553
+ ticker_type='auto',maxticks=15):
546
554
  """
547
555
  功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
548
556
  假定:数据表有索引,且已经按照索引排序
@@ -749,6 +757,11 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
749
757
 
750
758
  # 同轴绘图时,loc1/loc2未用上!
751
759
  plt.legend(loc=loc1,fontsize=legend_txt_size)
760
+
761
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
762
+ import matplotlib.dates as mdates
763
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
764
+
752
765
  plt.gcf().autofmt_xdate(ha="center") # 优化标注(自动倾斜)
753
766
  try:
754
767
  plt.gca().set_facecolor(facecolor)
@@ -793,7 +806,8 @@ def plot_line2_coaxial2(df01,ticker1,colname1,label1, \
793
806
  loc1='best',loc2='best', \
794
807
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
795
808
  color1='red',color2='blue',facecolor='whitesmoke', \
796
- ticker_type='auto'):
809
+ ticker_type='auto', \
810
+ maxticks=15):
797
811
  """
798
812
  功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
799
813
  假定:数据表有索引,且已经按照索引排序
@@ -1022,6 +1036,11 @@ def plot_line2_coaxial2(df01,ticker1,colname1,label1, \
1022
1036
 
1023
1037
  # 同轴绘图时,loc1/loc2未用上!
1024
1038
  plt.legend(loc=loc1,fontsize=legend_txt_size)
1039
+
1040
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
1041
+ import matplotlib.dates as mdates
1042
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1043
+
1025
1044
  plt.gcf().autofmt_xdate(ha="center") # 优化标注(自动倾斜)
1026
1045
  try:
1027
1046
  plt.gca().set_facecolor(facecolor)
@@ -1045,7 +1064,8 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
1045
1064
  xline=999,attention_point_area='', \
1046
1065
  loc1='upper left',loc2='lower left', \
1047
1066
  color1='red',color2='blue',facecolor='whitesmoke', \
1048
- ticker_type='auto'):
1067
+ ticker_type='auto', \
1068
+ maxticks=15):
1049
1069
  """
1050
1070
  功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
1051
1071
  假定:数据表有索引,且已经按照索引排序
@@ -1234,6 +1254,11 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
1234
1254
  label2txt=label2+'('+ticker_name(ticker2,ticker_type_list[1])+')'
1235
1255
  ax2.set_ylabel(label2txt,fontsize=ylabel_txt_size)
1236
1256
  ax2.legend(loc=loc2,fontsize=legend_txt_size)
1257
+
1258
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
1259
+ import matplotlib.dates as mdates
1260
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1261
+ ax2.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1237
1262
 
1238
1263
  #自动优化x轴标签
1239
1264
  plt.gcf().autofmt_xdate(ha="center") # 优化标注(自动倾斜)
@@ -1267,7 +1292,8 @@ def plot_line2_twinx2(df01,ticker1,colname1,label1, \
1267
1292
  resample_freq='H',loc1='upper left',loc2='lower left', \
1268
1293
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
1269
1294
  color1='red',color2='blue',facecolor='whitesmoke', \
1270
- ticker_type='auto'):
1295
+ ticker_type='auto', \
1296
+ maxticks=15):
1271
1297
  """
1272
1298
  功能:绘制两个证券的折线图。如果power=0不绘制趋势图,否则绘制多项式趋势图
1273
1299
  假定:数据表有索引,且已经按照索引排序
@@ -1482,6 +1508,11 @@ def plot_line2_twinx2(df01,ticker1,colname1,label1, \
1482
1508
  label2txt=label2+'('+ticker_name(ticker2,ticker_type_list[1])+')'
1483
1509
  ax2.set_ylabel(label2txt,fontsize=ylabel_txt_size)
1484
1510
  ax2.legend(loc=loc2,fontsize=legend_txt_size)
1511
+
1512
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
1513
+ import matplotlib.dates as mdates
1514
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1515
+ ax2.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1485
1516
 
1486
1517
  #自动优化x轴标签
1487
1518
  #格式化时间轴标注
@@ -1520,7 +1551,9 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
1520
1551
  attention_value='',attention_value_area='', \
1521
1552
  attention_point='',attention_point_area='', \
1522
1553
  mark_top=False,mark_bottom=False,mark_end=False, \
1523
- ticker_type='auto',facecolor='whitesmoke',maxticks=10,translate=False):
1554
+ ticker_type='auto',facecolor='whitesmoke', \
1555
+ maxticks_enable=True,maxticks=15, \
1556
+ translate=False):
1524
1557
  """
1525
1558
  函数功能:根据df的内容绘制折线图
1526
1559
  输入参数:
@@ -1658,7 +1691,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
1658
1691
  if annotate_value: #在标记曲线名称的同时标记其末端数值
1659
1692
  #y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
1660
1693
  y1=str(round(y_end,2)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 1 else str(round(y_end,3))
1661
- plt.annotate(text=' '+auto_translate2(c,translate)+':'+y1,
1694
+ plt.annotate(text=' '+auto_translate2(c,translate)+': '+y1,
1662
1695
  xy=(x_end, y_end),
1663
1696
  xytext=(x_end, y_end),fontsize=annotate_size,
1664
1697
  color=last_line_color)
@@ -1838,7 +1871,11 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
1838
1871
  if axhline_label !="":
1839
1872
  if '零线' in axhline_label:
1840
1873
  axhline_label=''
1841
- plt.axhline(y=axhline_value,label=auto_translate2(axhline_label,translate),color='black',linestyle=':',linewidth=2)
1874
+
1875
+ max_values = df2.max(numeric_only=True); global_max_values=max_values.max()
1876
+ min_values = df2.min(numeric_only=True); global_min_values=min_values.min()
1877
+ if global_max_values >= axhline_value and global_min_values <= axhline_value:
1878
+ plt.axhline(y=axhline_value,label=auto_translate2(axhline_label,translate),color='black',linestyle=':',linewidth=2)
1842
1879
  #plt.axhline(y=axhline_value,color='purple',linestyle=':',linewidth=1.5)
1843
1880
 
1844
1881
  #坐标轴标记
@@ -1851,9 +1888,10 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
1851
1888
  #图示标题
1852
1889
  plt.title(auto_translate2(title_txt,translate),fontweight='bold',fontsize=title_txt_size)
1853
1890
 
1854
- # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
1855
- import matplotlib.dates as mdates
1856
- ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1891
+ if maxticks_enable:
1892
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
1893
+ import matplotlib.dates as mdates
1894
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
1857
1895
 
1858
1896
  plt.gcf().autofmt_xdate(ha="center") # 优化标注(自动倾斜)
1859
1897
  try:
@@ -1913,7 +1951,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
1913
1951
  attention_point_area='', \
1914
1952
  annotate=False,annotate_value=False, \
1915
1953
  mark_top=False,mark_bottom=False,mark_end=False, \
1916
- facecolor='whitesmoke',maxticks=10,translate=False):
1954
+ facecolor='whitesmoke',maxticks=20,translate=False):
1917
1955
  """
1918
1956
  函数功能:根据df的内容绘制折线图
1919
1957
  输入参数:
@@ -2068,7 +2106,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
2068
2106
  if annotate_value: #在标记曲线名称的同时标记其末端数值
2069
2107
  #y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
2070
2108
  y1=str(int(y_end)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,4))
2071
- plt.annotate(text=auto_translate2(c,translate)+':'+y1,
2109
+ plt.annotate(text=auto_translate2(c,translate)+': '+y1,
2072
2110
  xy=(x_end, y_end),
2073
2111
  xytext=(x_end, y_end),fontsize=annotate_size,
2074
2112
  color=last_line_color)
@@ -2359,7 +2397,8 @@ def plot_2lines(df01,colname1,label1, \
2359
2397
  df02,colname2,label2, \
2360
2398
  ylabeltxt,titletxt,footnote,hline=0,vline=0,resample_freq='H', \
2361
2399
  date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
2362
- facecolor='whitesmoke'):
2400
+ facecolor='whitesmoke', \
2401
+ maxticks=15):
2363
2402
  """
2364
2403
  功能:绘制两个证券的折线图。如果hline=0不绘制水平虚线,vline=0不绘制垂直虚线
2365
2404
  假定:数据表有日期索引,且已经按照索引排序
@@ -2449,6 +2488,10 @@ def plot_2lines(df01,colname1,label1, \
2449
2488
  plt.xlabel(footnote,fontsize=xlabel_txt_size,ha='center')
2450
2489
  plt.legend(loc='best',fontsize=legend_txt_size)
2451
2490
 
2491
+ # 使用 AutoDateLocator 自动选择最佳间隔,目的是显示最后一个日期,亲测有效!!!
2492
+ import matplotlib.dates as mdates
2493
+ ax.xaxis.set_major_locator(mdates.AutoDateLocator(maxticks=maxticks))
2494
+
2452
2495
  plt.gcf().autofmt_xdate(ha="center") # 优化标注(自动倾斜)
2453
2496
  try:
2454
2497
  plt.gca().set_facecolor(facecolor)
@@ -2717,7 +2760,7 @@ if __name__=='__main__':
2717
2760
  firstColSpecial=True
2718
2761
  colWidth=0.1
2719
2762
  tabScale=2
2720
- figsize=(10,6)
2763
+ figsize=(12.8,6.4)
2721
2764
  cellLoc='right'
2722
2765
  fontsize=10
2723
2766
 
@@ -2729,7 +2772,7 @@ if __name__=='__main__':
2729
2772
  pandas2plttable(df)
2730
2773
 
2731
2774
  def pandas2plttable(df,titletxt,firstColSpecial=True,colWidth=0.1,tabScale=2,cellLoc='right', \
2732
- figsize=(10,4),fontsize=13,auto_len=False,title_x=0.5):
2775
+ figsize=(12.8,6.4),fontsize=13,auto_len=False,title_x=0.5):
2733
2776
  """
2734
2777
  功能:将一个df转换为matplotlib表格格式,打印图形表格,适应性广
2735
2778
  firstColSpecial:第一列是否特殊处理,默认True
@@ -2781,7 +2824,6 @@ def pandas2plttable(df,titletxt,firstColSpecial=True,colWidth=0.1,tabScale=2,cel
2781
2824
  for i in range(0,len(df)):
2782
2825
  vals=vals+[list(df.iloc[i])]
2783
2826
 
2784
- #plt.figure(figsize=figsize,dpi=figdpi)
2785
2827
  plt.figure(figsize=figsize)
2786
2828
 
2787
2829
  if not auto_len:
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=':')