From 77b16b48466646e7948fc280e59414adeee1e2dd Mon Sep 17 00:00:00 2001 From: SeanChenTaipei Date: Fri, 3 Mar 2023 14:55:05 +0800 Subject: [PATCH] style --- main.py | 21 ++++++++++---------- templates/strategy_tw.html | 40 +++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/main.py b/main.py index 9a36fc2..e24d84f 100644 --- a/main.py +++ b/main.py @@ -20,8 +20,8 @@ pd.options.plotting.backend = "plotly" # PARAMETERS CONFIGS = { - "ENV": "development", - "DEBUG": True, + # "ENV": "development", + # "DEBUG": True, "SECRET_KEY": os.urandom(30), # Set the secret key for session authentication "PERMANENT_SESSION_LIFETIME": timedelta(minutes=60) } @@ -238,16 +238,17 @@ def submit_stock_list(): ## Query DB conn = psycopg2.connect(**SQL_CONFIG) port = get_stock(conn, stock_list, session['tw']) + if len(port.index) > 750: + port = port.iloc[-750:, :] conn.close() - fig = port.plot(title = 'Assets in portfolio', - labels=dict(index="Date", value="Price", variable="Assets")) + fig = port.plot(title='資產價格走勢', labels=dict(index="Date", value="Price", variable="Assets")) fig['layout'] = dict( autosize=True, - legend={'title': {'text': 'Assets'}, 'tracegroupgap': 0}, + legend={'title': {'text': '資產價格走勢'}, 'tracegroupgap': 0}, title= {'text': 'Assets in portfolio'}, - xaxis= {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'Date'}}, - yaxis= {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'Price'}} + xaxis= {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': '日期'}}, + yaxis= {'anchor': 'x', 'domain': [0.0, 0.75], 'title': {'text': '價格'}} ) fig.update_layout(legend=dict( yanchor="top", @@ -395,9 +396,9 @@ def result(): # return render_template('result_tw.html') # handle login failed -@app.errorhandler(401) -def page_not_found(e): - return Response('

Failed

') +# @app.errorhandler(401) +# def page_not_found(e): +# return response('

Failed

') diff --git a/templates/strategy_tw.html b/templates/strategy_tw.html index f59c875..c38d865 100644 --- a/templates/strategy_tw.html +++ b/templates/strategy_tw.html @@ -57,7 +57,7 @@ div.card{ 投資組合名稱
- +
@@ -127,23 +127,27 @@ div.card{
-
- 訓練 / 回測數據比 - -
-
- 最佳化目標函數 - +
+
+
策略參數選擇
+
+ 訓練 / 回測數據比 + +
+
+ 最佳化目標函數 + +