siat 3.9.32__py3-none-any.whl → 3.10.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/other_indexes.py +11 -4
- siat/security_price2.py +7 -2
- siat/security_prices.py +68 -0
- {siat-3.9.32.dist-info → siat-3.10.1.dist-info}/METADATA +1 -1
- {siat-3.9.32.dist-info → siat-3.10.1.dist-info}/RECORD +8 -8
- {siat-3.9.32.dist-info → siat-3.10.1.dist-info}/LICENSE +0 -0
- {siat-3.9.32.dist-info → siat-3.10.1.dist-info}/WHEEL +0 -0
- {siat-3.9.32.dist-info → siat-3.10.1.dist-info}/top_level.txt +0 -0
siat/other_indexes.py
CHANGED
@@ -291,6 +291,7 @@ if __name__=='__main__':
|
|
291
291
|
api_key='VTRR3TA7L9O2DIX6'
|
292
292
|
keyword='AAPL'
|
293
293
|
keyword='Apple'
|
294
|
+
keyword='^TYX'
|
294
295
|
|
295
296
|
search_av("microsoft")
|
296
297
|
search_av("Apple")
|
@@ -308,13 +309,19 @@ def search_av(keyword,api_key='VTRR3TA7L9O2DIX6'):
|
|
308
309
|
|
309
310
|
data = response.json()
|
310
311
|
if "bestMatches" in data:
|
311
|
-
|
312
|
-
|
312
|
+
try:
|
313
|
+
firstcode=data["bestMatches"][0]['1. symbol']
|
314
|
+
firstname=data["bestMatches"][0]['2. name']
|
315
|
+
except:
|
316
|
+
print(f" #Warning(search_av): no contents found for {keyword} in Alpha Vantage")
|
317
|
+
#未找到可匹配的股票代码
|
318
|
+
return None,None,None
|
319
|
+
|
313
320
|
else:
|
314
321
|
if "Information" in data:
|
315
|
-
print(f" Warning(search_av): exceeded
|
322
|
+
print(f" #Warning(search_av): exceeded limit of requests per day in Alpha Vantage")
|
316
323
|
else:
|
317
|
-
print(f" Warning(search_av): keyword {keyword} not found in Alpha Vantage")
|
324
|
+
print(f" #Warning(search_av): keyword {keyword} not found in Alpha Vantage")
|
318
325
|
#未找到可匹配的股票代码
|
319
326
|
return None,None,None
|
320
327
|
|
siat/security_price2.py
CHANGED
@@ -171,9 +171,14 @@ def get_price_1ticker(ticker,fromdate,todate, \
|
|
171
171
|
if source in ['auto','yahoo'] and found not in ['Found','Empty']:
|
172
172
|
dft=None
|
173
173
|
if test_yahoo_finance():
|
174
|
-
#数据源情形
|
175
|
-
dft=
|
174
|
+
#数据源情形3a:yahoo, yahooquery, 需要访问yahoo
|
175
|
+
dft=get_price_yq(ticker1,fromdate,todate)
|
176
176
|
found=df_have_data(dft)
|
177
|
+
|
178
|
+
#数据源情形3b:yahoo, yfinance, 需要访问yahoo,直接为复权价
|
179
|
+
if found not in ['Found','Empty']:
|
180
|
+
dft=get_price_yf(ticker1,fromdate,todate)
|
181
|
+
found=df_have_data(dft)
|
177
182
|
|
178
183
|
#数据源情形4:yahoo, pandas_datareader,需要访问yahoo,似乎不工作了!
|
179
184
|
if found not in ['Found','Empty']:
|
siat/security_prices.py
CHANGED
@@ -1449,6 +1449,74 @@ if __name__=='__main__':
|
|
1449
1449
|
df4=get_prices_yf(['0700.HK','600519.SS'],'2020-12-1','2021-1-31')
|
1450
1450
|
df5=get_prices_yf(['AAPL','MSFT','0700.HK','600519.SS'],'2020-12-1','2021-1-31')
|
1451
1451
|
df6=get_prices_yf(['ABCD','EFGH','0700.HK','600519.SS'],'2020-12-1','2021-1-31')
|
1452
|
+
|
1453
|
+
#==============================================================================
|
1454
|
+
if __name__=='__main__':
|
1455
|
+
ticker='^TYX'
|
1456
|
+
start='2024-12-1'
|
1457
|
+
end='2025-1-31'
|
1458
|
+
|
1459
|
+
get_price_yq(ticker,start,end)
|
1460
|
+
|
1461
|
+
def get_price_yq(ticker,start,end):
|
1462
|
+
"""
|
1463
|
+
功能:从雅虎财经抓取股价,使用yahooquery(注意插件版本问题)
|
1464
|
+
输入:股票代码或股票代码列表,开始日期,结束日期
|
1465
|
+
ticker: 股票代码或股票代码列表。大陆股票代码加上后缀.SZ或.SS或.BJ,港股代码去掉前导0加后缀.HK
|
1466
|
+
start: 样本开始日期,尽量远的日期,以便取得足够多的原始样本,yyyy-mm-dd
|
1467
|
+
end: 样本结束日期,既可以是今天日期,也可以是一个历史日期
|
1468
|
+
|
1469
|
+
输出:指定收盘价格序列,最新日期的股价排列在前
|
1470
|
+
"""
|
1471
|
+
p=None
|
1472
|
+
|
1473
|
+
#支持多个证券
|
1474
|
+
import yahooquery as yq
|
1475
|
+
ticker1,islist=cvt_yftickerlist(ticker)
|
1476
|
+
if not islist:
|
1477
|
+
#下载单一股票的股价
|
1478
|
+
stock=yq.Ticker(ticker1, asynchronous=True)
|
1479
|
+
try:
|
1480
|
+
p=stock.history(start=start,end=end)
|
1481
|
+
#仅针对雅虎情况
|
1482
|
+
if p is not None:
|
1483
|
+
if len(p)==0: p=None
|
1484
|
+
except:
|
1485
|
+
p=None
|
1486
|
+
else:
|
1487
|
+
#下载股票列表的股价,与但股票情况相同,但需注意MultiInex结构
|
1488
|
+
stock=yq.Ticker(ticker1, asynchronous=True)
|
1489
|
+
try:
|
1490
|
+
p=stock.history(start=start,end=end)
|
1491
|
+
#仅针对雅虎情况
|
1492
|
+
if p is not None:
|
1493
|
+
if len(p)==0: p=None
|
1494
|
+
except:
|
1495
|
+
p=None
|
1496
|
+
|
1497
|
+
found=df_have_data(p)
|
1498
|
+
if found in ['Found','Empty']:
|
1499
|
+
p.rename(columns={'open':'Open','high':'High','low':'Low','close':'Close', \
|
1500
|
+
'adjclose':'Adj Close','volume':'Volume'},inplace=True)
|
1501
|
+
|
1502
|
+
if 'Adj Close' not in list(p):
|
1503
|
+
p['Adj Close']=p['Close']
|
1504
|
+
p['ticker']=ticker
|
1505
|
+
p['source']=text_lang('雅虎','Yahoo')
|
1506
|
+
|
1507
|
+
# 去掉一级Index
|
1508
|
+
p=p.droplevel('symbol')
|
1509
|
+
p['date']=p.index
|
1510
|
+
if len(p) > 0:
|
1511
|
+
print(" Successfully retrieved",len(p),"records for",ticker1)
|
1512
|
+
|
1513
|
+
#去掉时区
|
1514
|
+
p=df_index_timezone_remove(p)
|
1515
|
+
else:
|
1516
|
+
pass
|
1517
|
+
#print(" #Error(get_prices_yf):",ticker1,"not found or no prices in the period or inaccessible to yahoo")
|
1518
|
+
|
1519
|
+
return p
|
1452
1520
|
|
1453
1521
|
#==============================================================================
|
1454
1522
|
if __name__=='__main__':
|
@@ -89,7 +89,7 @@ siat/option_china_test.py,sha256=UQ-YUHUjoGBQyanLcM-yzqeEIUQP_gCQIeT0W6rnUnA,163
|
|
89
89
|
siat/option_pricing.py,sha256=vyQNgBsjcJi70Pa-fJTVVIGK_3jWh80tkd1ESnn3sE4,74069
|
90
90
|
siat/option_pricing_test.py,sha256=eeorV5Ja5vjlRXnP6fWJHetGU5Vb8SnLopkC6RV3GfA,2203
|
91
91
|
siat/option_sina_api_test.py,sha256=dn-k_wrQnAaNKHoROvWJEc7lqlU0bwiV2Aa4usWAFGM,5908
|
92
|
-
siat/other_indexes.py,sha256=
|
92
|
+
siat/other_indexes.py,sha256=zIUOcaytf0e2NnGU9Bkyiu3z_GaR_-T8nVGCZ4s4Bws,13615
|
93
93
|
siat/proxy_test.py,sha256=erQJrmGs2X46z8Gb1h-7GYQ0rTUcaR8dxHExWoBz2eM,2610
|
94
94
|
siat/quandl_test.py,sha256=EcPoXnLuqzPl5dKyVEZi3j3PJZFpsnU_iNPhLWC9p-A,1552
|
95
95
|
siat/risk_adjusted_return.py,sha256=6F8CpKm-HKO4wfnndri0ew-D3lDAH1fs5O9K5cphoLg,55096
|
@@ -102,8 +102,8 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
|
|
102
102
|
siat/sector_china.py,sha256=9zjdORWx5ia_gUezidhOKWmCnVDwWcnnjjugHudelaQ,157411
|
103
103
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
104
104
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
105
|
-
siat/security_price2.py,sha256=
|
106
|
-
siat/security_prices.py,sha256=
|
105
|
+
siat/security_price2.py,sha256=uC-wA6w3IlA9ZOJYINqIB7LexCbrnnqTkHTPuCSCwpo,27697
|
106
|
+
siat/security_prices.py,sha256=MD1pANBD4E_dppLHxgoc7QoceGmKO3huOr2IQpU_eiQ,111570
|
107
107
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
108
108
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
109
109
|
siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
|
@@ -145,8 +145,8 @@ siat/valuation_china.py,sha256=eSKIDckyjG8QkENlW_OKkqbQHno8pzDcomBO9iGNJVM,83079
|
|
145
145
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
146
146
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
147
147
|
siat/yf_name.py,sha256=laNKMTZ9hdenGX3IZ7G0a2RLBKEWtUQJFY9CWuk_fp8,24058
|
148
|
-
siat-3.
|
149
|
-
siat-3.
|
150
|
-
siat-3.
|
151
|
-
siat-3.
|
152
|
-
siat-3.
|
148
|
+
siat-3.10.1.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
149
|
+
siat-3.10.1.dist-info/METADATA,sha256=45hmgtcQRU3Qq-7X7UlCGRDQrV-_c-VNt8Oec76xNBQ,8396
|
150
|
+
siat-3.10.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
151
|
+
siat-3.10.1.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
152
|
+
siat-3.10.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|