diff --git a/main.py b/main.py index dc60432..9a36fc2 100644 --- a/main.py +++ b/main.py @@ -310,7 +310,7 @@ def buildPort(): # Query DB market_asset = '0050.TW' if session['tw']==1 else 'SPY' conn = psycopg2.connect(**SQL_CONFIG) - if 'market_asset' in stock_list: + if market_asset in stock_list: port = get_stock(conn, stock_list, session['tw']) market = port[market_asset] else: diff --git a/requirements.txt b/requirements.txt index a523387..0b2b732 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ Flask==2.2.2 Flask-Login==0.6.2 Flask-SQLAlchemy==3.0.3 gunicorn==20.0.4 -matplotlib==3.6.3 +matplotlib packaging==23.0 pandas==1.5.3 plotly==5.13.1 diff --git a/static/js/addStock.js b/static/js/addStock.js index ac6438e..a622b60 100644 --- a/static/js/addStock.js +++ b/static/js/addStock.js @@ -127,17 +127,21 @@ $submitBtn.click(function(event) { // console.log(cacheList.value, stockList); if (stockList.length > 0) { // cacheList = stockList; + $('#graph').html('
Loading...
') $.ajax({ url: '/postStock', //todo create_strategy method: 'POST', data: { stockList: JSON.stringify(stockList) }, success: function(response) { + $('#graph').html('') var graphs = JSON.parse(response); + Plotly.newPlot("graph", graphs.data, graphs.layout, {responsive: true}); console.log(response.layout); }, error: function(xhr) { + $('#graph').html('
錯誤
') console.log('Error submitting stock list: ' + xhr.responseText); } }); diff --git a/templates/strategy_tw.html b/templates/strategy_tw.html index a8f6cdd..f59c875 100644 --- a/templates/strategy_tw.html +++ b/templates/strategy_tw.html @@ -10,7 +10,7 @@ {% block title %}Strategy Page{% endblock%} {% block style %} -.input-group > input { + + +div.input-group > * { + border-radius: 0px; +} +div.card{ + border-radius: 2px; } {% endblock style %} @@ -35,51 +41,51 @@
-
投資組合建立步驟
+
{% if session.tw == 1 %}台股{% endif %}投資組合建立步驟
  1. 輸入投資組合名稱
  2. 選擇所參加的課程或競賽
  3. 選擇資產 (可使用搜索功能篩選)
  4. -
  5. 確認資產後按下 "確認資產", 查看資產價格動態圖表
  6. +
  7. 確認資產後按下確認資產, 查看資產價格動態圖表
  8. 選擇訓練 / 回測數據比例與最佳化目標函數
  9. -
  10. 確認後按下 "建立投資組合", 查看回傳訊息
  11. +
  12. 確認後按下確認建立, 查看回傳訊息
-
- - -
-
- - +
+
+ 投資組合名稱 +
+
+ +
- -
- - - {% if session.tw==0 %} - {% for key, data in data_us.items() -%} - - {% endfor %} - {% endif %} - {% for key, data in data_tw.items() -%} - - {% endfor %} - - +
+
+ 請選擇所參加的課程/競賽 +
+
+ +
+

+
+
+
+ 價格動態圖表 +
+
+
+
+
+
-
+
已選擇的資產
@@ -91,35 +97,57 @@
-
-
- - - -
- -
    +
    + + + {% if session.tw==0 %} + {% for key, data in data_us.items() -%} + + {% endfor %} + {% endif %} + {% for key, data in data_tw.items() -%} + + {% endfor %} + + +
    + +
    +
    +
    1. - 2330.TW | 台積電 | 2000-01-05 ~ + 2330.TW | 台積電
    -
    -
    +
    + 訓練 / 回測數據比 + +
    +
    + 最佳化目標函數 + +
+ +