Skip to content

Instantly share code, notes, and snippets.

@adxrgh
Last active May 21, 2017 04:54
Show Gist options
  • Save adxrgh/442233ef8bb7639b07c807bb608c0bd8 to your computer and use it in GitHub Desktop.
Save adxrgh/442233ef8bb7639b07c807bb608c0bd8 to your computer and use it in GitHub Desktop.
[tp.收益曲线]获得突破个股的今年以来的收益比较图 #wind
from WindPy import *
import pandas as pd
from pandas import DataFrame
w.start()
all_data={}
a=w.weqs('tp')
for ticker in a.Data[0]:
all_data[ticker]=w.wsd(ticker,'close','20170101')
price=DataFrame({tic:data.Data[0] for tic,data in all_data.items()},index=all_data[next(iter(all_data))].Times) # next (iter(my_dict))get firt key of a dict
syzs=(1+price.pct_change()).cumprod()
syzs.iloc[0,:]=1
syzs.plot()
sy=syzs.resample('W',how='last').pct_change()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment