siat 3.10.132__py3-none-any.whl → 3.10.133__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/__init__.py +0 -0
- siat/allin.py +0 -0
- siat/assets_liquidity.py +0 -0
- siat/beta_adjustment.py +0 -0
- siat/beta_adjustment_china.py +0 -0
- siat/blockchain.py +0 -0
- siat/bond.py +0 -0
- siat/bond_base.py +0 -0
- siat/bond_china.py +0 -0
- siat/bond_zh_sina.py +0 -0
- siat/capm_beta.py +0 -0
- siat/capm_beta2.py +0 -0
- siat/compare_cross.py +0 -0
- siat/copyrights.py +0 -0
- siat/cryptocurrency.py +0 -0
- siat/economy.py +0 -0
- siat/economy2.py +0 -0
- siat/esg.py +0 -0
- siat/event_study.py +0 -0
- siat/exchange_bond_china.pickle +0 -0
- siat/fama_french.py +0 -0
- siat/fin_stmt2_yahoo.py +0 -0
- siat/financial_base.py +0 -0
- siat/financial_statements.py +0 -0
- siat/financials.py +0 -0
- siat/financials2.py +0 -0
- siat/financials_china.py +0 -0
- siat/financials_china2.py +0 -0
- siat/fund.py +0 -0
- siat/fund_china.pickle +0 -0
- siat/fund_china.py +0 -0
- siat/future_china.py +0 -0
- siat/google_authenticator.py +0 -0
- siat/grafix.py +0 -0
- siat/holding_risk.py +0 -0
- siat/luchy_draw.py +0 -0
- siat/market_china.py +0 -0
- siat/markowitz.py +0 -0
- siat/markowitz2.py +0 -0
- siat/markowitz2_20250704.py +0 -0
- siat/markowitz2_20250705.py +0 -0
- siat/markowitz_simple.py +0 -0
- siat/ml_cases.py +0 -0
- siat/ml_cases_example.py +0 -0
- siat/option_china.py +0 -0
- siat/option_pricing.py +0 -0
- siat/other_indexes.py +0 -0
- siat/risk_adjusted_return.py +0 -0
- siat/risk_adjusted_return2.py +0 -0
- siat/risk_evaluation.py +0 -0
- siat/risk_free_rate.py +0 -0
- siat/sector_china.py +0 -0
- siat/security_price2.py +0 -0
- siat/security_prices.py +40 -2
- siat/security_trend.py +0 -0
- siat/security_trend2.py +0 -0
- siat/stock.py +0 -0
- siat/stock_advice_linear.py +0 -0
- siat/stock_base.py +0 -0
- siat/stock_china.py +0 -0
- siat/stock_info.pickle +0 -0
- siat/stock_prices_kneighbors.py +0 -0
- siat/stock_prices_linear.py +0 -0
- siat/stock_profile.py +0 -0
- siat/stock_technical.py +0 -0
- siat/stooq.py +0 -0
- siat/transaction.py +0 -0
- siat/translate.py +0 -0
- siat/valuation.py +0 -0
- siat/valuation_china.py +0 -0
- siat/var_model_validation.py +0 -0
- siat/yf_name.py +0 -0
- {siat-3.10.132.dist-info/licenses → siat-3.10.133.dist-info}/LICENSE +0 -0
- {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/METADATA +232 -235
- siat-3.10.133.dist-info/RECORD +78 -0
- {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/WHEEL +1 -1
- {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/top_level.txt +0 -1
- build/lib/build/lib/siat/__init__.py +0 -75
- build/lib/build/lib/siat/allin.py +0 -137
- build/lib/build/lib/siat/assets_liquidity.py +0 -915
- build/lib/build/lib/siat/beta_adjustment.py +0 -1058
- build/lib/build/lib/siat/beta_adjustment_china.py +0 -548
- build/lib/build/lib/siat/blockchain.py +0 -143
- build/lib/build/lib/siat/bond.py +0 -2900
- build/lib/build/lib/siat/bond_base.py +0 -992
- build/lib/build/lib/siat/bond_china.py +0 -100
- build/lib/build/lib/siat/bond_zh_sina.py +0 -143
- build/lib/build/lib/siat/capm_beta.py +0 -783
- build/lib/build/lib/siat/capm_beta2.py +0 -887
- build/lib/build/lib/siat/common.py +0 -5360
- build/lib/build/lib/siat/compare_cross.py +0 -642
- build/lib/build/lib/siat/copyrights.py +0 -18
- build/lib/build/lib/siat/cryptocurrency.py +0 -667
- build/lib/build/lib/siat/economy.py +0 -1471
- build/lib/build/lib/siat/economy2.py +0 -1853
- build/lib/build/lib/siat/esg.py +0 -536
- build/lib/build/lib/siat/event_study.py +0 -815
- build/lib/build/lib/siat/fama_french.py +0 -1521
- build/lib/build/lib/siat/fin_stmt2_yahoo.py +0 -982
- build/lib/build/lib/siat/financial_base.py +0 -1160
- build/lib/build/lib/siat/financial_statements.py +0 -598
- build/lib/build/lib/siat/financials.py +0 -2339
- build/lib/build/lib/siat/financials2.py +0 -1278
- build/lib/build/lib/siat/financials_china.py +0 -4433
- build/lib/build/lib/siat/financials_china2.py +0 -2212
- build/lib/build/lib/siat/fund.py +0 -629
- build/lib/build/lib/siat/fund_china.py +0 -3307
- build/lib/build/lib/siat/future_china.py +0 -551
- build/lib/build/lib/siat/google_authenticator.py +0 -47
- build/lib/build/lib/siat/grafix.py +0 -3636
- build/lib/build/lib/siat/holding_risk.py +0 -867
- build/lib/build/lib/siat/luchy_draw.py +0 -638
- build/lib/build/lib/siat/market_china.py +0 -1168
- build/lib/build/lib/siat/markowitz.py +0 -2363
- build/lib/build/lib/siat/markowitz2.py +0 -3150
- build/lib/build/lib/siat/markowitz2_20250704.py +0 -2969
- build/lib/build/lib/siat/markowitz2_20250705.py +0 -3158
- build/lib/build/lib/siat/markowitz_simple.py +0 -373
- build/lib/build/lib/siat/ml_cases.py +0 -2291
- build/lib/build/lib/siat/ml_cases_example.py +0 -60
- build/lib/build/lib/siat/option_china.py +0 -3069
- build/lib/build/lib/siat/option_pricing.py +0 -1925
- build/lib/build/lib/siat/other_indexes.py +0 -409
- build/lib/build/lib/siat/risk_adjusted_return.py +0 -1576
- build/lib/build/lib/siat/risk_adjusted_return2.py +0 -1900
- build/lib/build/lib/siat/risk_evaluation.py +0 -2218
- build/lib/build/lib/siat/risk_free_rate.py +0 -351
- build/lib/build/lib/siat/sector_china.py +0 -4140
- build/lib/build/lib/siat/security_price2.py +0 -727
- build/lib/build/lib/siat/security_prices.py +0 -3408
- build/lib/build/lib/siat/security_trend.py +0 -402
- build/lib/build/lib/siat/security_trend2.py +0 -646
- build/lib/build/lib/siat/stock.py +0 -4284
- build/lib/build/lib/siat/stock_advice_linear.py +0 -934
- build/lib/build/lib/siat/stock_base.py +0 -26
- build/lib/build/lib/siat/stock_china.py +0 -2095
- build/lib/build/lib/siat/stock_prices_kneighbors.py +0 -910
- build/lib/build/lib/siat/stock_prices_linear.py +0 -386
- build/lib/build/lib/siat/stock_profile.py +0 -707
- build/lib/build/lib/siat/stock_technical.py +0 -3305
- build/lib/build/lib/siat/stooq.py +0 -74
- build/lib/build/lib/siat/transaction.py +0 -347
- build/lib/build/lib/siat/translate.py +0 -5183
- build/lib/build/lib/siat/valuation.py +0 -1378
- build/lib/build/lib/siat/valuation_china.py +0 -2076
- build/lib/build/lib/siat/var_model_validation.py +0 -444
- build/lib/build/lib/siat/yf_name.py +0 -811
- build/lib/siat/__init__.py +0 -75
- build/lib/siat/allin.py +0 -137
- build/lib/siat/assets_liquidity.py +0 -915
- build/lib/siat/beta_adjustment.py +0 -1058
- build/lib/siat/beta_adjustment_china.py +0 -548
- build/lib/siat/blockchain.py +0 -143
- build/lib/siat/bond.py +0 -2900
- build/lib/siat/bond_base.py +0 -992
- build/lib/siat/bond_china.py +0 -100
- build/lib/siat/bond_zh_sina.py +0 -143
- build/lib/siat/capm_beta.py +0 -783
- build/lib/siat/capm_beta2.py +0 -887
- build/lib/siat/common.py +0 -5360
- build/lib/siat/compare_cross.py +0 -642
- build/lib/siat/copyrights.py +0 -18
- build/lib/siat/cryptocurrency.py +0 -667
- build/lib/siat/economy.py +0 -1471
- build/lib/siat/economy2.py +0 -1853
- build/lib/siat/esg.py +0 -536
- build/lib/siat/event_study.py +0 -815
- build/lib/siat/fama_french.py +0 -1521
- build/lib/siat/fin_stmt2_yahoo.py +0 -982
- build/lib/siat/financial_base.py +0 -1160
- build/lib/siat/financial_statements.py +0 -598
- build/lib/siat/financials.py +0 -2339
- build/lib/siat/financials2.py +0 -1278
- build/lib/siat/financials_china.py +0 -4433
- build/lib/siat/financials_china2.py +0 -2212
- build/lib/siat/fund.py +0 -629
- build/lib/siat/fund_china.py +0 -3307
- build/lib/siat/future_china.py +0 -551
- build/lib/siat/google_authenticator.py +0 -47
- build/lib/siat/grafix.py +0 -3636
- build/lib/siat/holding_risk.py +0 -867
- build/lib/siat/luchy_draw.py +0 -638
- build/lib/siat/market_china.py +0 -1168
- build/lib/siat/markowitz.py +0 -2363
- build/lib/siat/markowitz2.py +0 -3150
- build/lib/siat/markowitz2_20250704.py +0 -2969
- build/lib/siat/markowitz2_20250705.py +0 -3158
- build/lib/siat/markowitz_simple.py +0 -373
- build/lib/siat/ml_cases.py +0 -2291
- build/lib/siat/ml_cases_example.py +0 -60
- build/lib/siat/option_china.py +0 -3069
- build/lib/siat/option_pricing.py +0 -1925
- build/lib/siat/other_indexes.py +0 -409
- build/lib/siat/risk_adjusted_return.py +0 -1576
- build/lib/siat/risk_adjusted_return2.py +0 -1900
- build/lib/siat/risk_evaluation.py +0 -2218
- build/lib/siat/risk_free_rate.py +0 -351
- build/lib/siat/sector_china.py +0 -4140
- build/lib/siat/security_price2.py +0 -727
- build/lib/siat/security_prices.py +0 -3408
- build/lib/siat/security_trend.py +0 -402
- build/lib/siat/security_trend2.py +0 -646
- build/lib/siat/stock.py +0 -4284
- build/lib/siat/stock_advice_linear.py +0 -934
- build/lib/siat/stock_base.py +0 -26
- build/lib/siat/stock_china.py +0 -2095
- build/lib/siat/stock_prices_kneighbors.py +0 -910
- build/lib/siat/stock_prices_linear.py +0 -386
- build/lib/siat/stock_profile.py +0 -707
- build/lib/siat/stock_technical.py +0 -3305
- build/lib/siat/stooq.py +0 -74
- build/lib/siat/transaction.py +0 -347
- build/lib/siat/translate.py +0 -5183
- build/lib/siat/valuation.py +0 -1378
- build/lib/siat/valuation_china.py +0 -2076
- build/lib/siat/var_model_validation.py +0 -444
- build/lib/siat/yf_name.py +0 -811
- siat-3.10.132.dist-info/RECORD +0 -218
@@ -1,1168 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
所属工具包:证券投资分析工具SIAT
|
4
|
-
SIAT:Security Investment Analysis Tool
|
5
|
-
创建日期:2022年12月11日
|
6
|
-
最新修订日期:
|
7
|
-
作者:王德宏 (WANG Dehong, Peter)
|
8
|
-
作者单位:北京外国语大学国际商学院
|
9
|
-
作者邮件:wdehong2000@163.com
|
10
|
-
版权所有:王德宏
|
11
|
-
用途限制:仅限研究与教学使用,不可商用!商用需要额外授权。
|
12
|
-
特别声明:作者不对使用本工具进行证券投资导致的任何损益负责!
|
13
|
-
"""
|
14
|
-
#==============================================================================
|
15
|
-
#处理潜在的中文字符编码问题,免去中文字符前面加"u"
|
16
|
-
from __future__ import unicode_literals
|
17
|
-
|
18
|
-
#屏蔽所有警告性信息
|
19
|
-
import warnings; warnings.filterwarnings('ignore')
|
20
|
-
#==============================================================================
|
21
|
-
from siat.common import *
|
22
|
-
from siat.translate import *
|
23
|
-
from siat.grafix import *
|
24
|
-
from siat.security_prices import *
|
25
|
-
from siat.security_price2 import *
|
26
|
-
#==============================================================================
|
27
|
-
import matplotlib.pyplot as plt
|
28
|
-
|
29
|
-
title_txt_size=16
|
30
|
-
ylabel_txt_size=14
|
31
|
-
xlabel_txt_size=14
|
32
|
-
|
33
|
-
#==============================================================================
|
34
|
-
#==============================================================================
|
35
|
-
# 功能:沪深市场概况
|
36
|
-
#==============================================================================
|
37
|
-
if __name__=='__main__':
|
38
|
-
market='SSE'
|
39
|
-
market='SZSE'
|
40
|
-
|
41
|
-
def market_profile_china(market='SSE'):
|
42
|
-
"""
|
43
|
-
功能:沪深市场概况
|
44
|
-
|
45
|
-
注意:慎用,其数据与基于akshare的market_detail_china结果矛盾,例如市值流通比等
|
46
|
-
"""
|
47
|
-
market1=market.upper()
|
48
|
-
mktlist=['SSE','SZSE']
|
49
|
-
if market1 not in mktlist:
|
50
|
-
print(" #Error(market_profile_china): unsupported market",market)
|
51
|
-
print(" Supported market abbreviation:",mktlist)
|
52
|
-
import datetime as dt
|
53
|
-
today=dt.date.today()
|
54
|
-
|
55
|
-
import akshare as ak
|
56
|
-
lang=check_language()
|
57
|
-
|
58
|
-
# 上交所概况
|
59
|
-
if market1 == 'SSE':
|
60
|
-
try:
|
61
|
-
info=ak.stock_sse_summary()
|
62
|
-
except:
|
63
|
-
print(" #Error(market_profile_china): failed to retrieve info, try later")
|
64
|
-
return
|
65
|
-
|
66
|
-
info1=info.set_index('项目')
|
67
|
-
info1['全貌']=info1['股票']
|
68
|
-
|
69
|
-
# 报告日期
|
70
|
-
y4m2d2=info1.loc['报告时间','股票']
|
71
|
-
rpt_date=y4m2d2[0:4]+'-'+y4m2d2[4:6]+'-'+y4m2d2[6:8]
|
72
|
-
|
73
|
-
for i in list(info1):
|
74
|
-
info1[i]=info1[i].astype(float)
|
75
|
-
infot=info1.T
|
76
|
-
|
77
|
-
# 计算均值
|
78
|
-
for i in list(infot):
|
79
|
-
try:
|
80
|
-
infot[i+'均值']=round(infot[i]/infot['上市公司'],2)
|
81
|
-
except:
|
82
|
-
continue
|
83
|
-
infot['流通比率']=round(infot['流通市值']/infot['总市值'],4)
|
84
|
-
info2=infot.T
|
85
|
-
info2['项目']=info2.index
|
86
|
-
|
87
|
-
if lang == 'Chinese':
|
88
|
-
print("\n=== 上海证券交易所上市公司概况 ===")
|
89
|
-
else:
|
90
|
-
print("\n Exchange Stock Summary: Shanghai Stock Exchange")
|
91
|
-
|
92
|
-
typelist=['全貌','主板','科创板']
|
93
|
-
typelist2=['Overall','Main board','STAR board']
|
94
|
-
itemlist=['上市公司','总市值','总市值均值','流通市值','流通市值均值','流通比率']
|
95
|
-
itemlist2=['上市公司','总市值/亿元','总市值均值/亿元', \
|
96
|
-
'流通市值/亿元','流通市值均值/亿元','流通市值/总市值']
|
97
|
-
itemlist2e=['Listed firms','Total capitalization(RMB 100m)', \
|
98
|
-
'Total capitalization mean(RMB 100m)', \
|
99
|
-
'Outstandng capitalization(RMB 100m)', \
|
100
|
-
'Outstandng capitalization mean(RMB 100m)','Outstanding-total ratio']
|
101
|
-
|
102
|
-
for t in typelist:
|
103
|
-
subdf=info2[['项目',t]]
|
104
|
-
if lang == 'English':
|
105
|
-
pos=typelist.index(t)
|
106
|
-
t2=typelist2[pos]
|
107
|
-
print('\n*** '+t2+':')
|
108
|
-
else:
|
109
|
-
print('\n*** '+t+':')
|
110
|
-
|
111
|
-
lenlist=[]
|
112
|
-
for m in itemlist2:
|
113
|
-
l=hzlen(m)
|
114
|
-
lenlist=lenlist+[l]
|
115
|
-
maxlen=max(lenlist)
|
116
|
-
|
117
|
-
for i in itemlist:
|
118
|
-
|
119
|
-
try:
|
120
|
-
value=list(subdf[subdf['项目']==i][t])[0]
|
121
|
-
pos=itemlist.index(i)
|
122
|
-
|
123
|
-
if lang == 'Chinese':
|
124
|
-
i2=itemlist2[pos]
|
125
|
-
blanknum=maxlen-hzlen(i2)
|
126
|
-
#print(' ',i2+' '*blanknum+':',end='')
|
127
|
-
print(' ',i2+':',end='')
|
128
|
-
else:
|
129
|
-
i2e=itemlist2e[pos]
|
130
|
-
blanknum=maxlen-hzlen(i2e)
|
131
|
-
#print(' ',i2e+' '*blanknum+':',end='')
|
132
|
-
print(' ',i2e+':',end='')
|
133
|
-
except:
|
134
|
-
pos=itemlist.index(i)
|
135
|
-
i2=itemlist2[pos]
|
136
|
-
value=list(subdf[subdf['项目']==i2][t])[0]
|
137
|
-
i2e=itemlist2e[pos]
|
138
|
-
|
139
|
-
if lang == 'Chinese':
|
140
|
-
blanknum=maxlen-hzlen(i2)
|
141
|
-
#print(' ',i2+' '*blanknum+':',end='')
|
142
|
-
print(' ',i2+':',end='')
|
143
|
-
else:
|
144
|
-
blanknum=maxlen-hzlen(i2e)
|
145
|
-
#print(' ',i2e+' '*blanknum+':',end='')
|
146
|
-
print(' ',i2e+':',end='')
|
147
|
-
|
148
|
-
if i in ["上市股票",'上市公司']: #若是字符则转换成数字
|
149
|
-
value2=int(value)
|
150
|
-
else:
|
151
|
-
value2=float(value)
|
152
|
-
print("{:,}".format(value2))
|
153
|
-
|
154
|
-
if lang == 'Chinese':
|
155
|
-
#print(" 注:部分上市公司同时发行A股和B股")
|
156
|
-
print("\n数据来源:上交所,更新日期:",rpt_date)
|
157
|
-
print("注:部分上市公司同时有A/B股可交易股票")
|
158
|
-
else:
|
159
|
-
print("\nSource: Shanghai Stock Exchange, updated",rpt_date)
|
160
|
-
|
161
|
-
return info2
|
162
|
-
|
163
|
-
# 深交所概况
|
164
|
-
if market1 == 'SZSE':
|
165
|
-
try:
|
166
|
-
info=ak.stock_szse_summary()
|
167
|
-
except:
|
168
|
-
print(" #Error(market_profile_china): failed to retrieve info, try later")
|
169
|
-
return
|
170
|
-
|
171
|
-
# 字符串转数值
|
172
|
-
info.set_index('证券类别',inplace=True)
|
173
|
-
for i in list(info):
|
174
|
-
info[i]=info[i].astype(float)
|
175
|
-
|
176
|
-
# 计算均值
|
177
|
-
yiyuan=100000000.0
|
178
|
-
info['总市值']=round(info['总市值']/yiyuan,2)
|
179
|
-
info['流通市值']=round(info['流通市值']/yiyuan,2)
|
180
|
-
|
181
|
-
info1t=info.T
|
182
|
-
info1t['全貌']=info1t['股票']
|
183
|
-
#info1t['主板']=info1t['主板A股']+info1t['主板B股']+info1t['中小板']
|
184
|
-
info1t['主板']=info1t['主板A股']+info1t['主板B股']
|
185
|
-
info1t['创业板']=info1t['创业板A股']
|
186
|
-
|
187
|
-
infot2=info1t.T
|
188
|
-
infot2['流通比率']=round(infot2['流通市值']/infot2['总市值'],4)
|
189
|
-
|
190
|
-
for i in list(infot2):
|
191
|
-
try:
|
192
|
-
infot2[i+'均值']=round(infot2[i]/infot2['数量'],2)
|
193
|
-
except:
|
194
|
-
continue
|
195
|
-
|
196
|
-
info2=infot2.T
|
197
|
-
info2['项目']=info2.index
|
198
|
-
|
199
|
-
if lang == 'Chinese':
|
200
|
-
print("\n=== 深圳证券交易所上市公司概况 ===")
|
201
|
-
else:
|
202
|
-
print("\n Exchange Summary: Shenzhen Stock Exchange")
|
203
|
-
|
204
|
-
typelist=['全貌','主板','创业板']
|
205
|
-
typelist2=['Overall','Main board','GEM board']
|
206
|
-
itemlist=['数量','总市值','总市值均值','流通市值','流通市值均值','流通比率']
|
207
|
-
itemlist2=['上市公司','总市值/亿元','总市值均值/亿元', \
|
208
|
-
'流通市值/亿元','流通市值均值/亿元','流通市值/总市值']
|
209
|
-
itemlist2e=['Listed firms','Total capitalization(RMB 100m)', \
|
210
|
-
'Total capitalization mean(RMB 100m)', \
|
211
|
-
'Outstandng capitalization(RMB 100m)', \
|
212
|
-
'Outstandng capitalization mean(RMB 100m)','Outstanding-total ratio']
|
213
|
-
|
214
|
-
for t in typelist:
|
215
|
-
subdf=info2[['项目',t]]
|
216
|
-
if lang == 'English':
|
217
|
-
pos=typelist.index(t)
|
218
|
-
t2=typelist2[pos]
|
219
|
-
print('\n*** '+t2+':')
|
220
|
-
else:
|
221
|
-
print('\n*** '+t+':')
|
222
|
-
|
223
|
-
lenlist=[]
|
224
|
-
for m in itemlist2:
|
225
|
-
l=hzlen(m)
|
226
|
-
lenlist=lenlist+[l]
|
227
|
-
maxlen=max(lenlist)
|
228
|
-
|
229
|
-
for i in itemlist:
|
230
|
-
|
231
|
-
try:
|
232
|
-
value=list(subdf[subdf['项目']==i][t])[0]
|
233
|
-
pos=itemlist.index(i)
|
234
|
-
|
235
|
-
if lang == 'Chinese':
|
236
|
-
i2=itemlist2[pos]
|
237
|
-
blanknum=maxlen-hzlen(i2)
|
238
|
-
#print(' ',i2+' '*blanknum+':',end='')
|
239
|
-
print(' ',i2+':',end='')
|
240
|
-
else:
|
241
|
-
i2e=itemlist2e[pos]
|
242
|
-
blanknum=maxlen-hzlen(i2e)
|
243
|
-
#print(' ',i2e+' '*blanknum+':',end='')
|
244
|
-
print(' ',i2e+':',end='')
|
245
|
-
except:
|
246
|
-
pos=itemlist.index(i)
|
247
|
-
i2=itemlist2[pos]
|
248
|
-
value=list(subdf[subdf['项目']==i2][t])[0]
|
249
|
-
i2e=itemlist2e[pos]
|
250
|
-
|
251
|
-
if lang == 'Chinese':
|
252
|
-
blanknum=maxlen-hzlen(i2)
|
253
|
-
#print(' ',i2+' '*blanknum+':',end='')
|
254
|
-
print(' ',i2+':',end='')
|
255
|
-
else:
|
256
|
-
blanknum=maxlen-hzlen(i2e)
|
257
|
-
#print(' ',i2e+' '*blanknum+':',end='')
|
258
|
-
print(' ',i2e+':',end='')
|
259
|
-
|
260
|
-
if i in ['数量']: #若是字符则转换成数字
|
261
|
-
value2=int(value)
|
262
|
-
else:
|
263
|
-
value2=float(value)
|
264
|
-
print("{:,}".format(value2))
|
265
|
-
|
266
|
-
if lang == 'Chinese':
|
267
|
-
#print(" 注:部分上市公司同时发行A股和B股")
|
268
|
-
print("\n数据来源:深交所,",today)
|
269
|
-
print("注1:收盘前/后分别为昨日/今日数据")
|
270
|
-
print("注2:部分上市公司同时有A/B股可交易股票")
|
271
|
-
|
272
|
-
else:
|
273
|
-
print("\nSource: Shanghai Stock Exchange,",today)
|
274
|
-
print("Note: yesterday/today\'s data before/after close")
|
275
|
-
|
276
|
-
return info2
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
def market_profile_china_tmp(market='SSE'):
|
281
|
-
"""
|
282
|
-
功能:沪深市场概况,废弃!
|
283
|
-
"""
|
284
|
-
if market1 == 'SZSE':
|
285
|
-
df=ak.stock_szse_summary()
|
286
|
-
df1=df[df['证券类别'].isin(['股票','主板A股','主板B股','中小板','创业板A股'])]
|
287
|
-
|
288
|
-
#字段改名
|
289
|
-
"""
|
290
|
-
df1.rename(columns={'证券类别':'type','数量(只)':'上市股票/只', \
|
291
|
-
'总股本':'总股本/亿股(份)','总市值':'总市值/亿元', \
|
292
|
-
'流通股本':'流通股本/亿股(份)','流通市值':'流通市值/亿元'},inplace=True)
|
293
|
-
"""
|
294
|
-
df1.rename(columns={'证券类别':'type','数量':'上市股票/只', \
|
295
|
-
'总市值':'总市值/亿元', \
|
296
|
-
'流通市值':'流通市值/亿元'},inplace=True)
|
297
|
-
#df1['总股本/亿股(份)']=df1['总股本/亿股(份)'].apply(lambda x:round(x/100000000.0,2))
|
298
|
-
df1['总市值/亿元']=df1['总市值/亿元'].apply(lambda x:round(x/100000000.0,2))
|
299
|
-
#df1['流通股本/亿股(份)']=df1['流通股本/亿股(份)'].apply(lambda x:round(x/100000000.0,2))
|
300
|
-
df1['流通市值/亿元']=df1['流通市值/亿元'].apply(lambda x:round(x/100000000.0,2))
|
301
|
-
|
302
|
-
del df1['成交金额']
|
303
|
-
#del df1['成交量']
|
304
|
-
df1.loc[(df1['type']=='股票'),'type']='总貌'
|
305
|
-
df1.loc[(df1['type']=='创业板A股'),'type']='创业板'
|
306
|
-
|
307
|
-
#itemlist=['数量','总股本/亿股(份)','流通股本/亿股(份)','总市值/亿元','流通市值/亿元']
|
308
|
-
itemlist=['上市股票/只','总市值/亿元','流通市值/亿元']
|
309
|
-
itemliste=['Number of stocks','Total capitalization(RMB 100m)','Outstandng capitalization(RMB 100m)']
|
310
|
-
|
311
|
-
lenlist=[]
|
312
|
-
for m in itemlist:
|
313
|
-
l=hzlen(m)
|
314
|
-
lenlist=lenlist+[l]
|
315
|
-
maxlen=max(lenlist)
|
316
|
-
|
317
|
-
import pandas as pd
|
318
|
-
info=pd.DataFrame(columns=('type','item','number'))
|
319
|
-
df1s0=df1[df1['type']=='总貌']
|
320
|
-
for i in itemlist:
|
321
|
-
row=pd.Series({'type':'总貌','item':i,'number':list(df1s0[i])[0]})
|
322
|
-
try:
|
323
|
-
info=info.append(row,ignore_index=True)
|
324
|
-
except:
|
325
|
-
info=info._append(row,ignore_index=True)
|
326
|
-
|
327
|
-
df1s2=df1[df1['type']=='创业板']
|
328
|
-
for i in itemlist:
|
329
|
-
row=pd.Series({'type':'创业板','item':i,'number':list(df1s2[i])[0]})
|
330
|
-
try:
|
331
|
-
info=info.append(row,ignore_index=True)
|
332
|
-
except:
|
333
|
-
info=info._append(row,ignore_index=True)
|
334
|
-
|
335
|
-
df2=df1[df1['type'].isin(['主板A股', '主板B股', '中小板'])]
|
336
|
-
for i in itemlist:
|
337
|
-
row=pd.Series({'type':'主板','item':i,'number':df2[i].sum()})
|
338
|
-
try:
|
339
|
-
info=info.append(row,ignore_index=True)
|
340
|
-
except:
|
341
|
-
info=info._append(row,ignore_index=True)
|
342
|
-
|
343
|
-
if lang == 'Chinese':
|
344
|
-
print("\n=== 深圳证券交易所上市股票概况 ===\n")
|
345
|
-
else:
|
346
|
-
print("\n Exchange Stock Summary: Shenzhen Stock Exchange\n")
|
347
|
-
|
348
|
-
typelist=['总貌','主板','创业板']
|
349
|
-
typeliste=['Stock overall','Main board','GEM board']
|
350
|
-
|
351
|
-
for t in typelist:
|
352
|
-
subdf=info[info['type']==t]
|
353
|
-
if lang == 'Chinese':
|
354
|
-
print('*** '+t+':')
|
355
|
-
else:
|
356
|
-
pos=typelist.index(t)
|
357
|
-
te=typeliste[pos]
|
358
|
-
print('*** '+te+':')
|
359
|
-
|
360
|
-
for i in itemlist:
|
361
|
-
blanknum=maxlen-hzlen(i)
|
362
|
-
value=list(subdf[subdf['item']==i]['number'])[0]
|
363
|
-
|
364
|
-
if lang == 'Chinese':
|
365
|
-
#print(' ',i+' '*blanknum+':',end='')
|
366
|
-
print(' ',i+':',end='')
|
367
|
-
else:
|
368
|
-
pos=itemlist.index(i)
|
369
|
-
ie=itemliste[pos]
|
370
|
-
#print(' ',ie+' '*blanknum+':',end='')
|
371
|
-
print(' ',ie+':',end='')
|
372
|
-
|
373
|
-
print("{:,}".format(value))
|
374
|
-
|
375
|
-
if lang == 'Chinese':
|
376
|
-
print("\n 注:主板包括了中小板,数据来源:深交所,",today)
|
377
|
-
else:
|
378
|
-
print("\n Note: SMB board included in Main board\n Source: Shenzhen Stock Exchange,",today)
|
379
|
-
|
380
|
-
info=df
|
381
|
-
|
382
|
-
return info
|
383
|
-
|
384
|
-
if __name__=='__main__':
|
385
|
-
market_profile_china('SSE')
|
386
|
-
market_profile_china('SZSE')
|
387
|
-
|
388
|
-
#==============================================================================
|
389
|
-
#==============================================================================
|
390
|
-
#==============================================================================
|
391
|
-
# 沪深市场详细信息
|
392
|
-
#==============================================================================
|
393
|
-
if __name__=='__main__':
|
394
|
-
exchange='SZSE'
|
395
|
-
category='price'
|
396
|
-
|
397
|
-
df1sse1=market_detail_exchange_china(exchange='SSE',category='price')
|
398
|
-
df1szse1=market_detail_exchange_china(exchange='SZSE',category='price')
|
399
|
-
df1szse2=market_detail_exchange_china(exchange='SZSE',category='volume')
|
400
|
-
df1szse3=market_detail_exchange_china(exchange='SZSE',category='return')
|
401
|
-
df1szse4=market_detail_exchange_china(exchange='SZSE',category='valuation')
|
402
|
-
|
403
|
-
|
404
|
-
def market_detail_exchange_china(exchange='SSE',category='price'):
|
405
|
-
"""
|
406
|
-
功能:给出中国当前最新的三大股票交易所的更多细节,单个交易所
|
407
|
-
exchange:SSE, SZSE, BJSE
|
408
|
-
输出:构造表格型数据框df,直接利用Jupyter Notebook格式输出
|
409
|
-
数据来源:em东方财富
|
410
|
-
"""
|
411
|
-
# 检查交易所
|
412
|
-
exchange1=exchange.upper()
|
413
|
-
exchlist=["SSE","SZSE","BJSE"]
|
414
|
-
exchnamelist=["上海证券交易所","深圳证券交易所","北京证券交易所"]
|
415
|
-
if not (exchange1 in exchlist):
|
416
|
-
print(" #Error(market_detail_exchange_china): invalid exchange",exchange)
|
417
|
-
print(" Valid exchange",exchlist)
|
418
|
-
return None
|
419
|
-
pos=exchlist.index(exchange1)
|
420
|
-
exchname=exchnamelist[pos]
|
421
|
-
|
422
|
-
# 检查信息类别
|
423
|
-
category1=category.upper()
|
424
|
-
catelist=["PRICE","VOLUME","RETURN","VALUATION"]
|
425
|
-
catenamelist=["当前股价","当前成交量","近期投资回报","市值与估值"]
|
426
|
-
if not (category1 in catelist):
|
427
|
-
print(" #Error(market_detail_exchange_china): invalid category",category)
|
428
|
-
print(" Valid category",catelist)
|
429
|
-
return None
|
430
|
-
pos=catelist.index(category1)
|
431
|
-
catename=catenamelist[pos]
|
432
|
-
|
433
|
-
# 获取交易所最新细节数据
|
434
|
-
import akshare as ak
|
435
|
-
try:
|
436
|
-
if exchange1 == "SSE":
|
437
|
-
df0=ak.stock_sh_a_spot_em()
|
438
|
-
if exchange1 == "SZSE":
|
439
|
-
df0=ak.stock_sz_a_spot_em()
|
440
|
-
if exchange1 == "BJSE":
|
441
|
-
df0=ak.stock_bj_a_spot_em()
|
442
|
-
except:
|
443
|
-
print(" #Error(market_detail_exchange_china): info unavailable for",exchange,"\b, try again later")
|
444
|
-
return None
|
445
|
-
|
446
|
-
# 检查东方财富抓取限制
|
447
|
-
if len(df0) <= 100:
|
448
|
-
print(" #Warning(market_detail_exchange_china): web scraping restricted to 100 records by data source")
|
449
|
-
print(" Solution: upgrade akshare (pip install akshare --upgrade), restart Python kernel, run again")
|
450
|
-
return None
|
451
|
-
|
452
|
-
#DEBUG
|
453
|
-
#print(" Check1:",len(df0))
|
454
|
-
|
455
|
-
# 构造表格型数据框
|
456
|
-
import pandas as pd
|
457
|
-
item='项目'
|
458
|
-
df1=pd.DataFrame(columns=(item,exchname))
|
459
|
-
|
460
|
-
# 股票数量
|
461
|
-
value=df0['代码'].count()
|
462
|
-
dft=pd.DataFrame([["可交易股票数量",value]],columns=(item,exchname))
|
463
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
464
|
-
numOfStocks=value
|
465
|
-
|
466
|
-
#DEBUG
|
467
|
-
#print(" Check2:",len(df1))
|
468
|
-
|
469
|
-
|
470
|
-
if category1 == 'PRICE':
|
471
|
-
# 大分类空行
|
472
|
-
dft=pd.DataFrame([["股价价位",' ']],columns=(item,exchname))
|
473
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
474
|
-
|
475
|
-
# 昨收
|
476
|
-
value=round(df0['昨收'].mean(),2)
|
477
|
-
dft=pd.DataFrame([[" 昨日收盘价均值",value]],columns=(item,exchname))
|
478
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
479
|
-
|
480
|
-
# 今开
|
481
|
-
value=round(df0['今开'].mean(),2)
|
482
|
-
dft=pd.DataFrame([[" 今日开盘价均值",value]],columns=(item,exchname))
|
483
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
484
|
-
|
485
|
-
# 最新价
|
486
|
-
value=round(df0['最新价'].mean(),2)
|
487
|
-
dft=pd.DataFrame([[" 最新价均值",value]],columns=(item,exchname))
|
488
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
489
|
-
|
490
|
-
# 大分类空行
|
491
|
-
dft=pd.DataFrame([["股价涨跌",' ']],columns=(item,exchname))
|
492
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
493
|
-
|
494
|
-
# 涨速
|
495
|
-
value=round(df0['涨速'].mean(),4)
|
496
|
-
dft=pd.DataFrame([[" 当前涨速%",value]],columns=(item,exchname))
|
497
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
498
|
-
|
499
|
-
# 5分钟涨跌
|
500
|
-
value=round(df0['5分钟涨跌'].mean(),4)
|
501
|
-
dft=pd.DataFrame([[" 最近5分钟涨跌%",value]],columns=(item,exchname))
|
502
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
503
|
-
|
504
|
-
# 大分类空行
|
505
|
-
dft=pd.DataFrame([["今日与昨日相比",' ']],columns=(item,exchname))
|
506
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
507
|
-
|
508
|
-
# 振幅
|
509
|
-
value=round(df0['振幅'].mean(),4)
|
510
|
-
dft=pd.DataFrame([[" 振幅均值%",value]],columns=(item,exchname))
|
511
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
512
|
-
|
513
|
-
# 涨跌幅
|
514
|
-
value=round(df0['涨跌幅'].mean(),4)
|
515
|
-
dft=pd.DataFrame([[" 涨跌幅均值%",value]],columns=(item,exchname))
|
516
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
517
|
-
|
518
|
-
# 涨跌额
|
519
|
-
value=round(df0['涨跌额'].mean(),2)
|
520
|
-
dft=pd.DataFrame([[" 涨跌额均值(元)",value]],columns=(item,exchname))
|
521
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
522
|
-
|
523
|
-
#DEBUG
|
524
|
-
#print(" Check3:",len(df1))
|
525
|
-
|
526
|
-
|
527
|
-
if category1 == 'VOLUME':
|
528
|
-
# 大分类空行
|
529
|
-
dft=pd.DataFrame([["今日个股成交行情",' ']],columns=(item,exchname))
|
530
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
531
|
-
|
532
|
-
# 成交量
|
533
|
-
value=round(df0['成交量'].mean()/10000,2)
|
534
|
-
dft=pd.DataFrame([[" 成交量均值(万手)",value]],columns=(item,exchname))
|
535
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
536
|
-
|
537
|
-
# 成交额
|
538
|
-
value=round(df0['成交额'].mean()/100000000,2)
|
539
|
-
dft=pd.DataFrame([[" 成交额均值(亿元)",value]],columns=(item,exchname))
|
540
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
541
|
-
|
542
|
-
# 换手率
|
543
|
-
value=round(df0['换手率'].mean(),2)
|
544
|
-
dft=pd.DataFrame([[" 换手率均值%",value]],columns=(item,exchname))
|
545
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
546
|
-
|
547
|
-
# 大分类空行
|
548
|
-
dft=pd.DataFrame([["今日与之前相比",' ']],columns=(item,exchname))
|
549
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
550
|
-
|
551
|
-
# 量比
|
552
|
-
value=round(df0['量比'].mean(),2)
|
553
|
-
dft=pd.DataFrame([[" 量比均值(倍数)",value]],columns=(item,exchname))
|
554
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
555
|
-
|
556
|
-
#DEBUG
|
557
|
-
#print(" Check4:",len(df1))
|
558
|
-
|
559
|
-
if category1 == 'RETURN':
|
560
|
-
# 大分类空行
|
561
|
-
dft=pd.DataFrame([["投资回报:近一季度",' ']],columns=(item,exchname))
|
562
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
563
|
-
|
564
|
-
# 60日涨跌幅
|
565
|
-
value=round(df0['60日涨跌幅'].mean(),2)
|
566
|
-
dft=pd.DataFrame([[" MRQ涨跌幅均值%",value]],columns=(item,exchname))
|
567
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
568
|
-
|
569
|
-
value=round(df0['60日涨跌幅'].median(),2)
|
570
|
-
dft=pd.DataFrame([[" MRQ涨跌幅中位数%",value]],columns=(item,exchname))
|
571
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
572
|
-
|
573
|
-
value=round(df0['60日涨跌幅'].std(),2)
|
574
|
-
dft=pd.DataFrame([[" MRQ涨跌幅标准差%",value]],columns=(item,exchname))
|
575
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
576
|
-
|
577
|
-
df0t=df0[df0['60日涨跌幅']>0]
|
578
|
-
value=df0t['60日涨跌幅'].count()
|
579
|
-
dft=pd.DataFrame([[" MRQ上涨股票占比%",round(value / numOfStocks *100,2)]],columns=(item,exchname))
|
580
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
581
|
-
|
582
|
-
# 大分类空行
|
583
|
-
dft=pd.DataFrame([["投资回报:年初至今",' ']],columns=(item,exchname))
|
584
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
585
|
-
|
586
|
-
# 年初至今涨跌幅
|
587
|
-
value=round(df0['涨跌幅'].mean(),2)
|
588
|
-
dft=pd.DataFrame([[" YTD涨跌幅均值%",value]],columns=(item,exchname))
|
589
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
590
|
-
|
591
|
-
value=round(df0['年初至今涨跌幅'].median(),2)
|
592
|
-
dft=pd.DataFrame([[" YTD涨跌幅中位数%",value]],columns=(item,exchname))
|
593
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
594
|
-
|
595
|
-
value=round(df0['年初至今涨跌幅'].std(),2)
|
596
|
-
dft=pd.DataFrame([[" YTD涨跌幅标准差%",value]],columns=(item,exchname))
|
597
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
598
|
-
|
599
|
-
df0t=df0[df0['年初至今涨跌幅']>0]
|
600
|
-
value=df0t['年初至今涨跌幅'].count()
|
601
|
-
dft=pd.DataFrame([[" YTD上涨股票占比%",round(value / numOfStocks *100,2)]],columns=(item,exchname))
|
602
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
603
|
-
|
604
|
-
#DEBUG
|
605
|
-
#print(" Check5:",len(df1))
|
606
|
-
|
607
|
-
|
608
|
-
if category1 == 'VALUATION':
|
609
|
-
# 大分类空行
|
610
|
-
dft=pd.DataFrame([["总市值",' ']],columns=(item,exchname))
|
611
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
612
|
-
|
613
|
-
# 总市值
|
614
|
-
value=round(df0['总市值'].sum() / 1000000000000,2)
|
615
|
-
dft=pd.DataFrame([[" 市场总市值(万亿元)",value]],columns=(item,exchname))
|
616
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
617
|
-
totalMarketValue=value
|
618
|
-
|
619
|
-
value=round(df0['总市值'].mean() / 1000000000,2)
|
620
|
-
mean_val=value
|
621
|
-
dft=pd.DataFrame([[" 个股总市值均值(十亿元)",value]],columns=(item,exchname))
|
622
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
623
|
-
|
624
|
-
value=round(df0['总市值'].median() / 1000000000,2)
|
625
|
-
dft=pd.DataFrame([[" 个股总市值中位数(十亿元)",value]],columns=(item,exchname))
|
626
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
627
|
-
|
628
|
-
#value=round(df0['总市值'].std() / 1000000000,2)
|
629
|
-
std_val=round(df0['总市值'].std() / 1000000000,2)
|
630
|
-
value=round(std_val / mean_val,2)
|
631
|
-
dft=pd.DataFrame([[" 个股总市值标准差/均值",value]],columns=(item,exchname))
|
632
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
633
|
-
|
634
|
-
# 大分类空行
|
635
|
-
dft=pd.DataFrame([["流通市值",' ']],columns=(item,exchname))
|
636
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
637
|
-
|
638
|
-
# 流通市值
|
639
|
-
value=round(df0['流通市值'].sum() / 1000000000000,2)
|
640
|
-
dft=pd.DataFrame([[" 市场流通市值(万亿元)",value]],columns=(item,exchname))
|
641
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
642
|
-
outstandingMarketValue=value
|
643
|
-
|
644
|
-
# 流通比率
|
645
|
-
value=round(outstandingMarketValue / totalMarketValue * 100,2)
|
646
|
-
dft=pd.DataFrame([[" 市场流通比率%",value]],columns=(item,exchname))
|
647
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
648
|
-
|
649
|
-
value=round(df0['流通市值'].mean() / 1000000000,2)
|
650
|
-
mean_oval=value
|
651
|
-
dft=pd.DataFrame([[" 个股流通市值均值(十亿元)",value]],columns=(item,exchname))
|
652
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
653
|
-
|
654
|
-
value=round(df0['流通市值'].median() / 1000000000,2)
|
655
|
-
dft=pd.DataFrame([[" 个股流通市值中位数(十亿元)",value]],columns=(item,exchname))
|
656
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
657
|
-
|
658
|
-
std_oval=round(df0['流通市值'].std() / 1000000000,2)
|
659
|
-
value=round(std_oval / mean_oval,2)
|
660
|
-
dft=pd.DataFrame([[" 个股流通市值标准差/均值",value]],columns=(item,exchname))
|
661
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
662
|
-
|
663
|
-
# 大分类空行
|
664
|
-
dft=pd.DataFrame([["估值状况:市盈率",' ']],columns=(item,exchname))
|
665
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
666
|
-
|
667
|
-
# 市盈率-动态
|
668
|
-
value=round(df0['市盈率-动态'].mean(),2)
|
669
|
-
mean_pe=value
|
670
|
-
dft=pd.DataFrame([[" 个股市盈率均值",value]],columns=(item,exchname))
|
671
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
672
|
-
|
673
|
-
value=round(df0['市盈率-动态'].median(),2)
|
674
|
-
dft=pd.DataFrame([[" 个股市盈率中位数",value]],columns=(item,exchname))
|
675
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
676
|
-
|
677
|
-
std_pe=round(df0['市盈率-动态'].std(),2)
|
678
|
-
value=round(std_pe/mean_pe,2)
|
679
|
-
dft=pd.DataFrame([[" 个股市盈率标准差/均值",value]],columns=(item,exchname))
|
680
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
681
|
-
|
682
|
-
# 大分类空行
|
683
|
-
dft=pd.DataFrame([["估值状况:市净率",' ']],columns=(item,exchname))
|
684
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
685
|
-
|
686
|
-
# 市净率
|
687
|
-
value=round(df0['市净率'].mean(),2)
|
688
|
-
mean_pb=value
|
689
|
-
dft=pd.DataFrame([[" 个股市净率均值",value]],columns=(item,exchname))
|
690
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
691
|
-
|
692
|
-
value=round(df0['市净率'].median(),2)
|
693
|
-
dft=pd.DataFrame([[" 个股市净率中位数",value]],columns=(item,exchname))
|
694
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
695
|
-
|
696
|
-
std_pb=round(df0['市净率'].std(),2)
|
697
|
-
value=round(std_pb/mean_pb,2)
|
698
|
-
dft=pd.DataFrame([[" 个股市净率标准差/均值",value]],columns=(item,exchname))
|
699
|
-
df1=pd.concat([df1,dft],ignore_index=True)
|
700
|
-
|
701
|
-
#DEBUG
|
702
|
-
#print(" Check6:",len(df1))
|
703
|
-
|
704
|
-
df1.set_index(item,inplace=True)
|
705
|
-
|
706
|
-
#DEBUG
|
707
|
-
#print(" Check7:",len(df1))
|
708
|
-
|
709
|
-
return df1
|
710
|
-
|
711
|
-
|
712
|
-
#==============================================================================
|
713
|
-
#==============================================================================
|
714
|
-
if __name__=='__main__':
|
715
|
-
category='price'
|
716
|
-
category='valuation'
|
717
|
-
|
718
|
-
df1=market_detail_china(category='price')
|
719
|
-
df1=market_detail_china(category='price')
|
720
|
-
|
721
|
-
def market_detail_china(category='price',prettytab=True,plttab=False, \
|
722
|
-
colWidth=0.3,tabScale=2, \
|
723
|
-
#figsize=(10,6), \
|
724
|
-
figsize=(12.8,6.4), \
|
725
|
-
fontsize=13,cellLoc='center'):
|
726
|
-
"""
|
727
|
-
功能:给出中国当前最新的三大股票交易所的更多细节,合成
|
728
|
-
输出:构造表格型数据框df,直接利用Jupyter Notebook格式输出
|
729
|
-
数据来源:em东方财富
|
730
|
-
"""
|
731
|
-
|
732
|
-
# 检查信息类别
|
733
|
-
category1=category.upper()
|
734
|
-
catelist=["PRICE","VOLUME","RETURN","VALUATION"]
|
735
|
-
catenamelist=["当前股价","当前成交量","近期投资回报","市值与估值"]
|
736
|
-
if not (category1 in catelist):
|
737
|
-
print(" #Error(market_detail_exchange_china): invalid category",category)
|
738
|
-
print(" Valid category",catelist)
|
739
|
-
return None
|
740
|
-
|
741
|
-
# 合并三大交易所
|
742
|
-
import pandas as pd
|
743
|
-
df=pd.DataFrame()
|
744
|
-
exchlist=["SSE","SZSE","BJSE"]
|
745
|
-
for e in exchlist:
|
746
|
-
dft=market_detail_exchange_china(exchange=e,category=category)
|
747
|
-
if dft is None:
|
748
|
-
print(" #Warning(market_detail_china): info inaccessible for",e,"\b, try later")
|
749
|
-
#return None
|
750
|
-
continue
|
751
|
-
if len(dft)==0:
|
752
|
-
print(" #Warning(market_detail_china): zero info found for",e,"\b, try later")
|
753
|
-
continue
|
754
|
-
|
755
|
-
if len(df)==0:
|
756
|
-
df=dft
|
757
|
-
else:
|
758
|
-
df=pd.merge(df,dft,left_index=True,right_index=True)
|
759
|
-
|
760
|
-
if len(df)==0:
|
761
|
-
print(" #Warning(market_detail_china): zero info found for",exchlist,"\b, try later")
|
762
|
-
return None
|
763
|
-
|
764
|
-
# 处理索引字段
|
765
|
-
newcollist=['项目']+list(df)
|
766
|
-
df['项目']=df.index
|
767
|
-
df=df[newcollist]
|
768
|
-
|
769
|
-
# 将空缺值替换为空格
|
770
|
-
df.fillna('',inplace=True)
|
771
|
-
|
772
|
-
import datetime as dt
|
773
|
-
nowstr0=str(dt.datetime.now())
|
774
|
-
nowstr=nowstr0[:19]
|
775
|
-
|
776
|
-
# 前置空格个数
|
777
|
-
heading=' '*1
|
778
|
-
|
779
|
-
# 表格输出方式设置
|
780
|
-
plttab = not prettytab
|
781
|
-
|
782
|
-
if category1=='PRICE':
|
783
|
-
titletxt="中国三大股票交易所横向对比:股价与涨跌"
|
784
|
-
if prettytab:
|
785
|
-
market_detail_china2table(df,titletxt=titletxt)
|
786
|
-
if plttab:
|
787
|
-
pandas2plttable(df,titletxt=titletxt,colWidth=colWidth,tabScale=tabScale, \
|
788
|
-
figsize=figsize,fontsize=fontsize,cellLoc=cellLoc)
|
789
|
-
|
790
|
-
print(heading,"信息来源:东方财富,","统计时间:",nowstr)
|
791
|
-
print(heading,"注释:")
|
792
|
-
print(heading,"☆可交易股票数量:将随着股票停复牌情况变化")
|
793
|
-
print(heading,"☆昨日指的是上一个交易日")
|
794
|
-
print(heading,"☆涨速:平均每分钟股价变化率,表示股价变化速度")
|
795
|
-
print(heading,"☆5分钟涨跌:最新5分钟内股价的涨跌幅度")
|
796
|
-
print(heading,"☆振幅:最高最低价差绝对值/昨收,表示股价变化活跃程度")
|
797
|
-
print(heading,"☆涨跌幅:(最新价-昨收)/昨收,表示相对昨日的变化程度")
|
798
|
-
print(heading,"☆涨跌额:最新价-昨收,表示相对昨日的变化金额")
|
799
|
-
|
800
|
-
print(heading,"☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同")
|
801
|
-
print(heading,"☆若在非开市时间或开市前后短期内统计,部分结果数据可能出现空缺")
|
802
|
-
|
803
|
-
if category1=='VOLUME':
|
804
|
-
titletxt="中国三大股票交易所横向对比:成交状况"
|
805
|
-
if prettytab:
|
806
|
-
market_detail_china2table(df,titletxt=titletxt)
|
807
|
-
if plttab:
|
808
|
-
pandas2plttable(df,titletxt=titletxt,colWidth=colWidth,tabScale=tabScale, \
|
809
|
-
figsize=figsize,fontsize=fontsize,cellLoc=cellLoc)
|
810
|
-
|
811
|
-
print(heading,"信息来源:东方财富,","统计时间:",nowstr)
|
812
|
-
print(heading,"注:")
|
813
|
-
print(heading,"☆可交易股票数量:将随着股票停复牌情况变化")
|
814
|
-
print(heading,"☆成交量:当前成交股数,表示交易活跃度")
|
815
|
-
print(heading,"☆成交额:当前开市后的累计成交金额")
|
816
|
-
print(heading,"☆换手率:成交量/流通股数,表示成交量占比")
|
817
|
-
print(heading,"☆量比:当前平均每分钟成交量与过去5个交易日均值之比,表示当前成交量的变化")
|
818
|
-
|
819
|
-
print(heading,"☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同")
|
820
|
-
print(heading,"☆若在非开市时间或开市前后短期内统计,部分结果数据可能出现空缺")
|
821
|
-
|
822
|
-
if category1=='RETURN':
|
823
|
-
titletxt="中国三大股票交易所横向对比:投资回报"
|
824
|
-
if prettytab:
|
825
|
-
market_detail_china2table(df,titletxt=titletxt)
|
826
|
-
if plttab:
|
827
|
-
pandas2plttable(df,titletxt=titletxt,colWidth=colWidth,tabScale=tabScale, \
|
828
|
-
figsize=figsize,fontsize=fontsize,cellLoc=cellLoc)
|
829
|
-
|
830
|
-
print(heading,"信息来源:东方财富,","统计时间:",nowstr)
|
831
|
-
print(heading,"注:")
|
832
|
-
print(heading,"☆可交易股票数量:将随着股票停复牌情况变化")
|
833
|
-
print(heading,"☆MRQ:最近一个季度的滚动数据")
|
834
|
-
print(heading,"☆YTD:今年以来的累计情况")
|
835
|
-
|
836
|
-
print(heading,"☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同")
|
837
|
-
print(heading,"☆若在非开市时间或开市前后短期内统计,部分结果数据可能出现空缺")
|
838
|
-
|
839
|
-
if category1=='VALUATION':
|
840
|
-
titletxt="中国三大股票交易所横向对比:市值与估值"
|
841
|
-
if prettytab:
|
842
|
-
market_detail_china2table(df,titletxt=titletxt)
|
843
|
-
if plttab:
|
844
|
-
pandas2plttable(df,titletxt=titletxt,colWidth=colWidth,tabScale=tabScale, \
|
845
|
-
figsize=figsize,fontsize=fontsize,cellLoc=cellLoc)
|
846
|
-
|
847
|
-
print(heading,"信息来源:东方财富,","统计时间:",nowstr)
|
848
|
-
print(heading,"注:")
|
849
|
-
print(heading,"☆可交易股票数量:将随着股票停复牌情况变化")
|
850
|
-
print(heading,"☆市盈率:这里为动态市盈率,即市盈率TTM,过去12个月的连续变化")
|
851
|
-
print(heading,"☆市净率:这里为静态市净率")
|
852
|
-
|
853
|
-
print(heading,"☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同")
|
854
|
-
print(heading,"☆若在非开市时间或开市前后短期内统计,部分结果数据可能出现空缺")
|
855
|
-
#print(heading,"☆标准差/均值=标准差(数值)/均值,提升可比性")
|
856
|
-
|
857
|
-
return df
|
858
|
-
|
859
|
-
#==============================================================================
|
860
|
-
if __name__=='__main__':
|
861
|
-
titletxt="This is a title"
|
862
|
-
leftColAlign='l'
|
863
|
-
otherColAlign='c'
|
864
|
-
tabborder=False
|
865
|
-
|
866
|
-
|
867
|
-
def market_detail_china2table(df,titletxt,firstColSpecial=True,leftColAlign='l',otherColAlign='c',tabborder=False):
|
868
|
-
"""
|
869
|
-
功能:将一个df转换为prettytable格式,打印,在Jupyter Notebook下整齐
|
870
|
-
专门为函数market_detail_china制作,不包括索引字段
|
871
|
-
"""
|
872
|
-
#列名列表
|
873
|
-
col=list(df)
|
874
|
-
|
875
|
-
# 第一列长度取齐处理
|
876
|
-
if firstColSpecial:
|
877
|
-
#第一列的最长长度
|
878
|
-
firstcol=list(df[col[0]])
|
879
|
-
maxlen=0
|
880
|
-
for f in firstcol:
|
881
|
-
flen=hzlen(f)
|
882
|
-
if flen > maxlen:
|
883
|
-
maxlen=flen
|
884
|
-
|
885
|
-
#将第一列内容的长度取齐
|
886
|
-
df[col[0]]=df[col[0]].apply(lambda x:equalwidth(x,maxlen=maxlen,extchar=' ',endchar=' '))
|
887
|
-
|
888
|
-
collist=list(df)
|
889
|
-
|
890
|
-
from prettytable import PrettyTable
|
891
|
-
import sys
|
892
|
-
# 传入的字段名相当于表头
|
893
|
-
tb = PrettyTable(collist, encoding=sys.stdout.encoding)
|
894
|
-
|
895
|
-
for i in range(0, len(df)):
|
896
|
-
tb.add_row(list(df.iloc[i]))
|
897
|
-
|
898
|
-
firstcol=collist[0]
|
899
|
-
restcols=collist[1:]
|
900
|
-
tb.align[firstcol]=leftColAlign
|
901
|
-
for e in restcols:
|
902
|
-
tb.align[e]=otherColAlign
|
903
|
-
|
904
|
-
# 边框设置:使用dir(tb)查看属性
|
905
|
-
import prettytable as pt
|
906
|
-
if not tabborder:
|
907
|
-
# 无边框
|
908
|
-
#tb.set_style(pt.PLAIN_COLUMNS)
|
909
|
-
# 空一行,分离标题行与表体
|
910
|
-
#print()
|
911
|
-
tb.junction_char=' '
|
912
|
-
tb.horizontal_char=' '
|
913
|
-
tb.vertical_char=' '
|
914
|
-
|
915
|
-
# 设置标题
|
916
|
-
tb.title=titletxt
|
917
|
-
|
918
|
-
print(tb)
|
919
|
-
|
920
|
-
return
|
921
|
-
|
922
|
-
#==============================================================================
|
923
|
-
#==============================================================================
|
924
|
-
if __name__=='__main__':
|
925
|
-
category='price'
|
926
|
-
category='volume'
|
927
|
-
category='return'
|
928
|
-
category='valuation'
|
929
|
-
|
930
|
-
facecolor='papayawhip'
|
931
|
-
decimals=2
|
932
|
-
font_size='16px'
|
933
|
-
|
934
|
-
df1=market_detail_china(category='price')
|
935
|
-
df1=market_detail_china(category='price')
|
936
|
-
|
937
|
-
def market_detail_china2(category='price',
|
938
|
-
facecolor='papayawhip',
|
939
|
-
decimals=2,
|
940
|
-
font_size='20px'):
|
941
|
-
"""
|
942
|
-
功能:给出中国当前最新的三大股票交易所的更多细节,合成
|
943
|
-
输出:构造表格型数据框df,利用CSS格式输出
|
944
|
-
数据来源:em东方财富
|
945
|
-
"""
|
946
|
-
#确定表格字体大小
|
947
|
-
titile_font_size=font_size
|
948
|
-
heading_font_size=data_font_size=str(int(font_size.replace('px',''))-2)+'px'
|
949
|
-
|
950
|
-
# 检查信息类别
|
951
|
-
category1=category.upper()
|
952
|
-
catelist=["PRICE","VOLUME","RETURN","VALUATION"]
|
953
|
-
catenamelist=["当前股价","当前成交量","近期投资回报","市值与估值"]
|
954
|
-
if not (category1 in catelist):
|
955
|
-
print(" #Error(market_detail_china2): invalid category",category)
|
956
|
-
print(" Valid category",catelist)
|
957
|
-
return None
|
958
|
-
|
959
|
-
# 合并三大交易所
|
960
|
-
import pandas as pd
|
961
|
-
df=pd.DataFrame()
|
962
|
-
exchlist=["SSE","SZSE","BJSE"]
|
963
|
-
for e in exchlist:
|
964
|
-
dft=market_detail_exchange_china(exchange=e,category=category)
|
965
|
-
if dft is None:
|
966
|
-
print(" #Warning(market_detail_china): info inaccessible for",e,"\b, try later")
|
967
|
-
#return None
|
968
|
-
continue
|
969
|
-
if len(dft)==0:
|
970
|
-
print(" #Warning(market_detail_china): zero info found for",e,"\b, try later")
|
971
|
-
continue
|
972
|
-
|
973
|
-
if len(df)==0:
|
974
|
-
df=dft
|
975
|
-
else:
|
976
|
-
df=pd.merge(df,dft,left_index=True,right_index=True)
|
977
|
-
|
978
|
-
if len(df)==0:
|
979
|
-
print(" #Warning(market_detail_china2): zero info found for",exchlist,"\b, try later")
|
980
|
-
return None
|
981
|
-
|
982
|
-
# 处理索引字段
|
983
|
-
newcollist=['项目']+list(df)
|
984
|
-
df['项目']=df.index
|
985
|
-
df=df[newcollist]
|
986
|
-
|
987
|
-
# 将空缺值替换为空格
|
988
|
-
df.fillna('',inplace=True)
|
989
|
-
|
990
|
-
import datetime as dt
|
991
|
-
nowstr0=str(dt.datetime.now())
|
992
|
-
nowstr=nowstr0[:19]
|
993
|
-
|
994
|
-
#检查语言环境
|
995
|
-
lang=check_language()
|
996
|
-
|
997
|
-
# 前置空格个数
|
998
|
-
heading=' '*1
|
999
|
-
if lang == "English":
|
1000
|
-
df.rename(columns={'项目':'Item','上海证券交易所':'Shanghai SE','深圳证券交易所':'Shenzhen SE','北京证券交易所':'Beijing SE'},inplace=True)
|
1001
|
-
|
1002
|
-
if category1=='PRICE':
|
1003
|
-
titletxt=text_lang("中国三大股票交易所横向对比:股价与涨跌","China Stock Exchanges: Differences in Price")
|
1004
|
-
|
1005
|
-
ft0=heading+text_lang("信息来源:东方财富,统计时间:","Data source: EM, updated ")+nowstr+"\n"
|
1006
|
-
ft1=heading+text_lang("注释:\n","Notes:\n")
|
1007
|
-
ft2=heading+text_lang("☆可交易股票数量:将随着股票停复牌情况变化\n","*Tradeable stocks: vary with suspension/resumption\n")
|
1008
|
-
ft3=heading+text_lang("☆昨日指的是上一个交易日\n","*Prev: refers to previous trading day\n")
|
1009
|
-
ft4=heading+text_lang("☆涨速:平均每分钟股价变化率,表示股价变化速度\n","*Changing speed(涨速): rate of changes per minute\n")
|
1010
|
-
ft5=heading+text_lang("☆5分钟涨跌:最新5分钟内股价的涨跌幅度\n","*5 min up-down(5分钟涨跌): changes recent 5 minutes\n")
|
1011
|
-
ft6=heading+text_lang("☆振幅:最高最低价差绝对值/昨收,表示股价变化活跃程度\n","*Amplitude(振幅): (High - Low)/Prev Close\n")
|
1012
|
-
ft7=heading+text_lang("☆涨跌幅:(最新价-昨收)/昨收,表示相对昨日的变化程度\n","*Change%(涨跌幅): (Current Price/Prev Close) - 1\n")
|
1013
|
-
ft8=heading+text_lang("☆涨跌额:最新价-昨收,表示相对昨日的变化金额\n","*Change(涨跌额): Current Price - Prev Close\n")
|
1014
|
-
|
1015
|
-
ft9=heading+text_lang("☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同\n","*Based on real-time data, vary with time\n")
|
1016
|
-
ft10=heading+text_lang("☆若在非交易日或开市前后短期内统计,数据可能出现空缺\n","*Missing data may happen around non-trading time\n")
|
1017
|
-
|
1018
|
-
footnote=ft0+ft1+ft2+ft3+ft4+ft5+ft6+ft7+ft8+ft9+ft10
|
1019
|
-
|
1020
|
-
if lang == "English":
|
1021
|
-
itme_list=['Tradeable stocks',
|
1022
|
-
'Stock Price Level',
|
1023
|
-
'.....Prev close mean',
|
1024
|
-
'.....Today open mean',
|
1025
|
-
'.....Current price mean',
|
1026
|
-
'Stock Price Up-down',
|
1027
|
-
'.....Current change%',
|
1028
|
-
'.....Last 5 min change%',
|
1029
|
-
'Today vs. Prev',
|
1030
|
-
'.....Amplitude%',
|
1031
|
-
'.....Change% mean',
|
1032
|
-
'.....Change mean(RMB)']
|
1033
|
-
df['Item']=itme_list
|
1034
|
-
|
1035
|
-
df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
1036
|
-
first_col_align='left',second_col_align='right', \
|
1037
|
-
last_col_align='right',other_col_align='right', \
|
1038
|
-
titile_font_size=titile_font_size, \
|
1039
|
-
heading_font_size=heading_font_size, \
|
1040
|
-
data_font_size=data_font_size)
|
1041
|
-
|
1042
|
-
|
1043
|
-
if category1=='VOLUME':
|
1044
|
-
titletxt=text_lang("中国三大股票交易所横向对比:成交状况","China Stock Exchanges: Differences in Volume")
|
1045
|
-
|
1046
|
-
ft0=heading+text_lang("信息来源:东方财富,统计时间:","Data source: EM, updated ")+nowstr+"\n"
|
1047
|
-
ft1=heading+text_lang("注:\n","Notes:\n")
|
1048
|
-
ft2=heading+text_lang("☆可交易股票数量:将随着股票停复牌情况变化\n","*Tradeable stocks: vary with suspension/resumption\n")
|
1049
|
-
ft3=heading+text_lang("☆成交量:当前成交股数,表示交易活跃度\n","*Volume(成交量): traded number of shares since open today\n")
|
1050
|
-
ft4=heading+text_lang("☆成交额:当前开市后的累计成交金额\n","*Amount(成交额): traded dollar amount since open today\n")
|
1051
|
-
ft5=heading+text_lang("☆换手率:成交量/流通股数,表示成交量占比\n","*Turnover rate(换手率): volume/outstanding shares\n")
|
1052
|
-
ft6=heading+text_lang("☆量比:当前每分钟成交量/过去5个交易日均值,表示成交量变化\n","*Volume ratio(量比): current turnover per min/prev 5 mean\n")
|
1053
|
-
|
1054
|
-
ft9=heading+text_lang("☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同\n","*Based on real-time data, vary with time\n")
|
1055
|
-
ft10=heading+text_lang("☆若在非开市时间或开市前后短期内统计,数据可能出现空缺\n","*Missing data may happen around non-trading time\n")
|
1056
|
-
|
1057
|
-
footnote=ft0+ft1+ft2+ft3+ft4+ft5+ft6 + ft9+ft10
|
1058
|
-
|
1059
|
-
if lang == "English":
|
1060
|
-
itme_list=['Tradeable stocks',
|
1061
|
-
'Volume Level Today',
|
1062
|
-
'.....Volume mean(million)',
|
1063
|
-
'.....Amount mean(100 millions)',
|
1064
|
-
'.....Turnover rate mean %',
|
1065
|
-
'Today vs. Prev',
|
1066
|
-
'.....Volume ratio(times)']
|
1067
|
-
df['Item']=itme_list
|
1068
|
-
|
1069
|
-
df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
1070
|
-
first_col_align='left',second_col_align='right', \
|
1071
|
-
last_col_align='right',other_col_align='right', \
|
1072
|
-
titile_font_size=titile_font_size, \
|
1073
|
-
heading_font_size=heading_font_size, \
|
1074
|
-
data_font_size=data_font_size)
|
1075
|
-
|
1076
|
-
|
1077
|
-
if category1=='RETURN':
|
1078
|
-
titletxt=text_lang("中国三大股票交易所横向对比:投资回报","China Stock Exchanges: Differences in Return")
|
1079
|
-
|
1080
|
-
ft0=heading+text_lang("信息来源:东方财富,统计时间:","Data source: EM, updated ")+nowstr+"\n"
|
1081
|
-
ft1=heading+text_lang("注:\n","Notes:\n")
|
1082
|
-
ft2=heading+text_lang("☆可交易股票数量:将随着股票停复牌情况变化\n","*Tradeable stocks: vary with suspension/resumption\n")
|
1083
|
-
ft3=heading+text_lang("☆MRQ:最近一个季度的滚动数据\n","*MRQ: most recent quarter\n")
|
1084
|
-
ft4=heading+text_lang("☆YTD:今年以来的累计情况\n","*YTD: year to today\n")
|
1085
|
-
|
1086
|
-
ft9=heading+text_lang("☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同\n","*Based on real-time data, vary with time\n")
|
1087
|
-
ft10=heading+text_lang("☆若在非开市时间或开市前后短期内统计,数据可能出现空缺\n","*Missing data may happen around non-trading time\n")
|
1088
|
-
|
1089
|
-
footnote=ft0+ft1+ft2+ft3+ft4 + ft9+ft10
|
1090
|
-
|
1091
|
-
if lang == "English":
|
1092
|
-
itme_list=['Tradeable stocks',
|
1093
|
-
'MRQ Investment Return',
|
1094
|
-
'.....MRQ change% mean',
|
1095
|
-
'.....MRQ change% median',
|
1096
|
-
'.....MRQ change% std',
|
1097
|
-
'.....MRQ rising stock%',
|
1098
|
-
'YTD Investment Return',
|
1099
|
-
'.....YTD change% mean',
|
1100
|
-
'.....YTD change% median',
|
1101
|
-
'.....YTD change% std',
|
1102
|
-
'.....YTD rising stock%']
|
1103
|
-
df['Item']=itme_list
|
1104
|
-
|
1105
|
-
df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
1106
|
-
first_col_align='left',second_col_align='right', \
|
1107
|
-
last_col_align='right',other_col_align='right', \
|
1108
|
-
titile_font_size=titile_font_size, \
|
1109
|
-
heading_font_size=heading_font_size, \
|
1110
|
-
data_font_size=data_font_size)
|
1111
|
-
|
1112
|
-
|
1113
|
-
if category1=='VALUATION':
|
1114
|
-
titletxt=text_lang("中国三大股票交易所横向对比:市值与估值","China Stock Exchanges: Differences in Valuation")
|
1115
|
-
|
1116
|
-
ft0=heading+text_lang("信息来源:东方财富,统计时间:","Data source: EM, updated ")+nowstr+"\n"
|
1117
|
-
ft1=heading+text_lang("注:\n","Notes:\n")
|
1118
|
-
ft2=heading+text_lang("☆可交易股票数量:将随着股票停复牌情况变化\n","*Tradeable stocks: vary with suspension/resumption\n")
|
1119
|
-
ft3=heading+text_lang("☆市盈率:这里为动态市盈率,即市盈率TTM,过去12个月的连续变化\n","*P/E: price/earnings per share, TTM\n")
|
1120
|
-
ft4=heading+text_lang("☆市净率:这里为静态市净率\n","*P/B: price/net asset per share, stationary\n")
|
1121
|
-
ft5=heading+text_lang("☆标准差/均值=标准差(数值)/均值,提升可比性\n","*std/mean: degree of variation, better comparability\n")
|
1122
|
-
|
1123
|
-
ft9=heading+text_lang("☆使用实时数据,不同日期/每天不同时刻统计的结果可能不同\n","*Based on real-time data, vary with time\n")
|
1124
|
-
ft10=heading+text_lang("☆若在非开市时间或开市前后短期内统计,数据可能出现空缺\n","*Missing data may happen around non-trading time\n")
|
1125
|
-
|
1126
|
-
footnote=ft0+ft1+ft2+ft3+ft4+ft5 + ft9+ft10
|
1127
|
-
|
1128
|
-
if lang == "English":
|
1129
|
-
itme_list=['Tradeable stocks',
|
1130
|
-
'Total Market Cap (TMC)',
|
1131
|
-
'.....Whole Market TMC(trillion)',
|
1132
|
-
'.....Stock TMC mean(billion)',
|
1133
|
-
'.....Stock TMC median(billion)',
|
1134
|
-
'.....Stock TMC std/mean',
|
1135
|
-
'Outstanding Market Cap (OMC)',
|
1136
|
-
'.....Whole Market OMC(trillion)',
|
1137
|
-
'.....Whole Market outstanding %',
|
1138
|
-
'.....Stock OMC mean(billion)',
|
1139
|
-
'.....Stock OMC median(billion)',
|
1140
|
-
'.....Stock OMC std/mean',
|
1141
|
-
'Valuation: P/E',
|
1142
|
-
'.....Stock P/E mean',
|
1143
|
-
'.....Stock P/E median',
|
1144
|
-
'.....Stock P/E std/mean',
|
1145
|
-
'Valuation: P/B',
|
1146
|
-
'.....Stock P/B mean',
|
1147
|
-
'.....Stock P/B median',
|
1148
|
-
'.....Stock P/B std/mean']
|
1149
|
-
|
1150
|
-
df['Item']=itme_list
|
1151
|
-
|
1152
|
-
|
1153
|
-
df_display_CSS(df,titletxt=titletxt,footnote=footnote,facecolor=facecolor, \
|
1154
|
-
first_col_align='left',second_col_align='right', \
|
1155
|
-
last_col_align='right',other_col_align='right', \
|
1156
|
-
titile_font_size=titile_font_size, \
|
1157
|
-
heading_font_size=heading_font_size, \
|
1158
|
-
data_font_size=data_font_size)
|
1159
|
-
|
1160
|
-
|
1161
|
-
return df
|
1162
|
-
|
1163
|
-
#==============================================================================
|
1164
|
-
|
1165
|
-
#==============================================================================
|
1166
|
-
#==============================================================================
|
1167
|
-
#==============================================================================
|
1168
|
-
#==============================================================================
|