siat 3.0.38__py3-none-any.whl → 3.0.41__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/security_prices.py CHANGED
@@ -1786,6 +1786,7 @@ def calc_expanding_return(drdf0,basedate):
1786
1786
  retname2="Exp Ret%"
1787
1787
  import numpy as np
1788
1788
  #drdf[retname1]=np.exp(drdf["log(Daily Ret)"].expanding(min_periods=1).sum())-1.0
1789
+ #drdf[retname1]=np.exp(drdf["log(Daily Ret)"].expanding(min_periods=5).sum())-1.0
1789
1790
  first_close=drdf.head(1)['Close'].values[0]
1790
1791
  drdf[retname1]=drdf['Close']/first_close-1
1791
1792
  drdf[retname2]=drdf[retname1]*100.0
@@ -1794,6 +1795,7 @@ def calc_expanding_return(drdf0,basedate):
1794
1795
  retname3="Exp Adj Ret"
1795
1796
  retname4="Exp Adj Ret%"
1796
1797
  #drdf[retname3]=np.exp(drdf["log(Daily Adj Ret)"].expanding(min_periods=1).sum())-1.0
1798
+ #drdf[retname3]=np.exp(drdf["log(Daily Adj Ret)"].expanding(min_periods=5).sum())-1.0
1797
1799
  first_aclose=drdf.head(1)['Adj Close'].values[0]
1798
1800
  drdf[retname3]=drdf['Adj Close']/first_aclose-1
1799
1801
  drdf[retname4]=drdf[retname3]*100.0
@@ -1859,11 +1861,13 @@ def expanding_price_volatility(df0,basedate):
1859
1861
  import numpy as np
1860
1862
  #df[retname1]=df["Close"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)/np.mean(x)*np.sqrt(len(x)))
1861
1863
  df[retname1]=df["Close"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)/np.mean(x))
1864
+ #df[retname1]=df["Close"].expanding(min_periods=5).apply(lambda x: np.std(x,ddof=1)/np.mean(x))
1862
1865
 
1863
1866
  #计算扩展窗口调整价格风险:基于调整收盘价
1864
1867
  retname3="Exp Adj Price Volatility"
1865
1868
  #df[retname3]=df["Adj Close"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)/np.mean(x)*np.sqrt(len(x)))
1866
1869
  df[retname3]=df["Adj Close"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)/np.mean(x))
1870
+ #df[retname3]=df["Adj Close"].expanding(min_periods=5).apply(lambda x: np.std(x,ddof=1)/np.mean(x))
1867
1871
 
1868
1872
  return df
1869
1873
 
@@ -1936,6 +1940,7 @@ def expanding_ret_volatility(df0,basedate):
1936
1940
 
1937
1941
  #df[retname1]=df["Daily Ret"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)*np.sqrt(len(x)))
1938
1942
  df[retname1]=df["Daily Ret"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1))
1943
+ #df[retname1]=df["Daily Ret"].expanding(min_periods=5).apply(lambda x: np.std(x,ddof=1))
1939
1944
  df[retname2]=df[retname1]*100.0
1940
1945
 
1941
1946
  #计算扩展窗口调整收益率风险:基于调整收益率
@@ -1943,6 +1948,7 @@ def expanding_ret_volatility(df0,basedate):
1943
1948
  retname4="Exp Adj Ret Volatility%"
1944
1949
  #df[retname3]=df["Daily Adj Ret"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1)*np.sqrt(len(x)))
1945
1950
  df[retname3]=df["Daily Adj Ret"].expanding(min_periods=1).apply(lambda x: np.std(x,ddof=1))
1951
+ #df[retname3]=df["Daily Adj Ret"].expanding(min_periods=5).apply(lambda x: np.std(x,ddof=1))
1946
1952
  df[retname4]=df[retname3]*100.0
1947
1953
 
1948
1954
  return df
@@ -2051,6 +2057,7 @@ def expanding_ret_lpsd(df0,basedate):
2051
2057
  import numpy as np
