siat 2.14.2__py3-none-any.whl → 3.0.0__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/allin.py +1 -0
- siat/assets_liquidity.py +16 -16
- siat/beta_adjustment.py +6 -6
- siat/beta_adjustment_china.py +9 -9
- siat/bond.py +71 -67
- siat/capm_beta.py +11 -11
- siat/capm_beta2.py +49 -23
- siat/common.py +427 -60
- siat/compare_cross.py +15 -82
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +3 -3
- siat/financials.py +15 -15
- siat/financials2.py +8 -8
- siat/financials_china.py +20 -20
- siat/financials_china2.py +25 -25
- siat/fund_china.pickle +0 -0
- siat/fund_china.py +5 -4
- siat/grafix.py +195 -132
- siat/markowitz.py +6 -5
- siat/option_china.py +1 -1
- siat/option_pricing.py +6 -6
- siat/risk_adjusted_return.py +14 -14
- siat/risk_adjusted_return2.py +64 -42
- siat/risk_evaluation.py +32 -32
- siat/risk_free_rate.py +0 -0
- siat/sector_china.py +3 -195
- siat/security_price2.py +616 -0
- siat/security_prices.py +935 -308
- siat/security_trend2.py +28 -47
- siat/stock.py +225 -437
- siat/stock_china.py +19 -19
- siat/stock_info.pickle +0 -0
- siat/stock_technical.py +547 -144
- siat/transaction.py +3 -3
- siat/translate.py +781 -24
- siat/valuation.py +6 -6
- siat/var_model_validation.py +2 -2
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/METADATA +1 -1
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/RECORD +41 -40
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/WHEEL +0 -0
- {siat-2.14.2.dist-info → siat-3.0.0.dist-info}/top_level.txt +0 -0
siat/compare_cross.py
CHANGED
@@ -37,7 +37,8 @@ if __name__=='__main__':
|
|
37
37
|
|
38
38
|
df1=fetch_price_stock(ticker,start,end)
|
39
39
|
|
40
|
-
def fetch_price_stock(ticker,start,end,info_types=['Close','Volume'],
|
40
|
+
def fetch_price_stock(ticker,start,end,info_types=['Close','Volume'], \
|
41
|
+
adjust=-2*365,ticker_type='auto'):
|
41
42
|
"""
|
42
43
|
功能:获取股票、大盘指数、ETF和REITS的价格
|
43
44
|
ticker:股票代码
|
@@ -78,7 +79,10 @@ def fetch_price_stock(ticker,start,end,info_types=['Close','Volume'],adjust=-2*3
|
|
78
79
|
df['Adj Close']=df['Close']
|
79
80
|
df['Code']=ticker
|
80
81
|
df['Type']='stock'
|
81
|
-
|
82
|
+
|
83
|
+
#预处理ticker_type
|
84
|
+
ticker_type=ticker_type_preprocess_mticker_mixed(ticker,ticker_type)
|
85
|
+
df['Name']=ticker_name(ticker,ticker_type)
|
82
86
|
|
83
87
|
return df
|
84
88
|
|
@@ -142,83 +146,6 @@ def fetch_price_stock_portfolio(portfolio,start,end,info_types=['Close','Volume'
|
|
142
146
|
|
143
147
|
return df
|
144
148
|
|
145
|
-
#==============================================================================
|
146
|
-
if __name__=='__main__':
|
147
|
-
ticker='850831'
|
148
|
-
|
149
|
-
start='2023-1-1'
|
150
|
-
end='2023-4-4'
|
151
|
-
info_types=['Close','Volume']
|
152
|
-
|
153
|
-
df3=fetch_price_swindex(ticker,start,end)
|
154
|
-
|
155
|
-
def fetch_price_swindex(ticker,start,end,info_types=['Close','Volume'],adjust=-2*365):
|
156
|
-
"""
|
157
|
-
功能:获取申万行业指数的信息
|
158
|
-
ticker:申万行业指数
|
159
|
-
start,end:日期期间
|
160
|
-
info_types:信息测度,默认['Close'],还可以为['Close','Open','High','Low',
|
161
|
-
'Volume','Adj Close']
|
162
|
-
特点:为compare_indicator使用,包括指数名称
|
163
|
-
"""
|
164
|
-
# 检查日期期间的合理性
|
165
|
-
result,startpd,endpd=check_period(start,end)
|
166
|
-
if not result:
|
167
|
-
print(" #Error(fetch_price_swindex): invalid date period between",start,"and",end)
|
168
|
-
return None
|
169
|
-
|
170
|
-
start1=date_adjust(start,adjust=adjust)
|
171
|
-
_,start1pd,_=check_period(start1,end)
|
172
|
-
|
173
|
-
import akshare as ak
|
174
|
-
try:
|
175
|
-
prices= ak.index_hist_sw(symbol=ticker,period="day")
|
176
|
-
except:
|
177
|
-
print(" #Error(fetch_price_swindex): failed to fetch stock prices for",ticker)
|
178
|
-
return None
|
179
|
-
|
180
|
-
if prices is None:
|
181
|
-
print(" #Warning(fetch_price_swindex): no info found for",ticker,"during",start,"and",end)
|
182
|
-
return None
|
183
|
-
|
184
|
-
if len(prices)==0:
|
185
|
-
print(" #Warning(fetch_price_swindex): zero record found for",ticker,"during",start,"and",end)
|
186
|
-
return None
|
187
|
-
|
188
|
-
prices.columns=['Code','Date','Close','Open','High','Low','Volume','Amount']
|
189
|
-
million=1000000
|
190
|
-
prices['Volume']=prices['Volume']*million
|
191
|
-
prices['Amount']=prices['Amount']*million
|
192
|
-
|
193
|
-
import pandas as pd
|
194
|
-
prices['date']=pd.to_datetime(prices['Date'])
|
195
|
-
prices.set_index('date',inplace=True)
|
196
|
-
|
197
|
-
prices2=prices[(prices.index >= start1pd) & (prices.index <= endpd)]
|
198
|
-
|
199
|
-
|
200
|
-
if isinstance(info_types,str):
|
201
|
-
typelist=[info_types]
|
202
|
-
else:
|
203
|
-
typelist=info_types
|
204
|
-
|
205
|
-
import pandas as pd
|
206
|
-
df=pd.DataFrame()
|
207
|
-
|
208
|
-
for t in typelist:
|
209
|
-
try:
|
210
|
-
df[t]=prices2[t]
|
211
|
-
except:
|
212
|
-
continue
|
213
|
-
|
214
|
-
df['Adj Close']=df['Close']
|
215
|
-
df['Code']=ticker
|
216
|
-
df['Type']='swindex'
|
217
|
-
df['Name']='申万'+industry_sw_name(ticker)+'指数'
|
218
|
-
|
219
|
-
print(" Successfully retrieved",len(df),"records for sw index",ticker)
|
220
|
-
|
221
|
-
return df
|
222
149
|
|
223
150
|
#==============================================================================
|
224
151
|
if __name__=='__main__':
|
@@ -349,7 +276,7 @@ def compare_mrar_cross(dflist,rar_name,start,end, \
|
|
349
276
|
RF=False,window=252, \
|
350
277
|
axhline_value=0,axhline_label='零线',graph=True,printout=False, \
|
351
278
|
sortby='tpw_mean',scope='China', \
|
352
|
-
loc='best',annotate=False):
|
279
|
+
loc='best',annotate=False,ticker_type='auto'):
|
353
280
|
"""
|
354
281
|
功能:计算多种证券的rar比率,并绘图对比
|
355
282
|
比率:支持夏普比率、特雷诺比率、索替诺比率、阿尔法比率等
|
@@ -428,9 +355,15 @@ def compare_mrar_cross(dflist,rar_name,start,end, \
|
|
428
355
|
ds=None
|
429
356
|
if printout:
|
430
357
|
dfcols=list(df2)
|
358
|
+
|
359
|
+
#预处理ticker_type
|
360
|
+
ticker_type_list=ticker_type_preprocess_mticker_mixed(dfcols,ticker_type)
|
361
|
+
|
431
362
|
for c in dfcols:
|
432
|
-
#ccn=
|
433
|
-
|
363
|
+
#ccn=ticker_name(c)+'('+c+')'
|
364
|
+
pos=dfcols.index(c)
|
365
|
+
tt=ticker_type_list[pos]
|
366
|
+
ccn=ticker_name(c,tt)
|
434
367
|
df2.rename(columns={c:ccn},inplace=True)
|
435
368
|
|
436
369
|
if sortby=='tpw_mean':
|
siat/exchange_bond_china.pickle
CHANGED
Binary file
|
siat/fama_french.py
CHANGED
@@ -926,7 +926,7 @@ def reg_ff3_betas(ticker,start,end,scope='US',graph=True):
|
|
926
926
|
if graph == True:
|
927
927
|
gparms=parms.iloc[[1,2,3]]
|
928
928
|
print("\n",parms)
|
929
|
-
title=
|
929
|
+
title=ticker_name(ticker)+": FF3模型的贝塔系数"
|
930
930
|
plt.title(title,fontsize=12,fontweight='bold')
|
931
931
|
plt.ylabel("贝塔系数",fontsize=12,fontweight='bold')
|
932
932
|
|
@@ -1043,7 +1043,7 @@ def reg_ffc4_betas(ticker,start,end,scope='US',graph=True):
|
|
1043
1043
|
gparms=parms.iloc[[1,2,3,4]]
|
1044
1044
|
if graph == True:
|
1045
1045
|
#print("\n",parms)
|
1046
|
-
title=
|
1046
|
+
title=ticker_name(ticker)+": FFC4模型的贝塔系数"
|
1047
1047
|
plt.title(title,fontsize=12,fontweight='bold')
|
1048
1048
|
plt.ylabel("贝塔系数",fontsize=12,fontweight='bold')
|
1049
1049
|
|
@@ -1160,7 +1160,7 @@ def reg_ff5_betas(ticker,start,end,scope='US',graph=True):
|
|
1160
1160
|
gparms=parms.iloc[[1,2,3,4,5]]
|
1161
1161
|
if graph == True:
|
1162
1162
|
#print("\n",parms)
|
1163
|
-
title=
|
1163
|
+
title=ticker_name(ticker)+":FF5模型的贝塔系数"
|
1164
1164
|
plt.title(title,fontsize=12,fontweight='bold')
|
1165
1165
|
plt.ylabel("贝塔系数",fontsize=12,fontweight='bold')
|
1166
1166
|
|
siat/financials.py
CHANGED
@@ -179,8 +179,8 @@ def compare_history(tickers,items, \
|
|
179
179
|
colname=item1
|
180
180
|
collabel=ectranslate(item1)
|
181
181
|
ylabeltxt=''
|
182
|
-
#titletxt=
|
183
|
-
titletxt=
|
182
|
+
#titletxt=ticker_name(ticker1)+texttranslate(": 基于年(季)报的业绩历史")
|
183
|
+
titletxt=ticker_name(ticker1)+": 基于财务报表的业绩历史"
|
184
184
|
#footnote=texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
185
185
|
footnote="数据来源: 雅虎财经,"+' '+str(today)
|
186
186
|
|
@@ -203,8 +203,8 @@ def compare_history(tickers,items, \
|
|
203
203
|
colname2=item2
|
204
204
|
label2=ectranslate(item2)
|
205
205
|
ylabeltxt=''
|
206
|
-
#titletxt=
|
207
|
-
titletxt=
|
206
|
+
#titletxt=ticker_name(ticker1)+texttranslate(": 基于年(季)报的业绩历史对比")
|
207
|
+
titletxt=ticker_name(ticker1)+": 基于财务报表的业绩历史对比"
|
208
208
|
#footnote=texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
209
209
|
footnote="数据来源: 雅虎财经,"+' '+str(today)
|
210
210
|
|
@@ -241,8 +241,8 @@ def compare_history(tickers,items, \
|
|
241
241
|
colname2=item2
|
242
242
|
label2=ectranslate(item2)
|
243
243
|
ylabeltxt=''
|
244
|
-
#titletxt=
|
245
|
-
titletxt=
|
244
|
+
#titletxt=ticker_name(ticker1)+" vs "+ticker_name(ticker2)+texttranslate(": 基于年(季)报的业绩历史对比")
|
245
|
+
titletxt=ticker_name(ticker1)+" vs "+ticker_name(ticker2)+": 基于财务报表的业绩历史对比"
|
246
246
|
#footnote=texttranslate("数据来源: 雅虎财经,")+' '+str(today)
|
247
247
|
footnote="数据来源: 雅虎财经,"+' '+str(today)
|
248
248
|
|
@@ -382,7 +382,7 @@ def compare_snapshot(tickers,itemk, \
|
|
382
382
|
#print(" #Error(compare_snapshot): failed to get info of",item,"for",t)
|
383
383
|
continue
|
384
384
|
|
385
|
-
name=
|
385
|
+
name=ticker_name(t)
|
386
386
|
row=pd.Series({'ticker':t,'item':item,'value':value,'name':name})
|
387
387
|
try:
|
388
388
|
df=df.append(row,ignore_index=True)
|
@@ -446,14 +446,14 @@ def compare_snapshot(tickers,itemk, \
|
|
446
446
|
|
447
447
|
"""
|
448
448
|
if len(foundlist) > 0:
|
449
|
-
foundlist_names=
|
449
|
+
foundlist_names=ticker_name(foundlist)
|
450
450
|
print("Results:",itemk,"info found for the stocks below")
|
451
451
|
printInLine(foundlist_names,numberPerLine=numberPerLine,leadingBlanks=2)
|
452
452
|
printInLine(foundlist,numberPerLine=numberPerLine,leadingBlanks=2)
|
453
453
|
"""
|
454
454
|
if (len(notfoundlist) > 0):
|
455
455
|
print("Warning:",itemk,"info not found for the stocks below")
|
456
|
-
notfoundlist_names=
|
456
|
+
notfoundlist_names=ticker_name(notfoundlist)
|
457
457
|
printInLine(notfoundlist_names,numberPerLine=numberPerLine,leadingBlanks=2)
|
458
458
|
|
459
459
|
return df
|
@@ -545,7 +545,7 @@ def compare_snapshot2(tickers,itemk,graph=True):
|
|
545
545
|
name2=name1.split(',',1)[0]
|
546
546
|
name3=name2.split('.',1)[0]
|
547
547
|
"""
|
548
|
-
name=
|
548
|
+
name=ticker_name(t)
|
549
549
|
row=pd.Series({'ticker':t,'item':item,'value':value,'name':name})
|
550
550
|
try:
|
551
551
|
df=df.append(row,ignore_index=True)
|
@@ -610,7 +610,7 @@ def compare_tax(tickers,graph=True,axisamp=1.3,px=False):
|
|
610
610
|
print(" #Warning(compare_tax): stock info not available for",t)
|
611
611
|
continue
|
612
612
|
df1=df0.tail(1)
|
613
|
-
name=
|
613
|
+
name=ticker_name(t)
|
614
614
|
reportdate=df1.index[0]
|
615
615
|
taxrate=df1['tax rate'][0]
|
616
616
|
row=pd.Series({'ticker':t,'name':name,'date':reportdate,'tax rate':round(taxrate,3)})
|
@@ -712,7 +712,7 @@ def compare_igr_sgr(tickers,graph=True,axisamp=1.0,px=False):
|
|
712
712
|
if igr is None or sgr is None:
|
713
713
|
print(" #Warning(compare_igr_sgr): stock info not available for",t)
|
714
714
|
continue
|
715
|
-
name=
|
715
|
+
name=ticker_name(t)
|
716
716
|
row=pd.Series({'ticker':t,'name':name,'IGR':round(igr,3),'SGR':round(sgr,3)})
|
717
717
|
try:
|
718
718
|
df=df.append(row,ignore_index=True)
|
@@ -1925,7 +1925,7 @@ def compare_dupont(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10,hatchlist=
|
|
1925
1925
|
num=len(df['公司'])
|
1926
1926
|
for i in range(num):
|
1927
1927
|
code=df.loc[i,'公司']
|
1928
|
-
df.loc[i,'公司']=
|
1928
|
+
df.loc[i,'公司']=ticker_name(code)
|
1929
1929
|
|
1930
1930
|
f,ax1 = plt.subplots(1,figsize=(10,5))
|
1931
1931
|
w = 0.75
|
@@ -1949,7 +1949,7 @@ def compare_dupont(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10,hatchlist=
|
|
1949
1949
|
|
1950
1950
|
tickernamelist,fstypenamelist=[],[]
|
1951
1951
|
for i in range(num):
|
1952
|
-
tickernamelist=tickernamelist+[
|
1952
|
+
tickernamelist=tickernamelist+[ticker_name(tickerlist[i])]
|
1953
1953
|
if fstypelist[i]=='3M': fsname='季报'
|
1954
1954
|
else: fsname='年报'
|
1955
1955
|
fstypenamelist=fstypenamelist+[fsname]
|
@@ -1967,7 +1967,7 @@ def compare_dupont(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10,hatchlist=
|
|
1967
1967
|
for i in range(num):
|
1968
1968
|
if linenum % 4 == 3:
|
1969
1969
|
footnote=footnote+'\n'
|
1970
|
-
footnote=footnote+
|
1970
|
+
footnote=footnote+ticker_name(tickerlist[i])+":"+fsdatelist[i]+","+fstypenamelist[i]
|
1971
1971
|
if linenum < num -1:
|
1972
1972
|
footnote=footnote+';'
|
1973
1973
|
linenum=linenum + 1
|
siat/financials2.py
CHANGED
@@ -210,7 +210,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
210
210
|
|
211
211
|
fsdf4.replace(0,'---',inplace=True)
|
212
212
|
|
213
|
-
titletxt="\n***** "+
|
213
|
+
titletxt="\n***** "+ticker_name(tickers)+": BALANCE SHEET"+' *****\n'
|
214
214
|
print(titletxt)
|
215
215
|
"""
|
216
216
|
tablefmt_list=["plain","simple","github","grid","simple_grid","rounded_grid", \
|
@@ -307,7 +307,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
307
307
|
|
308
308
|
fsdf4.replace(0,'---',inplace=True)
|
309
309
|
|
310
|
-
titletxt="\n***** "+
|
310
|
+
titletxt="\n***** "+ticker_name(tickers)+": INCOME STATEMENTS"+' *****\n'
|
311
311
|
print(titletxt)
|
312
312
|
|
313
313
|
collist=list(fsdf4)
|
@@ -382,7 +382,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
382
382
|
|
383
383
|
fsdf4.replace(0,'---',inplace=True)
|
384
384
|
|
385
|
-
titletxt="\n***** "+
|
385
|
+
titletxt="\n***** "+ticker_name(tickers)+": CASHFLOW STATEMENTS"+' *****\n'
|
386
386
|
print(titletxt)
|
387
387
|
|
388
388
|
collist=list(fsdf4)
|
@@ -488,7 +488,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
488
488
|
|
489
489
|
fsdf4.replace(0,'---',inplace=True)
|
490
490
|
|
491
|
-
titletxt="\n***** "+
|
491
|
+
titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL STATEMENT SUMMARY"+' *****\n'
|
492
492
|
print(titletxt)
|
493
493
|
|
494
494
|
collist=list(fsdf4)
|
@@ -551,7 +551,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
551
551
|
# 变换年报/季报
|
552
552
|
fsdf['periodType']=fsdf['periodType'].apply(lambda x: 'Annual' if x=='12M' else 'Quarterly')
|
553
553
|
fsdf['reportDate']=fsdf['asOfDate'].apply(lambda x: x.strftime('%y-%m-%d'))
|
554
|
-
fsdf['Name']=fsdf['ticker'].apply(lambda x:
|
554
|
+
fsdf['Name']=fsdf['ticker'].apply(lambda x: ticker_name(x))
|
555
555
|
fsdf.set_index('Name',inplace=True)
|
556
556
|
|
557
557
|
fsdf.replace([np.inf, -np.inf], np.nan, inplace=True)
|
@@ -691,7 +691,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
691
691
|
|
692
692
|
fsdf4.replace(0,'---',inplace=True)
|
693
693
|
|
694
|
-
titletxt="\n***** "+
|
694
|
+
titletxt="\n***** "+ticker_name(tickers)+": FINANCIAL INDICATORS"+' *****\n'
|
695
695
|
print(titletxt)
|
696
696
|
|
697
697
|
collist=list(fsdf4)
|
@@ -758,7 +758,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
758
758
|
# 变换年报/季报
|
759
759
|
fsdf['periodType']=fsdf['periodType'].apply(lambda x: 'Annual' if x=='12M' else 'Quarterly')
|
760
760
|
fsdf['reportDate']=fsdf['asOfDate'].apply(lambda x: x.strftime('%y-%m-%d'))
|
761
|
-
fsdf['Name']=fsdf['ticker'].apply(lambda x:
|
761
|
+
fsdf['Name']=fsdf['ticker'].apply(lambda x: ticker_name(x))
|
762
762
|
fsdf.set_index('Name',inplace=True)
|
763
763
|
|
764
764
|
fsdf.replace([np.inf, -np.inf], np.nan, inplace=True)
|
@@ -856,7 +856,7 @@ def fs_analysis(tickers,fsdates=[],analysis_type='balance sheet', \
|
|
856
856
|
|
857
857
|
# 多只股票的杜邦分析对比
|
858
858
|
fsdf['periodType']=fsdf['periodType'].apply(lambda x: 'Annual' if x=='12M' else 'Quarterly')
|
859
|
-
fsdf['Company']=fsdf['ticker'].apply(lambda x:
|
859
|
+
fsdf['Company']=fsdf['ticker'].apply(lambda x: ticker_name(x))
|
860
860
|
|
861
861
|
|
862
862
|
collist=['Company','periodType','endDate','Profit Margin','Total Asset Turnover','Equity Multiplier','Return on Equity']
|
siat/financials_china.py
CHANGED
@@ -45,7 +45,7 @@ plt.rcParams['axes.unicode_minus'] = False
|
|
45
45
|
import pandas as pd
|
46
46
|
import akshare as ak
|
47
47
|
|
48
|
-
STOCK_SUFFIX_CHINA=['SS','SZ','BJ','NQ']
|
48
|
+
#STOCK_SUFFIX_CHINA=['SS','SZ','BJ','NQ']
|
49
49
|
#==============================================================================
|
50
50
|
#==============================================================================
|
51
51
|
if __name__=='__main__':
|
@@ -729,7 +729,7 @@ def compare_dupont_china(tickerlist,fsdate='latest',scale1 = 10,scale2 = 10, \
|
|
729
729
|
num=len(df['公司'])
|
730
730
|
for i in range(num):
|
731
731
|
code=df.loc[i,'公司']
|
732
|
-
df.loc[i,'公司']=
|
732
|
+
df.loc[i,'公司']=ticker_name(code).replace("(A股)",'')
|
733
733
|
|
734
734
|
f,ax1 = plt.subplots(1,figsize=(10,5))
|
735
735
|
w = 0.75
|
@@ -2256,12 +2256,12 @@ def cn_codetranslate(ticker):
|
|
2256
2256
|
"""
|
2257
2257
|
result,prefix,suffix=split_prefix_suffix(ticker)
|
2258
2258
|
if suffix in STOCK_SUFFIX_CHINA:
|
2259
|
-
name=
|
2259
|
+
name=ticker_name(ticker)
|
2260
2260
|
|
2261
2261
|
if suffix =='':
|
2262
2262
|
for s in STOCK_SUFFIX_CHINA:
|
2263
2263
|
ticker_try=ticker+'.'+s
|
2264
|
-
name=
|
2264
|
+
name=ticker_name(ticker_try)
|
2265
2265
|
print('\b'*99," Looking for the short name of stock",ticker)
|
2266
2266
|
if not (name == ticker_try): break
|
2267
2267
|
|
@@ -2428,7 +2428,7 @@ def compare_history_china(tickers,items,start,end,period_type='annual', \
|
|
2428
2428
|
#collabel=ectranslate(item1)
|
2429
2429
|
collabel=colname
|
2430
2430
|
ylabeltxt=''
|
2431
|
-
titletxt=
|
2431
|
+
titletxt=ticker_name(ticker1)+": 财务指标历史"
|
2432
2432
|
|
2433
2433
|
colmin=round(df1[colname].min(),2)
|
2434
2434
|
colmax=round(df1[colname].max(),2)
|
@@ -2482,9 +2482,9 @@ def compare_history_china(tickers,items,start,end,period_type='annual', \
|
|
2482
2482
|
colmin2=round(df2[colname2].min(),2)
|
2483
2483
|
colmax2=round(df2[colname2].max(),2)
|
2484
2484
|
colmean2=round(df2[colname2].mean(),2)
|
2485
|
-
footnote1=
|
2485
|
+
footnote1=ticker_name(ticker1)+":"+ \
|
2486
2486
|
str(colmin1)+" - "+str(colmax1)+",均值"+str(colmean1)
|
2487
|
-
footnote2=
|
2487
|
+
footnote2=ticker_name(ticker2)+":"+ \
|
2488
2488
|
str(colmin2)+" - "+str(colmax2)+",均值"+str(colmean2)
|
2489
2489
|
footnote=footnote1+'\n'+footnote2+'\n'+footnote9
|
2490
2490
|
|
@@ -2571,7 +2571,7 @@ def compare_snapshot_china(tickers,itemk,endDate='latest',datatag=True,tag_offse
|
|
2571
2571
|
t=rdf['ticker'].values[0]
|
2572
2572
|
item=cols[1]
|
2573
2573
|
value=rdf[item].values[0]
|
2574
|
-
name=
|
2574
|
+
name=ticker_name(t)
|
2575
2575
|
if name == t:
|
2576
2576
|
name=rdf[cols[2]].values[0]
|
2577
2577
|
row=pd.Series({'ticker':t,'item':item,'value':value,'name':name})
|
@@ -2656,7 +2656,7 @@ def compare_tax_china(tickers,endDate='latest',datatag=True,tag_offset=0.01,grap
|
|
2656
2656
|
print(" #Error(compare_tax_china): failed to get financial info for",t)
|
2657
2657
|
continue
|
2658
2658
|
df1=df0.tail(1)
|
2659
|
-
name=
|
2659
|
+
name=ticker_name(t)
|
2660
2660
|
reportdate=df1.index[0]
|
2661
2661
|
taxrate=df1['tax rate'][0]
|
2662
2662
|
row=pd.Series({'ticker':t,'name':name,'date':reportdate,'tax rate%':round(taxrate*100,2)})
|
@@ -2755,7 +2755,7 @@ def compare_igr_sgr_china(tickers,endDate='latest',graph=True,axisamp1=1.3,axisa
|
|
2755
2755
|
if igr is None or sgr is None:
|
2756
2756
|
print(" #Warning(compare_igr_sgr_china): no stock info found for",t)
|
2757
2757
|
continue
|
2758
|
-
name=
|
2758
|
+
name=ticker_name(t)
|
2759
2759
|
row=pd.Series({'ticker':t,'name':name,'IGR%':round(igr*100,2),'SGR%':round(sgr*100,2)})
|
2760
2760
|
try:
|
2761
2761
|
df=df.append(row,ignore_index=True)
|
@@ -2830,7 +2830,7 @@ def dupont_decompose_china(ticker,fsdate,gview=False):
|
|
2830
2830
|
#亿元
|
2831
2831
|
yi=100000000
|
2832
2832
|
|
2833
|
-
company_name=
|
2833
|
+
company_name=ticker_name(ticker)
|
2834
2834
|
# 定义杜邦分解项目变量
|
2835
2835
|
|
2836
2836
|
roe='【'+company_name+'】\n('+fsdate+')\n'+'净资产收益率'
|
@@ -3213,7 +3213,7 @@ def dupont_decompose_china(ticker,fsdate,gview=False):
|
|
3213
3213
|
|
3214
3214
|
from graphviz import Digraph
|
3215
3215
|
#按各公司的层数生产分层的节点:
|
3216
|
-
g=Digraph(name=
|
3216
|
+
g=Digraph(name=ticker_name(ticker)+fsdate)
|
3217
3217
|
|
3218
3218
|
for key in dic:
|
3219
3219
|
for n in range(number_of_layers+1):
|
@@ -3238,7 +3238,7 @@ def dupont_decompose_china(ticker,fsdate,gview=False):
|
|
3238
3238
|
|
3239
3239
|
#打印信息
|
3240
3240
|
if not gview:
|
3241
|
-
print("\n注:",
|
3241
|
+
print("\n注:",ticker_name(ticker),"\b,金额单位:亿元,财报日期:",fsdate)
|
3242
3242
|
print("1、为避免图示过大,这里未列出所有分解项目")
|
3243
3243
|
print("2、金融机构报表与普通企业结构不同,此处仅为约算")
|
3244
3244
|
print("3、应收款项包括应收账款、应收利息、应收保费以及应收票据等")
|
@@ -3411,7 +3411,7 @@ def get_fin_summary_1ticker_china(ticker,fsdates):
|
|
3411
3411
|
try:
|
3412
3412
|
dft2=dft[['选项','指标']+fsdates3]
|
3413
3413
|
except:
|
3414
|
-
print(" #Warning(get_fin_summary_1ticker_china): fin stmt of",fsdates3[0],"unavailable for",ticker+'('+
|
3414
|
+
print(" #Warning(get_fin_summary_1ticker_china): fin stmt of",fsdates3[0],"unavailable for",ticker+'('+ticker_name(ticker)+')')
|
3415
3415
|
return None
|
3416
3416
|
|
3417
3417
|
# 金额变换:元-->亿元,小数位截取
|
@@ -3689,7 +3689,7 @@ def compare_fin_summary_china(tickers,fsdates):
|
|
3689
3689
|
# 一只股票情形:多日期
|
3690
3690
|
if len(tickers_found) == 1:
|
3691
3691
|
ticker1=tickers[0]
|
3692
|
-
titletxt="\n===== 上市公司财务报表摘要:"+
|
3692
|
+
titletxt="\n===== 上市公司财务报表摘要:"+ticker_name(ticker1)+" ====="
|
3693
3693
|
print(titletxt)
|
3694
3694
|
|
3695
3695
|
fsdf1=fsdf[fsdf['ticker']==ticker1]
|
@@ -3730,7 +3730,7 @@ def compare_fin_summary_china(tickers,fsdates):
|
|
3730
3730
|
|
3731
3731
|
try:
|
3732
3732
|
dft2=dft[['选项','指标',fsdates3[0]]]
|
3733
|
-
dft2.rename(columns={fsdates3[0]:
|
3733
|
+
dft2.rename(columns={fsdates3[0]:ticker_name(t)},inplace=True)
|
3734
3734
|
except:
|
3735
3735
|
print(" #Error(compare_fin_summary_china): fin stmt of",t,'not found on',fsdates3[0])
|
3736
3736
|
return None
|
@@ -3797,9 +3797,9 @@ def get_fin_indicator_1ticker_china(ticker,fsdates):
|
|
3797
3797
|
fsdate_field=list(dft)[0]
|
3798
3798
|
dft2=dft[dft[fsdate_field].isin(fsdates3)]
|
3799
3799
|
if len(dft2) < len(fsdates3):
|
3800
|
-
print(" #Warning(get_fin_summary_1ticker_china): fin stmt of some dates unavailable for",ticker+'('+
|
3800
|
+
print(" #Warning(get_fin_summary_1ticker_china): fin stmt of some dates unavailable for",ticker+'('+ticker_name(ticker)+')')
|
3801
3801
|
if len(dft2) ==0:
|
3802
|
-
print(" #Error(get_fin_summary_1ticker_china): no fin stmts found for",ticker+'('+
|
3802
|
+
print(" #Error(get_fin_summary_1ticker_china): no fin stmts found for",ticker+'('+ticker_name(ticker)+') on',fsdates)
|
3803
3803
|
return None
|
3804
3804
|
|
3805
3805
|
# 去掉重复行
|
@@ -4171,7 +4171,7 @@ def compare_fin_indicator_china(tickers,fsdates):
|
|
4171
4171
|
# 一只股票情形:多日期
|
4172
4172
|
if len(tickers_found) == 1:
|
4173
4173
|
ticker1=tickers[0]
|
4174
|
-
titletxt="\n===== 上市公司主要财务比率和重要指标:"+
|
4174
|
+
titletxt="\n===== 上市公司主要财务比率和重要指标:"+ticker_name(ticker1)+" ====="
|
4175
4175
|
print(titletxt)
|
4176
4176
|
|
4177
4177
|
fsdf1=fsdf[fsdf['ticker']==ticker1]
|
@@ -4227,7 +4227,7 @@ def compare_fin_indicator_china(tickers,fsdates):
|
|
4227
4227
|
|
4228
4228
|
try:
|
4229
4229
|
dft2=dft[['选项','指标',fsdates3[0]]]
|
4230
|
-
dft2.rename(columns={fsdates3[0]:
|
4230
|
+
dft2.rename(columns={fsdates3[0]:ticker_name(t)},inplace=True)
|
4231
4231
|
except:
|
4232
4232
|
print(" #Error(compare_fin_summary_china): fin stmt of",fsdates3[0],'not found for',t)
|
4233
4233
|
return None
|