|
@@ -45,8 +45,13 @@ def get_pct(code, start_date, end_date):
|
|
|
|
|
|
|
|
|
|
|
|
|
# 路由定义
|
|
# 路由定义
|
|
|
-@app.route('/', methods=['GET', 'POST'])
|
|
|
|
|
|
|
+@app.route('/')
|
|
|
def index():
|
|
def index():
|
|
|
|
|
+ # 基础页面只负责渲染主页
|
|
|
|
|
+ return render_template('base_index.html')
|
|
|
|
|
+
|
|
|
|
|
+@app.route('/simple_backtest', methods=['GET', 'POST'])
|
|
|
|
|
+def simple_backtest():
|
|
|
if request.method == 'POST':
|
|
if request.method == 'POST':
|
|
|
file = request.files['file']
|
|
file = request.files['file']
|
|
|
if file:
|
|
if file:
|
|
@@ -54,8 +59,7 @@ def index():
|
|
|
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
|
|
file.save(filepath)
|
|
file.save(filepath)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- # 读取CSV文件
|
|
|
|
|
|
|
+ # 以下逻辑与原来的index函数中的POST处理逻辑相同
|
|
|
code_date_list = extract_code_date(filepath)
|
|
code_date_list = extract_code_date(filepath)
|
|
|
pct_list = []
|
|
pct_list = []
|
|
|
up_down_flags = []
|
|
up_down_flags = []
|
|
@@ -73,12 +77,15 @@ def index():
|
|
|
df['code'] = df['code'].astype(str).str.zfill(6)
|
|
df['code'] = df['code'].astype(str).str.zfill(6)
|
|
|
df['10_days_pct'] = pct_list
|
|
df['10_days_pct'] = pct_list
|
|
|
|
|
|
|
|
- return render_template('index.html',
|
|
|
|
|
- tables=[df.to_html(classes='table table-striped')],
|
|
|
|
|
|
|
+ # 注意这里渲染的是'simple_backtest.html'
|
|
|
|
|
+ return render_template('simple_backtest.html',
|
|
|
|
|
+ tables=[df.to_html(classes='table table-striped')],
|
|
|
titles=df.columns.values,
|
|
titles=df.columns.values,
|
|
|
up_probability=up_probability)
|
|
up_probability=up_probability)
|
|
|
|
|
|
|
|
- return render_template('index.html')
|
|
|
|
|
|
|
+ # 对于GET请求,渲染'simple_backtest.html'但不包含表格数据
|
|
|
|
|
+ return render_template('simple_backtest.html')
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
app.run(debug=True)
|
|
app.run(debug=True)
|