siat 3.2.2__py3-none-any.whl → 3.2.4__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/__init__.py CHANGED
@@ -20,12 +20,24 @@ InteractiveShell.ast_node_interactivity='all'
20
20
  try:
21
21
  import pkg_resources
22
22
  current_version=pkg_resources.get_distribution("siat").version
23
+ current_list=current_version.split('.')
23
24
  print("Successfully imported siat version",current_version)
24
25
 
25
26
  import luddite
26
27
  latest_version=luddite.get_version_pypi("siat")
28
+ latest_list=latest_version.split('.')
27
29
 
28
- if latest_version != current_version:
30
+ newest=True
31
+ if current_list[0] < latest_list[0]:
32
+ newest=False
33
+ elif current_list[1] < latest_list[1]:
34
+ newest=False
35
+ elif current_list[2] < latest_list[2]:
36
+ newest=False
37
+ else:
38
+ pass
39
+
40
+ if not newest:
29
41
  print("The latest version of siat is",latest_version,'\n')
30
42
  print("*** If you expect to upgrade siat in Anaconda Prompt, use the instruction below:")
31
43
  print(" pip install siat --upgrade")
@@ -35,7 +47,7 @@ try:
35
47
  print(" pip uninstall siat")
36
48
  print(" pip install siat",'\n')
37
49
 
38
- print("*** If you have a slow internet connection, use an option after the instruction above:")
50
+ print("*** If you have a slow internet connection, use an option trailing the instruction above:")
39
51
  print(" -i https://mirrors.aliyun.com/pypi/simple/",'\n')
40
52
 
41
53
  print("If you have done any of the above, restart the Python (eg. restarting the kernel)")
siat/markowitz2.py CHANGED
@@ -1442,6 +1442,9 @@ def portfolio_es_alpha(pf_info,simulation=1000,RF=0):
1442
1442
  mkt1=pd.DataFrame(mkt['Mkt'])
1443
1443
 
1444
1444
  stock_return0m=pd.merge(stock_return0,mkt1,how='left',left_index=True,right_index=True)
1445
+ #必须舍弃空值,否则下面的回归将得不到系数!!!
1446
+ stock_return0m.dropna(inplace=True)
1447
+
1445
1448
  #处理期间内无风险利率
1446
1449
  """
1447
1450
  if RF:
@@ -1492,8 +1495,7 @@ def portfolio_es_alpha(pf_info,simulation=1000,RF=0):
1492
1495
  stock_return['pReta']=(1+stock_return['pRet'])**252 - 1
1493
1496
  stock_return['Mkta']=(1+stock_return['Mkt'])**252 - 1
1494
1497
  """
1495
- #回归求截距项作为阿尔法指数
1496
-
1498
+ #回归求截距项作为阿尔法指数:参与回归的变量不能有空值,否则回归系数将为空值!!!
1497
1499
  (beta,alpha,_,_,_)=stats.linregress(stock_return['Mkt'],stock_return['pRet'])
1498
1500
  """
1499
1501
  mean_return=stock_return[tickerlist].mul(random_weight,axis=1).sum(axis=1).mean(axis=0)
@@ -1938,7 +1940,9 @@ if __name__=='__main__':
1938
1940
 
1939
1941
 
1940
1942
  #==============================================================================
1941
-
1943
+ if __name__=='__main__':
1944
+ graph=True; convex_hull=False
1945
+
1942
1946
  def portfolio_optimize_alpha(es_info,graph=True,convex_hull=False):
1943
1947
  """
1944
1948
  功能:计算投资组合的最高詹森阿尔法组合,并绘图
@@ -2020,7 +2024,9 @@ def portfolio_optimize_treynor(es_info,graph=True,convex_hull=False):
2020
2024
  return name_hiret,hiret_weights,name_lorisk,lorisk_weights,portfolio_returns
2021
2025
 
2022
2026
  #==============================================================================
2023
-
2027
+ if __name__=='__main__':
2028
+ col_ratio,col_y,col_x,name_hiret,name_lorisk,colorbartxt,title_ext,ylabeltxt,x_axis_name= \
2029
+ ('Sharpe', 'alpha', 'beta', 'MAR', 'GMBA', '阿尔法指数', '阿尔法指数', '阿尔法指数', '贝塔系数')
2024
2030
 
