From 6ed1ea8e4fb5d5895ec31f3eadbac57752e405b0 Mon Sep 17 00:00:00 2001 From: SeanChenTaipei Date: Mon, 13 Mar 2023 14:49:34 +0800 Subject: [PATCH] c --- main.py | 4 ++-- portfolio_builder.py | 10 ---------- static/js/addStock.js | 28 ++++++++-------------------- templates/404.html | 2 +- templates/custom.html | 8 ++++++++ templates/registration.html | 7 ------- templates/result.html | 3 +-- templates/strategy_tw.html | 3 +-- 8 files changed, 21 insertions(+), 44 deletions(-) diff --git a/main.py b/main.py index 117dfcc..2909975 100644 --- a/main.py +++ b/main.py @@ -392,8 +392,8 @@ def custom_post(): info = MVO.portfolio_info(np.array([1]), rets['Portfolio'].to_numpy().reshape(-1, 1), np.zeros(len(ret)-lookback)) info['username'] = session.get('username').split('@')[0] info['role'] = role_map[role] - info['id']='使用者自行上傳' - info['name']='使用者自行上傳' + info['id']='Custom data' + info['name']='Custom data' info['date'] = '-' info['alpha'] = '-' info['beta'] = '-' diff --git a/portfolio_builder.py b/portfolio_builder.py index 4fdaec0..23119f8 100644 --- a/portfolio_builder.py +++ b/portfolio_builder.py @@ -2,19 +2,9 @@ import json import time import numpy as np import pandas as pd - from scipy.optimize import minimize class MVO(object): - def __init__(self, data, market, ratio, role='max-sharpe'): - length, self.num = data.shape - tsize = int(length*ratio) - self.data_return = data.pct_change().dropna().to_numpy() - self.market_return = market.pct_change().dropna().to_numpy() - self.train[:tsize, :] - self.test[tsize:, :] - self.train_market = self.market_return[:tsize] - self.test_market = self.market_return[tsize:] @staticmethod def portfolio_info(w, ret, market_ret, rf=0): # return and drawdown diff --git a/static/js/addStock.js b/static/js/addStock.js index d120ae9..db9425d 100644 --- a/static/js/addStock.js +++ b/static/js/addStock.js @@ -10,7 +10,6 @@ const layout={'autosize': true, 'markers':true, } // Cache frequently-used DOM elements const $stockForm = $('#stock-form'); -// const $stockSelect = $('#stock-select'); const $compSelect = $('#competition'); const $stockList = $('#stock-list'); const $submitBtn = $('#submit-btn'); @@ -32,7 +31,14 @@ function addStockItem(stock, text) { `); $stockList.append($newItem); } - +function changeFunc(value) { + console.log(value); + if (value === 'quadratic_utility') { + $('#gamma').css("display", "flex"); + } else { + $('#gamma').css("display", "none"); + } +} // Function to delete a stock item from the list function deleteStockItem(itemIndex) { // Remove item from array @@ -48,17 +54,6 @@ $stockList.on('click', '.delete-btn', function(){ deleteStockItem(itemIndex); // console.log(stockList); }); - -function changeFunc(value) { - console.log(value); - if (value === 'quadratic_utility') { - $('#gamma').css("display", "flex"); - } else { - $('#gamma').css("display", "none"); - } -} - - // Event listener for submit button click $addStockBtn.click(function(event) { event.preventDefault(); @@ -171,10 +166,3 @@ $(document).ready(function(){ }); }); }); - -// window.onresize = function() { -// Plotly.relayout('graph', { -// 'xaxis.autorange': true, -// 'yaxis.autorange': true -// }); -// }; diff --git a/templates/404.html b/templates/404.html index 17151ef..9b97793 100644 --- a/templates/404.html +++ b/templates/404.html @@ -6,7 +6,7 @@ Document - +

404 Error

diff --git a/templates/custom.html b/templates/custom.html index fe7acce..d7bd931 100644 --- a/templates/custom.html +++ b/templates/custom.html @@ -78,4 +78,12 @@ } } + {% endblock script %} diff --git a/templates/registration.html b/templates/registration.html index 2d06eca..e89234e 100644 --- a/templates/registration.html +++ b/templates/registration.html @@ -66,12 +66,5 @@ - - - {% endblock %} \ No newline at end of file diff --git a/templates/result.html b/templates/result.html index c64e6a4..d99357e 100644 --- a/templates/result.html +++ b/templates/result.html @@ -9,7 +9,7 @@ {% block title %}Result Page{% endblock%} {% block content %} -
+
-
diff --git a/templates/strategy_tw.html b/templates/strategy_tw.html index 2b4d42a..fd904b7 100644 --- a/templates/strategy_tw.html +++ b/templates/strategy_tw.html @@ -84,7 +84,7 @@ div.card{
- +