siat 3.1.28__py3-none-any.whl → 3.2.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/stock_technical.py CHANGED
@@ -2435,9 +2435,21 @@ if __name__ =="__main__":
2435
2435
 
2436
2436
  start='2024-3-1'; end='2024-4-12'; ahead_days=30*3
2437
2437
 
2438
- technical='EMV'; indicator='Close'; line='default'
2438
+ technical='EMV'; indicator='Close'
2439
2439
 
2440
- df=security_technical_research(ticker,start,end,technical=technical, \
2440
+ attention_values=[0,25,50,75]
2441
+ ticker_type='auto'; source='auto'
2442
+ ahead_days=30*4
2443
+ resample_freq='6H'; smooth=True;linewidth=1.5
2444
+ date_range=False; date_freq=False; annotate=False
2445
+ graph=['ALL']; printout=False
2446
+ loc1='best'; loc2='best'
2447
+
2448
+ facecolor=['whitesmoke','papayawhip']
2449
+ price_line_style='dotted'; price_line_color='red'; price_line_width=5; price_line_marker='.'
2450
+
2451
+
2452
+ df=security_technical2(ticker,start,end,technical=technical, \
2441
2453
  loc1='lower left',loc2='lower right')
2442
2454
 
2443
2455
  tlist=['RSI','OBV','MACD','KDJ','VOL','PSY','ARBR','CR','EMV','Bollinger', \
@@ -2446,6 +2458,11 @@ if __name__ =="__main__":
2446
2458
  df=security_technical2(ticker,start,end,technical=t,loc1='lower left',loc2='lower right')
2447
2459
 
2448
2460
  def security_technical2(ticker,start='default',end='default', \
2461
+ technical=['MACD'],indicator='Close', \
2462
+ ticker_type='auto',source='auto', \
2463
+ attention_values=[0,25,50,75,100], \
2464
+
2465
+
2449
2466
  RSI_days=[6,24], \
2450
2467
  OBV_days=5, \
2451
2468
 
@@ -2476,13 +2493,14 @@ def security_technical2(ticker,start='default',end='default', \
2476
2493
  resample_freq='6H',smooth=True,linewidth=1.5, \
2477
2494
  date_range=False,date_freq=False,annotate=False, \
2478
2495
 
2479
- technical=['MACD'],indicator='Close', \
2480
2496
  graph=['ALL'],printout=False, \
2481
2497
  loc1='best',loc2='best', \
2482
- ticker_type='auto',source='auto', \
2483
2498
 
2484
- attention_values=[0,30,50,80], \
2485
- facecolor='papayawhip',price_line_color='red', \
2499
+ facecolor=['whitesmoke','papayawhip'], \
2500
+ #price_line_style=(0,(1,1)), \
2501
+ price_line_style='dotted', \
2502
+ price_line_color=['red','green'], \
2503
+ price_line_width=5,price_line_marker='o', \
2486
2504
 
2487
2505
  more_details=False):
2488
2506
  """
@@ -2537,6 +2555,7 @@ def security_technical2(ticker,start='default',end='default', \
2537
2555
  print(" #Warning(security_technical2): no prices found for",ticker,'as type',ticker_type)
2538
2556
  return None
2539
2557
 
2558
+ price['up_down']=price['Close']-price['Open']
2540
2559
 
2541
2560
  #计算技术指标
2542
2561
  df=calc_technical(price,fromdate,todate, \
@@ -2617,7 +2636,8 @@ def security_technical2(ticker,start='default',end='default', \
2617
2636
  'W%R':[1,''],
2618
2637
  'ROC':[1,''],
2619
2638
  'DMI':[1,''],
2620
- 'DMA':[1,''],}
2639
+ 'DMA':[1,''],
2640
+ 'Volume':[1/1000000,'百万']}
2621
2641
 
2622
2642
  mag_times=magnitude_list[technical1][0]
2623
2643
  mag_label=magnitude_list[technical1][1]
@@ -2649,18 +2669,55 @@ def security_technical2(ticker,start='default',end='default', \
2649
2669
  for c in tech_line_collist:
2650
2670
  df[c]=df[c] * mag_times
2651
2671
 
2672
+ df['Volume']=df['Volume'] * magnitude_list['Volume'][0]
2673
+
2652
2674
  #字段排序
2653
2675
  tech_line_collist.sort()
2654
- df1=df[tech_line_collist+[indicator]]
2676
+ df1=df[tech_line_collist+[indicator,'Volume','up_down']]
2655
2677
 
2656
2678
  #绘图----------------------------------------------------------------------
2657
2679
  import matplotlib.pyplot as plt
2658
-
2680
+ import matplotlib.dates as mdates
2681
+ #import matplotlib.gridspec as gridspec
2682
+ """
2659
2683
  fig = plt.figure()
2660
2684
  ax = fig.add_subplot(111)
2685
+ """
2686
+ """
2687
+ #图ax在上方,ax3在下方
2688
+ fig, (ax, ax3) = plt.subplots(2, sharex=True,figsize=(12,9))
2689
+
2661
2690
  #plt.gca().set_facecolor('whitesmoke')
2662
2691
  fig.gca().set_facecolor(facecolor) #放在这里生效,放尾部不生效
2692
+ """
2693
+ # 创建两行的布局,上半部分高度为4,下半部分高度为1
2694
+ fig = plt.figure(figsize=(14,9))
2695
+ #fig.gca().set_facecolor(facecolor)
2696
+
2697
+ if isinstance(facecolor,str):
2698
+ facecolor1=facecolor2=facecolor
2699
+ elif isinstance(facecolor,list):
2700
+ if len(facecolor) >= 2:
2701
+ facecolor1=facecolor[0]
2702
+ facecolor2=facecolor[1]
2703
+ elif len(facecolor) == 1:
2704
+ facecolor1=facecolor2=facecolor[0]
2705
+ else:
2706
+ facecolor1='whitesmoke'; facecolor2='papayawhip'
2663
2707
 
2708
+ gs = fig.add_gridspec(2, 1, height_ratios=[4, 1], hspace=0.05)
2709
+ ax = fig.add_subplot(gs[0])
2710
+ try:
2711
+ ax.set_facecolor(facecolor1)
2712
+ except:
2713
+ ax.set_facecolor('whitesmoke')
2714
+
2715
+ ax3 = fig.add_subplot(gs[1], sharex=ax)
2716
+ try:
2717
+ ax3.set_facecolor(facecolor2)
2718
+ except:
2719
+ ax3.set_facecolor('papayawhip')
2720
+
2664
2721
  """
2665
2722
  line0=False; line30=False; line50=False; line80=False
2666
2723
  for l in tech_line_collist:
@@ -2689,7 +2746,13 @@ def security_technical2(ticker,start='default',end='default', \
2689
2746
  attention_draws=[False] * len(attention_values)
2690
2747
 
2691
2748
  for l in tech_line_collist:
2692
- ax.plot(df1.index,df1[l],label=l.upper())
2749
+ labeltxt=l.upper()
2750
+ if labeltxt =='DEA':
2751
+ labeltxt='慢线(DEA)'
2752
+ if labeltxt =='DIF':
2753
+ labeltxt='快线(DIF)'
2754
+
2755
+ ax.plot(df1.index,df1[l],label=labeltxt)
2693
2756
 
2694
2757
  #判断是否绘制关注线
2695
2758
  lmax=df1[l].max(); lmin=df1[l].min()
@@ -2703,7 +2766,7 @@ def security_technical2(ticker,start='default',end='default', \
2703
2766
 
2704
2767
  #如果需要绘制关注线,且尚未绘制过,则绘制
2705
2768
  if line_al and not attention_draws[pos]:
2706
- plt.axhline(y=attention_values[pos],ls=":",c=color_list[pos],linewidth=2)
2769
+ ax.axhline(y=attention_values[pos],ls=":",c=color_list[pos],linewidth=2)
2707
2770
 
2708
2771
  attention_draws[pos]=True
2709
2772
 
@@ -2712,17 +2775,92 @@ def security_technical2(ticker,start='default',end='default', \
2712
2775
  ylabeltxt1=ylabeltxt1+'('+mag_label+')'
2713
2776
  ax.set_ylabel(ylabeltxt1,fontsize=ylabel_txt_size)
2714
2777
  ax.legend(loc=loc1,fontsize=legend_txt_size)
2778
+
2779
+ interval=int(len(df1)/10)+1
2780
+ ax.xaxis.set_major_locator(mdates.DayLocator(interval=interval)) # 隔interval天一个标记
2781
+ ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
2782
+ #ax.autoscale_view()
2783
+
2784
+ #区分涨跌颜色:红涨绿跌
2785
+ df1up=df1[df1['up_down'] >= 0]
2786
+ df1down=df1[df1['up_down'] < 0]
2787
+
2788
+ #绘制收盘价
2789
+ if isinstance(price_line_color,str):
2790
+ price_line_color1=price_line_color2=price_line_color
2791
+ elif isinstance(price_line_color,list):
2792
+ if len(price_line_color) >= 2:
2793
+ price_line_color1=price_line_color[0]
2794
+ price_line_color2=price_line_color[1]
2795
+ elif len(price_line_color) == 1:
2796
+ price_line_color1=price_line_color2=price_line_color[0]
2797
+ else:
2798
+ price_line_color1='red'; price_line_color2='green'
2715
2799
 
2800
+ import numpy as np
2801
+ df1['segment'] = (np.sign(df1['up_down'].shift(1)) != np.sign(df1['up_down'])).cumsum()
2802
+ seg_list=list(set(list(df1['segment'])))
2803
+
2716
2804
  ax2 = ax.twinx()
2717
2805
  ylabeltxt2='收盘价'
2718
2806
  ax2.set_ylabel(ylabeltxt2,fontsize=ylabel_txt_size)
2719
- ax2.plot(df1.index,df1[indicator],label=ylabeltxt2,linestyle='dotted',color=price_line_color)
2807
+
2808
+ #细灰线先画出轮廓
2809
+ ax2.plot(df1.index,df1[indicator],label='', \
2810
+ linestyle=price_line_style,color='grey',lw=1)
2811
+
2812
+ #不同颜色绘制涨跌价格线
2813
+ first_time=True; second_time=False
2814
+ for seg in seg_list:
2815
+ df1seg=df1[df1['segment']==seg]
2816
+ if df1seg['up_down'].values[0] >=0:
2817
+ seg_color=price_line_color1
2818
+ #labeltxt=ylabeltxt2+'(当日↑)'
2819
+ #labeltxt=ylabeltxt2+'(当日≥开盘价)'
2820
+ labeltxt=ylabeltxt2+'(当日阳线)'
2821
+ else:
2822
+ seg_color=price_line_color2
2823
+ #labeltxt=ylabeltxt2+'(当日↓)'
2824
+ #labeltxt=ylabeltxt2+'(当日<开盘价)'
2825
+ labeltxt=ylabeltxt2+'(当日阴线)'
2826
+
2827
+ if first_time:
2828
+ first_time=False; second_time=True
2829
+ elif second_time:
2830
+ second_time=False
2831
+ else:
2832
+ labeltxt=''
2833
+ """
2834
+ ax2.plot(df1seg.index,df1seg[indicator],label=labeltxt, \
2835
+ linestyle=':',color=seg_color,lw=price_line_width,marker=price_line_marker)
2836
+ """
2837
+ ax2.scatter(df1seg.index,df1seg[indicator],label=labeltxt, \
2838
+ linestyle=':',color=seg_color,lw=price_line_width,marker=price_line_marker)
2839
+
2840
+
2841
+ """
2842
+ ax2.plot(df1.index,df1[indicator],label=ylabeltxt2, \
2843
+ linestyle=price_line_style,color=price_line_color1,lw=price_line_width,marker=price_line_marker)
2844
+ ax2.scatter(df1down.index,df1down[indicator],label=ylabeltxt2, \
2845
+ linestyle=price_line_style,color=price_line_color2,lw=price_line_width,marker=price_line_marker)
2846
+ """
2847
+
2720
2848
  ax2.legend(loc=loc2,fontsize=legend_txt_size)
2721
2849
 
2850
+ #绘制交易量柱状图
2851
+ ax3.bar(df1up.index,df1up['Volume'],color=price_line_color1)
2852
+ ax3.bar(df1down.index,df1down['Volume'],color=price_line_color2)
2853
+
2854
+ ax3.set_ylabel("交易量(百万)",fontsize=ylabel_txt_size -4)
2855
+
2856
+ #fig.text(0.5, 0.04, 'x', ha='center')
2857
+ plt.subplots_adjust(hspace=0.2)
2858
+
2722
2859
  titletxt=ticker_name(ticker)+': '+tech_list[technical1]+technical1
2723
2860
  plt.title(titletxt,fontweight='bold',fontsize=title_txt_size)
2724
2861
 
2725
2862
  plt.gcf().autofmt_xdate()
2863
+ #fig.autofmt_xdate()
2726
2864
 
2727
2865
  plt.show(); plt.close()
2728
2866
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.1.28
3
+ Version: 3.2.1
4
4
  Summary: Securities Investment Analysis Tools (siat)
5
5
  Home-page: https://pypi.org/project/siat/
6
6
  Author: Prof. WANG Dehong, International Business School, Beijing Foreign Studies University
@@ -14,7 +14,7 @@ siat/bond_china.py,sha256=eYv-nMoWSS5fZ4VxnuJ29QFY9GUS6meGiIc0Xjm1fQI,3038
14
14
  siat/bond_test.py,sha256=yUOFw7ddGU-kb1rJdnsjkJWziDNgUR7OLDA7F7Ub91A,5246
15
15
  siat/bond_zh_sina.py,sha256=26BohGcS120utwqg9dJvdGm5OkuNpNu5bco80uOuQpU,4423
16
16
  siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
17
- siat/capm_beta2.py,sha256=UOI4sCz3ld7yezlARqPHvgHzfduDiGeRqNa82dDTCZ8,25849
17
+ siat/capm_beta2.py,sha256=1URX23ugY9uyeut3gdLn3rA3CHZ4Y455gt4IoqY89D8,26892
18
18
  siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
19
19
  siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
20
20
  siat/common.py,sha256=OtdgMsJUTGPuxEvZ6dm0V5V9Vfa2W3fEn22m1vRNfS8,141419
@@ -86,7 +86,7 @@ siat/option_sina_api_test.py,sha256=dn-k_wrQnAaNKHoROvWJEc7lqlU0bwiV2Aa4usWAFGM,
86
86
  siat/proxy_test.py,sha256=erQJrmGs2X46z8Gb1h-7GYQ0rTUcaR8dxHExWoBz2eM,2610
87
87
  siat/quandl_test.py,sha256=EcPoXnLuqzPl5dKyVEZi3j3PJZFpsnU_iNPhLWC9p-A,1552
88
88
  siat/risk_adjusted_return.py,sha256=L5FoeOFzvItT03gNBTCaIo32hUvncOJkbchtHOveSBM,54929
89
- siat/risk_adjusted_return2.py,sha256=PmwOvB0gJ9-v0fhTfl5lZ8eYfRwX07VsADYnSJ5iJb4,64866
89
+ siat/risk_adjusted_return2.py,sha256=mI2ynVICzSIHV4_-jZyZ4vbwI1-zen7Byug31lzViS4,65957
90
90
  siat/risk_adjusted_return_test.py,sha256=m_VHL5AtT74cJv5i7taTeTfnkX48y0AFJk5phawyYWg,3416
91
91
  siat/risk_evaluation.py,sha256=I6B3gty-t--AkDCO0tKF-291YfpnF-IkXcFjqNKCt9I,76286
92
92
  siat/risk_evaluation_test.py,sha256=YEXM96gKzTfwN4U61AS4Rr1tV7KgUvn4rRC6f3iMw9s,3731
@@ -95,14 +95,15 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
95
95
  siat/sector_china.py,sha256=nP6kfYsnaQWZj8dK-zklwSDW8FDS-obZWp_zL0ec2Ig,118603
96
96
  siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
97
97
  siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
98
- siat/security_price2.py,sha256=581xPduTjxEEHSkDNGn4v7VxsZ2C6vHeGJ51XB1GLuQ,25825
99
- siat/security_prices.py,sha256=a5U5qM5iX3Fl2GM8X1ceM5TGE5z32Q3ovMewKgE-6pg,103410
98
+ siat/security_price2.py,sha256=hx0hDixIaTPBnn7Y3BxdYym1v3lkPaWmcTRnJ-JyHJA,25828
99
+ siat/security_prices.py,sha256=RbGCw6Q3-eCX2dy_CjgbjuXwUtJIOPLuNxNstG0VEzM,104397
100
100
  siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
101
101
  siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
102
- siat/security_trend2.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
102
+ siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
103
+ siat/security_trend2.py,sha256=kCFi8NW4uOkSnl4MkWZB5_rfvDqUiQlVH8tGsvUluEY,25219
103
104
  siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
104
105
  siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
105
- siat/stock.py,sha256=dE-AitC0nba2Vf0iU_J2CgN9nB5MA2J2I8EH1zrM97U,140357
106
+ siat/stock.py,sha256=vNHqpYbwPnQM_wnvZ2XwW8oyMOX10h_EAC1hLyOI4Vo,142341
106
107
  siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
107
108
  siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
108
109
  siat/stock_china.py,sha256=zyUyghIrkkkYWlHRRP7Hoblxzfp-jrck60pTJpwMahg,91553
@@ -113,7 +114,8 @@ siat/stock_list_china_test.py,sha256=gv14UwMMvkZqtb6G7DCTSuehIwVHuVwu7w60p6gyHoo
113
114
  siat/stock_prices_kneighbors.py,sha256=WfZvo5EyeBsm-T37zDj7Sl9dPSRq5Bx4JxIJ9IUum6s,36738
114
115
  siat/stock_prices_linear.py,sha256=-OUKRr27L2aStQgJSlJOrJ4gay_G7P-m-7t7cU2Yoqk,13991
115
116
  siat/stock_profile.py,sha256=B3eIwzEmiCqiCaxIlhfdEPsQBoW1PFOe1hkiY3mVF6Y,26038
116
- siat/stock_technical.py,sha256=A4x18mZgYSA8SSiDz4u_O3gd5oVRgbI6JIiBfFY0tVw,116013
117
+ siat/stock_technical-20240620.py,sha256=A4x18mZgYSA8SSiDz4u_O3gd5oVRgbI6JIiBfFY0tVw,116013
118
+ siat/stock_technical.py,sha256=trbGq72OkzqR3s-GOk0mItIll4DaqnrMxh6LXxQaRZY,121108
117
119
  siat/stock_test.py,sha256=E9YJAvOw1VEGJSDI4IZuEjl0tGoisOIlN-g9UqA_IZE,19475
118
120
  siat/stooq.py,sha256=dOc_S5HLrYg48YAKTCs1eX8UTJOOkPM8qLL2KupqlLY,2470
119
121
  siat/temp.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
@@ -134,7 +136,7 @@ siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
134
136
  siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
135
137
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
136
138
  siat/var_model_validation.py,sha256=f-oDewg7bPzyNanz_Y_jLH68NowAA3gXFehW_weKGG0,14898
137
- siat-3.1.28.dist-info/METADATA,sha256=74IePv7Bc_JMuhwxyIrBUnhSp7ECuFEUoRRSQ8BnN-w,1448
138
- siat-3.1.28.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
139
- siat-3.1.28.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
140
- siat-3.1.28.dist-info/RECORD,,
139
+ siat-3.2.1.dist-info/METADATA,sha256=2yqURMD_EzOYQIUgGiAxhnd33FaB7Nz8zgNdVlWLtvk,1447
140
+ siat-3.2.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
141
+ siat-3.2.1.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
142
+ siat-3.2.1.dist-info/RECORD,,
File without changes