- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
Javascript麻瓜的練習:今天買不買股票
Exercise for Javascript Muggle: Buy or Not Buy the stock
- PER Price-to-Earning Ratio 本益比
- CashDividend 股利
- EPS Earning Per Share
- 如果希望買這個股票是15 年就還本 (PER=15),過去四年(2018, 2017, 2016, 2015) 平均下來,發的股利是每年平均一股 $3 (Average yearly cash dividend=$3),那麼根據這個期望值,這個股票的買點是每股 $3*15=$45。但是,這是由過去歷史來計算的。還不夠精確。我還想再加入考慮最近一年的情況。可是今年2019 的股利要等明年才發,如果我要今年買這個股票,我怎麼算出合理的買點?那就得拿最近四個 quarter 的 EPS 來估算明年可能的股利。
- estimated Cash Dividend for 2019 = total of last 4 quarterly EPS * confidence level,例如,最近四個 quarter 的 EPS,加總後是 $4。但是因為中美貿易戰可能影響獲利,所以 confidence level 我設定成 70%。PER =15。那就是說,買點應該是 $4*15*0.7=$42。
- 我把歷史參考價 $45 跟今年預估價 $42 加總 $87 再平均,就是 $43.5。這就是我的股票的買點。
- 如果今天 actual 股價是 $42,那就可以買啦!那如果是 $48,那就不買啦。
stock name: X
| |
Year
|
Cash Dividend
|
2015
|
4.5
|
2016
|
6
|
2017
|
6
|
2018
|
10
|
Avg (前四年平均股利)
|
(4.5+6+6+10)/4 = 6.5
|
- Historical reference price: calculate high price and low price for stock X
- High Price: CashDividend 6.5 * PER 20
- Low Price: CashDividend 6.5 * PER 15
Stock Name: A
|
EPS
|
2018-Q2
|
2.57
|
2018-Q3
|
5.91
|
2018-Q4
|
9.42
|
2019-Q1
|
3.75
|
2019 estimated Cash Dividend
|
2.57+5.91+9.42+3.75=21.65
|
- estimate to-date price: calculate high price and low price for stock X
- High Price: CashDividend 6.5 * PER 25 * confidence level 85%
- Low Price: CashDividend 6.5 * PER 15 * confidence level 85%
Historical Reference Price
|
Estimated Price
|
Avg Price * 85%
| |
high
|
6.5*25=162.5
|
21.65*25*0.85=460.0
|
(162.5+460)/2 = 311.3
|
low
|
6.5*15=97.5
|
21.65*15*0.85=276.0
|
(97.5+276.0)/2 = 186.8
|
- calculate the average Cash Dividend of last 4 years
- estimate the cash Dividend for current year 2019 by calculating the sum of last 4 quarterly EPS
- calculate the average of historical reference price and estimated to-date price
- Current price of stock X is 158. Your code should print the following message to the console:
- Name of stock: X, Current price: 158, Buy? Yes, cheap stock.
- Current price of stock X is 400. Your code should print the following message to the console:
- Name of stock: X, Current price: 400, Buy? No. expensive stock.
- Current price of stock X is 200. Your code should print the following message to the console:
- Name of stock: X, Current price: 200, Buy? Yes, inexpensive stock.
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
留言