- 大部分民眾把理財一事看得太簡單,也太輕率。投資前甚少做足周密的功課,投資產生虧損時則選擇長期持有,認為不賣出就沒有虧損
- 投資四大關鍵
- 高獲利一定伴隨高風險
- 投資過熱後一定泡沫化,歷史總是不斷的重演
- 人性是理財的最大殺手,唯有反市場操作才能投資獲利
- 認清金融機構的遊戲規則,才不會淪為短線進出幫金融業者賺手續費
- 所有投資都伴隨著風險,應先認清自己的希望與需求是什麼,冀求一蹴可幾,可能跌跌撞撞還不見得到的了終點站,掌握局面循序漸進,反倒可以安穩到達目的地
- 在國家國事強大時買進公債的人,報酬率會遠低於國家風雨飄搖之際買進的投資人,因為情勢危急,所以債券需要用更高的預期報酬來補償、吸引投資人。又如狀況差的公司,正因風險較高,所以需要用比較高的報酬補償投資人。所以我們能掌握,報酬就是來自於承擔風險。有了這種理解,可以使投資人面對市場大跌時,具備買進的勇氣。因為他會知道,這正是金融資產預期報酬較高的時候。正確的理解,將帶來低點買進的勇氣。正確的觀念,才是獲取更高報酬的基礎
- 雖然說報酬來自於風險,但不是去冒風險就一定有報酬。高風險資產所成弄的是更高的「預期」報酬,注意,是「預期」,未必是「實際」。投資不是膽子大的人就會贏,投資是一個小心地在金融市場中,承擔必要風險的大腦活動
- 投資風險有兩個面相,一個是來自市場,另一個來自於投資人自己
- 在上漲時樂觀地買進,在下跌中悲觀地賣出,這種高買低賣的行為,是標準且常見的財務自殺
- 歷史一再重演,這些最悲觀、大家都說市場最不值得投資的時刻,往往就是預期報酬最高的時間點
- 投資大眾很有趣的一點就在於:大家都承認市場是不理性的,但是每一個人都覺得自己是理性的
- 投資不是只有下跌的風險,錯過報酬一樣是風險
- 很多基金業者的專長不是資產管理,是行銷,他們是行銷業者,只是剛好在賣基金
- 投資是一個務實的過程,能幫助自己達成人生各階段重要目標的投資計畫,就是滿分的投資
- 看的越多,越覺得自己所知不足
- 幾乎所有投資管理人的績效表現都歸功於運氣,而非技術
- 你最大的投資風險在於「沒有妥善地分散資產」
- 投資組合真正重要的關鍵在於整體投資組合的表現如何,而不在於單一資產的表現狀況
- 人們總是被那些成功機率極小的高報酬方案所吸引,儘管在樂透彩每投資一美元的平均報酬不過 0.5 美元。讓自己變窮的最快方法就是講自己的投資首要目標設定成找到 next google
- 大多數投資者常見的病態投資行為有:
- 傾向極端過度自信
- 系統性地在特定類別股票上投資過多
- 在高成本的情況下,過度頻繁交易
- 經常非理性的進出股市
- 經紀商不是你的朋友,基金公司的利益和你的利益是相衝突的
- 基金公司只為了一個目的而存在:從投資大眾的行為中收取費用和佣金
Total Pageviews
2018/01/02
[閱讀筆記] The Four Pillars of Investing (1/12)
Labels:
Investment,
Reading
2018/01/01
[閱讀筆記] Purple Cow (1/2)
- 做為一頭 purple cow 的元素,就是必須 remarkable (卓越非凡)。remarkable 是指值得討論、注意的事情,獨一無二且全新有趣
- 保有一個老客戶所花的錢,比開發一個新客戶所花的錢便宜多了
- 世界已經改變,人們有太多的選擇,但時間卻越來越少,也讓人不知從何選擇起
- 除了利用科技和專業配合顧客的標準製造更好的商品之外,同時也邀請使用者體驗,並改變顧客的行為,你的商品效果將出奇的好
- 在還居於市場領先地位時,要把握該得的利潤,別再把錢花在市調研究上,把市場價格提高到合理的地位,把獲得的利潤投入吹造更有前瞻性的新產品上
- 不要投資在垂死的產品,要把獲得的利潤投資在建立新產品上
- 沒人會急著去使用你的新產品,大多消費者都是滿足現況、停滯不前的。你該把新產品賣給那些喜歡改變、喜歡嘗試新東西的消費者,他們會積極發掘你是葫蘆裡賣什麼藥的人,然後將你的創意傳播出去
- 你必須設計出卓越非凡的產品,吸引「早期接受者」;同時這項產品必須設計的夠彈性、夠討喜,能夠讓「早期接受者」輕易、快速地傳播出去
- 你該做的是,設計卓越非凡的產品,主打摩爾曲線左邊的「早期接受者」,然後讓「早期接受者」推銷出去
- 一個新商品,就是一個創意。能被傳播的創意,遠比不能流傳的創意容易成功,這就是所謂的「創意病毒」(ideavirus)。該如何創造出ideavirus,就是絕對不是試圖製造一個大家都可以適用的產品,為自己的產品找到一個特殊的市場,而非最大市場。
- 現在是一個消費者自主選擇的時代,是消費者決定要不要聽你說話,還是忽略你的存在
- 面對沒有人願意聽你說話的市場,最聰明的計畫就是「走為上策」
- 別盡想著要滿足所有人的需求,如果可以選擇,應該讓廣告(和產品)滿足你所選擇的客戶的需求,試著想想,如何開發這群人、向他們宣傳,就別在乎其他人了
- 如果你可以找出一個人別人無法提供服務的利基,並且提供這項服務,結果會如何?為什麼不開發一個與你自己競爭的產品,一個在市場上突出而引人注目的商品?
- 在商品充斥的市場中,和別人相同就是失敗;在競爭對手林立的市場中,平凡就是代表隱形
- 平凡無奇永遠是最危險的策略,平凡無趣永遠註定要失敗
- 評量的意義在於讓你知道哪裡有破洞,才知道要去修補。只要你願意做評量,就有改善的可能
- 在擁有一些不凡的成功事蹟之後,事業生活一帆風順通常是容易的,也以致於無法決定是否參加下一回合的戰火,而把時間和精力花在鞏固已經得到的東西,而不願意投資在未來的發展
- 一旦你準備創造某些真正卓越非凡的東西,你的挑戰就是同時處理這兩件事情
- 任何為乳牛添加養分的事情都是值得做的,要想辦法延續紫牛的生命,並且盡可能拉長從紫牛身上獲利的時間
- 創造一個你可以即時創造新紫牛的環境,在地一支子牛利潤竭盡時,隨時取而代之
- 正確的行銷是:把行銷的重點放在可以改變產品哪些設計,而不是廣告包裝上
Labels:
Reading
2017/12/11
[Fortify] Fix Path Manipulation
Problem
Before
Original code snippet:
After
Add dependency in your pom.xml
Updated code snippet:
Before
Original code snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public static List<String> readFile(String file) throws TdccInitException, IOException { List<String> rows = new ArrayList<>(); if (!StringUtils.isNotEmpty(file)) { throw new TdccInitException("Please assign file, must not be empty or null"); } Boolean isFileExisted = Files.exists(Paths.get(file)); if (!isFileExisted) { throw new TdccInitException(MessageFormat.format(wrongFileErr, file)); } else { rows = com.google.common.io.Files.readLines(new File(file), Charsets.UTF_8); } return rows; } |
After
Add dependency in your pom.xml
1 2 3 4 5 6 | <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency> |
Updated code snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public static List<String> readFile(String file) throws TdccInitException, IOException { List<String> rows = new ArrayList<>(); if (!StringUtils.isNotEmpty(file)) { throw new TdccInitException("Please assign file, must not be empty or null"); } file = FilenameUtils.normalize(file); Boolean isFileExisted = Files.exists(Paths.get(file)); if (!isFileExisted) { throw new TdccInitException(MessageFormat.format(wrongFileErr, file)); } else { rows = com.google.common.io.Files.readLines(new File(file), Charsets.UTF_8); } return rows; } |
Labels:
Fortify
2017/12/10
[DBCP2] [DB2] java.lang.AbstractMethodError: com.ibm.db2.jcc.t4.b.isValid(I)Z
Problem
I am using DBCP2 as my third party library to do connection pool.
But as I try to get connection it throws exception:
How-To
Owing to the isValid method was added in JDBC 4.0. I need to change IBM DB2 class from db2jcc.jar (JDBC 3.0) to db2jcc4.jar (JDBC 4.0), then this problem will be solved.
Reference
[1] https://stackoverflow.com/questions/37193965/java-lang-abstractmethoderror-com-ibm-db2-jcc-t4-b-isvalidiz
I am using DBCP2 as my third party library to do connection pool.
But as I try to get connection it throws exception:
java.lang.AbstractMethodError: com.ibm.db2.jcc.t4.b.isValid(I)Z
How-To
Owing to the isValid method was added in JDBC 4.0. I need to change IBM DB2 class from db2jcc.jar (JDBC 3.0) to db2jcc4.jar (JDBC 4.0), then this problem will be solved.
Reference
[1] https://stackoverflow.com/questions/37193965/java-lang-abstractmethoderror-com-ibm-db2-jcc-t4-b-isvalidiz
Labels:
Apache Project
2017/12/09
[Maven] How to assign WAR file name in pom.xml
Problem
When I utilize maven to build WAR file, the WAR file name always suffix by version which define in pom.xml (i.e. StockQry-1.0.war).
If I would like to have StockQry.war instead of StockQry-1.0.war, how to do it?
When I utilize maven to build WAR file, the WAR file name always suffix by version which define in pom.xml (i.e. StockQry-1.0.war).
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 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>StockQry</groupId> <artifactId>StockQry</artifactId> <version>1.0</version> <packaging>war</packaging> <build> <sourceDirectory>src</sourceDirectory> <resources> <resource> <directory>src</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> <plugins> <!-- ignore plugins --> </plugins> </build> <dependencies> <!-- ignore dependencies --> </dependencies> </project> |
How-To
Add finalName in build tag, the updated pom.xml are the following:
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 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>StockQry</groupId> <artifactId>StockQry</artifactId> <version>1.0</version> <packaging>war</packaging> <build> <finalName>StockQry</finalName> <sourceDirectory>src</sourceDirectory> <resources> <resource> <directory>src</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> <plugins> <!-- ignore plugins --> </plugins> </build> <dependencies> <!-- ignore dependencies --> </dependencies> </project> |
2017/12/08
[Java] How to write text message to IBM MQ?
Problem
I am using IBM MQ as my queue service.
How to write text message into IBM MQ by Java?
How-To
Here has sample code:
I am using IBM MQ as my queue service.
How to write text message into IBM MQ by Java?
How-To
Here has sample code:
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | package com.xxx.mql.service; import java.io.IOException; import java.util.Enumeration; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.commons.lang.StringUtils; import com.ibm.mq.jms.MQQueueConnection; import com.ibm.mq.jms.MQQueueConnectionFactory; import com.ibm.mq.jms.MQQueueReceiver; import com.ibm.mq.jms.MQQueueSender; import com.ibm.mq.jms.MQQueueSession; import com.tdcc.mql.enumeration.MQParamKeyType; import com.tdcc.mql.utils.MqlUtils; import lombok.extern.slf4j.Slf4j; @Slf4j public class TestMQService { private static TestMQService mqServuce; private static String mqHost = MQParamKeyType.MQ_HOST.getSystemValue(); private static String mqChannel = MQParamKeyType.MQ_CHANNEL.getSystemValue(); private static String mqUser = MQParamKeyType.MQ_USER.getSystemValue(); private static String mqPwd = MQParamKeyType.MQ_PASSWORD.getSystemValue(); private static String mqQueueMgr = MQParamKeyType.MQ_QUEUEMGR.getSystemValue(); private static String mqPort = MQParamKeyType.MQ_PORT.getSystemValue(); public static TestMQService getInstance() { if (mqServuce == null) { mqServuce = new TestMQService(); return mqServuce; } else { return mqServuce; } } /** * Send Message to MQ. * * @param queueName * @param message * @throws JMSException */ public void writeMessageToMQ(String queueName, String message) throws JMSException { MQQueueConnectionFactory connFactory = new MQQueueConnectionFactory(); MQQueueSender sender = null; MQQueueSession session = null; MQQueueConnection connection = null; try { connFactory.setHostName(mqHost); connFactory.setPort(Integer.parseInt(mqPort)); connFactory.setTransportType(1); connFactory.setQueueManager(mqQueueMgr); connFactory.setChannel(mqChannel); connection = (MQQueueConnection) connFactory.createQueueConnection(); session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); sender = (MQQueueSender) session.createSender(queue); connection.start(); TextMessage textMsg = session.createTextMessage(); textMsg.setText(message); sender.send(textMsg); } catch (JMSException e) { log.error(MqlUtils.toStackTrace(e)); } finally { if (sender != null) { sender.close(); } if (session != null) { session.close(); } if (connection != null) { connection.close(); } } } } |
Labels:
Java
2017/12/07
[Java] ClassCastException : cannot cast javax.jms.Message to javax.jms.TextMessage
Problem
I get ClassCastException when I read IBM MQ queue message by Java.
The code snippet looks like:
How-to
According to original requirement, the queue message should be text format.
Different content format will use different interface:
But actually it may has non-text format in IBM MQ, so I need to check its class type before do cast.
The updated code snippet are as bellows:
Reference
[1] https://docs.oracle.com/javaee/6/api/javax/jms/Message.html
I get ClassCastException when I read IBM MQ queue message by Java.
The code snippet looks like:
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | package com.xxx.mql.service; import java.io.IOException; import java.util.Enumeration; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.commons.lang.StringUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.base.Strings; import com.ibm.mq.jms.MQQueueConnection; import com.ibm.mq.jms.MQQueueConnectionFactory; import com.ibm.mq.jms.MQQueueReceiver; import com.ibm.mq.jms.MQQueueSession; import com.tdcc.common.type.MQInfoEnum; import com.tdcc.mql.utils.MqlUtils; import lombok.extern.slf4j.Slf4j; @Slf4j public class TestMQService { private static TestMQService mqServuce; private static String mqHost = MQInfoEnum.MQ_HOST.getValue(); private static String mqChannel = MQInfoEnum.MQ_CHANNEL.getValue(); private static String mqUser = MQInfoEnum.MQ_USER.getValue(); private static String mqPwd = ""; private static String mqQueueMgr = MQInfoEnum.MQ_QUEUEMGR.getValue(); public static TestMQService getInstance() { if (mqServuce == null) { mqServuce = new TestMQService(); return mqServuce; } else { return mqServuce; } } /** * 透過 JMS 去取得 queue message. * * @param queueName * @return * @throws JMSException */ public String readMessageByJMS(String queueName) throws JMSException { MQQueueConnectionFactory connFactory = new MQQueueConnectionFactory(); MQQueueReceiver receiver = null; MQQueueSession session = null; MQQueueConnection connection = null; String message = ""; try { // Config connFactory.setHostName(mqHost); connFactory.setPort(1414); connFactory.setTransportType(1); connFactory.setQueueManager(mqQueueMgr); connFactory.setChannel(mqChannel); connection = (MQQueueConnection) connFactory.createQueueConnection(); session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); receiver = (MQQueueReceiver) session.createReceiver(queue); connection.start(); if (receiver != null) { Message msg = receiver.receiveNoWait(); if (msg == null) { message = ""; } else { TextMessage textMsg = (TextMessage) msg; message = StringUtils.defaultIfBlank(textMsg.getText(), ""); } } } catch (JMSException e) { log.error(MqlUtils.toStackTrace(e)); } finally { if (receiver != null) { receiver.close(); } if (session != null) { session.close(); } if (connection != null) { connection.close(); } } log.info("[readMessageByJMS] message = " + message); return message; } } |
How-to
According to original requirement, the queue message should be text format.
Different content format will use different interface:
But actually it may has non-text format in IBM MQ, so I need to check its class type before do cast.
The updated code snippet are as bellows:
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | package com.xxx.mql.service; import java.io.IOException; import java.util.Enumeration; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; import javax.jms.QueueBrowser; import javax.jms.Session; import javax.jms.TextMessage; import org.apache.commons.lang.StringUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.base.Strings; import com.ibm.mq.jms.MQQueueConnection; import com.ibm.mq.jms.MQQueueConnectionFactory; import com.ibm.mq.jms.MQQueueReceiver; import com.ibm.mq.jms.MQQueueSession; import com.tdcc.common.type.MQInfoEnum; import com.tdcc.mql.utils.MqlUtils; import lombok.extern.slf4j.Slf4j; @Slf4j public class TestMQService { private static TestMQService mqServuce; private static String mqHost = MQInfoEnum.MQ_HOST.getValue(); private static String mqChannel = MQInfoEnum.MQ_CHANNEL.getValue(); private static String mqUser = MQInfoEnum.MQ_USER.getValue(); private static String mqPwd = ""; private static String mqQueueMgr = MQInfoEnum.MQ_QUEUEMGR.getValue(); public static TestMQService getInstance() { if (mqServuce == null) { mqServuce = new TestMQService(); return mqServuce; } else { return mqServuce; } } /** * 透過 JMS 去取得 queue message. * * @param queueName * @return * @throws JMSException */ public String readMessageByJMS(String queueName) throws JMSException { MQQueueConnectionFactory connFactory = new MQQueueConnectionFactory(); MQQueueReceiver receiver = null; MQQueueSession session = null; MQQueueConnection connection = null; String message = ""; try { // Config connFactory.setHostName(mqHost); connFactory.setPort(1414); connFactory.setTransportType(1); connFactory.setQueueManager(mqQueueMgr); connFactory.setChannel(mqChannel); connection = (MQQueueConnection) connFactory.createQueueConnection(); session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(queueName); receiver = (MQQueueReceiver) session.createReceiver(queue); connection.start(); if (receiver != null) { Message msg = receiver.receiveNoWait(); if (msg == null) { message = ""; } else { if (msg instanceof TextMessage) { TextMessage textMsg = (TextMessage) msg; message = StringUtils.defaultIfBlank(textMsg.getText(), ""); } else { String error = "*****不是文字訊息,跳過此筆訊息,class type = " + msg.getClass().toString(); log.error(error); } } } } catch (JMSException e) { log.error(MqlUtils.toStackTrace(e)); } finally { if (receiver != null) { receiver.close(); } if (session != null) { session.close(); } if (connection != null) { connection.close(); } } log.info("[readMessageByJMS] message = " + message); return message; } } |
Reference
[1] https://docs.oracle.com/javaee/6/api/javax/jms/Message.html
Labels:
Java
Subscribe to:
Posts (Atom)