siat 3.5.10__py3-none-any.whl → 3.5.12__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 +18 -8
- siat/grafix.py +9 -9
- siat/security_price2.py +5 -0
- siat/security_prices.py +19 -4
- siat/stock.py +36 -15
- siat/stooq.py +2 -1
- siat/translate.py +6 -3
- siat/yf_name.py +127 -3
- {siat-3.5.10.dist-info → siat-3.5.12.dist-info}/METADATA +1 -1
- {siat-3.5.10.dist-info → siat-3.5.12.dist-info}/RECORD +13 -13
- {siat-3.5.10.dist-info → siat-3.5.12.dist-info}/LICENSE +0 -0
- {siat-3.5.10.dist-info → siat-3.5.12.dist-info}/WHEEL +0 -0
- {siat-3.5.10.dist-info → siat-3.5.12.dist-info}/top_level.txt +0 -0
siat/common.py
CHANGED
@@ -2916,15 +2916,15 @@ def fix_package(file='stooq.py',package='pandas_datareader'):
|
|
2916
2916
|
result=copyfile(srcfile,objfile)
|
2917
2917
|
except IOError as e:
|
2918
2918
|
print(" #Error(fix_package): Unable to copy file. %s" % e)
|
2919
|
-
print(" Program failed most likely becos of incorrect source/target directories.")
|
2919
|
+
print(" Program failed, most likely becos of incorrect source/target directories.")
|
2920
2920
|
print(" Solution: manually copy the file",srcfile,"to the folder",objpath1)
|
2921
2921
|
#exit(1)
|
2922
2922
|
except:
|
2923
2923
|
print(" #Error(fix_package): Unexpected error:", sys.exc_info())
|
2924
2924
|
#exit(1)
|
2925
2925
|
else:
|
2926
|
-
print("
|
2927
|
-
print(" Please RESTART
|
2926
|
+
print(" Overrided",file,"in",package)
|
2927
|
+
print(" Please RESTART Python kernel before using siat")
|
2928
2928
|
|
2929
2929
|
return
|
2930
2930
|
|
@@ -3737,7 +3737,7 @@ def df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2,
|
|
3737
3737
|
first_col_align='left',second_col_align='right', \
|
3738
3738
|
last_col_align='right',other_col_align='right', \
|
3739
3739
|
titile_font_size='16px',heading_font_size='15px', \
|
3740
|
-
data_font_size='
|
3740
|
+
data_font_size='14px',footnote_font_size='13px'):
|
3741
3741
|
"""
|
3742
3742
|
功能:采样CSS式样显示df,适用于Jupyter环境,整齐紧凑,不挑浏览器
|
3743
3743
|
注意:若facecolor不被支持,则自动改为papayawhip
|
@@ -3808,7 +3808,14 @@ def df_display_CSS(df,titletxt='',footnote='',facecolor='papayawhip',decimals=2,
|
|
3808
3808
|
display(style6)
|
3809
3809
|
|
3810
3810
|
if not footnote=='':
|
3811
|
-
print(footnote)
|
3811
|
+
#print(footnote)
|
3812
|
+
|
3813
|
+
from IPython.display import display, HTML
|
3814
|
+
ft_list=footnote.split('\n') #分行显示,因下列显示方式无法识别换行
|
3815
|
+
for ft in ft_list:
|
3816
|
+
# 使用HTML和CSS设置字体大小
|
3817
|
+
html_code = f'<p style="font-size:{footnote_font_size};">{ft}</p>'
|
3818
|
+
display(HTML(html_code))
|
3812
3819
|
#print('') #空一行
|
3813
3820
|
|
3814
3821
|
return
|
@@ -4376,13 +4383,15 @@ if __name__ == '__main__':
|
|
4376
4383
|
column='Close'
|
4377
4384
|
|
4378
4385
|
annual_compound_growth(df,"Close")
|
4386
|
+
annual_compound_growth(df,"High")
|
4379
4387
|
|
4380
4388
|
def annual_compound_growth(df,column="Close"):
|
4381
4389
|
"""
|
4382
4390
|
|
4383
4391
|
功能:计算df[column]的简单年均复合增长率,假定df按照日期顺序升序排列
|
4392
|
+
适用于计算长期股价/指数的年均复合增长率,不适用于收益率的年均复合增长率计算
|
4384
4393
|
"""
|
4385
|
-
if not
|
4394
|
+
if not column in list(df):
|
4386
4395
|
print(" Sorry, column",column,"not found in the dataframe")
|
4387
4396
|
return
|
4388
4397
|
|
@@ -4392,10 +4401,11 @@ def annual_compound_growth(df,column="Close"):
|
|
4392
4401
|
years=days / 365
|
4393
4402
|
|
4394
4403
|
import numpy as np
|
4395
|
-
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,
|
4404
|
+
growth_rate=round((np.power(df[column][-1]/df[column][0],1/years)-1)*100,3)
|
4396
4405
|
rate_str=str(growth_rate)+'%'
|
4397
4406
|
|
4398
|
-
|
4407
|
+
day1str=day1.strftime("%Y-%m-%d"); day2str=day2.strftime("%Y-%m-%d")
|
4408
|
+
print("Annualized compound growth",rate_str,"from",day1str,"to",day2str)
|
4399
4409
|
|
4400
4410
|
return
|
4401
4411
|
#==============================================================================
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
212
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
227
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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(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,
|
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,4))
|
240
240
|
plt.annotate(text=' '+y1,
|
241
241
|
xy=(x_end, y_end),
|
242
242
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
1277
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
1288
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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(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,
|
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,4))
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
1474
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.
|
1485
|
+
s='%.2f' if abs(y) >= 100 else '%.2f' if abs(y) >= 10 else '%.4f'
|
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)
|
@@ -1495,7 +1495,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1495
1495
|
|
1496
1496
|
if annotate_value: #在标记曲线名称的同时标记其末端数值
|
1497
1497
|
#y1=str(int(y_end)) if y_end >= 100 else str(round(y_end,2))
|
1498
|
-
y1=str(int(y_end)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,
|
1498
|
+
y1=str(int(y_end)) if abs(y_end) >= 100 else str(round(y_end,2)) if abs(y_end) >= 10 else str(round(y_end,4))
|
1499
1499
|
plt.annotate(text=c+':'+y1,
|
1500
1500
|
xy=(x_end, y_end),
|
1501
1501
|
xytext=(x_end, y_end),fontsize=annotate_size,
|
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"基金的代码:-(
|
@@ -2837,6 +2850,7 @@ def fetch_price_swindex(ticker,start,end,info_types=['Close','Volume'],adjust=-2
|
|
2837
2850
|
info_types:信息测度,默认['Close'],还可以为['Close','Open','High','Low',
|
2838
2851
|
'Volume','Adj Close']
|
2839
2852
|
特点:为compare_indicator使用,包括指数名称
|
2853
|
+
|
2840
2854
|
"""
|
2841
2855
|
df=None
|
2842
2856
|
|
@@ -2854,6 +2868,7 @@ def fetch_price_swindex(ticker,start,end,info_types=['Close','Volume'],adjust=-2
|
|
2854
2868
|
ticker=ticker+'.SW'
|
2855
2869
|
ticker6=ticker[:6]
|
2856
2870
|
try:
|
2871
|
+
# 注意:如果失败,尝试升级akshare
|
2857
2872
|
prices= ak.index_hist_sw(symbol=ticker6,period="day")
|
2858
2873
|
except:
|
2859
2874
|
try:
|
siat/stock.py
CHANGED
@@ -2571,12 +2571,23 @@ if __name__ =="__main__":
|
|
2571
2571
|
fromdate="2021-1-1"
|
2572
2572
|
todate="2022-9-26"
|
2573
2573
|
|
2574
|
-
|
2574
|
+
|
2575
|
+
def security_dividend(ticker,start="L3Y",end="today",facecolor='whitesmoke',fontcolor='black'):
|
2576
|
+
"""
|
2577
|
+
功能:套壳函数stock_dividend
|
2578
|
+
"""
|
2579
|
+
df=stock_dividend(ticker,start,end,facecolor,fontcolor)
|
2580
|
+
return df
|
2581
|
+
|
2582
|
+
|
2583
|
+
def stock_dividend(ticker,start="L3Y",end="today",facecolor='whitesmoke',fontcolor='black'):
|
2575
2584
|
"""
|
2576
2585
|
功能:显示股票的分红历史
|
2577
2586
|
输入:单一股票代码
|
2578
2587
|
输出:分红历史
|
2579
2588
|
"""
|
2589
|
+
start,end=start_end_preprocess(start,end)
|
2590
|
+
|
2580
2591
|
fromdate,todate=start,end
|
2581
2592
|
|
2582
2593
|
print(" Searching for the dividend info of stock",ticker,"... ...")
|
@@ -2649,24 +2660,24 @@ def stock_dividend(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
|
|
2649
2660
|
|
2650
2661
|
lang=check_language()
|
2651
2662
|
tname=ticker_name(ticker,'stock')
|
2652
|
-
fromdatey2md=startdt.strftime('%
|
2653
|
-
todatey2md=enddt.strftime('%
|
2663
|
+
fromdatey2md=startdt.strftime('%Y/%m/%d')
|
2664
|
+
todatey2md=enddt.strftime('%Y/%m/%d')
|
2654
2665
|
|
2655
|
-
titletxt=text_lang("
|
2656
|
-
periodtxt=text_lang("
|
2666
|
+
titletxt=text_lang("证券分红","Stock Dividend")+': '+tname
|
2667
|
+
periodtxt=text_lang("期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
|
2657
2668
|
#sourcetxt=text_lang("数据来源: 雅虎财经,","Data source: Yahoo Finance,")
|
2658
|
-
sourcetxt=text_lang("数据来源:
|
2669
|
+
sourcetxt=text_lang("数据来源: Yahoo/Sina","Data source: Yahoo/Sina")
|
2659
2670
|
footnote=periodtxt+'\n'+sourcetxt
|
2660
2671
|
|
2661
2672
|
#修改列命为英文
|
2662
|
-
divprt.columns = [text_lang('序号','No.'),text_lang('日期','Date'),text_lang('星期','Weekday'),text_lang('
|
2673
|
+
divprt.columns = [text_lang('序号','No.'),text_lang('日期','Date'),text_lang('星期','Weekday'),text_lang('每股(份)红利','Dividend/share')]
|
2663
2674
|
|
2664
2675
|
"""
|
2665
2676
|
print(divprt.to_string(index=False))
|
2666
2677
|
"""
|
2667
2678
|
#print('') #空一行
|
2668
2679
|
|
2669
|
-
df_display_CSS(divprt,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=
|
2680
|
+
df_display_CSS(divprt,titletxt=titletxt,footnote=footnote,facecolor='papayawhip',decimals=4, \
|
2670
2681
|
first_col_align='center',second_col_align='center', \
|
2671
2682
|
last_col_align='right',other_col_align='center')
|
2672
2683
|
|
@@ -2701,13 +2712,23 @@ if __name__ =="__main__":
|
|
2701
2712
|
fromdate='2019-1-1'
|
2702
2713
|
todate='2020-6-30'
|
2703
2714
|
|
2704
|
-
#==============================================================================
|
2705
|
-
def
|
2715
|
+
#==============================================================================
|
2716
|
+
def security_split(ticker,start="L10Y",end="today",facecolor='whitesmoke',fontcolor='black'):
|
2717
|
+
"""
|
2718
|
+
功能:套壳函数stock_split
|
2719
|
+
"""
|
2720
|
+
df=stock_split(ticker,start,end,facecolor,fontcolor)
|
2721
|
+
return df
|
2722
|
+
|
2723
|
+
|
2724
|
+
def stock_split(ticker,start="L10Y",end="today",facecolor='whitesmoke',fontcolor='black'):
|
2706
2725
|
"""
|
2707
2726
|
功能:显示股票的分拆历史
|
2708
2727
|
输入:单一股票代码
|
2709
2728
|
输出:分拆历史
|
2710
2729
|
"""
|
2730
|
+
start,end=start_end_preprocess(start,end)
|
2731
|
+
|
2711
2732
|
fromdate,todate=start,end
|
2712
2733
|
|
2713
2734
|
print(" Searching for the split info of stock",ticker,"... ...")
|
@@ -2803,15 +2824,15 @@ def stock_split(ticker,start,end,facecolor='whitesmoke',fontcolor='black'):
|
|
2803
2824
|
today = datetime.date.today()
|
2804
2825
|
print('\n*** '+sourcetxt,today)
|
2805
2826
|
"""
|
2806
|
-
fromdatey2md=startdt.strftime('%
|
2807
|
-
todatey2md=enddt.strftime('%
|
2827
|
+
fromdatey2md=startdt.strftime('%Y/%m/%d')
|
2828
|
+
todatey2md=enddt.strftime('%Y/%m/%d')
|
2808
2829
|
|
2809
|
-
titletxt=text_lang("
|
2810
|
-
periodtxt=text_lang("
|
2830
|
+
titletxt=text_lang("证券分拆","Stock Split")+': '+tname
|
2831
|
+
periodtxt=text_lang("期间:","Period:")+' '+fromdatey2md+"-"+todatey2md
|
2811
2832
|
|
2812
2833
|
import datetime; todaydt=datetime.date.today(); todayy2md=str(todaydt.strftime('%y/%m/%d'))
|
2813
2834
|
#sourcetxt=text_lang("数据来源: 雅虎财经, ","Data source: Yahoo Finance, ")+todayy2md
|
2814
|
-
sourcetxt=text_lang("数据来源:
|
2835
|
+
sourcetxt=text_lang("数据来源: Yahoo/Sina","Data source: Yahoo Finance")
|
2815
2836
|
footnote=periodtxt+'\n'+ sourcetxt
|
2816
2837
|
|
2817
2838
|
#修改列命为英文
|
siat/stooq.py
CHANGED
@@ -46,9 +46,10 @@ class StooqDailyReader(_DailyBaseReader):
|
|
46
46
|
pass
|
47
47
|
#symbol = ".".join([symbol, country])
|
48
48
|
elif symbol_parts[1].lower() == "pl": #后缀为波兰
|
49
|
+
#pass
|
49
50
|
symbol = symbol_parts[0]
|
50
51
|
else:
|
51
|
-
pass
|
52
|
+
#pass
|
52
53
|
if symbol_parts[1].lower() not in [
|
53
54
|
"de",
|
54
55
|
"hk",
|
siat/translate.py
CHANGED
@@ -819,7 +819,7 @@ def codetranslate0(code):
|
|
819
819
|
['VIPS','唯品会'],['Vipshop','唯品会'],
|
820
820
|
['PDD','拼多多'],['Pinduoduo','拼多多'],
|
821
821
|
['BABA','阿里巴巴美股'],['Alibaba','阿里巴巴美股'],
|
822
|
-
['JD','京东美股'],
|
822
|
+
['JD','京东美股'],['MPNGY','美团美股'],
|
823
823
|
['SINA','新浪网'],['BIDU','百度'],['NTES','网易'],
|
824
824
|
|
825
825
|
['00700.HK','腾讯港股'],['TENCENT','腾讯控股'],
|
@@ -1083,7 +1083,8 @@ def codetranslate0(code):
|
|
1083
1083
|
['^OMXS','瑞典斯德哥尔摩指数'],['^DKDOW','道琼斯丹麦指数'],
|
1084
1084
|
['^HEX','芬兰赫尔辛基指数'],['^OMXV','立陶宛维尔纽斯指数'],
|
1085
1085
|
['^OMXR','拉脱维亚里加指数'],['^OMXT','爱沙尼亚塔林指数'],
|
1086
|
-
['^ICEX','冰岛综合指数'],['^
|
1086
|
+
['^ICEX','冰岛综合指数'],['^OMXC25','丹麦哥本哈根25指数'],
|
1087
|
+
['^FMIB','富时意大利指数'],
|
1087
1088
|
['^IBEX','西班牙IBEX指数'],['^OSEAX','挪威奥斯陆指数'],
|
1088
1089
|
['^SMI','瑞士SMI指数'],['^MOEX','俄罗斯莫斯科指数(卢布计价)'],
|
1089
1090
|
['^UX','乌克兰UX指数'],['^RTS','俄罗斯市值加权指数(美元计价)'],
|
@@ -1129,9 +1130,11 @@ def codetranslate0(code):
|
|
1129
1130
|
['^BSESN','孟买敏感指数'],['^SNX','孟买敏感指数'],['^NSEI','印度国交50指数'],
|
1130
1131
|
['^FCHI','法国CAC40指数'],['^GDAXI','德国DAX指数'],
|
1131
1132
|
['^CAC','法国CAC40指数'],['^DAX','德国DAX指数'],
|
1133
|
+
['^ATX','奥地利ATX指数'],
|
1132
1134
|
['IMOEX.ME','俄罗斯MOEX指数'],['^MOEX','俄罗斯MOEX指数'],
|
1133
1135
|
['^RTS','俄罗斯RTS指数(美元标价)'],
|
1134
|
-
['^TASI','沙特TASI指数'],
|
1136
|
+
['^TASI','沙特TASI指数'],
|
1137
|
+
['TA35.TA','以色列TA35指数'],['^TA125.TA','以色列TA125指数'],
|
1135
1138
|
['^BVSP','巴西BVSP指数'],['^JNX4.JO','南非40指数'],
|
1136
1139
|
['^KLSE','吉隆坡综合指数'],['^KLCI','吉隆坡综合指数'],
|
1137
1140
|
['^JCI','雅加达综合指数'],
|
siat/yf_name.py
CHANGED
@@ -94,6 +94,7 @@ if __name__=='__main__':
|
|
94
94
|
ticker='600333.ss'
|
95
95
|
ticker='600444.ss'
|
96
96
|
ticker='600777.ss'
|
97
|
+
ticker='GC=F'
|
97
98
|
|
98
99
|
yahoo_name1(ticker)
|
99
100
|
|
@@ -242,12 +243,129 @@ if __name__=='__main__':
|
|
242
243
|
|
243
244
|
#发现问题后单独测试
|
244
245
|
ticker='600088.SS'
|
246
|
+
ticker="ALI=F"
|
247
|
+
ticker="ZS=F"
|
248
|
+
ticker="ES=F"
|
249
|
+
|
250
|
+
ticker_info(ticker)
|
251
|
+
|
245
252
|
yahoo_name1(ticker)
|
246
253
|
yahoo_name2(ticker)
|
247
254
|
|
248
255
|
yahoo_name2(ticker,short_name=True)
|
249
256
|
|
250
257
|
ticker_name(ticker)
|
258
|
+
|
259
|
+
numeric_to_date(1734652800)
|
260
|
+
|
261
|
+
def numeric_to_date(numeric):
|
262
|
+
# 数值转日期
|
263
|
+
from datetime import datetime, timedelta
|
264
|
+
epoch = datetime(1970, 1, 1)
|
265
|
+
return (epoch + timedelta(seconds=numeric)).strftime('%Y-%m-%d')
|
266
|
+
|
267
|
+
if __name__=='__main__':
|
268
|
+
ticker="ES=F" #期货
|
269
|
+
ticker="VIX241120C00035000" #期权
|
270
|
+
|
271
|
+
ticker_info(ticker, info="interest")
|
272
|
+
ticker_info(ticker, info="open interest")
|
273
|
+
ticker_info(ticker, info="volume")
|
274
|
+
ticker_info(ticker, info="average volume")
|
275
|
+
ticker_info(ticker, info="REGULAR CLOSE")
|
276
|
+
ticker_info(ticker, info="day average")
|
277
|
+
|
278
|
+
ticker_info(ticker, info=["regular close","fifty day average","two hundred day average"])
|
279
|
+
|
280
|
+
def ticker_info(ticker,info="all"):
|
281
|
+
"""
|
282
|
+
|
283
|
+
功能:显示yahoo证券代码的信息,可多个信息类型
|
284
|
+
"""
|
285
|
+
if isinstance(info,str):
|
286
|
+
infos=[info]
|
287
|
+
elif isinstance(info,list):
|
288
|
+
infos=info
|
289
|
+
else:
|
290
|
+
print(" Sorry, unsupported info type:",info)
|
291
|
+
return
|
292
|
+
|
293
|
+
first_time=True
|
294
|
+
for i in infos:
|
295
|
+
if first_time:
|
296
|
+
ticker_info1(ticker,info=i,test_access=True,print_title=True)
|
297
|
+
first_time=False
|
298
|
+
else:
|
299
|
+
ticker_info1(ticker,info=i,test_access=False,print_title=False)
|
300
|
+
|
301
|
+
return
|
302
|
+
|
303
|
+
if __name__=='__main__':
|
304
|
+
ticker="TSLA260618C00330000"
|
305
|
+
|
306
|
+
ticker_info1(ticker)
|
307
|
+
ticker_info1(ticker, info="open interest")
|
308
|
+
|
309
|
+
def ticker_info1(ticker,info="all",test_access=True,print_title=True):
|
310
|
+
"""
|
311
|
+
|
312
|
+
功能:显示yahoo证券代码的信息,1个信息类型
|
313
|
+
"""
|
314
|
+
#测试雅虎
|
315
|
+
if test_access:
|
316
|
+
if not test_yahoo_access():
|
317
|
+
print(" Sorry, data source Yahoo is currently not reachable")
|
318
|
+
return
|
319
|
+
|
320
|
+
#去掉ticker中的.US后缀
|
321
|
+
ticker=ticker.upper()
|
322
|
+
ticker1=ticker.replace('.US', "")
|
323
|
+
|
324
|
+
import yfinance as yf
|
325
|
+
ticker_info = yf.Ticker(ticker1)
|
326
|
+
|
327
|
+
import datetime
|
328
|
+
stoday = datetime.date.today().strftime("%Y-%m-%d")
|
329
|
+
|
330
|
+
info_list=info.split(); found=False
|
331
|
+
"""
|
332
|
+
info_yahoo=(info_list[0]).lower()
|
333
|
+
for i in info_list[1:]:
|
334
|
+
info_yahoo=info_yahoo+(i.lower()).capitalize()
|
335
|
+
"""
|
336
|
+
|
337
|
+
try:
|
338
|
+
t_info=ticker_info.info
|
339
|
+
|
340
|
+
if print_title:
|
341
|
+
print("*** Ticker",ticker,'Information @'+stoday)
|
342
|
+
|
343
|
+
if ('all' in info) or ('All' in info) or ('ALL' in info):
|
344
|
+
for k in t_info.keys():
|
345
|
+
if not 'Date' in k:
|
346
|
+
print(' '+k+':',t_info[k])
|
347
|
+
else:
|
348
|
+
print(' '+k+':',numeric_to_date(t_info[k]))
|
349
|
+
#display(t_info)
|
350
|
+
else:
|
351
|
+
for k in t_info.keys():
|
352
|
+
for i in info_list:
|
353
|
+
if (not i.lower() in k) and (not (i.lower()).capitalize() in k):
|
354
|
+
found=False; break
|
355
|
+
else:
|
356
|
+
found=True
|
357
|
+
if not found: continue
|
358
|
+
|
359
|
+
if not 'Date' in k:
|
360
|
+
print(' '+k+':',t_info[k])
|
361
|
+
else:
|
362
|
+
print(' '+k+':',numeric_to_date(t_info[k]))
|
363
|
+
|
364
|
+
except:
|
365
|
+
print(" Sorry, ticker",ticker,"is not found in data source Yahoo")
|
366
|
+
|
367
|
+
return
|
368
|
+
|
251
369
|
|
252
370
|
def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
|
253
371
|
"""
|
@@ -256,7 +374,6 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
|
|
256
374
|
现存问题:需要访问雅虎,且耗时稍长
|
257
375
|
"""
|
258
376
|
|
259
|
-
|
260
377
|
#测试雅虎
|
261
378
|
if not test_yahoo_access():
|
262
379
|
return ticker
|
@@ -276,9 +393,16 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
|
|
276
393
|
|
277
394
|
try:
|
278
395
|
if short_name:
|
279
|
-
|
396
|
+
try:
|
397
|
+
t_name0=t_info['shortName']
|
398
|
+
except:
|
399
|
+
t_name0=t_info['longName']
|
280
400
|
else:
|
281
|
-
|
401
|
+
try:
|
402
|
+
t_name0=t_info['longName']
|
403
|
+
except:
|
404
|
+
t_name0=t_info['shortName']
|
405
|
+
|
282
406
|
if len(t_name0) > maxlen:
|
283
407
|
t_name0=t_info['shortName']
|
284
408
|
except:
|
@@ -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=dqvWnw2gyMVo7l2dMyhJeaJZJIyUCVcTMTXC1ryHQos,160442
|
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
|
@@ -60,7 +60,7 @@ 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=rya9u6jzNnuw1Io4Ub6Da8h276DCzbyL3hjWpzHY0mY,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
|
@@ -97,15 +97,15 @@ 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=Zhn6pvwLy996mbBHDorbqWQdQw9RHdr9m0yzke3ya8M,108597
|
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
|
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=oUPX2yHGclBoO97d5XocvdSJ8grwpDoJ8aJtOlu4oas,155637
|
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
|
@@ -119,7 +119,7 @@ siat/stock_profile.py,sha256=B3eIwzEmiCqiCaxIlhfdEPsQBoW1PFOe1hkiY3mVF6Y,26038
|
|
119
119
|
siat/stock_technical-20240620.py,sha256=A4x18mZgYSA8SSiDz4u_O3gd5oVRgbI6JIiBfFY0tVw,116013
|
120
120
|
siat/stock_technical.py,sha256=urnbFubwsYcl8dEPLM6DfdBmsia4xQ1rvM-71VZTM88,136050
|
121
121
|
siat/stock_test.py,sha256=E9YJAvOw1VEGJSDI4IZuEjl0tGoisOIlN-g9UqA_IZE,19475
|
122
|
-
siat/stooq.py,sha256=
|
122
|
+
siat/stooq.py,sha256=SiRnSUu92pfzIZQ8N4Yo-9VOVSwUSqQE0wqXhF-4y9g,2493
|
123
123
|
siat/temp.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
124
124
|
siat/test2_graphviz.py,sha256=05w2YJuIBH0LsJjdA60EFn7rL0vCo-CA6EVJEQOXNE4,16648
|
125
125
|
siat/test_graphviz.py,sha256=CETKpDL8PnysS-PD3fHkeAgagUxjaUl0CsXPiadQySg,16999
|
@@ -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=wj9ct1j967u1KOjCJVoeopSaypWWWTxzEeJKeUACp4c,241177
|
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=7uLAcOc8XwfYDjuLqWDiUZHfdMpEbytW7E2ayNNT3f4,20069
|
143
|
+
siat-3.5.12.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
144
|
+
siat-3.5.12.dist-info/METADATA,sha256=Shgl7GEqy3CgeZ7j_sOjjmX34n1dkjSUh4rhQ_JCBfg,8010
|
145
|
+
siat-3.5.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
146
|
+
siat-3.5.12.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
147
|
+
siat-3.5.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|