Compare commits

...

5 Commits

Author SHA1 Message Date
SeanChenTaipei f30ce83649 f 2 years ago
SeanChenTaipei 9c214de61a f 2 years ago
SeanChenTaipei 72aa37391b f 2 years ago
SeanChenTaipei e6d4ea10c6 d 2 years ago
SeanChenTaipei 41cedf648e f 2 years ago
  1. 6
      main.py
  2. 1
      sql_script/create_strategy.sql
  3. 7
      static/js/addStock.js
  4. 5
      templates/base.html
  5. 5
      templates/strategy_tw.html

@ -339,13 +339,13 @@ def buildPort():
info = MVO.portfolio_info(np.array([1]), rets['Portfolio'].to_numpy().reshape(-1, 1), market.pct_change().dropna().to_numpy())
data = (ts, name, session.get('username').split('@')[0], comp, role, info['annual_ret'],
info['vol'], info['mdd'], info['annual_sr'],
info['beta'], info['alpha'], info['var10'], info['R2'], True, comment, stock_list, json.dumps(weight.to_dict()), json.dumps(rets.to_dict()))
info['beta'], info['alpha'], info['var10'], info['R2'], gamma, True, comment, stock_list, json.dumps(weight.to_dict()), json.dumps(rets.to_dict()))
sql='insert into strategy \
(date, name, username,\
competition, role, annual_ret,\
vol, mdd, annual_sr, beta, alpha,\
var10, R2, tw, notes, assets, weight, ret)\
values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) RETURNING id;'
var10, R2, gamma, tw, notes, assets, weight, ret)\
values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) RETURNING id;'
with conn:
with conn.cursor() as curs:
curs.execute(sql, data)

@ -14,6 +14,7 @@ CREATE TABLE strategy (
alpha REAL NOT NULL,
var10 REAL NOT NULL,
R2 REAL NOT NULL,
gamma REAL NOT NULL,
tw BOOLEAN DEFAULT TRUE,
notes VARCHAR(255),
assets TEXT[] NOT NULL,

@ -67,7 +67,7 @@ $addStockBtn.click(function(event) {
var text = $('input[name=assetSelect]').val();
// const selectedStock = text;
// var text = $('#stock-select option:selected').text();
console.log(text)
// console.log(text)
if (text != null && text!= '' && stockList.indexOf(text)===-1) {
// Add new item to list
addStockItem(text, text);
@ -75,7 +75,7 @@ $addStockBtn.click(function(event) {
// Clear input field
$('#stockAll').val('');
}
console.log(stockList);
// console.log(stockList);
});
// Event listener for submit button click
@ -83,7 +83,7 @@ $submitPort.click(function(event) {
event.preventDefault();
if (stockList.length > 1){
$('#portModal').modal('show');
console.log('asset confirm');
// console.log('asset confirm');
// $(this).prop('disabled', true);
}
});
@ -120,6 +120,7 @@ $sendPort.click(function(event) {
},
error: function(xhr) {
console.log('Error submitting stock list: ' + xhr.responseText);
alert('建立失敗,請確認資產名稱是否正確! 美股代號均為大寫、台股代號為數字後接".TW"或是"TWO"');
}
});
$commentPort.val('');

@ -21,6 +21,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css">
{% endblock %}
<style>
body {
/* // padding-bottom: 10px; */
@ -385,14 +386,14 @@
</div>
<!-- Copyright -->
</footer>
<!--jQuery -->
<script
src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
crossorigin="anonymous"
></script>
<!-- Boostrap Scripts -->
<script
defer

@ -51,8 +51,8 @@ div.card{
<li><span class="fa-li"><i class="fa-solid fa-scroll"></i></span>未輸入投資組合名稱則會由系統隨機生成。</li>
</ul>
</div>
<div class="modal" id="intro" tabindex="-1" data-bs-backdrop="static">
<div class="modal-dialog">
<div class="modal fade" id="intro" tabindex="-1" data-bs-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="card-title text-xl font-bold pt-2">
@ -79,7 +79,6 @@ div.card{
</div>
</div>
</div>
<div class="card my-2" style="border-radius: 7px;">
<div class="card-header d-flex">
<div class="py-2 font-bold text-xl">

Loading…
Cancel
Save