def filter_stock_by_average_pe(min, max):
path = os.path.join(current_folder, '3????????????%s.csv' % today)
if not os.path.exists(path): # ?????3???????
calcu_all_stocks_3year_average_profit(calcu_average_profit_end_year)
gplb = pd.read_csv(path, index_col=0, encoding='utf-8')
# ????????
price_path = os.path.join(current_folder, today + '????.csv')
if not os.path.exists(price_path):
ts.get_today_all().set_index('code').to_csv(price_path, encoding="utf-8")
current_price = pd.read_csv(price_path, encoding="utf-8", index_col=0)
current_price = current_price[['trade']]
current_price.columns = ['??']
gplb = gplb[
['??', '??', '??', '????', '???', '???(?)', '????', '????', '????', '???', '????',
'????']]
data = pd.merge(gplb, current_price, left_index=True, right_index=True)
# ??????????????????????????????
data['?????'] = data['???'] * data['??'] * 10000 / data['????']
print('%s:' % today)
print()
print('%d???' % data.shape[0])
print('3???????%.1f' % round(data['?????'].median(), 1))
print('3???????%.1f' % round(data['???'].median(), 1))
data = data[data['?????'] < max]
data = data[data['?????'] > min]
data['?????'] = data['?????'].round(1)
data['????'] = data['????'].round()
data['???'] = data['???'].round(1)
data['????'] = data['????'].round()
data['????'] = data['????'].round()
data['???'] = data['???'].round()
data['????'] = data['????'].round()
average_pe_file = os.path.join(current_folder, today + '-3???????%s?%s?????.xlsx' % (min, max))
data.to_excel(average_pe_file)
calcu_3year_average_pe.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录