Total Pageviews

2014/10/31

2014/10 Travel

億載金城

台南市移民署

四草紅樹林綠色隧道

台南林百貨

善化胡厝寮


鹿耳門天后宮


台南火車站

2014/10/29

How to read Excel file by Apache POI

Requirement
Assume we have an excel file, we would like to read the data which in sheet2.
We only need the amount in Column E and column I, and the value of Column A show be 'XXX年'

Here has sample code (focus on Line 17~33)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public class POITest {  
  private final static Logger LOG = LoggerFactory.getLogger(POITest.class);  
  /**  
   * The main method.  
   *   
   * @param args  
   *      the arguments  
   * @throws IOException  
   *       Signals that an I/O exception has occurred.  
    */  
   public static void main(String[] args) throws IOException {  
     String testFile = "D:\\work\\ifms\\TestFiles\\4102294114W75Y7OW0.xls";  
     Integer sheetNum = 1;  
     FileInputStream file = null;  
     try {  
       file = new FileInputStream(new File(testFile));  
       // Get the workbook instance for XLS file  
       HSSFWorkbook workbook = new HSSFWorkbook(file);  
       // Get the specific sheet from the workbook  
       HSSFSheet sheet = workbook.getSheetAt(sheetNum);  
       // Get iterator to all the rows in current sheet  
       Iterator rowIterator = sheet.iterator();  
       List list = new ArrayList<>();  
       while (rowIterator.hasNext()) {  
         Row row = rowIterator.next();  
         if (StringUtils.indexOf(row.getCell(0).toString(), "年") > 0) {//condition  
           Test test = new POITest().new Test();  
           test.setYear(row.getCell(0).toString());//column A  
           test.setGdp(new BigDecimal(row.getCell(4).getNumericCellValue()));//column E  
           test.setGnp(new BigDecimal(row.getCell(8).getNumericCellValue()));//column I  
           list.add(test);  
         }  
       }  
       for (Test vo : list) {  
         LOG.debug("vo=" + vo.toString());  
       }  
     } catch (FileNotFoundException e) {  
       throw new RuntimeException(e);  
     } catch (IOException e) {  
       throw new RuntimeException(e);  
     } finally {  
       file.close();  
     }  
   }  
   private class Test {  
     private String year;  
     private BigDecimal gdp;  
     private BigDecimal gnp;  
     public String getYear() {  
       return year;  
     }  
     public void setYear(String year) {  
       this.year = year;  
     }  
     public BigDecimal getGdp() {  
       return gdp;  
     }  
     public void setGdp(BigDecimal gdp) {  
       this.gdp = gdp;  
     }  
     public BigDecimal getGnp() {  
       return gnp;  
     }  
     public void setGnp(BigDecimal gnp) {  
       this.gnp = gnp;  
     }  
     public String toString() {  
       return ToStringBuilder.reflectionToString(this);  
     }  
   }  
 } 

