siat 3.2.20__py3-none-any.whl → 3.2.30__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/allin.py +3 -0
- siat/common.py +32 -7
- siat/grafix.py +41 -7
- siat/luchy_draw.py +252 -0
- siat/market_china.py +171 -0
- siat/risk_adjusted_return2.py +22 -13
- siat/security_trend2.py +3 -2
- siat/stock.py +45 -12
- siat/stock_technical.py +137 -78
- siat/translate.py +13 -0
- {siat-3.2.20.dist-info → siat-3.2.30.dist-info}/METADATA +1 -1
- {siat-3.2.20.dist-info → siat-3.2.30.dist-info}/RECORD +14 -13
- {siat-3.2.20.dist-info → siat-3.2.30.dist-info}/WHEEL +0 -0
- {siat-3.2.20.dist-info → siat-3.2.30.dist-info}/top_level.txt +0 -0
siat/security_trend2.py
CHANGED
@@ -100,6 +100,7 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
100
100
|
ret_type='Annual Ret%',RF=0,regression_period=365,market_index="auto", \
|
101
101
|
sortby='tpw_mean',trailing=7,trend_threshhold=0.05, \
|
102
102
|
|
103
|
+
band_area='', \
|
103
104
|
graph=True,twinx=False,loc1='best',loc2='best', \
|
104
105
|
datatag=False,power=0, \
|
105
106
|
smooth=True,date_range=False,date_freq=False, \
|
@@ -220,7 +221,7 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
220
221
|
if not isinstance(mav,list):
|
221
222
|
mav=[mav]
|
222
223
|
df=candlestick(stkcd=tickers[0],fromdate=fromdate,todate=todate,mav=mav, \
|
223
|
-
ticker_type=ticker_type,facecolor=facecolor)
|
224
|
+
ticker_type=ticker_type,facecolor=facecolor,loc=loc1)
|
224
225
|
return df
|
225
226
|
|
226
227
|
if kline and kline_demo:
|
@@ -388,7 +389,7 @@ def security_trend(ticker,indicator='Close',adjust='', \
|
|
388
389
|
df=security_mindicators(ticker=tickers[0],measures=measures, \
|
389
390
|
adjust=adjust, \
|
390
391
|
fromdate=fromdate,todate=todate, \
|
391
|
-
graph=graph,smooth=smooth,loc=loc1, \
|
392
|
+
graph=graph,smooth=smooth,band_area=band_area,loc=loc1, \
|
392
393
|
date_range=date_range,date_freq=date_freq, \
|
393
394
|
annotate=annotate,annotate_value=annotate_value, \
|
394
395
|
source=source,
|
siat/stock.py
CHANGED
@@ -814,6 +814,7 @@ if __name__ =="__main__":
|
|
814
814
|
def security_mindicators(ticker,measures,
|
815
815
|
fromdate,todate, \
|
816
816
|
adjust='', \
|
817
|
+
band_area='', \
|
817
818
|
graph=True,smooth=True,loc='best',facecolor='whitesmoke', \
|
818
819
|
date_range=False,date_freq=False, \
|
819
820
|
annotate=False,annotate_value=False, \
|
@@ -904,7 +905,8 @@ def security_mindicators(ticker,measures,
|
|
904
905
|
data_label=False,resample_freq='6H',smooth=smooth, \
|
905
906
|
date_range=date_range,date_freq=date_freq,date_fmt='%Y-%m-%d', \
|
906
907
|
annotate=annotate,annotate_value=annotate_value, \
|
907
|
-
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor
|
908
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end,facecolor=facecolor, \
|
909
|
+
band_area=band_area,loc=loc)
|
908
910
|
|
909
911
|
return df1
|
910
912
|
|
@@ -1651,7 +1653,7 @@ def compare_msecurity(tickers,measure,start,end, \
|
|
1651
1653
|
print(" #Error(compare_msecurity): support only one measure")
|
1652
1654
|
return None
|
1653
1655
|
|
1654
|
-
print(" Searching for multiple security
|
1656
|
+
print(" Searching for multiple security for",measure,"...")
|
1655
1657
|
#屏蔽函数内print信息输出的类
|
1656
1658
|
import os, sys
|
1657
1659
|
class HiddenPrints:
|
@@ -1738,10 +1740,15 @@ def compare_msecurity(tickers,measure,start,end, \
|
|
1738
1740
|
title_txt=title_txt+': '+title_txt2
|
1739
1741
|
|
1740
1742
|
# 标准化处理
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1743
|
+
try:
|
1744
|
+
dfs2,axhline_label,x_label,y_label,plus_sign=df_preprocess(dfs,measure, \
|
1745
|
+
axhline_label=axhline_label,x_label=x_label,y_label=y_label, \
|
1746
|
+
preprocess=preprocess,scaling_option=scaling_option)
|
1747
|
+
except:
|
1748
|
+
print(" #Error(compare_msecurity): preprocess failed, returning dfs for further check")
|
1749
|
+
#df_display_CSS(dfs,titletxt='Unexpected Data in dfs')
|
1750
|
+
return dfs
|
1751
|
+
|
1745
1752
|
# 填充非交易日的缺失值,使得绘制的曲线连续
|
1746
1753
|
dfs2.fillna(axis=0,method='ffill',inplace=True)
|
1747
1754
|
#dfs2.fillna(axis=0,method='bfill',inplace=True)
|
@@ -1900,9 +1907,21 @@ def stock_Kline(ticker,start='default',end='default',volume=True, \
|
|
1900
1907
|
|
1901
1908
|
return df
|
1902
1909
|
|
1903
|
-
|
1910
|
+
if __name__ =="__main__":
|
1911
|
+
stkcd="BABA"
|
1912
|
+
fromdate="2024-5-1"
|
1913
|
+
todate="2024-6-20"
|
1914
|
+
volume=True
|
1915
|
+
style='China'
|
1916
|
+
mav=[5,10]
|
1917
|
+
ticker_type='auto'
|
1918
|
+
facecolor='whitesmoke'
|
1919
|
+
loc='best'
|
1920
|
+
|
1921
|
+
|
1922
|
+
|
1904
1923
|
def candlestick(stkcd,fromdate,todate,volume=True,style='China',mav=[5,10], \
|
1905
|
-
ticker_type='auto',facecolor='whitesmoke'):
|
1924
|
+
ticker_type='auto',facecolor='whitesmoke',loc='best'):
|
1906
1925
|
"""
|
1907
1926
|
功能:绘制证券价格K线图。
|
1908
1927
|
输入:证券代码ticker;开始日期fromdate,结束日期todate;
|
@@ -1929,7 +1948,7 @@ def candlestick(stkcd,fromdate,todate,volume=True,style='China',mav=[5,10], \
|
|
1929
1948
|
|
1930
1949
|
#延长开始日期,以便绘制长期均线
|
1931
1950
|
#fromdate1=date_adjust(fromdate, adjust=-mav_max*2)
|
1932
|
-
fromdate1=
|
1951
|
+
fromdate1=fromdate
|
1933
1952
|
|
1934
1953
|
#检查命令参数
|
1935
1954
|
stylelist=['binance','China','blueskies','brasil','charles','checkers','classic','default', \
|
@@ -1949,14 +1968,14 @@ def candlestick(stkcd,fromdate,todate,volume=True,style='China',mav=[5,10], \
|
|
1949
1968
|
wick="inherit" # 蜡烛图影线的颜色
|
1950
1969
|
)
|
1951
1970
|
s = mpf.make_mpf_style(
|
1952
|
-
gridaxis='both',
|
1953
|
-
gridstyle='-.',
|
1971
|
+
#gridaxis='both',
|
1972
|
+
#gridstyle='-.',
|
1954
1973
|
y_on_right=True,
|
1955
1974
|
marketcolors=mc,
|
1956
1975
|
edgecolor='black',
|
1957
1976
|
figcolor='white',
|
1958
1977
|
facecolor=facecolor,
|
1959
|
-
gridcolor='cyan',
|
1978
|
+
#gridcolor='cyan',
|
1960
1979
|
rc=mpfrc)
|
1961
1980
|
|
1962
1981
|
#抓取证券价格
|
@@ -1993,6 +2012,9 @@ def candlestick(stkcd,fromdate,todate,volume=True,style='China',mav=[5,10], \
|
|
1993
2012
|
#titletxt=ticker_name(stkcd)
|
1994
2013
|
titletxt=ticker_name(stkcd,ticker_type=ticker_type)
|
1995
2014
|
|
2015
|
+
#空一行
|
2016
|
+
print('')
|
2017
|
+
|
1996
2018
|
fig, axlist = mpf.plot(daily,type='candle',
|
1997
2019
|
volume=volume,
|
1998
2020
|
show_nontrading=False,#自动剔除非交易日空白
|
@@ -2017,6 +2039,17 @@ def candlestick(stkcd,fromdate,todate,volume=True,style='China',mav=[5,10], \
|
|
2017
2039
|
#style='italic',
|
2018
2040
|
#fontfamily='fantasy',
|
2019
2041
|
loc='center')
|
2042
|
+
|
2043
|
+
#设置图例,注意前两个为图中期间开始日期的线和柱子
|
2044
|
+
mav_labels=['期间首日线','期间首日柱']
|
2045
|
+
for d in mav:
|
2046
|
+
mav_labels=mav_labels+[str(d)+"日移动均线"]
|
2047
|
+
axlist[0].legend(mav_labels,loc=loc)
|
2048
|
+
"""
|
2049
|
+
#去掉前两个无用的图例
|
2050
|
+
handles, labels = axlist[0].get_legend_handles_labels()
|
2051
|
+
axlist[0].legend(handles=handles[2:],labels=labels[2:],loc=loc)
|
2052
|
+
"""
|
2020
2053
|
fig.show()
|
2021
2054
|
reset_plt()
|
2022
2055
|
|