+
    ȜiT                        R t ^ RIt^ RIt^ RIt^ RIHt R!R R lltR"R R lltR"R	 R
 llt	R#R R llt
R$R R lltR%R R lltR&R R lltR'R R lltR(R R llt]R8X  d   ]! RRR7      t]! ]4       ]! RR7      t]! ]4       ]	! RR7      t]! ]4       ]! RR7      t]! ]4       ]! RRRR7      t]! ]4       ]! RR7      t]! ]4       ]! RRR7      t]! ]4       ]! RR R7      t]! ]4       R# R# ))u~   
Date: 2024/10/23 13:00
Desc: 申万宏源研究-指数系列
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
N)get_tqdmdayc                P    V ^8  d   QhR\         R\         R\        P                  /# )   symbolperiodreturnstrpd	DataFrame)formats   "h/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/akshare/index/index_research_sw.py__annotate__r      s%     = =# =# =",, =    c                   RRRRRR/pRpRV R	W!,          /pR
R/p\         P                  ! W4VRR7      pVP                  4       p\        P                  ! VR,          4      pVP                  RRRRRRRRRRRRRRRRRRRR /
R!R"7       V. R%O,          p\        P                  ! VR,          R#R$7      P                  P                  VR&   \        P                  ! VR,          R#R$7      VR&   \        P                  ! VR,          R#R$7      VR&   \        P                  ! VR,          R#R$7      VR&   \        P                  ! VR,          R#R$7      VR&   \        P                  ! VR ,          R#R$7      VR &   V# )&u\  
申万宏源研究-指数发布-指数详情-指数历史数据
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
:param symbol: 指数代码
:type symbol: str
:param period: choice of {"day", "week", "month"}
:type period: str
:return: 指数历史数据
:rtype: pandas.DataFrame
r   DAYweekWEEKmonthMONTHzAhttps://www.swsresearch.com/institute-sw/api/index_publish/trend/swindexcoder   
User-AgentoMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36Fparamsheadersverifydata   代码bargaindate   日期	openindex   开盘maxindex   最高minindex   最低
closeindex   收盘hike markupbargainamount	   成交量
bargainsum	   成交额Tcolumnsinplacecoerceerrors)r   r!   r)   r#   r%   r'   r.   r0   
requestsgetjsonr   r   renameto_datetimedtdate
to_numeric)	r   r   
period_mapurlr   r   r	data_jsontemp_dfs	   &&       r   index_hist_swrE      s    	uJ
 NCv*$F
 	 )G 	SGAIll9V,-GNN88(Bb[+
    		
G wx'8JMMRRGHgh&7IGHgh&7IGHgh&7IGH==)=hOGK==)=hOGKNr   801001c                D    V ^8  d   QhR\         R\        P                  /# r   r   r   r	   )r   s   "r   r   r   Q   s     + + +BLL +r   c                   RpRV /pRR/p\         P                  ! WVRR7      pVP                  4       p\        P                  ! VR,          4      pVP                  RR	R
RRRRRRR/RR7       V. RO,          p\        P                  ! VR,          RR7      P                  P                  VR&   \        P                  ! VR,          RR7      VR&   V# )u  
申万宏源研究-指数发布-指数详情-指数分时数据
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
:param symbol: 指数代码
:type symbol: str
:return: 指数分时数据
:rtype: pandas.DataFrame
zMhttps://www.swsresearch.com/institute-sw/api/index_publish/details/timelines/r   r   r   Fr   r   l1r   l2   名称l8   价格trading_dater!   trading_time   时间Tr1   r4   r5   )r   rL   rN   r!   rQ   r7   r   rA   r   r   rB   rC   rD   s   &      r   index_min_swrS   Q   s     	X  	vF 	 )G 	SGAIll9V,-GNN(((HH
   	 	
G wx'8JMMRRGHgh&7IGHNr   c                D    V ^8  d   QhR\         R\        P                  /# rH   r	   )r   s   "r   r   r      s     ) )s )",, )r   c                   RpRV RRRR/pRR/p\         P                  ! WVR	R
7      pVP                  4       p\        P                  ! VR,          R,          4      pVP                  RR7       VR,          ^,           VR&   VP                  RRRRRRRRRR/RR7       V. RO,          p\        P                  ! VR,          RR7      P                  P                  VR&   \        P                  ! VR,          RR7      VR&   V# )u  
申万宏源研究-指数发布-指数详情-成分股
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
:param symbol: 指数代码
:type symbol: str
:return: 成分股
:rtype: pandas.DataFrame
zThttps://www.swsresearch.com/institute-sw/api/index_publish/details/component_stocks/r   page1	page_size10000r   r   Fr   r   resultsT)r3   index   序号	stockcode   证券代码	stockname   证券名称	newweight   最新权重beginningdate   计入日期r1   r4   r5   )r\   r^   r`   rb   rd   )r8   r9   r:   r   r   reset_indexr;   r<   r=   r>   r?   rR   s   &      r   index_component_swrf      s    aCVVS+wGF )G 	SGAIll9V,Y78G%w'!+GGNNX^
   	 	
G !nnW^-DXVYY^^GN mmGN,CHUGNNr   c                D    V ^8  d   QhR\         R\        P                  /# rH   r	   )r   s   "r   r   r      s     / / /r|| /r   c                   RpR^R^
RV RRRRR^/pR	R
/p\         P                  ! WVRR7      pVP                  4       p\        P                  ! VR,          R,          4      pVP                  RRRRRRRRRR/RR7       V. RO,          p\        P                  ! VR,          RR7      VR&   \        P                  ! VR,          RR7      VR&   \        P                  ! VR,          RR7      VR&   V# )u  
申万宏源研究-申万指数-股票指数
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
:param symbol: choice of {"大类风格指数", "金创指数"}
:type symbol: str
:return: 指数系列实时行情数据
:rtype: pandas.DataFrame
z>https://www.swsresearch.com/insWechatSw/dflgOrJcIndex/pageListpageNopageSizeindexTypeName	sortFieldr+   rule	indexTyper   r   F)r:   r   r   r   listswIndexCode   指数代码swIndexName   指数名称lastCloseIndex	   昨收盘
lastMarkup   日涨跌幅
yearMarkup   年涨跌幅Tr1   r4   r5   )rq   rs   ru   rw   ry   )r8   postr:   r   r   r;   r?   )r   rA   payloadr   rB   rC   rD   s   &      r   __index_realtime_swr|      s    KC!BRQG 	 )G 	cGAIll9V,V45GNN>>k..
   	 	