2052
2058
  #df[retname1]=df["Daily Ret"].expanding(min_periods=1).apply(lambda x: lpsd(x)*np.sqrt(len(x)))
2053
2059
  df[retname1]=df["Daily Ret"].expanding(min_periods=1).apply(lambda x: lpsd(x))
2060
+ #df[retname1]=df["Daily Ret"].expanding(min_periods=5).apply(lambda x: lpsd(x))
2054
2061
  df[retname2]=df[retname1]*100.0
2055
2062
 
2056
2063
  #计算扩展窗口调整下偏标准差:基于调整收益率
@@ -2058,6 +2065,7 @@ def expanding_ret_lpsd(df0,basedate):
2058
2065
  retname4=retname3+'%'
2059
2066
  #df[retname3]=df["Daily Adj Ret"].expanding(min_periods=1).apply(lambda x: lpsd(x)*np.sqrt(len(x)))
2060
2067
  df[retname3]=df["Daily Adj Ret"].expanding(min_periods=1).apply(lambda x: lpsd(x))
2068
+ #df[retname3]=df["Daily Adj Ret"].expanding(min_periods=5).apply(lambda x: lpsd(x))
2061
2069
  df[retname4]=df[retname3]*100.0
2062
2070
 
2063
2071
  return df
siat/stock.py CHANGED
@@ -1574,7 +1574,7 @@ def compare_msecurity(tickers,measure,start,end, \
1574
1574
  print(" #Error(compare_msecurity): support only one measure")
1575
1575
  return None
1576
1576
 
1577
- print(" Searching for multiple security information for",measure,"\b, it takes great time, please wait ...")
1577
+ print(" Searching for multiple security information for",measure,"\b, it may take great time ...")
1578
1578
  #屏蔽函数内print信息输出的类
1579
1579
  import os, sys
1580
1580
  class HiddenPrints:
siat/stock_info.pickle CHANGED
Binary file
siat/stock_technical.py CHANGED
@@ -2003,12 +2003,15 @@ def security_bollinger(ticker,fromdate,todate,boll_days=20, \
2003
2003
 
2004
2004
  try:
2005
2005
  #pricedf=get_price(ticker,fromdate1,todate)
2006
- pricedf=get_price_1ticker_mixed(ticker=ticker,fromdate=fromdate1, \
2006
+ pricedf,found=get_price_1ticker_mixed(ticker=ticker,fromdate=fromdate1, \
2007
2007
  todate=todate,ticker_type=ticker_type)
2008
2008
  except:
2009
2009
  print(" #Error(security_bollinger): price info not found for",ticker)
2010
2010
  return None
2011
-
2011
+ if found not in ['Found']:
2012
+ print(" #Error(): ticker info either inaccessible or not found for",ticker)
2013
+ return None
2014
+
2012
2015
  # 滚动均值与标准差
2013
2016
  pricedf['bmiddle']=pricedf["Close"].rolling(window=boll_days).mean()
2014
2017
  pricedf['bsd']=pricedf["Close"].rolling(window=boll_days).std()
@@ -2351,7 +2354,9 @@ def security_technical(ticker,start='default',end='default', \
2351
2354
 
2352
2355
  if 'Bollinger' in technical1:
2353
2356
  vallist=['MV','PE','PB','ROE']
2354
- if val in vallist and val in indicator1: #只能处理股票估值,无需ticker_type
2357
+ #if val in vallist and val in indicator1: #只能处理股票估值,无需ticker_type
2358
+ if any(val in indicator1 for val in vallist):
2359
+ val=list(set(indicator1).intersection(set(vallist)))[0] #找出2个列表中第1个共同元素
2355
2360
  df=security_Bubble(ticker=ticker,start=fromdate,end=todate,boll_years=boll_years, \
2356
2361
  indicator=val, \
2357
2362
  graph=True,smooth=smooth,loc=loc1, \