SeanChenTaipei 2 years ago
parent 0481aba993
commit 6ed1ea8e4f
  1. 4
      main.py
  2. 10
      portfolio_builder.py
  3. 28
      static/js/addStock.js
  4. 2
      templates/404.html
  5. 8
      templates/custom.html
  6. 7
      templates/registration.html
  7. 3
      templates/result.html
  8. 3
      templates/strategy_tw.html

@ -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'] = '-'

@ -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

@ -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) {
</li>`);
$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
// });
// };

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="background-image: linear-gradient(to bottom right, #5d9faa , #c4e0e5);">
<body style="background-image: linear-gradient(to bottom right, #5d9faa , #c4e0e5);min-height:92%;">
<div class="container-fluid justify-content-center">
<h1 class="font-bold text-4xl">404 Error</h1>
</div>

@ -78,4 +78,12 @@
}
}
</script>
<script>
$("#csv_file").on("change", function () {
if(this.files[0].size > 1000000) {
alert("檔案大小請勿超過 1MB !!");
$(this).val(null);
}
});
</script>
{% endblock script %}

@ -66,12 +66,5 @@
</div>
</div>
</section>
<!-- {% if error %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endif %} -->
</div>
{% endblock %}

@ -9,7 +9,7 @@
{% block title %}Result Page{% endblock%}
{% block content %}
<div class="container-fluid" style="background-color: #eee;;min-height:92%;position:relative;">
<div class="container-fluid" style="background-color: #eee;min-height:92%;position:relative;">
<div class="container-fluid px-1 py-4">
<div class="alert alert-secondary p-3 mx-3" role="alert" style="border: 1px solid black">
<div class="flex-row">
@ -85,7 +85,6 @@
</div>
</div>
</div>
</div>
</div>

@ -84,7 +84,7 @@ div.card{
</div>
<div class="card-body">
<label for="portName" class="form-label font-bold">輸入投資組合名稱: </label>
<input id="portName" name="portName" type="text" class="form-control mb-3" placeholder="EX. 韓總 No.1" required>
<input id="portName" name="portName" type="text" class="form-control mb-3" placeholder="EX. 112最帥" required>
<label for="competition" class="form-label font-bold">選擇所屬課程或競賽: </label>
<select id="competition" class="form-select mb-3" size="1">
{% include 'competitions.html' %}
@ -119,7 +119,6 @@ div.card{
</ol>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save