G ==)=hOGK mmGN,CHUGN mmGN,CHUGNNr   c                D    V ^8  d   QhR\         R\        P                  /# rH   r	   )r   s   "r   r   r      s     = =c =r|| =r   c                n   V R9   d   \        V 4      pV# RpRRRRRV /pRR/p\        P                  ! W#VR	R
7      pVP                  4       pVR,          R,          p\        P
                  ! V^2,          4      p\        P                  ! 4       p	\        4       p
V
! \        ^V^,           4      R	R7       F|  pVP                  RV/4       \        P                  ! W#VR	R
7      pVP                  4       p\        P                  ! VR,          R,          4      p\        P                  ! W.RR7      p	K~  	  . ROV	n        V	. RO,          p	\        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   \        P                  ! V	R,          RR7      V	R&   V	# )u4  
申万宏源研究-指数系列
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数", "大类风格指数", "金创指数"}
:type symbol: str
:return: 指数系列实时行情数据
:rtype: pandas.DataFrame
zChttps://www.swsresearch.com/institute-sw/api/index_publish/current/rV   rW   rX   50	indextyper   r   Fr   r   countleaverZ   Tobjsignore_indexru   	   今开盘r0   	   最高价	   最低价	   最新价r.   r4   r5   >      金创指数   大类风格指数)	rq   rs   ru   r   r0   r   r   r   r.   )	rq   rs   ru   r   r   r0   r.   r   r   )r|   r8   r9   r:   mathceilr   r   r   rangeupdateconcatr2   r?   )r   rD   rA   r   r   rB   rC   	total_num
total_pagebig_dftqdmrV   s   &           r   index_realtime_swr      s    77%f-
OCc;k6BF )G 	SGAI&!'*I9r>*J\\^F:DU1j1n-U;vtn%LLWUKFFH	,,y0;< 1E <
FN 
	
F --{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;Mr      市场表征c                \    V ^8  d   QhR\         R\         R\         R\        P                  /# )r   r   
start_dateend_dater   r	   )r   s   "r   r   r     s:     K KKK K \\	Kr   c                   RpRRRRRV RRP                  VR	,          VR
,          VR,          .4      RRP                  VR	,          VR
,          VR,          .4      RRRR/pRR/p\        P                  ! W4VRR7      pVP                  4       pVR,          R,          p\        P
                  ! V^2,          4      p	\        P                  ! 4       p