Here is the log which print in console
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@2d7349d7[year=80,gdp=4958220,gnp=5093770]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@6bf4d990[year=81,gdp=5534544,gnp=5655306]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@17f7b44f[year=82,gdp=6110101,gnp=6224145]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@75ebad4[year=83,gdp=6685505,gnp=6793022]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@5c3bb813[year=84,gdp=7277545,gnp=7388464]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@54b216b3[year=85,gdp=7906075,gnp=8015577]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@77f06d35[year=86,gdp=8574784,gnp=8664395]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@4991f017[year=87,gdp=9204174,gnp=9272725]  
[main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@c299bbd[year=88,gdp=9649049,gnp=9739567]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@7faf9b87[year=89,gdp=10187394,gnp=10326952]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@620bfd8e[year=90,gdp=9930387,gnp=10122411]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@133a7ec[year=91,gdp=10411639,gnp=10654141]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@66557791[year=92,gdp=10696257,gnp=11025130]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@751d0513[year=93,gdp=11365292,gnp=11737391]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@44385e76[year=94,gdp=11740279,gnp=12031145]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@50c1b7f7[year=95,gdp=12243471,gnp=12555170]  
 [main] DEBUG g.n.e.w.c.Ets402rReportController - vo=gov.nta.ets.web.controller.Ets402rReportController$Test@5e14e28c[year=96,gdp=12910511,gnp=13243277] 

Reference
[1] http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/

2014/10/27

How to use Google Guava to do Collection Filter

Requirement

We have a collection data (List of value object), we would like to find the objects which fyr is 101. 
Here has the collection data:
1:  dtoList=[  
2:  gov.nta.fms.dto.FmsSumRateDto@1a395e5a[fyr=101,accmon=01,alc=168407392348.53,alcavg=0.0809],   
3:  gov.nta.fms.dto.FmsSumRateDto@2c617429[fyr=101,accmon=02,alc=164834284030.53,alcavg=0.0792],   
4:  gov.nta.fms.dto.FmsSumRateDto@32114682[fyr=101,accmon=03,alc=180965071697.53,alcavg=0.0869],   
5:  gov.nta.fms.dto.FmsSumRateDto@c2c1a7c[fyr=101,accmon=04,alc=165659472439.53,alcavg=0.0796],   
6:  gov.nta.fms.dto.FmsSumRateDto@237ec922[fyr=101,accmon=05,alc=180372232532.53,alcavg=0.0866],   
7:  gov.nta.fms.dto.FmsSumRateDto@58c6e962[fyr=101,accmon=06,alc=176357775471.53,alcavg=0.0847],   
8:  gov.nta.fms.dto.FmsSumRateDto@6b044e76[fyr=101,accmon=07,alc=187368376522.53,alcavg=0.09],   
9:  gov.nta.fms.dto.FmsSumRateDto@67bb5bdd[fyr=101,accmon=08,alc=181824695849.53,alcavg=0.0873],   
10:  gov.nta.fms.dto.FmsSumRateDto@3d8c3f5f[fyr=101,accmon=09,alc=170308922011.45,alcavg=0.0818],   
11:  gov.nta.fms.dto.FmsSumRateDto@4294958a[fyr=101,accmon=10,alc=168308032423.95,alcavg=0.0808],   
12:  gov.nta.fms.dto.FmsSumRateDto@28e5b92c[fyr=101,accmon=11,alc=179491195734.95,alcavg=0.0862],   
13:  gov.nta.fms.dto.FmsSumRateDto@1e00cae[fyr=101,accmon=12,alc=157844063362.95,alcavg=0.0758],   
14:  gov.nta.fms.dto.FmsSumRateDto@1c607478[fyr=102,accmon=01,alc=170969213258.95,alcavg=0.0806],   
15:  gov.nta.fms.dto.FmsSumRateDto@7e80d6[fyr=102,accmon=02,alc=159840653037.95,alcavg=0.0753],   
16:  gov.nta.fms.dto.FmsSumRateDto@713c61da[fyr=102,accmon=03,alc=169579370948.95,alcavg=0.0799],   
17:  gov.nta.fms.dto.FmsSumRateDto@333c694a[fyr=102,accmon=04,alc=169624940547.95,alcavg=0.0799],   
18:  gov.nta.fms.dto.FmsSumRateDto@4324938d[fyr=102,accmon=05,alc=173064277154.95,alcavg=0.0816],   
19:  gov.nta.fms.dto.FmsSumRateDto@1653306b[fyr=102,accmon=06,alc=169616844409.95,alcavg=0.0799],   
20:  gov.nta.fms.dto.FmsSumRateDto@2f8fcc40[fyr=102,accmon=07,alc=175060305269.95,alcavg=0.0825],   
21:  gov.nta.fms.dto.FmsSumRateDto@9aa9625[fyr=102,accmon=08,alc=193638114494.95,alcavg=0.0913],   
22:  gov.nta.fms.dto.FmsSumRateDto@1e675c18[fyr=102,accmon=09,alc=198567712906.95,alcavg=0.0936],   
23:  gov.nta.fms.dto.FmsSumRateDto@13cf3b40[fyr=102,accmon=10,alc=181427982270.95,alcavg=0.0855],   
24:  gov.nta.fms.dto.FmsSumRateDto@a3af0e9[fyr=102,accmon=11,alc=187353709301.95,alcavg=0.0883],   
25:  gov.nta.fms.dto.FmsSumRateDto@239e563e[fyr=102,accmon=12,alc=172980508042.95,alcavg=0.0815]  
26:  ]  


How to Use Google Guava API
1. Create Predicate instance to determines a true or false value for a given input. (Line1~Line7)
2. Utilize Collection2.filter to return the elements of unfiltered that satisfy a predicate.(Line8~line9)

Here has the code snippet:
1:     Predicate predicate = new Predicate() {  
2:        @Override  
3:        public boolean apply(FmsSumRateDto input) {  
4:          //Determines true or false value for a given input.  
5:          return "101".equqls(input.getFyr());  
6:        }  
7:      };  
8:      //Returns the elements of unfiltered that satisfy a predicate.  
9:      Iterator result = Collections2.filter(dtoList, predicate).iterator();  
10:      while(result.hasNext()) {  
11:        log.debug("result="+result.next().toString());  
12:      }  

Here is the result which statisfy the predicate:
1:  result=gov.nta.fms.dto.FmsSumRateDto@1a395e5a[fyr=101,accmon=01,alc=168407392348.53,alcavg=0.0809]  
2:  result=gov.nta.fms.dto.FmsSumRateDto@2c617429[fyr=101,accmon=02,alc=164834284030.53,alcavg=0.0792]  
3:  result=gov.nta.fms.dto.FmsSumRateDto@32114682[fyr=101,accmon=03,alc=180965071697.53,alcavg=0.0869]  
4:  result=gov.nta.fms.dto.FmsSumRateDto@c2c1a7c[fyr=101,accmon=04,alc=165659472439.53,alcavg=0.0796]  
5:  result=gov.nta.fms.dto.FmsSumRateDto@237ec922[fyr=101,accmon=05,alc=180372232532.53,alcavg=0.0866]  
6:  result=gov.nta.fms.dto.FmsSumRateDto@58c6e962[fyr=101,accmon=06,alc=176357775471.53,alcavg=0.0847]  
7:  result=gov.nta.fms.dto.FmsSumRateDto@6b044e76[fyr=101,accmon=07,alc=187368376522.53,alcavg=0.09]  
8:  result=gov.nta.fms.dto.FmsSumRateDto@67bb5bdd[fyr=101,accmon=08,alc=181824695849.53,alcavg=0.0873]  
9:  result=gov.nta.fms.dto.FmsSumRateDto@3d8c3f5f[fyr=101,accmon=09,alc=170308922011.45,alcavg=0.0818]  
10:  result=gov.nta.fms.dto.FmsSumRateDto@4294958a[fyr=101,accmon=10,alc=168308032423.95,alcavg=0.0808]  
11:  result=gov.nta.fms.dto.FmsSumRateDto@28e5b92c[fyr=101,accmon=11,alc=179491195734.95,alcavg=0.0862]  
12:  result=gov.nta.fms.dto.FmsSumRateDto@1e00cae[fyr=101,accmon=12,alc=157844063362.95,alcavg=0.0758] 


Reference


2014/10/23

要去哪裡查詢零股交易的相關資訊


有時候股票除了配現金以外,還會給零股給投資大眾,為了讓買賣比較容易(因為零股只能利用盤後交易),故通常會利用盤後交易來買零股湊成一張

我們如果要去查詢零股最佳一檔買、賣價格的話,可以到基本市況報導網站( http://mis.twse.com.tw/stock/oddTrade.jsp ) 查詢



 假設如果我要找的是『食品類股』,在上市類股下拉單選取『食品工業』

 該網站就會顯示相關食品類股的零股揭示買價、賣價、成交價以及成交股數


有關零股更多資訊可以參考 http://www.masterlink.com.tw/service/qanda/Q&A-6.htm 

2014/10/21

How to copy text from Notepad++ to Microsoft Word and keep its color to distinguish keywords


Notepad++ can distinguish between different languages source code can be written in. For example, a language could distinguish certain keywords that have to be differently interpreted, and as such it can be useful to distinguish these keywords using another color or font. 


For example.
The language is Java.

The language is SQL.


Scenario
If we would like to copy SQL statement from Notepad++ to Microsoft Word in my system design document, but it seems cannot keep its color to distinguish keywords. 
For example.

Resolution
Step1. Select text you would like to copy.

Step2. Plugins --> NppExport --> Copy RTF to clipboard

Step3. Paste text to Microsoft word


2014/10/16

How to display Tradition Chinese Character in Git Bash

Problem
Why I cannot display Tradition Chinese Character in Git Bash correctly?

Solution
You need to edit three files under git\etc

1. edit gitconfig file and append configuration as following:
1:  [gui]  
2:  encoding = utf-8   
3:  #log编码  
4:  [i18n]  
5:  commitencoding = utf-8   
6:  #支持中文路径  
7:  [svn]  
8:  pathnameencoding = utf-8   

2. edit git-completion.bash file and append configuration  as following:
1:  #正常顯示中文  
2:  alias ls='ls --show-control-chars --color=auto'  

3. edit inputrc file and append configuration  as following:
1:  #bash中可以正常输入中文  
2:  set output-meta on   
3:  set convert-meta off  

Check Result

2014/10/15

JRebel - Reload any changes without restart server

As a developer, we do not want to waste time to restart server again and again to see the implace of code changes.
You can try JRebel to save your time.

If you are using Eclipse, here has good step-by-step installation and configuration guide: http://manuals.zeroturnaround.com/jrebel/ide/eclipse.html

For more information, please check http://zeroturnaround.com/software/jrebel/learn/

Demo

Here has code snippet, and it will print debug message as entering this method
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  @RequestMapping(value = "/query/tab1", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)  
  public @ResponseBody  
  List findTab1(@RequestBody Fms420rFormBean formBean, Alerter alerter) {  
    log.debug("test");  
    List dataList = service.queryTab1(formBean.getYear(), formBean.getMonth());  
    if (CollectionUtils.isEmpty(dataList)) {  
      alerter.info(Messages.warning_notFound());  
    } else {  
      alerter.info(Messages.success_find());  
     }  
     return dataList;  
   } 

And the console will print "test" debugging message as entering this method:
1:  19:15:45,493 INFO [stdout]  [20123] DEBUG gov.nta.fms.web.rest.Fms420rResource - test  

In order to test JRebel, I just modified the debug message to "JRebel test" and submit query without restart application server
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 @RequestMapping(value = "/query/tab1", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)  
 public @ResponseBody  
 List findTab1(@RequestBody Fms420rFormBean formBean, Alerter alerter) {  
   log.debug("JRebel test");  
   List dataList = service.queryTab1(formBean.getYear(), formBean.getMonth());  
   if (CollectionUtils.isEmpty(dataList)) {  
     alerter.info(Messages.warning_notFound());  
   } else {  
     alerter.info(Messages.success_find());  
    }  
    return dataList;  
  } 
 
See....I don't redeploy and restart application server, but the console print the up-to-date debug message. 
1:  19:16:19,742 INFO [stdout]  [20123] DEBUG gov.nta.fms.web.rest.Fms420rResource - JRebel test  

It's because of JRebel reload any changes classes automatically. 
When you change any class or resource in your IDE, the change will reflect in you application immediately, skipping the build and redeploy phases.




2014/10/14

How to find out the PID (process ID) of processes in Windows

Problem
If I would like to find out the PID of javaw.java proecess, how do I do?
Windows task manager seems does not have PID information.

Solution 1
View-->Selected Columns-->Checked PID-->OK

Then we can find out the PID information.


Solution 2
Open command prompt, and execute tasklist /fi "Imagename eq JAVAW.exe"
Then we can get the PID information
映像名稱                       PID 工作階段名稱      工作階段 #    RAM使用量
========================= ======== ================ =========== ============
javaw.exe                    10368 Console                    1  1,620,884 K



Reference

2014/10/01

[閱讀筆記] 拆開獲利的糖衣



  1. 債券價格的變動與利率負相關,利率上升,債券價格會下跌;利率下降,債券價格會上漲
  2. 短期投資來說,股票的波動大於債券。但是,若是拉長到30年,股票的波動只有債券的一半,但報酬好很多
  3. 波動是投資主要風險,但不是唯一風險。對許多長期投資者來說,如果採用波動不夠大的投資組合,這樣的投資成本長期看來會造成更大的壞處
  4. 多頭市場是在悲觀中生成,在懷疑中成長,在樂觀中成熟,在亢奮中消逝
  5. 股市是經濟的領先指標,投資人不會等經濟資料顯示經濟復甦才開始投資,他們會提前哄抬股價
  6. 如果你的投資期間很長,長期來說,由於貨幣升貶本質是零和、不規則的循環,貨幣對全球投資組合的影響會互相抵消,接近于零
  7. 貨幣的波動很大,長期來說,投資人很難掌握短期的市場時機,靠交易外匯獲利
  8. 如果每個人都在關注某一件事,你知道你可以放心忽略那件事,往別的方向看,關注大家沒注意的事,以及可能對未來市場走向有很大影響的事
  9. 衡量市場氛圍往往不是一種科學,反而更像藝術


2014/09/30

2014/09 南投

溪頭漢光樓

大學池


溪頭天空步道




竹山紫南宮



2014/09/25

[閱讀筆記] 漫步華爾街

  1. 股價過去的波動不能用來準確預測未來的走勢,因為股市沒有記憶
  2. 股價循環就和賭徒的好壞運一樣,沒有週期可言
  3. 股價波動的歷史,並不能提供有用的資訊,讓投資大眾在管理投資組合時,能持續表現得比長期持有更好
  4. 設定停損點來做買賣,在考慮高額佣金後,使用這套辦法買個股或股票指數,並不一定能勝過簡單的買進持有策略。因此個別投資者最好避免使用這套辦法,以及避開推薦他的經紀人
  5. 頻繁進出股市的代價是,你的交易手續費會大增,計入手續費成本後,投資人所獲反不如簡單地買進並持有多種股票
  6. 技術分析的信號和接下來的股價表現間沒有關係。如果你跟著信號買進賣出,扣掉手續費,報酬仍不比買進持有好
  7. 籃球選手上一次射進籃框與下一次射進籃框的無關,其影響的是球員的『預期』,不是『表現』。股市情況亦然,昨日上漲,所以預期今日也會上漲,過去表現良好,所以預期未來也會表現良好
  8. 相信股市大師預言的人,必定抱憾而終
  9. 股市的行為是隨機漫步的,他就像一個醉漢,在空曠的地面上顢頇行走,他是非理性的,他是不可預測的
  10. 證券分析師無法預測長期持續的成長,因為這根本不存在
  11. 無論是穩定的公共事業,或是隨景氣循環起伏的電子公司,沒有一個產業是容易預測的
  12. 證券分析師平均每年錯誤率為31.3%,代表其在預測時,面對著極大的困難。投資人進行投資決策時,如果盲從這些預測,最後往往希望落空
  13. 影響分析師預測的五大因素:ㄧ、隨機事件的影響;二、創意的會計程序創造令人存疑的盈餘;三、分析師能力不足;四、最好的分析師往往轉任銷售部門或擔任投資組合的管理;五、在擁有大量投資銀行業務的公司裡,分析師面對利益衝突的困境
  14. 公司的損益表好比三點式泳裝,露出來的部分有趣,遮住的地方更重要
  15. 世俗的智慧告訴我們,隨俗而失敗,比不隨俗而成功,更能得到讚美
  16. 投資人購買共同基金的獲利,並不比買進並持有沒有管理的廣泛股票指數好
  17. 共同基金以往的良好績效不能用來推測其未來績效。決定基金績效排名的一項重要因素,仍然是我們的老朋友-運氣
  18. 宣布股票分割不能帶來有用的新資訊,雖然宣布股票分割的公司其股價在宣布的前一段時間就上漲了,宣布後的相關表現卻和市場其他股票沒什麼兩樣。蛋糕不會因為多切幾塊而變大
  19. 股價的變動非常快速,快到沒有人每次都能迅速的從中獲利。如新聞的發生是隨機的,無法預測的,不論是研讀過去的技術資料或基本面資料,都沒有幫助
  20. 股票的價值取決於未來的成長幅度和持續時間,但是要估計它們非常困難
  21. 如果過去股價對於預測未來股價沒什麼用,就不必採用任何技術分析規則來選擇買賣時間點。簡單的買進並長期持有,並不亞於任何技術分析策略
  22. 市場經常反應過度,因此最好遠離眼前時髦的股票,專注於購買那些目前失寵的股票
  23. 尋找價值的投資人,要選擇本益比低、股價與帳面價值比低的股票。價值是基於目前的現實而非未來
  24. 股價與帳面價值比低的股票,未來報酬通常較高
  25. 選擇低本益比的股票比較好,如果成長實現,將帶來加倍利潤;若成長失敗,損失也有限
  26. 股票是衡量機制,不是投票機制
  27. 購買可展期的定期保險,你可以不斷更新保單而不必重新體檢。所謂「遞減」的定期保險是,保單更新時保額可逐次降低,因為隨著時間逝去,需要的保險會跟著遞減
  28. 決定股票報酬三因素:購買時的股利報酬率、盈餘成長率、本益比的改變
  29. 債券的報酬決定於購買時債券到期日的報酬率、利率的改變對債券價格的影響
  30. 平均成本投資法是指在一段很長的時間中,每隔一段時間已一定的金額購買投資標的,如此可以大大減低股票投資風險,因為不會發生所有股票都在最高點的情形
  31. 投資普通股票和債券的持有期越長,風險就越低,但是你得有耐性忍受過程中,投資價值逐年波動的情形
  32. S&P 500指數的表現,長期優於共同基金與機構投資人的平均績效。成長型和價值型共同基金能勝過股票指數的,屈指可數
  33. 四項成功選股原則:只購買至少維持五年盈餘成長超過平均的股票、不購買股價高於合理價值的股票、購買有故事題材的股票、盡可能減少進出
  34. 事實上,少數表現超群、打敗超群的人,其成功有99%可能來自運氣,雖然人們自吹自捧自己的行動,但是那多半來自機運,較少來自偉大的構想



2014/09/21

如何知道債券配息的金額是否來自本金


當我們在看一些基金或債券的資訊的時候,常會看到類似這樣的警語:本基金主要係投資於非投資等級之高風險債券且配息來源可能為本金

有看到這句警語的話,就要想一下,每個月配給我們的現金,是不是從我們的本金拿出來的,如果是的話,就要考慮一下了,那我們要怎麼知道配給我們的現金有沒有從本金拿出來呢?當他的宣傳廣告宣稱有5%年化報酬率,是不是真的有5%呢?

我們分別會需要四個資訊:年化配息率、可分配淨利益佔配息比率、本金佔配息比率以及還原配息率,以下會以聯博全球高收益債券基金AT股當做範例

1. 年化配息率
年化配息率 = 每單位配息金額 / 淨值 * 12
鉅亨網得來的資訊,每單位配息金額為0.0213,淨值為4.67


所以,年化配息率為

2, 3 可分配淨利益佔配息比率、本金佔配息比率
先到聯博的網站找出此檔基金

點進去該檔基金後,滑鼠往下滾,可以找到配息組成詳情

打開pdf後可以看到可分配淨利益佔配息比率、本金佔配息比率


 4. 還原配息率
查到可分配淨利益佔配息比率、本金佔配息比率以後,可以得知其報酬率名符其實,因為本金佔配息比率是0%,所以還原配息率=年化配息率*可分配淨利益佔配息比率還是5.47%


如果用另外一檔房貸收益基金AT股,來看從其每單位分配金額除以淨值,可以得出他的年化配息率是4.99%,但是實際上本金佔配息比例高達51%,所以經過還原以後,實際上的配息率只有2.45%





2014/09/07

Warren Buffett's 23 Most Brilliant Insights About Investing

挺不錯的投資建議
  1. Buying a stock is about more than just the price. 
  2. You don't have to be a genius to invest well.
  3. But, master the basics. 
  4. Don't buy a stock just because everyone hates it. 
  5. Bad things aren't obvious when times are good.
  6. Always be liquid.
  7. The best time to buy a company is when it's in trouble. 
  8. Stocks have always come out of crises. 
  9. Don't be fooled by that Cinderella feeling you get from great returns.
  10. Think long-term. 
  11. Forever is a good holding period. 
  12. Buy businesses that can be run by idiots. 
  13. Be greedy when others are fearful.
  14. You don't have to move at every opportunity.
  15. Ignore politics and macroeconomics when picking stocks.
  16. The more you trade, the more you underperform. 
  17. Price and value are not the same. 
  18. There are no bonus points for complicated investments. 
  19. A good businessperson makes a good investor.
  20. Higher taxes aren't a dealbreaker.
  21. Companies that don't change can be great investments.
  22. Time will tell.
  23. This is the most important thing. "Rule No. 1: never lose money; rule No. 2: don't forget rule No. 1"

發現最近看的幾本書,漸漸歸納出一些原則
  • 要正確預測未來股價、營收成長是很難的,所以股價長跌勢不可預測的,這就是統計學家或經濟學家所提出的隨機漫步(random walk)
  • 投資的原則越簡單越好
  • 股價不代表其真實價值,運用本益比來協助判斷
  • 不要購買股價高過其價值的股票
  • How to Value a Business, and How to Think About Market Prices是兩個最基本且重要的課題
  • 長期持有的報酬率,遠大於一直殺進殺出的投資人
  • 找個笨蛋都能會經營的產業
  • 汰弱留強,好的股票繼續持有,不好的股票就賣掉
  • 長期來說,股市報酬率會是正數
  • 危機入市
  • 不要跟著群眾一窩蜂,在人們恐懼時貪婪,在人們貪婪時恐懼

http://www.businessinsider.com/warren-buffetts-investing-quotes-2014-8?op=1


2014/09/06

A good web site to learn AngularJS


If we would like to learn AngularJS, you can go to here, http://jsbin.com/, to learn. You just need a web browser, do not need to have any IDE(Integrated Development Environment) tools.

Here has a quick start.
1. Go to http://jsbin.com/

2. Click "Add Library"


3. Choose "Angular 1.2.14 stable"


 4. It will import "angular.min.js" automatically

5. Place "ng-app" directive in html tag 

6. create a input text for typing name

7. Check output preivew

8. Design the welcome message as user type in name

9. Demo