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.
Files changed (218) hide show
  1. siat/__init__.py +0 -0
  2. siat/allin.py +0 -0
  3. siat/assets_liquidity.py +0 -0
  4. siat/beta_adjustment.py +0 -0
  5. siat/beta_adjustment_china.py +0 -0
  6. siat/blockchain.py +0 -0
  7. siat/bond.py +0 -0
  8. siat/bond_base.py +0 -0
  9. siat/bond_china.py +0 -0
  10. siat/bond_zh_sina.py +0 -0
  11. siat/capm_beta.py +0 -0
  12. siat/capm_beta2.py +0 -0
  13. siat/compare_cross.py +0 -0
  14. siat/copyrights.py +0 -0
  15. siat/cryptocurrency.py +0 -0
  16. siat/economy.py +0 -0
  17. siat/economy2.py +0 -0
  18. siat/esg.py +0 -0
  19. siat/event_study.py +0 -0
  20. siat/exchange_bond_china.pickle +0 -0
  21. siat/fama_french.py +0 -0
  22. siat/fin_stmt2_yahoo.py +0 -0
  23. siat/financial_base.py +0 -0
  24. siat/financial_statements.py +0 -0
  25. siat/financials.py +0 -0
  26. siat/financials2.py +0 -0
  27. siat/financials_china.py +0 -0
  28. siat/financials_china2.py +0 -0
  29. siat/fund.py +0 -0
  30. siat/fund_china.pickle +0 -0
  31. siat/fund_china.py +0 -0
  32. siat/future_china.py +0 -0
  33. siat/google_authenticator.py +0 -0
  34. siat/grafix.py +0 -0
  35. siat/holding_risk.py +0 -0
  36. siat/luchy_draw.py +0 -0
  37. siat/market_china.py +0 -0
  38. siat/markowitz.py +0 -0
  39. siat/markowitz2.py +0 -0
  40. siat/markowitz2_20250704.py +0 -0
  41. siat/markowitz2_20250705.py +0 -0
  42. siat/markowitz_simple.py +0 -0
  43. siat/ml_cases.py +0 -0
  44. siat/ml_cases_example.py +0 -0
  45. siat/option_china.py +0 -0
  46. siat/option_pricing.py +0 -0
  47. siat/other_indexes.py +0 -0
  48. siat/risk_adjusted_return.py +0 -0
  49. siat/risk_adjusted_return2.py +0 -0
  50. siat/risk_evaluation.py +0 -0
  51. siat/risk_free_rate.py +0 -0
  52. siat/sector_china.py +0 -0
  53. siat/security_price2.py +0 -0
  54. siat/security_prices.py +40 -2
  55. siat/security_trend.py +0 -0
  56. siat/security_trend2.py +0 -0
  57. siat/stock.py +0 -0
  58. siat/stock_advice_linear.py +0 -0
  59. siat/stock_base.py +0 -0
  60. siat/stock_china.py +0 -0
  61. siat/stock_info.pickle +0 -0
  62. siat/stock_prices_kneighbors.py +0 -0
  63. siat/stock_prices_linear.py +0 -0
  64. siat/stock_profile.py +0 -0
  65. siat/stock_technical.py +0 -0
  66. siat/stooq.py +0 -0
  67. siat/transaction.py +0 -0
  68. siat/translate.py +0 -0
  69. siat/valuation.py +0 -0
  70. siat/valuation_china.py +0 -0
  71. siat/var_model_validation.py +0 -0
  72. siat/yf_name.py +0 -0
  73. {siat-3.10.132.dist-info/licenses → siat-3.10.133.dist-info}/LICENSE +0 -0
  74. {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/METADATA +232 -235
  75. siat-3.10.133.dist-info/RECORD +78 -0
  76. {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/WHEEL +1 -1
  77. {siat-3.10.132.dist-info → siat-3.10.133.dist-info}/top_level.txt +0 -1
  78. build/lib/build/lib/siat/__init__.py +0 -75
  79. build/lib/build/lib/siat/allin.py +0 -137
  80. build/lib/build/lib/siat/assets_liquidity.py +0 -915
  81. build/lib/build/lib/siat/beta_adjustment.py +0 -1058
  82. build/lib/build/lib/siat/beta_adjustment_china.py +0 -548
  83. build/lib/build/lib/siat/blockchain.py +0 -143
  84. build/lib/build/lib/siat/bond.py +0 -2900
  85. build/lib/build/lib/siat/bond_base.py +0 -992
  86. build/lib/build/lib/siat/bond_china.py +0 -100
  87. build/lib/build/lib/siat/bond_zh_sina.py +0 -143
  88. build/lib/build/lib/siat/capm_beta.py +0 -783
  89. build/lib/build/lib/siat/capm_beta2.py +0 -887
  90. build/lib/build/lib/siat/common.py +0 -5360
  91. build/lib/build/lib/siat/compare_cross.py +0 -642
  92. build/lib/build/lib/siat/copyrights.py +0 -18
  93. build/lib/build/lib/siat/cryptocurrency.py +0 -667
  94. build/lib/build/lib/siat/economy.py +0 -1471
  95. build/lib/build/lib/siat/economy2.py +0 -1853
  96. build/lib/build/lib/siat/esg.py +0 -536
  97. build/lib/build/lib/siat/event_study.py +0 -815
  98. build/lib/build/lib/siat/fama_french.py +0 -1521
  99. build/lib/build/lib/siat/fin_stmt2_yahoo.py +0 -982
  100. build/lib/build/lib/siat/financial_base.py +0 -1160
  101. build/lib/build/lib/siat/financial_statements.py +0 -598
  102. build/lib/build/lib/siat/financials.py +0 -2339
  103. build/lib/build/lib/siat/financials2.py +0 -1278
  104. build/lib/build/lib/siat/financials_china.py +0 -4433
  105. build/lib/build/lib/siat/financials_china2.py +0 -2212
  106. build/lib/build/lib/siat/fund.py +0 -629
  107. build/lib/build/lib/siat/fund_china.py +0 -3307
  108. build/lib/build/lib/siat/future_china.py +0 -551
  109. build/lib/build/lib/siat/google_authenticator.py +0 -47
  110. build/lib/build/lib/siat/grafix.py +0 -3636
  111. build/lib/build/lib/siat/holding_risk.py +0 -867
  112. build/lib/build/lib/siat/luchy_draw.py +0 -638
  113. build/lib/build/lib/siat/market_china.py +0 -1168
  114. build/lib/build/lib/siat/markowitz.py +0 -2363
  115. build/lib/build/lib/siat/markowitz2.py +0 -3150
  116. build/lib/build/lib/siat/markowitz2_20250704.py +0 -2969
  117. build/lib/build/lib/siat/markowitz2_20250705.py +0 -3158
  118. build/lib/build/lib/siat/markowitz_simple.py +0 -373
  119. build/lib/build/lib/siat/ml_cases.py +0 -2291
  120. build/lib/build/lib/siat/ml_cases_example.py +0 -60
  121. build/lib/build/lib/siat/option_china.py +0 -3069
  122. build/lib/build/lib/siat/option_pricing.py +0 -1925
  123. build/lib/build/lib/siat/other_indexes.py +0 -409
  124. build/lib/build/lib/siat/risk_adjusted_return.py +0 -1576
  125. build/lib/build/lib/siat/risk_adjusted_return2.py +0 -1900
  126. build/lib/build/lib/siat/risk_evaluation.py +0 -2218
  127. build/lib/build/lib/siat/risk_free_rate.py +0 -351
  128. build/lib/build/lib/siat/sector_china.py +0 -4140
  129. build/lib/build/lib/siat/security_price2.py +0 -727
  130. build/lib/build/lib/siat/security_prices.py +0 -3408
  131. build/lib/build/lib/siat/security_trend.py +0 -402
  132. build/lib/build/lib/siat/security_trend2.py +0 -646
  133. build/lib/build/lib/siat/stock.py +0 -4284
  134. build/lib/build/lib/siat/stock_advice_linear.py +0 -934
  135. build/lib/build/lib/siat/stock_base.py +0 -26
  136. build/lib/build/lib/siat/stock_china.py +0 -2095
  137. build/lib/build/lib/siat/stock_prices_kneighbors.py +0 -910
  138. build/lib/build/lib/siat/stock_prices_linear.py +0 -386
  139. build/lib/build/lib/siat/stock_profile.py +0 -707
  140. build/lib/build/lib/siat/stock_technical.py +0 -3305
  141. build/lib/build/lib/siat/stooq.py +0 -74
  142. build/lib/build/lib/siat/transaction.py +0 -347
  143. build/lib/build/lib/siat/translate.py +0 -5183
  144. build/lib/build/lib/siat/valuation.py +0 -1378
  145. build/lib/build/lib/siat/valuation_china.py +0 -2076
  146. build/lib/build/lib/siat/var_model_validation.py +0 -444
  147. build/lib/build/lib/siat/yf_name.py +0 -811
  148. build/lib/siat/__init__.py +0 -75
  149. build/lib/siat/allin.py +0 -137
  150. build/lib/siat/assets_liquidity.py +0 -915
  151. build/lib/siat/beta_adjustment.py +0 -1058
  152. build/lib/siat/beta_adjustment_china.py +0 -548
  153. build/lib/siat/blockchain.py +0 -143
  154. build/lib/siat/bond.py +0 -2900
  155. build/lib/siat/bond_base.py +0 -992
  156. build/lib/siat/bond_china.py +0 -100
  157. build/lib/siat/bond_zh_sina.py +0 -143
  158. build/lib/siat/capm_beta.py +0 -783
  159. build/lib/siat/capm_beta2.py +0 -887
  160. build/lib/siat/common.py +0 -5360
  161. build/lib/siat/compare_cross.py +0 -642
  162. build/lib/siat/copyrights.py +0 -18
  163. build/lib/siat/cryptocurrency.py +0 -667
  164. build/lib/siat/economy.py +0 -1471
  165. build/lib/siat/economy2.py +0 -1853
  166. build/lib/siat/esg.py +0 -536
  167. build/lib/siat/event_study.py +0 -815
  168. build/lib/siat/fama_french.py +0 -1521
  169. build/lib/siat/fin_stmt2_yahoo.py +0 -982
  170. build/lib/siat/financial_base.py +0 -1160
  171. build/lib/siat/financial_statements.py +0 -598
  172. build/lib/siat/financials.py +0 -2339
  173. build/lib/siat/financials2.py +0 -1278
  174. build/lib/siat/financials_china.py +0 -4433
  175. build/lib/siat/financials_china2.py +0 -2212
  176. build/lib/siat/fund.py +0 -629
  177. build/lib/siat/fund_china.py +0 -3307
  178. build/lib/siat/future_china.py +0 -551
  179. build/lib/siat/google_authenticator.py +0 -47
  180. build/lib/siat/grafix.py +0 -3636
  181. build/lib/siat/holding_risk.py +0 -867
  182. build/lib/siat/luchy_draw.py +0 -638
  183. build/lib/siat/market_china.py +0 -1168
  184. build/lib/siat/markowitz.py +0 -2363
  185. build/lib/siat/markowitz2.py +0 -3150
  186. build/lib/siat/markowitz2_20250704.py +0 -2969
  187. build/lib/siat/markowitz2_20250705.py +0 -3158
  188. build/lib/siat/markowitz_simple.py +0 -373
  189. build/lib/siat/ml_cases.py +0 -2291
  190. build/lib/siat/ml_cases_example.py +0 -60
  191. build/lib/siat/option_china.py +0 -3069
  192. build/lib/siat/option_pricing.py +0 -1925
  193. build/lib/siat/other_indexes.py +0 -409
  194. build/lib/siat/risk_adjusted_return.py +0 -1576
  195. build/lib/siat/risk_adjusted_return2.py +0 -1900
  196. build/lib/siat/risk_evaluation.py +0 -2218
  197. build/lib/siat/risk_free_rate.py +0 -351
  198. build/lib/siat/sector_china.py +0 -4140
  199. build/lib/siat/security_price2.py +0 -727
  200. build/lib/siat/security_prices.py +0 -3408
  201. build/lib/siat/security_trend.py +0 -402
  202. build/lib/siat/security_trend2.py +0 -646
  203. build/lib/siat/stock.py +0 -4284
  204. build/lib/siat/stock_advice_linear.py +0 -934
  205. build/lib/siat/stock_base.py +0 -26
  206. build/lib/siat/stock_china.py +0 -2095
  207. build/lib/siat/stock_prices_kneighbors.py +0 -910
  208. build/lib/siat/stock_prices_linear.py +0 -386
  209. build/lib/siat/stock_profile.py +0 -707
  210. build/lib/siat/stock_technical.py +0 -3305
  211. build/lib/siat/stooq.py +0 -74
  212. build/lib/siat/transaction.py +0 -347
  213. build/lib/siat/translate.py +0 -5183
  214. build/lib/siat/valuation.py +0 -1378
  215. build/lib/siat/valuation_china.py +0 -2076
  216. build/lib/siat/var_model_validation.py +0 -444
  217. build/lib/siat/yf_name.py +0 -811
  218. siat-3.10.132.dist-info/RECORD +0 -218
build/lib/siat/fund.py DELETED
@@ -1,629 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- 本模块功能:基金
4
- 所属工具包:证券投资分析工具SIAT
5
- SIAT:Security Investment Analysis Tool
6
- 创建日期:2020年10月17日
7
- 最新修订日期:2020年10月18日
8
- 作者:王德宏 (WANG Dehong, Peter)
9
- 作者单位:北京外国语大学国际商学院
10
- 版权所有:王德宏
11
- 用途限制:仅限研究与教学使用,不可商用!商用需要额外授权。
12
- 特别声明:作者不对使用本工具进行证券投资导致的任何损益负责!
13
- """
14
-
15
- #==============================================================================
16
- #关闭所有警告
17
- import warnings; warnings.filterwarnings('ignore')
18
- from siat.bond_base import *
19
- #==============================================================================
20
- if __name__=='__main__':
21
- txt='QDII-指数'
22
-
23
- def strlen(txt):
24
- """
25
- 功能:计算中英文混合字符串的实际长度
26
- """
27
- lenTxt = len(txt)
28
- lenTxt_utf8 = len(txt.encode('utf-8'))
29
- size = int((lenTxt_utf8 - lenTxt)/2 + lenTxt)
30
-
31
- return size
32
-
33
- #==============================================================================
34
- def check_period(fromdate, todate):
35
- """
36
- 功能:根据开始/结束日期检查日期与期间的合理性
37
- 输入参数:
38
- fromdate:开始日期。格式:YYYY-MM-DD
39
- enddate:开始日期。格式:YYYY-MM-DD
40
- 输出参数:
41
- validity:期间合理性。True-合理,False-不合理
42
- start:开始日期。格式:datetime类型
43
- end:结束日期。格式:datetime类型
44
- """
45
- import pandas as pd
46
-
47
- #测试开始日期的合理性
48
- try:
49
- start=pd.to_datetime(fromdate)
50
- except:
51
- print("*** 错误#1(check_period),无效的日期:",fromdate)
52
- return None, None, None
53
-
54
- #测试结束日期的合理性
55
- try:
56
- end=pd.to_datetime(todate)
57
- except:
58
- print("*** 错误#2(check_period),无效的日期:",todate)
59
- return None, None, None
60
-
61
- #测试日期期间的合理性
62
- if start > end:
63
- print("*** 错误#3(check_period),无效的日期期间: 从",fromdate,"至",todate)
64
- return None, None, None
65
-
66
- return True, start, end
67
-
68
- if __name__ =="__main__":
69
- check_period('2020-1-1','2020-2-4')
70
- check_period('2020-1-1','2010-2-4')
71
-
72
- #==============================================================================
73
-
74
- #==============================================================================
75
-
76
- if __name__=='__main__':
77
- fund_type='全部类型'
78
-
79
- def pof_list_china(fund_type='全部类型',printout=True):
80
- """
81
- 功能:抓取公募基金列表,按照基金类型列表,按照基金名称拼音排序
82
- """
83
- print("Searching for publicly offering fund (POF) information in China ...")
84
- import akshare as ak
85
-
86
- #基金基本信息:基金代码,基金简称,基金类型
87
- df = ak.fund_em_fund_name()
88
- df.sort_values(by=['拼音全称'],na_position='first',inplace=True)
89
- df.drop_duplicates(subset=['基金代码','基金类型'], keep='first',inplace=True)
90
-
91
- #获取基金类型列表,并去掉重复项
92
- typelist=list(set(list(df['基金类型'])))
93
- #判断类型是否支持
94
- if fund_type not in typelist+['全部类型']:
95
- print("#Error(fund_list_china): unsupported fund type:",fund_type)
96
- print("Supported fund_type:",typelist+['全部类型'])
97
- return None
98
-
99
- #摘取选定的基金类型
100
- if fund_type != '全部类型':
101
- df2=df[df['基金类型']==fund_type]
102
- else:
103
- df2=df
104
- df3=df2[['基金简称','基金代码','基金类型']]
105
- df3.reset_index(drop=True,inplace=True)
106
-
107
- #打印种类数量信息
108
- if printout:
109
- num=len(df3)
110
- if fund_type != '全部类型':
111
- print("共找到",num,"支基金,","类型为"+fund_type)
112
- return df3
113
-
114
- print("\n======= 中国公募基金种类概况 =======")
115
- print("公募基金总数:","{:,}".format(num))
116
- print("其中包括:")
117
-
118
- typelist.sort(reverse=False)
119
- maxlen=0
120
- for t in typelist:
121
- tlen=strlen(t)
122
- if tlen > maxlen: maxlen=tlen
123
- maxlen=maxlen+1
124
-
125
- for t in typelist:
126
- tlen=strlen(t)
127
- n=len(df[df['基金类型']==t])
128
- prefix=' '*4+t+' '*(maxlen-tlen)+':'
129
- print(prefix,"{:,}".format(n),"\b,",round(n/num*100,2),'\b%')
130
-
131
- import datetime
132
- todaydt = datetime.date.today()
133
- print("来源:东方财富/天天基金,",todaydt)
134
-
135
- return df3
136
-
137
- if __name__=='__main__':
138
- df=pof_list_china()
139
-
140
- #==============================================================================
141
- if __name__=='__main__':
142
- info_type='单位净值'
143
-
144
- def oef_rank_china(info_type='单位净值',fund_type='全部类型'):
145
- """
146
- 功能:中国开放式基金排名,单位净值,累计净值,手续费
147
- """
148
- typelist=['单位净值','累计净值','手续费']
149
- if info_type not in typelist:
150
- print("#Error(oef_rank_china): unsupported info type",info_type)
151
- print("Supported info type:",typelist)
152
- return None
153
-
154
- print("Searching for open-ended fund (OEF) information in China ...")
155
- import akshare as ak
156
-
157
- #获取开放式基金实时信息
158
- df1 = ak.fund_em_open_fund_daily()
159
- collist=list(df1)
160
- nvname1=collist[2]
161
- nvdate=nvname1[:10]
162
- nvname2=collist[3]
163
- #修改列名
164
- df1.rename(columns={nvname1:'单位净值',nvname2:'累计净值'}, inplace=True)
165
- #df1a=df1.drop(df1[df1['单位净值']==''].index)
166
- #df1b=df1a.drop(df1a[df1a['累计净值']==''].index)
167
- df1c=df1[['基金代码','基金简称','单位净值','累计净值','申购状态','赎回状态','手续费']]
168
-
169
-
170
- #获取所有公募基金类型信息
171
- df2 = ak.fund_em_fund_name()
172
- df2a=df2[['基金代码','基金类型']]
173
-
174
- #合成基金类型信息
175
- import pandas as pd
176
- df = pd.merge(df1c,df2a,on = ['基金代码'],how='left')
177
- #过滤基金类型
178
- if fund_type != '全部类型':
179
- fundtypelist=list(set(list(df['基金类型'])))
180
- if fund_type not in fundtypelist:
181
- print("#Error(oef_rank_china): unsupported fund type",fund_type)
182
- print("Supported fund type:",fundtypelist)
183
- return None
184
- df=df[df['基金类型']==fund_type]
185
-
186
- if info_type == '单位净值':
187
- df.sort_values(by=['单位净值'],ascending=False,inplace=True)
188
- dfprint=df[['基金简称','基金代码','基金类型','单位净值','累计净值','手续费']]
189
- print("\n===== 中国开放式基金排名:单位净值最高前十名 =====")
190
-
191
- if info_type == '累计净值':
192
- df.sort_values(by=['累计净值'],ascending=False,inplace=True)
193
- dfprint=df[['基金简称','基金代码','基金类型','累计净值','单位净值','手续费']]
194
- print("\n===== 中国开放式基金排名:累计净值最高前十名 =====")
195
-
196
- if info_type == '手续费':
197
- df.sort_values(by=['手续费'],ascending=False,inplace=True)
198
- dfprint=df[['基金简称','基金代码','基金类型','手续费']]
199
- print("\n===== 中国开放式基金排名:手续费最高前十名 =====")
200
-
201
- #设置打印对齐
202
- pd.set_option('display.max_columns', 1000)
203
- pd.set_option('display.width', 1000)
204
- pd.set_option('display.max_colwidth', 1000)
205
- pd.set_option('display.unicode.ambiguous_as_wide', True)
206
- pd.set_option('display.unicode.east_asian_width', True)
207
-
208
- dfprint.dropna(inplace=True)
209
- dfprint.reset_index(drop=True,inplace=True)
210
- dfprint10=dfprint.head(10)
211
- #print(dfprint10.to_string(index=False))
212
- print(dfprint10)
213
- print(" 共找到披露净值信息的开放式基金数量:",len(dfprint),'\b. ',end='')
214
- print("基金类型:",fund_type)
215
-
216
- print(" 净值日期:",nvdate,'\b. ',end='')
217
- import datetime
218
- todaydt = datetime.date.today()
219
- print(" 来源:东方财富/天天基金,",todaydt)
220
-
221
- return df
222
-
223
- if __name__=='__main__':
224
- df=oef_rank_china(info_type='单位净值')
225
- df=oef_rank_china(info_type='累计净值')
226
- df=oef_rank_china(info_type='手续费')
227
-
228
- #==============================================================================
229
- if __name__=='__main__':
230
- fund='519035'
231
- fromdate='2020-1-1'
232
- todate='2020-10-16'
233
- trend_type='净值'
234
- power=0
235
- twinx=False
236
- zeroline=False
237
-
238
- def oef_trend_china(fund,fromdate,todate,trend_type='净值',power=0):
239
- """
240
- 功能:开放式基金业绩趋势,单位净值,累计净值,近三个月收益率,同类排名,总排名
241
- """
242
- #检查走势类型
243
- trendlist=["净值","收益率","排名"]
244
- if trend_type not in trendlist:
245
- print("#Error(oef_trend_china): unsupported trend type:",trend_type)
246
- print("Supported trend types:",trendlist)
247
- return None
248
-
249
- #检查日期
250
- result,start,end=check_period(fromdate,todate)
251
- if not result:
252
- print("#Error(oef_trend_china): invalid date period:",fromdate,todate)
253
- return None
254
- """
255
- #转换日期格式
256
- import datetime
257
- startdate=datetime.datetime.strftime(start,"%Y-%m-%d")
258
- enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
259
- """
260
- print("Searching for open-ended fund (OEF) trend info in China ...")
261
- import akshare as ak
262
-
263
- #开放式基金-历史数据
264
- import datetime; todaydt = datetime.date.today()
265
- source="来源:东方财富/天天基金"
266
- import siat.grafix as grf
267
-
268
- #绘制单位/累计净值对比图
269
- if trend_type == '净值':
270
- df1 = ak.fund_em_open_fund_info(fund=fund, indicator="单位净值走势")
271
- df1.rename(columns={'x':'date','y':'单位净值'}, inplace=True)
272
- df1['日期']=df1['date']
273
- df1.set_index(['date'],inplace=True)
274
-
275
- df2 = ak.fund_em_open_fund_info(fund=fund, indicator="累计净值走势")
276
- df2.rename(columns={'x':'date','y':'累计净值'}, inplace=True)
277
- df2.set_index(['date'],inplace=True)
278
-
279
- #合并
280
- import pandas as pd
281
- df = pd.merge(df1,df2,left_index=True,right_index=True,how='inner')
282
- dfp=df[(df['日期'] >= start)]
283
- dfp=dfp[(dfp['日期'] <= end)]
284
-
285
- #绘制双线图
286
- ticker1=fund; colname1='单位净值';label1='单位净值'
287
- ticker2=fund; colname2='累计净值';label2='累计净值'
288
- ylabeltxt='人民币元'
289
- titletxt="开放式基金的净值趋势:"+fund
290
-
291
- footnote=source+', '+str(todaydt)
292
- grf.plot_line2(dfp,ticker1,colname1,label1, \
293
- dfp,ticker2,colname2,label2, \
294
- ylabeltxt,titletxt,footnote,power=power)
295
- return df
296
-
297
- #绘制累计收益率单线图
298
- if trend_type == '收益率':
299
- df = ak.fund_em_open_fund_info(fund=fund, indicator="累计收益率走势")
300
- df.rename(columns={'x':'date','y':'累计收益率'}, inplace=True)
301
- df['日期']=df['date']
302
- df.set_index(['date'],inplace=True)
303
- dfp=df[(df['日期'] >= start)]
304
- dfp=dfp[(dfp['日期'] <= end)]
305
-
306
- colname='累计收益率'; collabel='累计收益率%'
307
- ylabeltxt=''
308
- titletxt="开放式基金的累计收益率趋势:"+fund
309
- footnote=source+', '+str(todaydt)
310
- grf.plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
311
- return df
312
-
313
- #绘制同类排名图:近三个月收益率
314
- if trend_type == '排名':
315
- df1 = ak.fund_em_open_fund_info(fund=fund, indicator="同类排名走势")
316
- df1.rename(columns={'x':'date','y':'同类排名','sc':'总排名'}, inplace=True)
317
- df1['日期']=df1['date']
318
- df1.set_index(['date'],inplace=True)
319
-
320
- df2 = ak.fund_em_open_fund_info(fund=fund, indicator="同类排名百分比")
321
- df2.rename(columns={'x':'date','y':'同类排名百分比'}, inplace=True)
322
- df2.set_index(['date'],inplace=True)
323
-
324
- #合并
325
- import pandas as pd
326
- df = pd.merge(df1,df2,left_index=True,right_index=True,how='inner')
327
- dfp=df[(df['日期'] >= start)]
328
- dfp=dfp[(dfp['日期'] <= end)]
329
-
330
- #绘制双线图:同类排名
331
- ticker1=fund; colname1='同类排名';label1='同类排名'
332
- ticker2=fund; colname2='同类排名百分比';label2='同类排名百分比'
333
- ylabeltxt=''
334
- titletxt="开放式基金的近三个月收益率排名趋势:"+fund
335
- footnote=source+', '+str(todaydt)
336
- grf.plot_line2(dfp,ticker1,colname1,label1, \
337
- dfp,ticker2,colname2,label2, \
338
- ylabeltxt,titletxt,footnote,power=power,twinx=True)
339
-
340
- #
341
- ticker2=fund; colname2='总排名';label2='开放式基金总排名'
342
- grf.plot_line2(dfp,ticker1,colname1,label1, \
343
- dfp,ticker2,colname2,label2, \
344
- ylabeltxt,titletxt,footnote,power=power,twinx=True)
345
-
346
- return df
347
-
348
- #==============================================================================
349
- if __name__=='__main__':
350
- pass
351
-
352
- def mmf_rank_china():
353
- """
354
- 功能:中国货币型基金排名,7日年化收益率%
355
- """
356
-
357
- print("Searching for money market fund (OEF) information in China ...")
358
- import akshare as ak
359
-
360
- #获取货币型基金实时信息
361
- df = ak.fund_em_money_fund_daily()
362
- collist=list(df)
363
- nvname=collist[6]
364
- nvdate=nvname[:10]
365
- #修改列名
366
- df.rename(columns={nvname:'7日年化%'}, inplace=True)
367
- #dfa=df.drop(df[df['7日年化%']==''].index)
368
- dfb=df[['基金代码','基金简称','7日年化%','成立日期','基金经理','手续费']]
369
-
370
- dfb.sort_values(by=['7日年化%'],ascending=False,inplace=True)
371
- dfprint=dfb[['基金简称','基金代码','7日年化%','基金经理','手续费']]
372
- print("\n======= 中国货币型基金排名:7日年化收益率最高前十名 =======")
373
-
374
- #设置打印对齐
375
- import pandas as pd
376
- pd.set_option('display.max_columns', 1000)
377
- pd.set_option('display.width', 1000)
378
- pd.set_option('display.max_colwidth', 1000)
379
- pd.set_option('display.unicode.ambiguous_as_wide', True)
380
- pd.set_option('display.unicode.east_asian_width', True)
381
-
382
- dfprint.dropna(inplace=True)
383
- dfprint.reset_index(drop=True,inplace=True)
384
- dfprint10=dfprint.head(10)
385
- #print(dfprint10.to_string(index=False))
386
- print(dfprint10)
387
- print("共找到披露收益率信息的货币型基金数量:",len(dfprint))
388
-
389
- print("收益率日期:",nvdate,'\b. ',end='')
390
- import datetime
391
- todaydt = datetime.date.today()
392
- print("来源:东方财富/天天基金,",todaydt)
393
-
394
- return df
395
-
396
- if __name__=='__main__':
397
- df=mmf_rank_china()
398
-
399
- #==============================================================================
400
- if __name__=='__main__':
401
- fund='320019'
402
- fromdate='2020-1-1'
403
- todate='2020-10-16'
404
- power=0
405
-
406
- def mmf_trend_china(fund,fromdate,todate,power=0):
407
- """
408
- 功能:货币型基金业绩趋势,7日年化收益率
409
- """
410
-
411
- #检查日期
412
- result,start,end=check_period(fromdate,todate)
413
- if not result:
414
- print("#Error(mmf_trend_china): invalid date period:",fromdate,todate)
415
- return None
416
- import datetime
417
- startdate=datetime.datetime.strftime(start,"%Y-%m-%d")
418
- enddate=str(datetime.datetime.strftime(end,"%Y-%m-%d"))
419
-
420
- print("Searching for money market fund (MMF) trend info in China ...")
421
- import akshare as ak
422
-
423
- #基金历史数据
424
- import datetime; dt = datetime.date.today()
425
- source="来源:东方财富/天天基金"
426
- import siat.grafix as grf
427
-
428
- #绘制收益率单线图
429
- df = ak.fund_em_money_fund_info(fund)
430
- df.sort_values(by=['净值日期'],ascending=True,inplace=True)
431
- df['7日年化%']=df['7日年化收益率'].astype("float")
432
-
433
- import pandas as pd
434
- df['date']=pd.to_datetime(df['净值日期'])
435
- df.set_index(['date'],inplace=True)
436
-
437
- dfp = df[(df.index >= startdate)]
438
- dfp = dfp[(dfp.index <= enddate)]
439
-
440
- colname='7日年化%'; collabel='7日年化%'
441
- ylabeltxt=''
442
- titletxt="货币型基金的7日年化收益率趋势:"+fund
443
- footnote=source+', '+str(todaydt)
444
- grf.plot_line(dfp,colname,collabel,ylabeltxt,titletxt,footnote,power=power)
445
-
446
- return df
447
-
448
-
449
- #==============================================================================
450
- #==============================================================================
451
- #==============================================================================
452
- #以下信息专注于中国内地基金信息,来源于akshare,暂时废弃!
453
- #==============================================================================
454
- #==============================================================================
455
- def fund_member_china():
456
- """
457
- 爬虫来源地址:https://zhuanlan.zhihu.com/p/97487003
458
- 功能:获取中国证券投资基金业协会-会员机构综合查询
459
- 返回:单次返回当前时刻所有历史数据
460
- 处理:
461
- 1、按照“机构(会员)名称”排序
462
- 2、按照“机构(会员)名称”+“会员代表”去掉重复
463
- 3、可解析出:公募基金管理公司,私募基金管理人
464
- """
465
- import akshare as ak
466
-
467
- #XXX会员机构综合查询
468
- df = ak.amac_member_info()
469
-
470
- #XXX私募基金管理人综合查询
471
- df = ak.amac_manager_info()
472
-
473
- #XXX证券公司私募基金子公司管理人信息
474
- df = ak.amac_member_sub_info()
475
-
476
- #XXX私募基金管理人基金产品
477
- df = ak.amac_fund_info()
478
-
479
- #XXX证券公司集合资管产品
480
- df = ak.amac_securities_info()
481
-
482
- #XXX证券公司直投基金:
483
- #中国证券投资基金业协会-信息公示-私募基金管理人公示-基金产品公示-证券公司直投基金
484
- df = ak.amac_aoin_info()
485
-
486
- #XXX证券公司私募投资基金
487
- df = ak.amac_fund_sub_info()
488
-
489
- #XXX基金公司及子公司集合资管产品
490
- #中国证券投资基金业协会-信息公示-私募基金管理人公示-基金产品公示-基金公司及子公司集合资管产品
491
- df = ak.amac_fund_account_info()
492
-
493
- #XXX期货公司集合资管产品
494
- #中国证券投资基金业协会-信息公示-私募基金管理人公示-基金产品公示-期货公司集合资管产品
495
- df = ak.amac_futures_info()
496
-
497
- #某个ETF基金的历史行情
498
- df = ak.fund_etf_hist_sina(symbol="sz169103")
499
-
500
- #==========================================================================
501
- #以下为公募数据:
502
- #爬虫来源地址:https://my.oschina.net/akshare/blog/4341149
503
- #XXX开放式基金净值:
504
- #基金代码,基金简称,单位净值,累计净值,申购状态,赎回状态,手续费
505
- df = ak.fund_em_daily()
506
-
507
- #XXX基金信息:单位净值走势
508
- df = ak.fund_em_info(fund="710001", indicator="单位净值走势")
509
-
510
- #XXX基金信息:累计净值走势
511
- df = ak.fund_em_info(fund="710001", indicator="累计净值走势")
512
-
513
- #XXX基金信息:累计收益率走势
514
- df = ak.fund_em_info(fund="710001", indicator="累计收益率走势")
515
-
516
- #XXX基金信息:同类排名走势
517
- #y:同类型排名-每日近三月排名
518
- #sc:总排名-每日近三月排名
519
- df = ak.fund_em_info(fund="710001", indicator="同类排名走势")
520
-
521
- #XXX基金信息:同类排名百分比,同类型排名-每日近3月收益排名百分比
522
- df = ak.fund_em_info(fund="710001", indicator="同类排名百分比")
523
-
524
- #XXX基金信息:分红送配详情
525
- df = ak.fund_em_info(fund="161606", indicator="分红送配详情")
526
-
527
- #XXX基金信息:拆分详情
528
- df = ak.fund_em_info(fund="161606", indicator="拆分详情")
529
-
530
- #基金净值估算数据,当前获取在交易日的所有基金的净值估算数据
531
- #爬虫来源:https://zhuanlan.zhihu.com/p/140478554?from_voters_page=true
532
- #信息内容:基金代码,基金类型,单位净值,基金名称
533
- df = ak.fund_em_value_estimation()
534
-
535
- #基金持股:获取个股的基金持股数据
536
- #爬虫来源:https://my.oschina.net/akshare/blog/4428824
537
- #持股的基金类型:symbol="基金持仓"; choice of {"基金持仓", "QFII持仓", "社保持仓", "券商持仓", "保险持仓", "信托持仓"}
538
- #返回:单次返回指定 symbol 和 date 的所有历史数据
539
- df = ak.stock_report_fund_hold(symbol="基金持仓", date="20200630")
540
-
541
- ###Fama-French三因子回归A股实证(附源码)
542
- #代码来源:https://mp.weixin.qq.com/s?__biz=MzU5NDY0NDM2NA==&mid=2247486057&idx=1&sn=0fb3f8558da4e55789ce340c03b648cc&chksm=fe7f568ac908df9c22bae8b52207633984ec91ef7b2728eea8c6a75089b8f2db284e3d611775&scene=21#wechat_redirect
543
-
544
- ###Carhart四因子模型A股实证(附源码)
545
- #代码来源:https://my.oschina.net/akshare/blog/4340998
546
-
547
- #==========================================================================
548
- ###其他公募基金实时/历史行情
549
- #爬虫来源:https://cloud.tencent.com/developer/article/1624480
550
- #基金基本信息:基金代码,基金简称,基金类型
551
- df = ak.fund_em_fund_name()
552
-
553
- #开放式基金-实时数据
554
- df = ak.fund_em_open_fund_daily()
555
-
556
- #开放式基金-历史数据
557
- df = ak.fund_em_open_fund_info(fund="710001", indicator="单位净值走势")
558
- df = ak.fund_em_open_fund_info(fund="710001", indicator="累计净值走势")
559
- df = ak.fund_em_open_fund_info(fund="710001", indicator="累计收益率走势")
560
- df = ak.fund_em_open_fund_info(fund="710001", indicator="同类排名走势")
561
- df = ak.fund_em_open_fund_info(fund="710001", indicator="同类排名百分比")
562
- df = ak.fund_em_open_fund_info(fund="161606", indicator="分红送配详情")
563
- df = ak.fund_em_open_fund_info(fund="161606", indicator="拆分详情")
564
-
565
- #货币型基金-实时数据
566
- #基金代码,基金简称,当前交易日-单位净值,7日年化收益率,成立日期,基金经理,手续费
567
- df = ak.fund_em_money_fund_daily()
568
-
569
- #货币型基金-历史数据
570
- #净值日期,7日年化收益率,申购状态,赎回状态
571
- df = ak.fund_em_money_fund_info(fund="000009")
572
-
573
- #理财型基金-实时数据
574
- #基金代码,基金简称,当前交易日-7日年化收益率,封闭期,申购状态
575
- df = ak.fund_em_financial_fund_daily()
576
-
577
- #理财型基金-历史数据
578
- #净值日期,7日年化收益率,申购状态,赎回状态
579
- df = ak.fund_em_financial_fund_info(fund="000134")
580
-
581
- #分级基金-实时数据
582
- #基金代码,基金简称,单位净值,累计净值,市价,折价率,手续费
583
- df = ak.fund_em_graded_fund_daily()
584
-
585
- #分级基金-历史数据
586
- #净值日期,7日年化收益率,申购状态,赎回状态
587
- df = ak.fund_em_graded_fund_info(fund="150232")
588
-
589
- #场内交易基金ETF-实时数据
590
- #基金代码,基金简称,类型,当前交易日-单位净值,当前交易日-累计净值,市价,折价率
591
- df = ak.fund_em_etf_fund_daily()
592
-
593
- #场内交易基金-历史数据
594
- #净值日期,单位净值,累计净值,日增长率%,申购状态,申购状态
595
- df = ak.fund_em_etf_fund_info(fund="511280")
596
-
597
- ###抓取沪深股市所有指数关联的公募基金列表(含ETF、增强、分级等)
598
- #代码来源:https://blog.csdn.net/leeleilei/article/details/106124894
599
-
600
- ###pyecharts绘制可伸缩蜡烛图
601
- #代码地址:https://segmentfault.com/a/1190000021999451?utm_source=sf-related
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
-
615
-
616
-
617
-
618
-
619
-
620
-
621
-
622
-
623
-
624
-
625
-
626
-
627
-
628
-
629
-