\        4       pV! \        ^V	^,           4      RR7       F|  pVP                  RV/4       \        P                  ! W4VRR7      pVP                  4       p\        P                  ! VR,          R,          4      p\        P                  ! W.RR7      p
K~  	  V
P                  RRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5/RR67       \        P                  ! V
R,          R7R87      P                  P                  V
R&   \        P                   ! V
R!,          R7R87      V
R!&   \        P                   ! V
R#,          R7R87      V
R#&   \        P                   ! V
R%,          R7R87      V
R%&   \        P                   ! V
R',          R7R87      V
R'&   \        P                   ! V
R),          R7R87      V
R)&   \        P                   ! V
R+,          R7R87      V
R+&   \        P                   ! V
R-,          R7R87      V
R-&   \        P                   ! V
R/,          R7R87      V
R/&   \        P                   ! V
R1,          R7R87      V
R1&   \        P                   ! V
R3,          R7R87      V
R3&   \        P                   ! V
R5,          R7R87      V
R5&   V
P#                  R.RRR97       V
# ):ud  
申万宏源研究-指数分析
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
:type symbol: str
:param start_date: 开始日期
:type start_date: str
:param end_date: 结束日期
:type end_date: str
:return: 指数分析
:rtype: pandas.DataFrame
zRhttps://www.swsresearch.com/institute-sw/api/index_analysis/index_analysis_report/rV   rW   rX   r   
index_typer   -N   Nr      Nr   NNr   typer   r   allr   r   Fr   r   r   r   rZ   Tr   rq   swindexnamers   r       发布日期r(      收盘指数r-   r.   r,   	   涨跌幅turnoverrate	   换手率pe	   市盈率pb	   市净率	meanprice   均价bargainsumrate   成交额占比negotiablessharesum1   流通市值negotiablessharesum2   平均流通市值dp	   股息率r1   r4   r5   byr3   r   joinr8   r9   r:   r   r   r   r   r   r   r   r   r;   r<   r=   r>   r?   sort_values)r   r   r   rA   r   r   rB   rC   r   r   r   r   rV   rD   s   &&&           r   index_analysis_daily_swr     s   " _CTfchh
2
3BPQCHHhrlHSM8B<HIuF 	 )G 	SGAI&!'*I9r>*J\\^F:DU1j1n-U;vtn%LLWUKFFH	,,y0;< 1E < MM>>>.[kK++/"N"$8+
  #  &  ^^F>,B8TWW\\F>]]6.+A(SF>--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;}}VH%5hGF8 "f5F.GPX YF]]6.+A(SF>#%==8L1MV^#_F --{(;HMF;
>*DtLMr   r   c                D    V ^8  d   QhR\         R\        P                  /# rH   r	   )r   s   "r   r   r   k  s       2<< r   c                h   RpRV P                  4       /pRR/p\        P                  ! WVRR7      pVP                  4       p\        P
                  ! VR,          4      p\        P                  ! VR,          R	R
7      P                  P                  VR&   R.Vn	        VP                  R.RRR7       V# )u   
申万宏源研究-周/月报表-日期序列
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
:param symbol: choice of {"week", "month"}
:type symbol: str
:return: 日期序列
:rtype: pandas.DataFrame
zPhttps://www.swsresearch.com/institute-sw/api/index_analysis/week_month_datetime/r   r   r   Fr   r   r    r4   r5   r>   Tr   )upperr8   r9   r:   r   r   r<   r=   r>   r2   r   rR   s   &      r   index_analysis_week_month_swr   k  s     ]Cflln%F )G 	SGAIll9V,-G^^xb M hGOF8TENr   c                P    V ^8  d   QhR\         R\         R\        P                  /# r   r   r>   r   r	   )r   s   "r   r   r     s/     H HH
H \\Hr   c                |   RpRRRRRV RRP                  VR	,          VR
,          VR,          .4      RRRR/pRR/p\        P                  ! W#VRR7      pVP                  4       pVR,          R,          p\        P
                  ! V^2,          4      p\        P                  ! 4       p	\        4       p
