siat 3.10.25__py3-none-any.whl → 3.10.125__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/assets_liquidity.py +168 -30
- siat/bond.py +91 -30
- siat/capm_beta.py +36 -10
- siat/capm_beta2.py +34 -3
- siat/common.py +95 -8
- siat/economy.py +3 -3
- siat/economy2.py +75 -1
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +292 -12
- siat/financial_statements.py +26 -85
- siat/financials.py +156 -20
- siat/financials_china.py +1 -1
- siat/fund_china.py +52 -22
- siat/future_china.py +53 -59
- siat/grafix.py +218 -155
- siat/holding_risk.py +38 -31
- siat/market_china.py +22 -11
- siat/markowitz2.py +72 -10
- siat/option_china.py +93 -31
- siat/option_pricing.py +16 -6
- siat/other_indexes.py +16 -3
- siat/risk_adjusted_return.py +283 -164
- siat/risk_adjusted_return2.py +3 -1
- siat/risk_evaluation.py +298 -25
- siat/sector_china.py +24 -11
- siat/security_price2.py +19 -4
- siat/security_prices.py +228 -28
- siat/security_trend2.py +14 -14
- siat/stock.py +38 -3
- siat/translate.py +20 -10
- siat/var_model_validation.py +59 -0
- {siat-3.10.25.dist-info → siat-3.10.125.dist-info}/METADATA +1 -1
- {siat-3.10.25.dist-info → siat-3.10.125.dist-info}/RECORD +36 -36
- {siat-3.10.25.dist-info → siat-3.10.125.dist-info}/LICENSE +0 -0
- {siat-3.10.25.dist-info → siat-3.10.125.dist-info}/WHEEL +0 -0
- {siat-3.10.25.dist-info → siat-3.10.125.dist-info}/top_level.txt +0 -0
siat/financials.py
CHANGED
@@ -61,14 +61,19 @@ if czxt in ['linux']: #website Jupyter
|
|
61
61
|
plt.rcParams['axes.unicode_minus'] = False
|
62
62
|
#==============================================================================
|
63
63
|
if __name__ == '__main__':
|
64
|
-
|
65
|
-
|
64
|
+
ticker=['AAPL','MSFT']
|
65
|
+
indicator=['Current Ratio','Quick Ratio']
|
66
|
+
|
67
|
+
ticker=['BABA','JD']
|
68
|
+
indicator='Cashflow per Share'
|
69
|
+
|
66
70
|
datatag=False
|
67
71
|
power=0
|
68
72
|
zeroline=False
|
69
73
|
twinx=False
|
74
|
+
loc1=loc2='best'
|
70
75
|
|
71
|
-
def compare_history(
|
76
|
+
def compare_history(ticker,indicator, \
|
72
77
|
datatag=False,power=0,zeroline=False,twinx=False, \
|
73
78
|
loc1='best',loc2='best',graph=True):
|
74
79
|
"""
|
@@ -77,6 +82,9 @@ def compare_history(tickers,items, \
|
|
77
82
|
zeroline=False:不绘制水平零线
|
78
83
|
twinx=False:单纵轴
|
79
84
|
"""
|
85
|
+
tickers=ticker
|
86
|
+
items=indicator
|
87
|
+
|
80
88
|
#检查power的范围是否合理
|
81
89
|
if not (power in range(0,80)):
|
82
90
|
print(" #Error(compare_history): invalid parameter, power =",power)
|
@@ -147,8 +155,12 @@ def compare_history(tickers,items, \
|
|
147
155
|
#抓取数据
|
148
156
|
info1=get_financial_rates(ticker1)
|
149
157
|
if info1 is None:
|
150
|
-
print(" #
|
151
|
-
|
158
|
+
print(f" #Warning(compare_history): unable to get data for {ticker1}, retrying ...")
|
159
|
+
sleep_random(max_sleep=30)
|
160
|
+
info1=get_financial_rates(ticker1)
|
161
|
+
if info1 is None:
|
162
|
+
print(" #Error(compare_history): failed to retrieved financials for",ticker1)
|
163
|
+
return None,None
|
152
164
|
|
153
165
|
cols1=['ticker','endDate','periodType',item1]
|
154
166
|
df1=info1[cols1]
|
@@ -166,14 +178,18 @@ def compare_history(tickers,items, \
|
|
166
178
|
item2=item1
|
167
179
|
info2=get_financial_rates(ticker2)
|
168
180
|
if info2 is None:
|
169
|
-
print(" #
|
170
|
-
|
181
|
+
print(f" #Warning(compare_history): unable to get data for {ticker2}, retrying ...")
|
182
|
+
sleep_random(max_sleep=30)
|
183
|
+
info2=get_financial_rates(ticker2)
|
184
|
+
if info2 is None:
|
185
|
+
print(" #Error(compare_history): failed to retrieved financials for",ticker2)
|
186
|
+
return None,None
|
171
187
|
|
172
188
|
df2=info2[cols1]
|
173
189
|
df2['date']=df2['endDate']
|
174
190
|
df2.set_index('date',inplace=True)
|
175
191
|
|
176
|
-
import datetime;
|
192
|
+
import datetime; todaydt=datetime.date.today()
|
177
193
|
#绘图:T1I1,单折线
|
178
194
|
if mode == 'T1I1'and graph:
|
179
195
|
df=df1
|
@@ -183,7 +199,7 @@ def compare_history(tickers,items, \
|
|
183
199
|
#titletxt=ticker_name(ticker1)+texttranslate(": 基于年(季)报的业绩历史")
|
184
200
|
titletxt=ticker_name(ticker1)+": 财报业绩历史"
|
185
201
|
#footnote=texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
186
|
-
footnote="数据来源: 雅虎财经,"+' '+str(
|
202
|
+
footnote="数据来源: 雅虎财经,"+' '+str(todaydt)
|
187
203
|
|
188
204
|
plot_line(df,colname,collabel,ylabeltxt,titletxt,footnote, \
|
189
205
|
datatag=datatag,power=power,zeroline=zeroline,resample_freq='3M', \
|
@@ -245,10 +261,19 @@ def compare_history(tickers,items, \
|
|
245
261
|
#titletxt=ticker_name(ticker1)+" vs "+ticker_name(ticker2)+texttranslate(": 基于年(季)报的业绩历史对比")
|
246
262
|
titletxt=ticker_name(ticker1)+" vs "+ticker_name(ticker2)+": 财报业绩历史对比"
|
247
263
|
#footnote=texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
248
|
-
footnote="数据来源: 雅虎财经,"+' '+str(
|
264
|
+
footnote="数据来源: 雅虎财经,"+' '+str(todaydt)
|
249
265
|
|
250
|
-
|
251
|
-
|
266
|
+
#克服双线绘制时第2条线错乱问题:两个df日期强制取齐,能解决问题,但原因不明
|
267
|
+
tname1=ticker_name(ticker1)
|
268
|
+
df1.rename(columns={item1:tname1},inplace=True)
|
269
|
+
tname2=ticker_name(ticker2)
|
270
|
+
df2.rename(columns={item2:ticker_name(ticker2)},inplace=True)
|
271
|
+
df12=pd.merge(df1,df2,how='inner',left_index=True,right_index=True)
|
272
|
+
df1t=df12[[tname1]]
|
273
|
+
df2t=df12[[tname2]]
|
274
|
+
|
275
|
+
plot_line2(df1t,ticker1,tname1,label1, \
|
276
|
+
df2t,ticker2,tname2,label2, \
|
252
277
|
ylabeltxt,titletxt,footnote, \
|
253
278
|
power=power,zeroline=zeroline,twinx=twinx,resample_freq='3M', \
|
254
279
|
loc1=loc1,loc2=loc2)
|
@@ -362,7 +387,7 @@ def compare_snapshot(ticker,indicator, \
|
|
362
387
|
|
363
388
|
notfoundlist=[]
|
364
389
|
total0=len(tickers)
|
365
|
-
print(" Searching",itemk,"for
|
390
|
+
print(" Searching",itemk,"for designated companies ...")
|
366
391
|
for t in tickers:
|
367
392
|
|
368
393
|
current=tickers.index(t)
|
@@ -1966,11 +1991,12 @@ if __name__=='__main__':
|
|
1966
1991
|
|
1967
1992
|
def compare_dupont(tickerlist,fsdate='latest', \
|
1968
1993
|
sort='PM',facecolor='whitesmoke',font_size='16px', \
|
1994
|
+
loc1='best',retry=10, \
|
1969
1995
|
scale1 = 10,scale2 = 10,hatchlist=['.', 'o', '\\']):
|
1970
1996
|
"""
|
1971
1997
|
功能:获得tickerlist中每只股票的杜邦分析项目,绘制柱状叠加比较图
|
1972
1998
|
tickerlist:股票代码列表,建议在10只以内
|
1973
|
-
fsdate
|
1999
|
+
fsdate:财报日期,默认为最新一期季报/年报,或具体日期,格式:YYYY-MM-DD
|
1974
2000
|
scale1:用于放大销售净利率,避免与权益乘数数量级不一致导致绘图难看问题,可自行调整
|
1975
2001
|
scale2:用于放大总资产周转率,避免与权益乘数数量级不一致导致绘图难看问题,可自行调整
|
1976
2002
|
hatchlist:绘制柱状图的纹理,用于黑白打印时区分,可自定义,
|
@@ -2009,23 +2035,56 @@ def compare_dupont(tickerlist,fsdate='latest', \
|
|
2009
2035
|
dpidflist,dpilist,fsdatelist,fstypelist=[],[],[],[]
|
2010
2036
|
name1list,name2list,name3list,name4list,name5list,name6list=[],[],[],[],[],[]
|
2011
2037
|
newtickerlist=[]
|
2012
|
-
print("Working on DuPont factsheet
|
2038
|
+
print("Working on DuPont factsheet, it takes a very long time, take a breather ...")
|
2039
|
+
|
2040
|
+
#第1次尝试
|
2041
|
+
faillist=[]
|
2013
2042
|
for t in tickerlist:
|
2014
2043
|
try:
|
2015
2044
|
with HiddenPrints():
|
2016
2045
|
dpidf=calc_dupont(t)
|
2017
2046
|
except:
|
2018
|
-
print(" #Warning(compare_dupont):
|
2047
|
+
print(" #Warning(compare_dupont): found errors in accounting items, ignore",t)
|
2048
|
+
continue
|
2049
|
+
|
2050
|
+
#未出错,但未抓取到数据,再试
|
2051
|
+
if dpidf is None:
|
2052
|
+
faillist=faillist+[t]
|
2053
|
+
#sleep_random(max_sleep=30)
|
2019
2054
|
continue
|
2055
|
+
|
2020
2056
|
if fsdate == 'latest':
|
2021
2057
|
try:
|
2022
2058
|
dpi=dpidf.tail(1)
|
2023
2059
|
except:
|
2024
|
-
print(" #Warning(compare_dupont):
|
2060
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2061
|
+
faillist=faillist+[t]
|
2062
|
+
#sleep_random(max_sleep=30)
|
2063
|
+
continue
|
2064
|
+
elif fsdate == 'annual':
|
2065
|
+
dpidf_tmp=dpidf[dpidf['periodType']=="12M"]
|
2066
|
+
try:
|
2067
|
+
dpi=dpidf_tmp.tail(1)
|
2068
|
+
except:
|
2069
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2070
|
+
faillist=faillist+[t]
|
2071
|
+
#sleep_random(max_sleep=30)
|
2072
|
+
continue
|
2073
|
+
|
2074
|
+
elif fsdate == 'quarterly':
|
2075
|
+
dpidf_tmp=dpidf[dpidf['periodType']=="3M"]
|
2076
|
+
try:
|
2077
|
+
dpi=dpidf_tmp.tail(1)
|
2078
|
+
except:
|
2079
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2080
|
+
faillist=faillist+[t]
|
2081
|
+
#sleep_random(max_sleep=30)
|
2025
2082
|
continue
|
2026
2083
|
else: dpi=dpidf[dpidf['endDate']==fsdate]
|
2027
2084
|
if len(dpi) == 0:
|
2028
|
-
print(" #Warning(compare_dupont):
|
2085
|
+
print(" #Warning(compare_dupont): financial statements not found for",t,'@',fsdate)
|
2086
|
+
faillist=faillist+[t]
|
2087
|
+
#sleep_random(max_sleep=30)
|
2029
2088
|
continue
|
2030
2089
|
|
2031
2090
|
newtickerlist=newtickerlist+[t]
|
@@ -2042,7 +2101,84 @@ def compare_dupont(tickerlist,fsdate='latest', \
|
|
2042
2101
|
name6list=name6list+[dpi['periodType'][0]]
|
2043
2102
|
|
2044
2103
|
#显示进度
|
2045
|
-
print_progress_percent2(t,tickerlist,steps=5,leading_blanks=4)
|
2104
|
+
#print_progress_percent2(t,tickerlist,steps=5,leading_blanks=4)
|
2105
|
+
print(f" *** Successfully obtained financial information for {t}")
|
2106
|
+
|
2107
|
+
#第2次尝试
|
2108
|
+
for i in range(retry):
|
2109
|
+
if len(faillist) == 0: break
|
2110
|
+
|
2111
|
+
tickerlist=faillist
|
2112
|
+
faillist=[]
|
2113
|
+
|
2114
|
+
for t in tickerlist:
|
2115
|
+
try:
|
2116
|
+
with HiddenPrints():
|
2117
|
+
dpidf=calc_dupont(t)
|
2118
|
+
except:
|
2119
|
+
print(" #Warning(compare_dupont): found errors in accounting items, ignore",t)
|
2120
|
+
continue
|
2121
|
+
|
2122
|
+
#未出错,但未抓取到数据,再试
|
2123
|
+
if dpidf is None:
|
2124
|
+
faillist=faillist+[t]
|
2125
|
+
#sleep_random(max_sleep=30)
|
2126
|
+
continue
|
2127
|
+
|
2128
|
+
if fsdate == 'latest':
|
2129
|
+
try:
|
2130
|
+
dpi=dpidf.tail(1)
|
2131
|
+
except:
|
2132
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2133
|
+
faillist=faillist+[t]
|
2134
|
+
#sleep_random(max_sleep=30)
|
2135
|
+
continue
|
2136
|
+
elif fsdate == 'annual':
|
2137
|
+
dpidf_tmp=dpidf[dpidf['periodType']=="12M"]
|
2138
|
+
try:
|
2139
|
+
dpi=dpidf_tmp.tail(1)
|
2140
|
+
except:
|
2141
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2142
|
+
faillist=faillist+[t]
|
2143
|
+
#sleep_random(max_sleep=30)
|
2144
|
+
continue
|
2145
|
+
|
2146
|
+
elif fsdate == 'quarterly':
|
2147
|
+
dpidf_tmp=dpidf[dpidf['periodType']=="3M"]
|
2148
|
+
try:
|
2149
|
+
dpi=dpidf_tmp.tail(1)
|
2150
|
+
except:
|
2151
|
+
print(f" #Warning(compare_dupont): got empty data for {t} @ {fsdate} financials")
|
2152
|
+
faillist=faillist+[t]
|
2153
|
+
#sleep_random(max_sleep=30)
|
2154
|
+
continue
|
2155
|
+
else: dpi=dpidf[dpidf['endDate']==fsdate]
|
2156
|
+
if len(dpi) == 0:
|
2157
|
+
print(" #Warning(compare_dupont): financial statements not found for",t,'@',fsdate)
|
2158
|
+
faillist=faillist+[t]
|
2159
|
+
#sleep_random(max_sleep=30)
|
2160
|
+
continue
|
2161
|
+
|
2162
|
+
newtickerlist=newtickerlist+[t]
|
2163
|
+
dpidflist=dpidflist+[dpidf]
|
2164
|
+
dpilist=dpilist+[dpi]
|
2165
|
+
fsdatelist=fsdatelist+[dpi['endDate'][0]]
|
2166
|
+
fstypelist=fstypelist+[dpi['periodType'][0]]
|
2167
|
+
|
2168
|
+
name1list=name1list+[dpi['Profit Margin'][0]*scale1]
|
2169
|
+
name2list=name2list+[dpi['Total Asset Turnover'][0]*scale2]
|
2170
|
+
name3list=name3list+[dpi['Equity Multiplier'][0]]
|
2171
|
+
name4list=name4list+[dpi['ROE'][0]]
|
2172
|
+
name5list=name5list+[dpi['endDate'][0]]
|
2173
|
+
name6list=name6list+[dpi['periodType'][0]]
|
2174
|
+
|
2175
|
+
#显示进度
|
2176
|
+
#print_progress_percent2(t,tickerlist,steps=5,leading_blanks=4)
|
2177
|
+
print(f" *** Successfully obtained financial information for {t}")
|
2178
|
+
|
2179
|
+
|
2180
|
+
if len(faillist) > 0:
|
2181
|
+
print(f" ~~~ Pity: failed to fetch financials for {faillist}")
|
2046
2182
|
|
2047
2183
|
tickerlist=newtickerlist
|
2048
2184
|
raw_data = {ticker:tickerlist,
|
@@ -2132,7 +2268,7 @@ def compare_dupont(tickerlist,fsdate='latest', \
|
|
2132
2268
|
footnote2=footnote1+'\n'+texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
2133
2269
|
plt.xlabel(footnote2,fontsize=xlabel_txt_size)
|
2134
2270
|
|
2135
|
-
plt.legend(loc=
|
2271
|
+
plt.legend(loc=loc1,fontsize=legend_txt_size)
|
2136
2272
|
if lang == 'Chinese':
|
2137
2273
|
plt.title("杜邦分析对比图"+sorttxt,fontsize=title_txt_size,fontweight='bold')
|
2138
2274
|
else:
|
siat/financials_china.py
CHANGED
@@ -692,7 +692,7 @@ def compare_dupont_china(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10, \
|
|
692
692
|
可用的符号:'-', '+', 'x', '\\', '*', 'o', 'O', '.'
|
693
693
|
"""
|
694
694
|
error_flag=False
|
695
|
-
if fsdate
|
695
|
+
if fsdate in ['latest','annual','quarterly']:
|
696
696
|
import datetime as dt; end=str(dt.date.today())
|
697
697
|
start=date_adjust(end, adjust=-365)
|
698
698
|
else:
|
siat/fund_china.py
CHANGED
@@ -1390,7 +1390,7 @@ def oef_trend_china(ticker,start,end='today',indicator='净值', \
|
|
1390
1390
|
df1['总排名']=df1['总排名'].astype('int64')
|
1391
1391
|
df1.set_index(['date'],inplace=True)
|
1392
1392
|
|
1393
|
-
df2 = ak.fund_open_fund_info_em(
|
1393
|
+
df2 = ak.fund_open_fund_info_em(fund1, indicator="同类排名百分比")
|
1394
1394
|
df2.rename(columns={'报告日期':'date','同类型排名-每日近3月收益排名百分比':'同类排名百分比'}, inplace=True)
|
1395
1395
|
df2.set_index(['date'],inplace=True)
|
1396
1396
|
|
@@ -1543,7 +1543,7 @@ def mmf_trend_china(ticker,start,end='today',indicator='7日年化%',power=0, \
|
|
1543
1543
|
startdate=datetime.datetime.strftime(start,"%Y-%m-%d")
|
1544
1544
|
enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
|
1545
1545
|
|
1546
|
-
print("Searching for money market fund (MMF)
|
1546
|
+
print("Searching for money market fund (MMF) info in China ...")
|
1547
1547
|
import akshare as ak
|
1548
1548
|
import pandas as pd
|
1549
1549
|
|
@@ -1754,9 +1754,10 @@ if __name__=='__main__':
|
|
1754
1754
|
|
1755
1755
|
#==============================================================================
|
1756
1756
|
if __name__=='__main__':
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1757
|
+
ticker='159922.SS'
|
1758
|
+
ticker='510580'
|
1759
|
+
start='2025-1-1'
|
1760
|
+
end='2025-5-30'
|
1760
1761
|
|
1761
1762
|
def etf_trend_china(ticker,start,end='today',indicator='净值',power=0, \
|
1762
1763
|
average_value=True,facecolor='whitesmoke', \
|
@@ -1765,7 +1766,7 @@ def etf_trend_china(ticker,start,end='today',indicator='净值',power=0, \
|
|
1765
1766
|
功能:ETF基金业绩趋势,单位净值,累计净值
|
1766
1767
|
"""
|
1767
1768
|
fund=ticker
|
1768
|
-
fromdate,todate=start_end_preprocess(start,end
|
1769
|
+
fromdate,todate=start_end_preprocess(start,end)
|
1769
1770
|
|
1770
1771
|
indicator_list=['净值','单位净值','累计净值']
|
1771
1772
|
if indicator not in indicator_list:
|
@@ -1789,7 +1790,7 @@ def etf_trend_china(ticker,start,end='today',indicator='净值',power=0, \
|
|
1789
1790
|
|
1790
1791
|
#获取基金数据
|
1791
1792
|
fund1=fund[:6]
|
1792
|
-
df =
|
1793
|
+
df = ak.fund_etf_fund_info_em(fund1)
|
1793
1794
|
df['date']=pd.to_datetime(df['净值日期'])
|
1794
1795
|
df.set_index(['date'],inplace=True)
|
1795
1796
|
df['单位净值']=df['单位净值'].astype("float")
|
@@ -2461,14 +2462,14 @@ def fund_info_china0():
|
|
2461
2462
|
wmf_df = ak.fund_financial_fund_daily_em()
|
2462
2463
|
#理财型基金-历史数据
|
2463
2464
|
#净值日期,7日年化收益率,申购状态,赎回状态
|
2464
|
-
wmf_hist_df = ak.fund_financial_fund_info_em(
|
2465
|
+
wmf_hist_df = ak.fund_financial_fund_info_em("000134")
|
2465
2466
|
|
2466
2467
|
###########分级基金(结构化基金)-实时数据
|
2467
2468
|
#基金代码,基金简称,单位净值,累计净值,市价,折价率,手续费
|
2468
2469
|
gsf_df = ak.fund_graded_fund_daily_em()
|
2469
2470
|
#分级基金-历史数据
|
2470
2471
|
#净值日期,7日年化收益率,申购状态,赎回状态
|
2471
|
-
gsf_hist_df = ak.fund_graded_fund_info_em(
|
2472
|
+
gsf_hist_df = ak.fund_graded_fund_info_em("150232")
|
2472
2473
|
|
2473
2474
|
###抓取沪深股市所有指数关联的公募基金列表(含ETF、增强、分级等)
|
2474
2475
|
#代码来源:https://blog.csdn.net/leeleilei/article/details/106124894
|
@@ -2584,7 +2585,7 @@ def fund_info_china(fund):
|
|
2584
2585
|
|
2585
2586
|
# 基金评级
|
2586
2587
|
df6=pd.DataFrame()
|
2587
|
-
titletxt6="
|
2588
|
+
titletxt6="基金概况与评级"
|
2588
2589
|
footnote6="注:评级机构为上海证券、招商证券和济安金信,数字表示星星个数,在同类基金中通常越高越好"
|
2589
2590
|
try:
|
2590
2591
|
dft6 = ak.fund_rating_all()
|
@@ -2594,13 +2595,17 @@ def fund_info_china(fund):
|
|
2594
2595
|
|
2595
2596
|
if len(dft6t) >= 1:
|
2596
2597
|
df6=dft6t
|
2597
|
-
printInMarkdown(df6,titletxt=titletxt6,footnote=footnote6)
|
2598
|
+
#printInMarkdown(df6,titletxt=titletxt6,footnote=footnote6)
|
2599
|
+
df_display_CSS(df6,titletxt=titletxt6,footnote=footnote6,facecolor='papayawhip', \
|
2600
|
+
first_col_align='left',second_col_align='left', \
|
2601
|
+
last_col_align='center',other_col_align='center')
|
2602
|
+
|
2598
2603
|
except:
|
2599
2604
|
pass
|
2600
2605
|
|
2601
2606
|
# 指数型基金信息
|
2602
2607
|
df2=pd.DataFrame()
|
2603
|
-
titletxt2="
|
2608
|
+
titletxt2="指数型基金的相关信息"
|
2604
2609
|
footnote2="注:单位净值元,日/今年来/今年来的增长率及手续费为百分比"
|
2605
2610
|
try:
|
2606
2611
|
dft2 = ak.fund_info_index_em(symbol="全部", indicator="全部")
|
@@ -2608,13 +2613,17 @@ def fund_info_china(fund):
|
|
2608
2613
|
dft2t=dft2[dft2['基金代码']==fund1]
|
2609
2614
|
|
2610
2615
|
if len(dft2t) >= 1:
|
2611
|
-
df2=dft2t[['基金代码','单位净值','日期','日增长率','今年来','
|
2612
|
-
printInMarkdown(df2,titletxt=titletxt2,footnote=footnote2)
|
2616
|
+
df2=dft2t[['基金代码','单位净值','日期','日增长率','今年来','手续费']]
|
2617
|
+
#printInMarkdown(df2,titletxt=titletxt2,footnote=footnote2)
|
2618
|
+
df_display_CSS(df2,titletxt=titletxt2,footnote=footnote2,facecolor='papayawhip', \
|
2619
|
+
first_col_align='left',second_col_align='left', \
|
2620
|
+
last_col_align='center',other_col_align='center')
|
2621
|
+
|
2613
2622
|
except:
|
2614
2623
|
pass
|
2615
2624
|
|
2616
2625
|
# 基金持仓:股票
|
2617
|
-
titletxt3="
|
2626
|
+
titletxt3="基金持仓情况:股票"
|
2618
2627
|
footnote3="注:占净值比例为百分比,持股数为万股,(持仓)市值为万元"
|
2619
2628
|
df3=pd.DataFrame()
|
2620
2629
|
import datetime; today = datetime.date.today()
|
@@ -2626,12 +2635,16 @@ def fund_info_china(fund):
|
|
2626
2635
|
if len(dft3) >= 1:
|
2627
2636
|
df3=dft3
|
2628
2637
|
df3['持仓类型']='股票'
|
2629
|
-
printInMarkdown(df3,titletxt=titletxt3,footnote=footnote3)
|
2638
|
+
#printInMarkdown(df3,titletxt=titletxt3,footnote=footnote3)
|
2639
|
+
df_display_CSS(df3,titletxt=titletxt3,footnote=footnote3,facecolor='papayawhip', \
|
2640
|
+
first_col_align='left',second_col_align='left', \
|
2641
|
+
last_col_align='center',other_col_align='center')
|
2642
|
+
|
2630
2643
|
except:
|
2631
2644
|
pass
|
2632
2645
|
|
2633
2646
|
# 基金持仓:债券
|
2634
|
-
titletxt4="
|
2647
|
+
titletxt4="基金持仓情况:债券"
|
2635
2648
|
df4=pd.DataFrame()
|
2636
2649
|
try:
|
2637
2650
|
dft4 = ak.fund_portfolio_bond_hold_em(symbol=fund1,date=thisYear)
|
@@ -2640,13 +2653,19 @@ def fund_info_china(fund):
|
|
2640
2653
|
if len(dft4) >= 1:
|
2641
2654
|
df4=dft4
|
2642
2655
|
df4['持仓类型']='债券'
|
2643
|
-
printInMarkdown(df4,titletxt=titletxt4)
|
2656
|
+
#printInMarkdown(df4,titletxt=titletxt4)
|
2657
|
+
df_display_CSS(df4,titletxt=titletxt4,footnote='',facecolor='papayawhip', \
|
2658
|
+
first_col_align='left',second_col_align='left', \
|
2659
|
+
last_col_align='center',other_col_align='center')
|
2660
|
+
|
2644
2661
|
except:
|
2662
|
+
print('')
|
2663
|
+
print(titletxt4)
|
2645
2664
|
print("\n #Warning(fund_info_china): unable to retrieve bond holding info for",fund,"@",thisYear)
|
2646
2665
|
|
2647
2666
|
|
2648
2667
|
# 基金持仓:行业配置
|
2649
|
-
titletxt5="
|
2668
|
+
titletxt5="基金的行业配置情况"
|
2650
2669
|
footnote5="注:占净值比例为百分比,市值为万元"
|
2651
2670
|
df5=pd.DataFrame()
|
2652
2671
|
try:
|
@@ -2656,12 +2675,16 @@ def fund_info_china(fund):
|
|
2656
2675
|
if len(dft5) >= 1:
|
2657
2676
|
df5=dft5
|
2658
2677
|
df5['持仓类型']='行业配置'
|
2659
|
-
printInMarkdown(df5,titletxt=titletxt5,footnote=footnote5)
|
2678
|
+
#printInMarkdown(df5,titletxt=titletxt5,footnote=footnote5)
|
2679
|
+
df_display_CSS(df5,titletxt=titletxt5,footnote=footnote5,facecolor='papayawhip', \
|
2680
|
+
first_col_align='left',second_col_align='left', \
|
2681
|
+
last_col_align='center',other_col_align='center')
|
2682
|
+
|
2660
2683
|
except:
|
2661
2684
|
pass
|
2662
2685
|
|
2663
2686
|
# 基金经理
|
2664
|
-
titletxt7="
|
2687
|
+
titletxt7="基金经理的相关情况"
|
2665
2688
|
source="数据来源:东方财富/天天基金"
|
2666
2689
|
footnote7="注:从业时间为天数,现任基金资产总规模为该基金经理管辖所有基金的总规模(亿元),最佳回报为历史业绩(百分比)\n"+source+","+str(today)
|
2667
2690
|
|
@@ -2674,13 +2697,20 @@ def fund_info_china(fund):
|
|
2674
2697
|
current=dft7t['现任基金'].values[0]
|
2675
2698
|
df7=dft7t[['姓名','所属公司','累计从业时间','现任基金资产总规模','现任基金最佳回报']]
|
2676
2699
|
|
2677
|
-
printInMarkdown(df7,titletxt=titletxt7)
|
2700
|
+
#printInMarkdown(df7,titletxt=titletxt7)
|
2701
|
+
df_display_CSS(df7,titletxt=titletxt7,footnote='',facecolor='papayawhip', \
|
2702
|
+
first_col_align='left',second_col_align='left', \
|
2703
|
+
last_col_align='center',other_col_align='center')
|
2704
|
+
|
2705
|
+
|
2678
2706
|
print(' ')
|
2679
2707
|
print("基金经理当前兼任情况:")
|
2680
2708
|
num=print_long_text(current)
|
2681
2709
|
print(' ')
|
2682
2710
|
print(footnote7)
|
2683
2711
|
except:
|
2712
|
+
print('')
|
2713
|
+
print(titletxt7)
|
2684
2714
|
print("\n #Warning(fund_info_china): unable to retrieve job info for",fmanager)
|
2685
2715
|
|
2686
2716
|
return
|