siat 3.5.9__py3-none-any.whl → 3.5.11__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 +30 -1
- siat/security_price2.py +5 -0
- siat/security_prices.py +17 -4
- siat/translate.py +10 -5
- siat/yf_name.py +14 -6
- {siat-3.5.9.dist-info → siat-3.5.11.dist-info}/METADATA +1 -1
- {siat-3.5.9.dist-info → siat-3.5.11.dist-info}/RECORD +10 -10
- {siat-3.5.9.dist-info → siat-3.5.11.dist-info}/WHEEL +1 -1
- {siat-3.5.9.dist-info → siat-3.5.11.dist-info}/LICENSE +0 -0
- {siat-3.5.9.dist-info → siat-3.5.11.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -4320,7 +4320,6 @@ def df_annual_return(df):
|
|
4320
4320
|
|
4321
4321
|
#==============================================================================
|
4322
4322
|
|
4323
|
-
|
4324
4323
|
if __name__ == '__main__':
|
4325
4324
|
df=security_trend("600519.SS",graph=False)
|
4326
4325
|
option="save"
|
@@ -4372,5 +4371,35 @@ def df_restore(file):
|
|
4372
4371
|
|
4373
4372
|
|
4374
4373
|
#==============================================================================
|
4374
|
+
if __name__ == '__main__':
|
4375
|
+
df=security_trend("600519.SS",start="L5Y",graph=False)
|
4376
|
+
column='Close'
|
4377
|
+
|
4378
|
+
annual_compound_growth(df,"Close")
|
4379
|
+
annual_compound_growth(df,"High")
|
4380
|
+
|
4381
|
+
def annual_compound_growth(df,column="Close"):
|
4382
|
+
"""
|
4383
|
+
|
4384
|
+
功能:计算df[column]的简单年均复合增长率,假定df按照日期顺序升序排列
|
4385
|
+
适用于计算长期股价/指数的年均复合增长率,不适用于收益率的年均复合增长率计算
|
4386
|
+
"""
|
4387
|
+
if not column in list(df):
|
4388
|
+
print(" Sorry, column",column,"not found in the dataframe")
|
4389
|
+
return
|
4390
|
+
|
4391
|
+
day1=df.index[0]; day2=df.index[-1]
|
4392
|
+
days=days_between_dates(day1, day2)
|
4393
|
+
|
4394
|
+
years=days / 365
|
4395
|
+
|
4396
|
+
import numpy as np
|
4397
|
+
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,2)
|
4398
|
+
rate_str=str(growth_rate)+'%'
|
4399
|
+
|
4400
|
+
day1str=day1.strftime("%Y-%m-%d"); day2str=day2.strftime("%Y-%m-%d")
|
4401
|
+
print("Annual compound growth",rate_str,"from",day1str,"to",day2str)
|
4402
|
+
|
4403
|
+
return
|
4375
4404
|
#==============================================================================
|
4376
4405
|
#==============================================================================
|
siat/security_price2.py
CHANGED
@@ -42,6 +42,8 @@ if __name__=='__main__':
|
|
42
42
|
|
43
43
|
ticker='AAPL'
|
44
44
|
|
45
|
+
ticker="006257"
|
46
|
+
|
45
47
|
|
46
48
|
fromdate='2024-5-1'; todate='2024-5-20'
|
47
49
|
|
@@ -55,7 +57,10 @@ if __name__=='__main__':
|
|
55
57
|
source='auto'
|
56
58
|
#source='yahoo'
|
57
59
|
|
60
|
+
adjust=''
|
58
61
|
adjust='qfq'
|
62
|
+
|
63
|
+
fill=False
|
59
64
|
fill=True
|
60
65
|
|
61
66
|
price,found=get_price_1ticker(ticker=ticker,fromdate=fromdate,todate=todate, \
|
siat/security_prices.py
CHANGED
@@ -708,6 +708,9 @@ if __name__=='__main__':
|
|
708
708
|
ticker='159990.SZ' #ETF基金
|
709
709
|
ticker='169201.SZ' #LOF基金
|
710
710
|
ticker='180801.SZ' #封闭式基金
|
711
|
+
|
712
|
+
ticker="006257"
|
713
|
+
|
711
714
|
ticker_type='auto'
|
712
715
|
|
713
716
|
ticker='sh019319' #国债
|
@@ -821,12 +824,22 @@ def get_price_ak_cn(ticker,fromdate,todate,adjust='',ticker_type='auto'):
|
|
821
824
|
df = exchange_bond_price(ticker2,fromdate,todate,graph=False,data_crop=False)
|
822
825
|
df['Date']=df.index
|
823
826
|
except:
|
824
|
-
|
825
|
-
|
827
|
+
try:
|
828
|
+
#再次尝试抓取开放式基金单位净值
|
829
|
+
df =get_price_oef_china(ticker2,fromdate,todate)
|
830
|
+
df['Date']=df.index
|
831
|
+
|
832
|
+
df['ticker']=ticker
|
833
|
+
df['Adj Close']=df['Close']
|
834
|
+
df['source']='Sina'
|
835
|
+
except:
|
836
|
+
df=None
|
837
|
+
#print(" #Error(get_price_ak_cn): failed to find prices for",ticker)
|
838
|
+
return None
|
826
839
|
found=df_have_data(df)
|
827
840
|
|
828
|
-
|
829
|
-
if found
|
841
|
+
#已找到证券信息,或在规定时段无数据
|
842
|
+
if found in ['Empty','Found']: return df
|
830
843
|
|
831
844
|
#债券优先,然后查找指数、股票和基金。因部分债券代码(特别是国债)与基金代码重合,需要甄别!
|
832
845
|
#例如;sh010504既是"05国债⑷"也是"招商稳兴混合C"基金的代码:-(
|
siat/translate.py
CHANGED
@@ -1112,15 +1112,17 @@ def codetranslate0(code):
|
|
1112
1112
|
['TRS5.UK','SPDR美债3-7年期ETF'],['TRSX.UK','SPDR美债7-10年期ETF'],
|
1113
1113
|
['LUTR.UK','SPDR美债10+年期ETF'],
|
1114
1114
|
|
1115
|
+
# 除了^FTW5000,其他的貌似缺数据
|
1115
1116
|
['^FTW5000','威尔希尔5000全市场指数'],
|
1116
|
-
|
1117
1117
|
['^W4500','威尔希尔4500指数'],
|
1118
1118
|
['^FTW2500','威尔希尔2500指数'],
|
1119
1119
|
['^FTWUSG','威尔希尔美国巨型公司指数'],['^FTWUSL','威尔希尔美国大型公司指数'],
|
1120
1120
|
['^FTWUSD','威尔希尔美国中型公司指数'],['^FTWUSS','威尔希尔美国小型公司指数'],
|
1121
1121
|
['^FTWUSO','威尔希尔美国微型公司指数'],
|
1122
1122
|
|
1123
|
-
['FVTT.FGI','富时越南指数'],['
|
1123
|
+
['FVTT.FGI','富时越南指数'],['SWMCX','嘉信美国中盘股指数ETF'],
|
1124
|
+
['^RUT','罗素2000指数'],['^RUI','罗素1000指数'],
|
1125
|
+
|
1124
1126
|
['^HSI','恒生指数'],['^N225','日经225指数'],
|
1125
1127
|
['WIKOR.FGI','富时韩国指数'],['^KS11','韩国综合指数'],
|
1126
1128
|
['^KOSPI','韩国综合指数'],
|
@@ -1129,7 +1131,8 @@ def codetranslate0(code):
|
|
1129
1131
|
['^CAC','法国CAC40指数'],['^DAX','德国DAX指数'],
|
1130
1132
|
['IMOEX.ME','俄罗斯MOEX指数'],['^MOEX','俄罗斯MOEX指数'],
|
1131
1133
|
['^RTS','俄罗斯RTS指数(美元标价)'],
|
1132
|
-
['^TASI','沙特TASI指数'],
|
1134
|
+
['^TASI','沙特TASI指数'],
|
1135
|
+
['TA35.TA','以色列TA35指数'],['^TA125.TA','以色列TA125指数'],
|
1133
1136
|
['^BVSP','巴西BVSP指数'],['^JNX4.JO','南非40指数'],
|
1134
1137
|
['^KLSE','吉隆坡综合指数'],['^KLCI','吉隆坡综合指数'],
|
1135
1138
|
['^JCI','雅加达综合指数'],
|
@@ -1949,7 +1952,8 @@ def codetranslate1(code):
|
|
1949
1952
|
['000019.SS','SSE Governance Index'],['000048.SS','SSE CSR Index'],
|
1950
1953
|
|
1951
1954
|
['899050.BJ','BSE50 Index'],['^SPX','Standard & Poor 500 Index'],
|
1952
|
-
['^RUT','Russell 2000 Index'],['^
|
1955
|
+
['^RUT','Russell 2000 Index'],['^RUI','Russell 1000 Index'],
|
1956
|
+
['^NKX','Nikkei 225 Index'],
|
1953
1957
|
['^NDQ','NASDAQ Composite Index'],['^NDX','NASDAQ 100 Index'],
|
1954
1958
|
['IBM','IBM Corp'],
|
1955
1959
|
|
@@ -2000,7 +2004,8 @@ def codetranslate1(code):
|
|
2000
2004
|
['^SNX','India SENSEX 30 Index'],['^FTM','UK FTSE 250 Index'],
|
2001
2005
|
['^KLCI','Kuala Lumpur Composite Index'],['^KLSE','Kuala Lumpur Composite Index'],
|
2002
2006
|
|
2003
|
-
['FVTT.FGI','FTSE Viernam Index'],
|
2007
|
+
['FVTT.FGI','FTSE Viernam Index'],
|
2008
|
+
['^RUT','Russell 2000 Index'],['^RUI','Russell 1000 Index'],
|
2004
2009
|
['^HSI','Hang Seng Index'],['^N225','Nikkei 225 Index'],
|
2005
2010
|
['WIKOR.FGI','FTSE Korea Index'],['^KS11','Korea Composite Index'],
|
2006
2011
|
['^KOSPI','Korea Composite Index'],['^BSESN','SENSEX Index'],
|
siat/yf_name.py
CHANGED
@@ -228,7 +228,9 @@ if __name__=='__main__':
|
|
228
228
|
ticker='600777.ss'
|
229
229
|
ticker='CPL.WA'
|
230
230
|
|
231
|
-
|
231
|
+
ticker='SWMCX'
|
232
|
+
|
233
|
+
yahoo_name1(ticker)
|
232
234
|
|
233
235
|
#极端测试
|
234
236
|
inamelist=[]
|
@@ -309,6 +311,8 @@ if __name__ == '__main__':
|
|
309
311
|
stock_code='1155.KL'
|
310
312
|
stock_code='MSFT'
|
311
313
|
|
314
|
+
stock_code='SWMCX'
|
315
|
+
|
312
316
|
yahoo_name1_direct(stock_code)
|
313
317
|
|
314
318
|
|
@@ -322,6 +326,7 @@ def yahoo_name1_direct(stock_code,add_suffix=True):
|
|
322
326
|
stock_code1=stock_code.upper()
|
323
327
|
|
324
328
|
#抓取证券名称
|
329
|
+
# https://finance.yahoo.com/quote/SWMCX/
|
325
330
|
url = f"https://finance.yahoo.com/quote/{stock_code1}/"
|
326
331
|
response = requests.get(url)
|
327
332
|
if response.status_code == 200:
|
@@ -345,6 +350,7 @@ def yahoo_name1_direct(stock_code,add_suffix=True):
|
|
345
350
|
if __name__=='__main__':
|
346
351
|
original_name='Oponeo.pl SA'
|
347
352
|
original_name='Apple Inc'
|
353
|
+
original_name='Schwab US Mid-Cap Index'
|
348
354
|
|
349
355
|
filter_stock_name(original_name)
|
350
356
|
|
@@ -352,6 +358,10 @@ def filter_stock_name(original_name):
|
|
352
358
|
"""
|
353
359
|
功能:过滤从网站上抓取到的证券名称,去掉尾部的公司类别词汇,缩短长度,便于显示
|
354
360
|
"""
|
361
|
+
|
362
|
+
#将字符串中的多个空格变为单个空格
|
363
|
+
original_name=replace_multiple_spaces(original_name)
|
364
|
+
|
355
365
|
#定义需要去掉的单词,注意顺序不要轻易颠倒!子串包含的,要长文在前!前置留空格的为避免误删
|
356
366
|
remove_list=[' CORPORATION',' BERHAD',' BHD',' PLC',' INC',' AG ST',' NA O N', \
|
357
367
|
' AKTIENGESELLSCHAFT','(PUBL)',' LLC', \
|
@@ -363,13 +373,11 @@ def filter_stock_name(original_name):
|
|
363
373
|
|
364
374
|
#去掉逗号和句点
|
365
375
|
name1=original_name.replace(',',' ')
|
376
|
+
name1=name1.replace(' ',' ')
|
366
377
|
name2=name1.replace('.',' ')
|
367
378
|
|
368
|
-
#将字符串中的多个空格变为单个空格
|
369
|
-
name3=replace_multiple_spaces(name2)
|
370
|
-
|
371
379
|
#将字符串字母全部大写
|
372
|
-
name4=
|
380
|
+
name4=name2.upper()
|
373
381
|
|
374
382
|
name5=name4
|
375
383
|
for ss in remove_list:
|
@@ -377,7 +385,7 @@ def filter_stock_name(original_name):
|
|
377
385
|
|
378
386
|
name6=name5.strip()
|
379
387
|
|
380
|
-
name7=original_name[:len(name6)]
|
388
|
+
name7=original_name[:len(name6)+1]
|
381
389
|
|
382
390
|
shorter_name=name7
|
383
391
|
return shorter_name
|
@@ -18,7 +18,7 @@ siat/capm_beta.py,sha256=cxXdRVBQBllhbfz1LeTJAIWvyRYhW54nhtNUXv4HwS0,29063
|
|
18
18
|
siat/capm_beta2.py,sha256=lUuCPVSxebkA2yye1PXu1V2Jd2UKEwD_kIA25DCIDTs,29750
|
19
19
|
siat/capm_beta_test.py,sha256=ImR0c5mc4hIl714XmHztdl7qg8v1E2lycKyiqnFj6qs,1745
|
20
20
|
siat/cmat_commons.py,sha256=Nj9Kf0alywaztVoMVeVVL_EZk5jRERJy8R8kBw88_Tg,38116
|
21
|
-
siat/common.py,sha256=
|
21
|
+
siat/common.py,sha256=MP24qZMxGN-EJTo3fevK7RIVanc-uSm0fGluKM723wc,160094
|
22
22
|
siat/compare_cross.py,sha256=3iP9TH2h3w27F2ARZc7FjKcErYCzWRc-TPiymOyoVtw,24171
|
23
23
|
siat/compare_cross_test.py,sha256=xra5XYmQGEtfIZL2h-GssdH2hLdFIhG3eoCrkDrL3gY,3473
|
24
24
|
siat/concepts_iwencai.py,sha256=m1YEDtECRT6FqtzlKm91pt2I9d3Z_XoP59BtWdRdu8I,3061
|
@@ -97,8 +97,8 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
|
|
97
97
|
siat/sector_china.py,sha256=MX1pzqvHvmWD9qGAe8lnUoCXSWjwnjBK8HhAbijTirI,150761
|
98
98
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
99
99
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
100
|
-
siat/security_price2.py,sha256=
|
101
|
-
siat/security_prices.py,sha256=
|
100
|
+
siat/security_price2.py,sha256=FkX-EeqS5Gqm2kIKnDqrqSk_nvG3BbL3Eu4eEmw1OEY,26379
|
101
|
+
siat/security_prices.py,sha256=bzdZ5I6cLPoO9Eu5Fy0T-VHkUxa6pOeEPbLAHgi_weA,108536
|
102
102
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
103
103
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
104
104
|
siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
|
@@ -131,7 +131,7 @@ siat/transaction_test.py,sha256=Z8g1LJCN4-mnUByXMUMoFmN0t105cbmsz2QmvSuIkbU,1858
|
|
131
131
|
siat/translate-20230125.py,sha256=NPPSXhT38s5t9fzMvl_fvi4ckSB73ThLmZetVI-xGdU,117953
|
132
132
|
siat/translate-20230206.py,sha256=-vtI125WyaJhmPotOpDAmclt_XnYVaWU9ByLWZ6FyYE,118133
|
133
133
|
siat/translate-20230215.py,sha256=TJgtPE3n8IjljmZ4Pefy8dmHoNdFF-1zpML6BhA9FKE,121657
|
134
|
-
siat/translate.py,sha256=
|
134
|
+
siat/translate.py,sha256=EV2hlAB-YqBT8NYjJSjMVHsK6mn0qbLVHiJGugUcbrM,241067
|
135
135
|
siat/translate_20240606.py,sha256=63IyHWEU3Uz9mjwyuAX3fqY4nUMdwh0ICQAgmgPXP7Y,215121
|
136
136
|
siat/translate_241003_keep.py,sha256=un7Fqe1v35MXsja5exZgjmLzrZtt66NARZIGlyFuGGU,218747
|
137
137
|
siat/universal_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
@@ -139,9 +139,9 @@ siat/valuation.py,sha256=WCqL5zYkZ_Y3MLeoWXTu3G1CknwGdYzhpszbT6cEoYk,49255
|
|
139
139
|
siat/valuation_china.py,sha256=CVp1IwIsF3Om0J29RGkyxZLt4n9Ug-ua_RKhLwL9fUQ,69624
|
140
140
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
141
141
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
142
|
-
siat/yf_name.py,sha256=
|
143
|
-
siat-3.5.
|
144
|
-
siat-3.5.
|
145
|
-
siat-3.5.
|
146
|
-
siat-3.5.
|
147
|
-
siat-3.5.
|
142
|
+
siat/yf_name.py,sha256=b4nefqEEbbinCEJ60_EysDCF9JZRott3wwclosZdrH8,16404
|
143
|
+
siat-3.5.11.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
144
|
+
siat-3.5.11.dist-info/METADATA,sha256=yfWj-hdifWXYqqhdhrT1zpfyDAO3BHXcScOeuXzFFNM,8010
|
145
|
+
siat-3.5.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
146
|
+
siat-3.5.11.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
147
|
+
siat-3.5.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|