V
! \        ^V^,           4      RR7       F|  pVP                  RV/4       \        P                  ! W#VRR7      pVP                  4       p\        P                  ! VR,          R,          4      p\        P                  ! W.RR7      p	K~  	  V	P                  RRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3/RR47       \        P                  ! V	R,          R5R67      P                  P                  V	R&   \        P                   ! V	R,          R5R67      V	R&   \        P                   ! V	R!,          R5R67      V	R!&   \        P                   ! V	R#,          R5R67      V	R#&   \        P                   ! V	R%,          R5R67      V	R%&   \        P                   ! V	R',          R5R67      V	R'&   \        P                   ! V	R),          R5R67      V	R)&   \        P                   ! V	R+,          R5R67      V	R+&   \        P                   ! V	R-,          R5R67      V	R-&   \        P                   ! V	R/,          R5R67      V	R/&   \        P                   ! V	R1,          R5R67      V	R1&   \        P                   ! V	R3,          R5R67      V	R3&   V	P#                  R.RRR77       V	# )8u|  
申万宏源研究-指数分析-周报告
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
:type symbol: str
:param date: 查询日期; 通过调用 ak.index_analysis_week_month_sw(date="20221104") 接口获取
:type date: str
:return: 指数分析
:rtype: pandas.DataFrame
Shttps://www.swsresearch.com/institute-sw/api/index_analysis/index_analysis_reports/rV   rW   rX   r   r   r    r   r   r   r   r   r   r   r   r   r   Fr   r   r   r   rZ   Tr   rq   r   rs   r   r(   r   r-   r.   r,   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r4   r5   r   r   r   r>   rA   r   r   rB   rC   r   r   r   r   rV   rD   s   &&           r   index_analysis_weekly_swr     s    `CTfsxxb49d2h ?@uF 	 )G 	SGAI&!'*I9r>*J\\^F:DU1j1n-U;vtn%LLWUKFFH	,,y0;< 1E < MM>>>.[kK++/"N"$8+
  #  &  ^^F>,B8TWW\\F>]]6.+A(SF>--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;}}VH%5hGF8 "f5F.GPX YF]]6.+A(SF>#%==8L1MV^#_F --{(;HMF;
>*DtLMr   c                P    V ^8  d   QhR\         R\         R\        P                  /# r   r	   )r   s   "r   r   r     s/     G GG
G \\Gr   c                |   RpRRRRRV RRP                  VR	,          VR
,          VR,          .4      RRRR/pRR/p\        P                  ! W#VRR7      pVP                  4       pVR,          R,          p\        P
                  ! V^2,          4      p\        P                  ! 4       p	\        4       p
V
! \        ^V^,           4      RR7       F|  pVP                  RV/4       \        P                  ! W#VRR7      pVP                  4       p\        P                  ! VR,          R,          4      p\        P                  ! W.RR7      p	K~  	  V	P                  RRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3/RR47       \        P                  ! V	R,          R5R67      P                  P                  V	R&   \        P                   ! V	R,          R5R67      V	R&   \        P                   ! V	R!,          R5R67      V	R!&   \        P                   ! V	R#,          R5R67      V	R#&   \        P                   ! V	R%,          R5R67      V	R%&   \        P                   ! V	R',          R5R67      V	R'&   \        P                   ! V	R),          R5R67      V	R)&   \        P                   ! V	R+,          R5R67      V	R+&   \        P                   ! V	R-,          R5R67      V	R-&   \        P                   ! V	R/,          R5R67      V	R/&   \        P                   ! V	R1,          R5R67      V	R1&   \        P                   ! V	R3,          R5R67      V	R3&   V	P#                  R.RRR77       V	# )8um  
申万宏源研究-指数分析-月报告
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
:type symbol: str
:param date: 查询日期; 通过调用 ak.index_analysis_week_month_sw() 接口获取
:type date: str
:return: 指数分析
:rtype: pandas.DataFrame
r   rV   rW   rX   r   r   r    r   r   r   r   r   r   r   r   r   r   Fr   r   r   r   rZ   Tr   rq   r   rs   r   r(   r   r-   r.   r,   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r4   r5   r   r   r   s   &&           r   index_analysis_monthly_swr     s    `CTfsxxb49d2h ?@uF 	 )G 	SGAI&!'*I9r>*J\\^F:DU1j1n-U;vtn%LLWUKFFH	,,y0;< 1E < MM>>>.[kK++/"N"$8+
  #  &  ^^F>,B8TWW\\F>]]6.+A(SF>--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;--{(;HMF;}}VH%5hGF8 "f5F.GPX YF]]6.+A(SF>#%==8L1MV^#_F --{(;HMF;
>*DtLMr   __main__801193)r   r   )r   20241025)r   r   r   )r   r>   20240930)801030r   )rF   )r   )u   二级行业)r   20221103r   )r   )r   20221104)r   20221031)__doc__r   pandasr   r8   akshare.utils.tqdmr   rE   rS   rf   r|   r   r   r   r   r   __name__index_hist_sw_dfprintindex_min_sw_dfindex_component_sw_dfindex_realtime_sw_dfindex_analysis_daily_sw_dfindex_analysis_week_month_sw_dfindex_analysis_weekly_sw_dfindex_analysis_monthly_sw_df r   r   <module>r      s      '=@+\)X/d=@K\4HVGT z$HUC	
"(3O	/.h?	
 ,NC	
!8*z" 

$%&B'&R#	
)*":J# 

%&#<J$  

&'; r   