Last active
May 21, 2017 04:54
-
-
Save adxrgh/442233ef8bb7639b07c807bb608c0bd8 to your computer and use it in GitHub Desktop.
[tp.收益曲线]获得突破个股的今年以来的收益比较图 #wind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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