siat 3.2.4__py3-none-any.whl → 3.2.10__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/common.py +25 -0
- siat/security_price2.py +4 -4
- siat/security_prices.py +22 -3
- siat/stock_technical.py +588 -376
- {siat-3.2.4.dist-info → siat-3.2.10.dist-info}/METADATA +1 -1
- {siat-3.2.4.dist-info → siat-3.2.10.dist-info}/RECORD +8 -8
- {siat-3.2.4.dist-info → siat-3.2.10.dist-info}/WHEEL +0 -0
- {siat-3.2.4.dist-info → siat-3.2.10.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -3824,6 +3824,31 @@ def is_weekend(adate):
|
|
3824
3824
|
|
3825
3825
|
|
3826
3826
|
#==============================================================================
|
3827
|
+
if __name__=='__main__':
|
3828
|
+
alist=['EMA40','EMA5','EMA','EMA20']
|
3829
|
+
alist=['EMA20','EMA5']
|
3830
|
+
sort_list_by_len(alist)
|
3831
|
+
|
3832
|
+
def sort_list_by_len(alist,reverse=False):
|
3833
|
+
"""
|
3834
|
+
功能:基于字符串列表中元素的长度和大小排序
|
3835
|
+
"""
|
3836
|
+
import pandas as pd
|
3837
|
+
adf=pd.DataFrame(columns=('item','len'))
|
3838
|
+
for a in alist:
|
3839
|
+
row=pd.Series({'item':a,'len':len(a)})
|
3840
|
+
try:
|
3841
|
+
adf=v.append(row,ignore_index=True)
|
3842
|
+
except:
|
3843
|
+
adf=adf._append(row,ignore_index=True)
|
3844
|
+
if not reverse:
|
3845
|
+
adf.sort_values(by=['len','item'],ascending=True,inplace=True)
|
3846
|
+
else:
|
3847
|
+
adf.sort_values(by=['len','item'],ascending=False,inplace=True)
|
3848
|
+
|
3849
|
+
alist_sorted=list(adf['item'])
|
3850
|
+
|
3851
|
+
return alist_sorted
|
3827
3852
|
#==============================================================================
|
3828
3853
|
#==============================================================================
|
3829
3854
|
#==============================================================================
|
siat/security_price2.py
CHANGED
@@ -86,8 +86,8 @@ def get_price_1ticker(ticker,fromdate,todate, \
|
|
86
86
|
#print(" #Warning(get_price_1ticker): invalid date period from",fromdate,"to",todate)
|
87
87
|
return df,found
|
88
88
|
|
89
|
-
|
90
|
-
ak_fq_list=['','qfq','hfq','qfq-factor','hfq-factor']
|
89
|
+
#检查复权选项合理性:adj_only特别指最高最低价开盘收盘价全为复权价
|
90
|
+
ak_fq_list=['','qfq','hfq','qfq-factor','hfq-factor','adj_only']
|
91
91
|
if adjust not in ak_fq_list:
|
92
92
|
adjust='qfq'
|
93
93
|
|
@@ -149,11 +149,11 @@ def get_price_1ticker(ticker,fromdate,todate, \
|
|
149
149
|
if source in ['auto','yahoo'] and found not in ['Found','Empty']:
|
150
150
|
dft=None
|
151
151
|
if test_yahoo_finance():
|
152
|
-
#数据源情形3:yahoo, yfinance, 需要访问yahoo
|
152
|
+
#数据源情形3:yahoo, yfinance, 需要访问yahoo,直接为复权价?
|
153
153
|
dft=get_price_yf(ticker1,fromdate,todate)
|
154
154
|
found=df_have_data(dft)
|
155
155
|
|
156
|
-
#数据源情形4:yahoo, pandas_datareader,需要访问yahoo
|
156
|
+
#数据源情形4:yahoo, pandas_datareader,需要访问yahoo,似乎不工作!
|
157
157
|
if found not in ['Found','Empty']:
|
158
158
|
dft=get_prices_yahoo(ticker1,fromdate,todate)
|
159
159
|
found=df_have_data(dft)
|
siat/security_prices.py
CHANGED
@@ -755,14 +755,14 @@ def get_price_ak_cn(ticker,fromdate,todate,adjust='',ticker_type='auto'):
|
|
755
755
|
end1=end.strftime('%Y%m%d')
|
756
756
|
|
757
757
|
#adjustlist=['none','hfq','qfq']
|
758
|
-
adjustlist=['','qfq','hfq','qfq-factor','hfq-factor']
|
758
|
+
adjustlist=['','qfq','hfq','qfq-factor','hfq-factor','adj_only']
|
759
759
|
if adjust not in adjustlist:
|
760
760
|
print(" #Warning(get_price_ak_cn): adjust only supports",adjustlist)
|
761
761
|
return None
|
762
762
|
|
763
763
|
_,prefix,suffix=split_prefix_suffix(ticker2)
|
764
|
-
|
765
|
-
if adjust
|
764
|
+
#考虑股票复权情形:仅收盘价为复权价,指数/基金/债券无复权
|
765
|
+
if adjust not in ['','adj_only']:
|
766
766
|
if ticker_type in ['auto','stock'] and suffix not in ['SW']:
|
767
767
|
try:
|
768
768
|
#仅用于股票的历史行情数据(考虑复权)
|
@@ -775,6 +775,18 @@ def get_price_ak_cn(ticker,fromdate,todate,adjust='',ticker_type='auto'):
|
|
775
775
|
except:
|
776
776
|
df=None
|
777
777
|
found=df_have_data(df)
|
778
|
+
|
779
|
+
#考虑股票复权情形:所有价格均为复权价,指数/基金/债券无复权
|
780
|
+
if adjust == 'adj_only':
|
781
|
+
if ticker_type in ['auto','stock'] and suffix not in ['SW']:
|
782
|
+
try:
|
783
|
+
#仅用于股票的历史行情数据(考虑复权)
|
784
|
+
df=ak.stock_zh_a_daily(ticker2,start1,end1,adjust='qfq')
|
785
|
+
df['Adj Close']=df['close']
|
786
|
+
df['Date']=df['date']
|
787
|
+
except:
|
788
|
+
df=None
|
789
|
+
found=df_have_data(df)
|
778
790
|
|
779
791
|
#股票(无复权)指数/基金/债券
|
780
792
|
if found != 'Found':
|
@@ -961,6 +973,10 @@ def get_price_ak_us(symbol, fromdate, todate, adjust=""):
|
|
961
973
|
try:
|
962
974
|
if adjust=='':
|
963
975
|
df=ak.stock_us_daily(symbol=symbol,adjust=adjust)
|
976
|
+
elif adjust=='Adj_only':
|
977
|
+
df=ak.stock_us_daily(symbol=symbol,adjust='qfq')
|
978
|
+
df['Adj Close']=df['close']
|
979
|
+
|
964
980
|
else:
|
965
981
|
dffqno=ak.stock_us_daily(symbol=symbol,adjust='')
|
966
982
|
dffq=ak.stock_us_daily(symbol=symbol,adjust='qfq')
|
@@ -1048,6 +1064,9 @@ def get_price_ak_hk(symbol,fromdate,todate,adjust=""):
|
|
1048
1064
|
try:
|
1049
1065
|
if adjust == '':
|
1050
1066
|
df=ak.stock_hk_daily(symbol=symbol3, adjust=adjust)
|
1067
|
+
elif adjust == 'Adj_only':
|
1068
|
+
df=ak.stock_hk_daily(symbol=symbol3, adjust='qfq')
|
1069
|
+
df['Adj Close']=df['close']
|
1051
1070
|
else:
|
1052
1071
|
dffqno=ak.stock_hk_daily(symbol=symbol3, adjust='')
|
1053
1072
|
dffq =ak.stock_hk_daily(symbol=symbol3,adjust='qfq')
|