python 做量化的初步尝试,对数据类型还是有点儿不熟,不过有参考策略看真是不错
#计算peg的思路
df_Growth_PE_G = df_PE_G[(df_PE_G.pe_ratio > 0) & (df_PE_G.inc_net_profit_year_on_year > 0)]
df_Growth_PE_G.dropna()
#dataframe转series
Series_PE = df_Growth_PE_G.ix[:, 'pe_ratio']
Series_G = df_Growth_PE_G.ix[:, 'inc_net_profit_year_on_year']
#得到PEG的series
Series_PEG = Series_PE / Series_G
Series_PEG.index = df_Growth_PE_G.ix[:, 0]
#使用Series构造dataframe
df_PEG = pd.DataFrame(Series_PEG)
本文介绍了使用Python进行量化投资的初步尝试,并详细展示了如何从财务数据中计算股票的PEG比率。通过筛选出PE比率和净利润增长率均为正的数据,转换为Series格式后计算PEG比率。

2669

被折叠的 条评论
为什么被折叠?



