Skip to content

Commit

Permalink
Add a 10 Cap frame to UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
kocielnik committed Dec 6, 2024
1 parent 332893e commit f4a8a5c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion isthisstockgood/DataFetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def fetchDataForTickerSymbol(ticker):
'debt_equity_ratio',
'margin_of_safety_price',
'current_price'
'ten_cap_price'
"""
if not ticker:
return None
Expand All @@ -56,7 +57,9 @@ def fetchDataForTickerSymbol(ticker):
margin_of_safety_price, sticker_price = \
_calculateMarginOfSafetyPrice(msn_money.equity_growth_rates[-1], msn_money.pe_low, msn_money.pe_high, msn_money.eps[-1], five_year_growth_rate)
payback_time = _calculatePaybackTime(msn_money.equity_growth_rates[-1], msn_money.last_year_net_income, msn_money.market_cap, five_year_growth_rate)
computed_free_cash_flow = round(float(msn_money.free_cash_flow[-1]) * msn_money.shares_outstanding)
free_cash_flow_per_share = float(msn_money.free_cash_flow[-1])
computed_free_cash_flow = round(free_cash_flow_per_share * msn_money.shares_outstanding)
ten_cap_price = 10 * free_cash_flow_per_share
template_values = {
'ticker' : ticker,
'name' : msn_money.name if msn_money and msn_money.name else 'null',
Expand All @@ -68,6 +71,7 @@ def fetchDataForTickerSymbol(ticker):
'cash': msn_money.free_cash_flow_growth_rates if msn_money and msn_money.free_cash_flow_growth_rates else [],
'total_debt' : msn_money.total_debt,
'free_cash_flow' : computed_free_cash_flow,
'ten_cap_price' : ten_cap_price,
'debt_payoff_time' : round(float(msn_money.total_debt) / computed_free_cash_flow),
'debt_equity_ratio' : msn_money.debt_equity_ratio if msn_money and msn_money.debt_equity_ratio >= 0 else -1,
'margin_of_safety_price' : margin_of_safety_price if margin_of_safety_price else 'null',
Expand Down
18 changes: 17 additions & 1 deletion isthisstockgood/templates/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ $(document).ready(function() {
colorCellWithBackgroundColor('#' + key, Color.red());
}

// Update 10 Cap section
let ten_cap_key = 'ten_cap_price';
let ten_cap_field_id = '#' + ten_cap_key;
let current_price = data['current_price'];
updateHtmlWithValueForKey(data, ten_cap_key, /*commas=*/true);
if (!data[ten_cap_key]) {
colorCellWithBackgroundColor(ten_cap_field_id, Color.red());
}
if (current_price > data[ten_cap_key]) {
colorCellWithBackgroundColor(ten_cap_field_id, Color.red());
}
else {
colorCellWithBackgroundColor(ten_cap_field_id, Color.green());
}


// Update Market Cap numbers
updateHtmlWithValueForKey(data, 'average_volume', /*commas=*/true);
let averageVolume = data['average_volume'];
Expand Down Expand Up @@ -212,4 +228,4 @@ function colorCellWithIDForZeroBasedRange(id, range) {
}

colorCellWithBackgroundColor(id, backgroundColor);
}
}
2 changes: 1 addition & 1 deletion isthisstockgood/templates/json/stock_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"current_price" : {{ current_price }},
"sticker_price" : {{ sticker_price }},
"payback_time" : {{ payback_time }},
"ten_cap" : {{ ten_cap }},
"ten_cap_price" : {{ ten_cap_price }},
"average_volume" : {{ average_volume }}
}
2 changes: 1 addition & 1 deletion isthisstockgood/templates/loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

this.shadowRoot.append(style, wrapper);

this.animationTimeout = None;
this.animationTimeout = null;
}

static get observedAttributes() { return ['data-message']; }
Expand Down
6 changes: 3 additions & 3 deletions isthisstockgood/templates/searchbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class="col-md-3 nopadding">
<input
type="text"
autofocus
class="form-control"
id="ticker"
placeholder="Ticker Symbol"
maxlength=8
onkeydown="return validateInput(event)"/>
maxlength=8/>
</div>
<div class="col-md-1 nopadding">
<input
Expand All @@ -32,4 +32,4 @@

<script>
{% include "js/search.js" %}
</script>
</script>
2 changes: 1 addition & 1 deletion isthisstockgood/templates/ten_cap.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<thead class="thead-light">
<th>10 Cap Buy price</th>
</thead>
<td id="ten_cap">
<td id="ten_cap_price">
-
</td>
</tr>
Expand Down

0 comments on commit f4a8a5c

Please sign in to comment.