2025
2031
  def portfolio_optimize_rar(es_info,col_ratio,col_y,col_x,name_hiret,name_lorisk, \
2026
2032
  colorbartxt,title_ext,ylabeltxt,x_axis_name,graph=True, \
@@ -2132,6 +2138,7 @@ if __name__=='__main__':
2132
2138
 
2133
2139
  RF=0
2134
2140
  graph=True;hirar_return=False;lorisk=True
2141
+ convex_hull=False
2135
2142
 
2136
2143
  def portfolio_optimize(pf_info,ratio='sharpe',simulation=10000,RF=0, \
2137
2144
  graph=True,hirar_return=False,lorisk=True,convex_hull=False):
siat/stock_technical.py CHANGED
@@ -2505,18 +2505,18 @@ def security_technical2(ticker,start='default',end='default', \
2505
2505
  #price_line_style=(0,(1,1)), \
2506
2506
  price_line_style='dotted', \
2507
2507
  price_line_color=['red','green'], \
2508
- price_line_width=5,price_line_marker='o', \
2508
+ price_line_width=1,price_line_marker='o', \
2509
2509
  marker_sizes=[30,120,250], \
2510
2510
  ):
2511
2511
  """
2512
2512
  功能:计算和绘制证券技术分析指标的简易图,仅供进一步探索使用,仅用于单个证券(股债基)
2513
2513
 
2514
- 支持的探索指标:仅供探索使用
2514
+ 支持的探索指标:
2515
2515
  OBV、SAR、VOL、PSY、ARBR、CR、EMV、TRIX、DMA、BIAS、CCI、W%R、ROC、DMI
2516
2516
  支持的其他指标:不如单独的指令功能强
2517
2517
  MACD、RSI、KDJ、BOLL
2518
2518
 
2519
- 关注的阈值:默认[0,30,50,80],attention_values=[0,30,50,80], 可以自定义,但0线一般建议保留。
2519
+ 关注的阈值:默认[0,25,50,75,100],attention_values=[0,25,50,75,100], 可以自定义。
2520
2520
  收盘价折线:默认红色虚线,price_line_color='red'
2521
2521
  """
2522
2522
  #检查证券代码
@@ -2615,6 +2615,13 @@ def security_technical2(ticker,start='default',end='default', \
2615
2615
 
2616
2616
  indicator=indicator, \
2617
2617
  more_details=more_details)
2618
+ #未安装talib
2619
+ if df is None:
2620
+ return None
2621
+
2622
+ if len(df) == 0:
2623
+ print(" #Warning(security_technical2): zero records calculated for",technical,"using indicator",indicator)
2624
+ return None
2618
2625
 
2619
2626
  #技术指标的绘图线
2620
2627
  tech_line_default={'RSI':['rsi'],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: siat
3
- Version: 3.2.2
3
+ Version: 3.2.4
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
@@ -1,4 +1,4 @@
1
- siat/__init__.py,sha256=2c0GKq4KaxA0vfdvMeyCPiNR6wODmH6CGj8n5UDOywY,2182
1
+ siat/__init__.py,sha256=0N9ER3IIQkOVCLiX2nvfOmYfaYpt4OMd-r0Hbh2DSJc,2496
2
2
  siat/allin.py,sha256=f1VWxZLvPLR57ilk9GOziZMWjyAYOYLXbvQI4z38r50,2708
3
3
  siat/alpha_vantage_test.py,sha256=tKr-vmuFH3CZAqwmISz6jzjPHzV1JJl3sPfZdz8aTfM,747
4
4
  siat/assets_liquidity.py,sha256=deAJ60YcqMUgrXY7jy7BfzLutoy4uOEtfXqqMSujCRo,28889
@@ -67,7 +67,7 @@ siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
67
67
  siat/market_china.py,sha256=nabx24qm7N51OafTrwUw542pNeFJ3JaQ1wqyv-nLN5I,37883
68
68
  siat/markowitz.py,sha256=c06gCRhMABnrb30F-npJsKVv8nFfEoNNR3bzrkMCyGg,97406
69
69
  siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
70
- siat/markowitz2.py,sha256=0FfGv8JzBWTjq3mjCDmT5K-lqpW6RvIggFD4h4SAGzM,109539
70
+ siat/markowitz2.py,sha256=yu3I90RQUxk8k8D7kCa7b0wNfckOjKWHQZNTUq8512o,110060
71
71
  siat/markowitz_ccb_test.py,sha256=xBkkoaNHdq9KSUrNuHGgKTdNYUvgi84kNYcf719eoyE,1593
72
72
  siat/markowitz_ef_test.py,sha256=wjNlICkgRIqnonPeSIHo4Mu2GRtb9dr21wDt2kMNEcI,4032
73
73
  siat/markowitz_old.py,sha256=Lf7O_4QWT8RsdkHiUyc_7kKY3eZjKDtFR89Fz3pwYnY,33046
@@ -115,7 +115,7 @@ siat/stock_prices_kneighbors.py,sha256=WfZvo5EyeBsm-T37zDj7Sl9dPSRq5Bx4JxIJ9IUum
115
115
  siat/stock_prices_linear.py,sha256=-OUKRr27L2aStQgJSlJOrJ4gay_G7P-m-7t7cU2Yoqk,13991
116
116
  siat/stock_profile.py,sha256=B3eIwzEmiCqiCaxIlhfdEPsQBoW1PFOe1hkiY3mVF6Y,26038
117
117
  siat/stock_technical-20240620.py,sha256=A4x18mZgYSA8SSiDz4u_O3gd5oVRgbI6JIiBfFY0tVw,116013
118
- siat/stock_technical.py,sha256=I7AeesRFKAK_8MZcqtV1ppvnqsTZfQYgxU3iTAUzMiQ,122806
118
+ siat/stock_technical.py,sha256=BYvPqwROBek24AgeOLQIAn0X1nc0CKM_6JGWfmOzyoc,122996
119
119
  siat/stock_test.py,sha256=E9YJAvOw1VEGJSDI4IZuEjl0tGoisOIlN-g9UqA_IZE,19475
120
120
  siat/stooq.py,sha256=dOc_S5HLrYg48YAKTCs1eX8UTJOOkPM8qLL2KupqlLY,2470
121
121
  siat/temp.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
@@ -136,7 +136,7 @@ siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
136
136
  siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
137
137
  siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
138
138
  siat/var_model_validation.py,sha256=f-oDewg7bPzyNanz_Y_jLH68NowAA3gXFehW_weKGG0,14898
139
- siat-3.2.2.dist-info/METADATA,sha256=kYXGiGAqJnm-hrtVardCgjNQ1A7SvjHoNTEudqWWV1Q,1447
140
- siat-3.2.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
141
- siat-3.2.2.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
142
- siat-3.2.2.dist-info/RECORD,,
139
+ siat-3.2.4.dist-info/METADATA,sha256=ZYOQXEN6fDtTEw8LfrqXyElewAO9OuxEax03JzawUas,1447
140
+ siat-3.2.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
141
+ siat-3.2.4.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
142
+ siat-3.2.4.dist-info/RECORD,,
File without changes