siat 3.5.2__py3-none-any.whl → 3.5.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/bond.py +128 -0
- siat/common.py +54 -13
- siat/fund_china.py +2 -2
- siat/grafix.py +10 -10
- siat/stock.py +4 -0
- siat/translate.py +8 -4
- siat/yf_name.py +14 -6
- {siat-3.5.2.dist-info → siat-3.5.10.dist-info}/METADATA +1 -1
- {siat-3.5.2.dist-info → siat-3.5.10.dist-info}/RECORD +12 -12
- {siat-3.5.2.dist-info → siat-3.5.10.dist-info}/LICENSE +0 -0
- {siat-3.5.2.dist-info → siat-3.5.10.dist-info}/WHEEL +0 -0
- {siat-3.5.2.dist-info → siat-3.5.10.dist-info}/top_level.txt +0 -0
siat/bond.py
CHANGED
@@ -2705,5 +2705,133 @@ def bond_malkiel(coupon_rate,maturity_years,ytm,coupon_times=2,par_value=100, \
|
|
2705
2705
|
|
2706
2706
|
|
2707
2707
|
#==============================================================================
|
2708
|
+
if __name__ =="__main__":
|
2709
|
+
start="MRY"; end="today"
|
2710
|
+
term="1Y"
|
2711
|
+
term=["1Y","5Y","10Y"]
|
2712
|
+
|
2713
|
+
power=1
|
2714
|
+
average_value=True
|
2715
|
+
loc1="best"; loc2="best"
|
2716
|
+
mark_top=False; mark_bottom=False; mark_end=False
|
2717
|
+
twinx=False
|
2718
|
+
|
2719
|
+
annotate=True; annotate_value=True
|
2720
|
+
facecolor="papayawhip"
|
2721
|
+
|
2722
|
+
rates=treasury_yield_trend_china(term="1Y")
|
2723
|
+
rates=treasury_yield_trend_china(term=["1Y","5Y","10Y"])
|
2724
|
+
|
2725
|
+
def treasury_trend_china(term="1Y",start="MRY",end="today", \
|
2726
|
+
power=0, \
|
2727
|
+
average_value=False, \
|
2728
|
+
mark_top=False,mark_bottom=False,mark_end=False, \
|
2729
|
+
annotate=True,annotate_value=True, \
|
2730
|
+
twinx=False, \
|
2731
|
+
loc1="best",loc2="best", \
|
2732
|
+
facecolor="papayawhip"):
|
2733
|
+
"""
|
2734
|
+
|
2735
|
+
功能:分析中国国债收益率走势,支持单个期限或多个期限进行对比
|
2736
|
+
"""
|
2737
|
+
#检查国债期限
|
2738
|
+
term_list=['3M','6M','1Y','3Y','5Y','7Y','10Y','30Y']
|
2739
|
+
term_list_names=['3个月','6个月','1年期','3年期','5年期','7年期','10年期','30年期']
|
2740
|
+
|
2741
|
+
start1,end1=start_end_preprocess(start,end)
|
2742
|
+
#期间不能超过一年
|
2743
|
+
import pandas as pd
|
2744
|
+
date1=pd.to_datetime(start1)
|
2745
|
+
date2=pd.to_datetime(end1)
|
2746
|
+
days=days_between_dates(date1, date2)
|
2747
|
+
if days>=365:
|
2748
|
+
days=365
|
2749
|
+
start1=date_adjust(end1, adjust=-days)
|
2750
|
+
|
2751
|
+
if isinstance(term,str):
|
2752
|
+
if not term in term_list:
|
2753
|
+
print(" #Warning(treasury_trend_china): unsupported treasury term",term)
|
2754
|
+
print(" Supported terms:", end='')
|
2755
|
+
print_list(term_list,leading_blanks=1,end='\n')
|
2756
|
+
return None
|
2757
|
+
termlist=[term]
|
2758
|
+
elif isinstance(term,list):
|
2759
|
+
for t in term:
|
2760
|
+
if not t in term_list:
|
2761
|
+
print(" #Warning(treasury_trend_china): unsupported treasury term",t)
|
2762
|
+
term.remove(t)
|
2763
|
+
termlist=term
|
2764
|
+
else:
|
2765
|
+
print(" #Warning(treasury_trend_china):",term," is unsupported")
|
2766
|
+
print(" Supported terms:", end='')
|
2767
|
+
print_list(term_list,leading_blanks=1,end='\n')
|
2768
|
+
return None
|
2769
|
+
|
2770
|
+
print(" Searching treasury information in China ...")
|
2771
|
+
df=pd.DataFrame()
|
2772
|
+
for t in termlist:
|
2773
|
+
if len(termlist) > 1:
|
2774
|
+
print_progress_percent2(t,termlist,steps=len(termlist),leading_blanks=4)
|
2775
|
+
|
2776
|
+
dftmp=treasury_yields_china(start1,end1,term=t)
|
2777
|
+
dftmp[t]=dftmp['rate']*100 #转换为百分数
|
2778
|
+
dftmp1=pd.DataFrame(dftmp[t])
|
2779
|
+
|
2780
|
+
if len(df)==0:
|
2781
|
+
df=dftmp1
|
2782
|
+
else:
|
2783
|
+
df=pd.merge(df,dftmp1,left_index=True,right_index=True)
|
2784
|
+
|
2785
|
+
#绘图
|
2786
|
+
titletxt=text_lang("中国国债收益率走势","China Treasury Yield Trend")
|
2787
|
+
ylabeltxt=text_lang('收益率%',"Yield%")
|
2788
|
+
import datetime; todaydt = datetime.date.today()
|
2789
|
+
footnote=text_lang("数据来源:中国债券信息网,","Data source: China Bond Info, ")+str(todaydt)
|
2790
|
+
|
2791
|
+
if len(termlist)==1: #单曲线
|
2792
|
+
pos=term_list.index(termlist[0])
|
2793
|
+
termname=term_list_names[pos]
|
2794
|
+
ylabeltxt=text_lang(termname+ylabeltxt,termlist[0]+' '+ylabeltxt)
|
2795
|
+
|
2796
|
+
plot_line(df,colname=termlist[0],collabel=termlist[0], \
|
2797
|
+
ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote, \
|
2798
|
+
power=power,average_value=average_value, \
|
2799
|
+
loc=loc1, \
|
2800
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
2801
|
+
facecolor=facecolor)
|
2802
|
+
|
2803
|
+
if len(termlist)==2: #两条曲线,twinx
|
2804
|
+
bond1=termlist[0]; pos1=term_list.index(bond1); bond1name=term_list_names[pos1]
|
2805
|
+
bond2=termlist[1]; pos2=term_list.index(bond2); bond2name=term_list_names[pos2]
|
2708
2806
|
|
2807
|
+
df1=pd.DataFrame(df[bond1]); ticker1=''; colname1=bond1; label1=bond1name
|
2808
|
+
df2=pd.DataFrame(df[bond2]); ticker2=''; colname2=bond2; label2=bond2name
|
2809
|
+
|
2810
|
+
plot_line2(df1,ticker1,colname1,label1, \
|
2811
|
+
df2,ticker2,colname2,label2, \
|
2812
|
+
ylabeltxt=ylabeltxt,titletxt=titletxt,footnote=footnote, \
|
2813
|
+
power=power, \
|
2814
|
+
twinx=twinx, \
|
2815
|
+
loc1=loc1,loc2=loc2, \
|
2816
|
+
color1='red',color2='blue',facecolor=facecolor)
|
2817
|
+
|
2818
|
+
if len(termlist) > 2: #多条曲线
|
2819
|
+
df['date']=df.index
|
2820
|
+
df.set_index("date",inplace=True)
|
2821
|
+
|
2822
|
+
for t in termlist:
|
2823
|
+
tpos=term_list.index(t); tname=term_list_names[tpos]
|
2824
|
+
df.rename(columns={t:tname},inplace=True)
|
2825
|
+
|
2826
|
+
draw_lines(df,y_label=ylabeltxt,x_label=footnote, \
|
2827
|
+
axhline_value=0,axhline_label='', \
|
2828
|
+
title_txt=titletxt, \
|
2829
|
+
data_label=False, \
|
2830
|
+
loc=loc1,annotate=annotate,annotate_value=annotate_value, \
|
2831
|
+
mark_top=mark_top,mark_bottom=mark_bottom,mark_end=mark_end, \
|
2832
|
+
facecolor=facecolor)
|
2833
|
+
|
2834
|
+
return df
|
2835
|
+
|
2836
|
+
|
2709
2837
|
#==============================================================================
|
siat/common.py
CHANGED
@@ -1361,38 +1361,45 @@ if __name__=='__main__':
|
|
1361
1361
|
shibor_rate('2021-11-19',rate_period='ON')
|
1362
1362
|
#==============================================================================
|
1363
1363
|
if __name__=='__main__':
|
1364
|
-
start='
|
1365
|
-
end='
|
1364
|
+
start='2023-11-1'
|
1365
|
+
end='2024-10-30'
|
1366
1366
|
term='1Y'
|
1367
|
+
|
1368
|
+
treasury_yields_china(start,end,term='1Y')
|
1367
1369
|
|
1368
|
-
def treasury_yields_china(start,end,term='1Y'):
|
1370
|
+
def treasury_yields_china(start,end='today',term='1Y'):
|
1369
1371
|
"""
|
1370
1372
|
功能:抓取指定期间和期限的国债收益率
|
1371
1373
|
|
1372
1374
|
注意:这里得到的是年化利率,不带百分号,不是日利率!(日利率=年化利率/365)
|
1373
1375
|
"""
|
1376
|
+
start,end=start_end_preprocess(start,end)
|
1377
|
+
|
1374
1378
|
#检查日期期间
|
1375
1379
|
valid,start1,end1=check_period(start,end)
|
1376
1380
|
if not valid:
|
1377
|
-
print(" #
|
1381
|
+
print(" #Warning(treasury_yields_china): invalid date period from",start,"to",end)
|
1378
1382
|
return None
|
1379
1383
|
|
1380
1384
|
#检查利率期间有效性
|
1381
1385
|
term_list=['3M','6M','1Y','3Y','5Y','7Y','10Y','30Y']
|
1382
1386
|
if not (term in term_list):
|
1383
|
-
print(" #
|
1387
|
+
print(" #Warning(treasury_yields_china): invalid rate period",term)
|
1384
1388
|
print(" Supported rate periods:",term_list)
|
1385
1389
|
return None
|
1386
1390
|
|
1387
1391
|
#抓取中债国债收益率
|
1388
1392
|
import akshare as ak
|
1389
|
-
|
1393
|
+
start2=start1.strftime("%Y%m%d")
|
1394
|
+
end2=end1.strftime("%Y%m%d")
|
1395
|
+
df = ak.bond_china_yield(start_date=start2,end_date=end2)
|
1390
1396
|
if len(df)==0:
|
1397
|
+
print(" #Warning(treasury_yields_china): empty data found, try again later")
|
1391
1398
|
return None
|
1392
1399
|
|
1393
1400
|
df1=df[df['曲线名称']=='中债国债收益率曲线']
|
1394
1401
|
df1.columns=['curve','date']+term_list
|
1395
|
-
df1.sort_values(by=['date'],ascending=
|
1402
|
+
df1.sort_values(by=['date'],ascending=True,inplace=True)
|
1396
1403
|
|
1397
1404
|
df1['Date']=pd.to_datetime(df1['date'])
|
1398
1405
|
df1.set_index(['Date'],inplace=True)
|
@@ -1401,6 +1408,7 @@ def treasury_yields_china(start,end,term='1Y'):
|
|
1401
1408
|
df1['period']=term
|
1402
1409
|
df2=df1[['date','rate','period']]
|
1403
1410
|
|
1411
|
+
|
1404
1412
|
return df2
|
1405
1413
|
|
1406
1414
|
if __name__=='__main__':
|
@@ -4312,7 +4320,6 @@ def df_annual_return(df):
|
|
4312
4320
|
|
4313
4321
|
#==============================================================================
|
4314
4322
|
|
4315
|
-
|
4316
4323
|
if __name__ == '__main__':
|
4317
4324
|
df=security_trend("600519.SS",graph=False)
|
4318
4325
|
option="save"
|
@@ -4329,15 +4336,20 @@ def df_save(df,file="df"):
|
|
4329
4336
|
file_name=file
|
4330
4337
|
else:
|
4331
4338
|
file_name=file+'.pkl'
|
4339
|
+
|
4340
|
+
try:
|
4341
|
+
df.to_pickle(file_name)
|
4332
4342
|
|
4333
|
-
|
4334
|
-
|
4343
|
+
import os; path=os.getcwd()
|
4344
|
+
print(" Data is saved to file",path+"\\"+file_name)
|
4345
|
+
except:
|
4346
|
+
print(" #Error(df_save): failed to save data to file",file_name)
|
4335
4347
|
|
4336
4348
|
return
|
4337
4349
|
|
4338
4350
|
def df_restore(file):
|
4339
4351
|
"""
|
4340
|
-
|
4352
|
+
功能:从文件恢复df数据,适用于那些需要大量时间获取的df
|
4341
4353
|
"""
|
4342
4354
|
|
4343
4355
|
import pandas as pd
|
@@ -4349,13 +4361,42 @@ def df_restore(file):
|
|
4349
4361
|
|
4350
4362
|
try:
|
4351
4363
|
df=pd.read_pickle(file_name)
|
4352
|
-
|
4364
|
+
|
4365
|
+
import os; path=os.getcwd()
|
4366
|
+
print(" Data is restored from file",path+"\\"+file_name)
|
4353
4367
|
except:
|
4354
|
-
print(" #
|
4368
|
+
print(" #Error(df_restore): file not found for",file_name)
|
4355
4369
|
df=None
|
4356
4370
|
return df
|
4357
4371
|
|
4358
4372
|
|
4359
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
|
+
|
4380
|
+
def annual_compound_growth(df,column="Close"):
|
4381
|
+
"""
|
4382
|
+
|
4383
|
+
功能:计算df[column]的简单年均复合增长率,假定df按照日期顺序升序排列
|
4384
|
+
"""
|
4385
|
+
if not "Close" in list(df):
|
4386
|
+
print(" Sorry, column",column,"not found in the dataframe")
|
4387
|
+
return
|
4388
|
+
|
4389
|
+
day1=df.index[0]; day2=df.index[-1]
|
4390
|
+
days=days_between_dates(day1, day2)
|
4391
|
+
|
4392
|
+
years=days / 365
|
4393
|
+
|
4394
|
+
import numpy as np
|
4395
|
+
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,2)
|
4396
|
+
rate_str=str(growth_rate)+'%'
|
4397
|
+
|
4398
|
+
print("Annual compound growth rate:",rate_str)
|
4399
|
+
|
4400
|
+
return
|
4360
4401
|
#==============================================================================
|
4361
4402
|
#==============================================================================
|
siat/fund_china.py
CHANGED
@@ -911,7 +911,7 @@ def oef_rank_china2(df,fund_type='全部类型',rank=5,indicator='单位净值')
|
|
911
911
|
formatted_hour = time.strftime("%H", current_time)
|
912
912
|
footnote5=''
|
913
913
|
if (formatted_hour >= '18' or formatted_hour <= '06') and not is_weekend(todaydt):
|
914
|
-
footnote5="
|
914
|
+
footnote5="注意:此时若为数据源更新时段,获取的信息可能不全\n"
|
915
915
|
|
916
916
|
footnote=footnote1+footnote2+footnote3+footnote4+footnote5
|
917
917
|
|
@@ -1149,7 +1149,7 @@ def oef_rank_china(indicator='单位净值',fund_type='全部类型',rank=5):
|
|
1149
1149
|
formatted_hour = time.strftime("%H", current_time)
|
1150
1150
|
footnote4=''
|
1151
1151
|
if formatted_hour > '17':
|
1152
|
-
footnote4="
|
1152
|
+
footnote4="此时若为数据源更新时段,获取的信息可能不全\n"
|
1153
1153
|
|
1154
1154
|
footnote5="数据来源:新浪财经/天天基金"
|
1155
1155
|
footnote=footnote1+footnote2+footnote3+footnote4+footnote5
|
siat/grafix.py
CHANGED
@@ -209,7 +209,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
209
209
|
#y1=round(y+high_low*0.01,2)
|
210
210
|
y1=y+high_low*0.01
|
211
211
|
#s='%.0f' if y >= 100 else '%.2f'
|
212
|
-
s='%.
|
212
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
213
213
|
plt.text(x,y1,s % y,ha='right',va='bottom',color='red')
|
214
214
|
"""
|
215
215
|
s='%.0f' if y >= 100 else '%.2f'
|
@@ -224,7 +224,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
224
224
|
#y1=round(y-high_low*0.055,2) #标记位置对应y1的底部
|
225
225
|
y1=y-high_low*0.050 #标记位置对应y1的底部
|
226
226
|
#s='%.0f' if y >= 100 else '%.2f'
|
227
|
-
s='%.
|
227
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
228
228
|
#plt.text(x,y1,s % y,ha='center',va='bottom',color='seagreen')
|
229
229
|
plt.text(x,y1,s % y,ha='right',va='bottom',color='seagreen')
|
230
230
|
plt.scatter(x,y, color='seagreen',marker='8',s=70)
|
@@ -236,7 +236,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
236
236
|
x_end = df_end[colname].idxmin() # 末端值的x坐标
|
237
237
|
|
238
238
|
#y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
|
239
|
-
y1=str(
|
239
|
+
y1=str(round(y_end,2)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,3))
|
240
240
|
plt.annotate(text=' '+y1,
|
241
241
|
xy=(x_end, y_end),
|
242
242
|
xytext=(x_end, y_end),fontsize=annotate_size)
|
@@ -1242,7 +1242,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1242
1242
|
|
1243
1243
|
if annotate_value: #在标记曲线名称的同时标记其末端数值
|
1244
1244
|
#y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
|
1245
|
-
y1=str(
|
1245
|
+
y1=str(round(y_end,2)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,3))
|
1246
1246
|
plt.annotate(text=c+':'+y1,
|
1247
1247
|
xy=(x_end, y_end),
|
1248
1248
|
xytext=(x_end, y_end),fontsize=annotate_size,
|
@@ -1274,7 +1274,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1274
1274
|
#y1=round(y+high_low*0.01,2)
|
1275
1275
|
y1=y+high_low*0.01
|
1276
1276
|
#s='%.0f' if y >= 100 else '%.2f'
|
1277
|
-
s='%.
|
1277
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
1278
1278
|
#plt.text(x,y1,s % y,ha='center',va='bottom',color='red')
|
1279
1279
|
plt.text(x,y1,s % y,ha='right',va='bottom',color=last_line_color)
|
1280
1280
|
plt.scatter(x,y, color='red',marker='8',s=70)
|
@@ -1285,7 +1285,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1285
1285
|
#y1=round(y-high_low*0.055,2) #标记位置对应y1的底部
|
1286
1286
|
y1=y-high_low*0.050 #标记位置对应y1的底部
|
1287
1287
|
#s='%.0f' if y >= 100 else '%.2f'
|
1288
|
-
s='%.
|
1288
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
1289
1289
|
#plt.text(x,y1,s % y,ha='center',va='bottom',color='seagreen')
|
1290
1290
|
plt.text(x,y1,s % y,ha='right',va='bottom',color=last_line_color)
|
1291
1291
|
plt.scatter(x,y, color='seagreen',marker='8',s=70)
|
@@ -1297,7 +1297,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1297
1297
|
x_end = df_end[c].idxmin() # 末端值的x坐标
|
1298
1298
|
|
1299
1299
|
#y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
|
1300
|
-
y1=str(
|
1300
|
+
y1=str(round(y_end,2)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,3))
|
1301
1301
|
plt.annotate(text=' '+y1,
|
1302
1302
|
xy=(x_end, y_end),
|
1303
1303
|
xytext=(x_end, y_end),fontsize=annotate_size,
|
@@ -1471,7 +1471,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1471
1471
|
#y1=round(y+high_low*0.01,2)
|
1472
1472
|
y1=y+high_low*0.01
|
1473
1473
|
#s='%.0f' if y >= 100 else '%.2f'
|
1474
|
-
s='%.
|
1474
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
1475
1475
|
#plt.text(x,y1,s % y,ha='center',va='bottom',color='red')
|
1476
1476
|
plt.text(x,y1,s % y,ha='right',va='bottom',color=last_line_color)
|
1477
1477
|
plt.scatter(x,y, color='red',marker='8',s=70)
|
@@ -1482,7 +1482,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1482
1482
|
#y1=round(y-high_low*0.055,2) #标记位置对应y1的底部
|
1483
1483
|
y1=y-high_low*0.050 #标记位置对应y1的底部
|
1484
1484
|
#s='%.0f' if y >= 100 else '%.2f'
|
1485
|
-
s='%.
|
1485
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.3f'
|
1486
1486
|
#plt.text(x,y1,s % y,ha='center',va='bottom',color='seagreen')
|
1487
1487
|
plt.text(x,y1,s % y,ha='right',va='bottom',color=last_line_color)
|
1488
1488
|
plt.scatter(x,y, color='seagreen',marker='8',s=70)
|
@@ -1513,7 +1513,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1513
1513
|
x_end = df_end[c].idxmin() # 末端值的x坐标
|
1514
1514
|
|
1515
1515
|
#y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
|
1516
|
-
y1=str(
|
1516
|
+
y1=str(round(y_end,2)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,3))
|
1517
1517
|
plt.annotate(text=y1,
|
1518
1518
|
xy=(x_end, y_end),
|
1519
1519
|
xytext=(x_end, y_end),fontsize=annotate_size,
|
siat/stock.py
CHANGED
@@ -681,6 +681,10 @@ def security_indicator(ticker,indicator, \
|
|
681
681
|
adjust=adjust, \
|
682
682
|
todate=todate,source=source,ticker_type=ticker_type)
|
683
683
|
|
684
|
+
if not found == "Found":
|
685
|
+
print(" #Error(security_indicator): no security info found for",ticker)
|
686
|
+
return None
|
687
|
+
|
684
688
|
# 去掉时区信息,避免日期时区冲突问题
|
685
689
|
pricedf=df_index_timezone_remove(pricedf)
|
686
690
|
"""
|
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','韩国综合指数'],
|
@@ -1949,7 +1951,8 @@ def codetranslate1(code):
|
|
1949
1951
|
['000019.SS','SSE Governance Index'],['000048.SS','SSE CSR Index'],
|
1950
1952
|
|
1951
1953
|
['899050.BJ','BSE50 Index'],['^SPX','Standard & Poor 500 Index'],
|
1952
|
-
['^RUT','Russell 2000 Index'],['^
|
1954
|
+
['^RUT','Russell 2000 Index'],['^RUI','Russell 1000 Index'],
|
1955
|
+
['^NKX','Nikkei 225 Index'],
|
1953
1956
|
['^NDQ','NASDAQ Composite Index'],['^NDX','NASDAQ 100 Index'],
|
1954
1957
|
['IBM','IBM Corp'],
|
1955
1958
|
|
@@ -2000,7 +2003,8 @@ def codetranslate1(code):
|
|
2000
2003
|
['^SNX','India SENSEX 30 Index'],['^FTM','UK FTSE 250 Index'],
|
2001
2004
|
['^KLCI','Kuala Lumpur Composite Index'],['^KLSE','Kuala Lumpur Composite Index'],
|
2002
2005
|
|
2003
|
-
['FVTT.FGI','FTSE Viernam Index'],
|
2006
|
+
['FVTT.FGI','FTSE Viernam Index'],
|
2007
|
+
['^RUT','Russell 2000 Index'],['^RUI','Russell 1000 Index'],
|
2004
2008
|
['^HSI','Hang Seng Index'],['^N225','Nikkei 225 Index'],
|
2005
2009
|
['WIKOR.FGI','FTSE Korea Index'],['^KS11','Korea Composite Index'],
|
2006
2010
|
['^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
|
@@ -9,7 +9,7 @@ siat/beta_adjustment.py,sha256=viJJE9O82SbA_VYuJtrs3HT0OWYhk4yvmoywskrAhaI,37287
|
|
9
9
|
siat/beta_adjustment_china.py,sha256=QAVhTQxfV7NSakNPMfQtGMeRzEHVBC8JZQTqD5Owp2I,20802
|
10
10
|
siat/beta_adjustment_test.py,sha256=nBhvQQfqxooCHjy5hL0a8V0ZC58BjuCZVFpqpWpHeF0,2467
|
11
11
|
siat/blockchain.py,sha256=awF3GDtlwaJhku0a2kLuXOS8d3IzkjR_RyzlZWvD3L4,6032
|
12
|
-
siat/bond.py,sha256=
|
12
|
+
siat/bond.py,sha256=BswqLEiOWbsfYD6ZDVLrvgQRQu2qGVzMDnf8y7RHQLU,109140
|
13
13
|
siat/bond_base.py,sha256=KBm0hOQSE6fruXd9eJztY9pXCN19iv7aCXZZcnVM4yY,37637
|
14
14
|
siat/bond_china.py,sha256=eYv-nMoWSS5fZ4VxnuJ29QFY9GUS6meGiIc0Xjm1fQI,3038
|
15
15
|
siat/bond_test.py,sha256=yUOFw7ddGU-kb1rJdnsjkJWziDNgUR7OLDA7F7Ub91A,5246
|
@@ -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=fWeaJYg9sb_cvX_VDLlz_0ph3cXhnoTMd_R8UyArGTY,159842
|
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
|
@@ -53,14 +53,14 @@ siat/financials_test.py,sha256=HJ3CPo_Xckz2wXi3AEP6ZNWCF1Duc1pLi0Y10USiImc,23829
|
|
53
53
|
siat/fred_test.py,sha256=KF50ssSbsfpa_kT6iuomD0vG4eXztAcOasZxg1OGX5w,1201
|
54
54
|
siat/fund.py,sha256=wMDORsCBV8ZXfgwbtq-0bu3qqWY66dHnbqgllW0gWCo,24637
|
55
55
|
siat/fund_china.pickle,sha256=x_nPPdwy7wzIhtZQOplgDyTSyyUdXy9lbNxWysq7N6k,2437771
|
56
|
-
siat/fund_china.py,sha256=
|
56
|
+
siat/fund_china.py,sha256=jRAibZiHXAjUwlHoIiXK_moFhEYvVzl2Q0FhfYRZiFk,111907
|
57
57
|
siat/fund_china_test.py,sha256=-Bh6m0J0GPpIbYXx-H2vpzJoNFI6pE2C2jVPa8DazgE,6649
|
58
58
|
siat/fund_test.py,sha256=V4ADb8Gsp8gyeFTwcgRsJBpnUih_O-Q2V1ILc5oKjK8,1116
|
59
59
|
siat/future_china.py,sha256=F-HsIf2Op8Z22RzTjet1g8COzldgnMjFNSXsAkeGyWo,17595
|
60
60
|
siat/future_china_test.py,sha256=BrSzmDVaOHki6rntOtosmRn-6dkfOBuLulJNqh7MOpc,1163
|
61
61
|
siat/global_index_test.py,sha256=hnFp3wqqzzL-kAP8mgxDZ54Bd5Ijf6ENi5YJlGBgcXw,2402
|
62
62
|
siat/google_authenticator.py,sha256=ZUbZR8OW0IAKDbcYtlqGqIpZdERpFor9NccFELxg9yI,1637
|
63
|
-
siat/grafix.py,sha256=
|
63
|
+
siat/grafix.py,sha256=9brQItikS7aHXO1mnwgEYCzfq1tjzOHWOCVgiFyaHNA,87873
|
64
64
|
siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
|
65
65
|
siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
|
66
66
|
siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
|
@@ -105,7 +105,7 @@ siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmW
|
|
105
105
|
siat/security_trend2.py,sha256=JHrO5zDBYMLbpvotdaqaUcFrxm2di60kMVOdeom8t8A,26336
|
106
106
|
siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
|
107
107
|
siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
|
108
|
-
siat/stock.py,sha256
|
108
|
+
siat/stock.py,sha256=-vhAVxaEjoF3jlU2geAI3Y_OT9-IsEz21DFSOy68QCA,155054
|
109
109
|
siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
|
110
110
|
siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
|
111
111
|
siat/stock_china.py,sha256=zyUyghIrkkkYWlHRRP7Hoblxzfp-jrck60pTJpwMahg,91553
|
@@ -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=F_lG6sDPqXNNGGMUuJG5sKlbT5rHg-MbJv9Gj0Z78bg,241020
|
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.10.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
144
|
+
siat-3.5.10.dist-info/METADATA,sha256=VhLy7oNbXKyaSoco22mVNFWrHWnlE5sihNkMIZgU9Mk,8010
|
145
|
+
siat-3.5.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
146
|
+
siat-3.5.10.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
147
|
+
siat-3.5.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|