證 券分析之計量化技術指標
∼ 2019輔仁大學 股票投資模擬競賽 ∼
王冠倫12
國立臺灣大學
民國 108 年 10 月 23 日
1電子信箱:polyphonicared@gmail.com
2個人網站:https://www.csie.ntu.edu.tw/∼d06922002/
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
自我介紹
研究興趣:
時間序列模型
仿真建模投資組合選取 主要應用:
多資產即時交易
尋找資產間長期均衡
建構可控風險投資組合 目前議題:
共整合檢定 結構性變動分析 均值回復機率之估計
柴比雪夫的啟示
柴比雪夫不等式 [33]
任意給定 r ∈ N, r > 0,令一隨機變數 Xt且其 E[|X |r]存在。那 麼,對於任意的 c ∈ R 與 > 0,我們有
Pr [|X − c| ≥ ] ≤ E [|X − c|r]
r . 柴比雪夫不等式 (r = 2, c = E[X ])
令有一隨機變數 Xt其變異數有限 (Var[X ] < ∞),則對於任意 的 > 0,我們有
Pr [|X − E[X ]| ≥ ] ≤ Var[X ]
2 .
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
比較同策略僅持倉差異 (1/2)
單位時間下期望報酬為 µ,變異數為 σ2。 總時間為 T ,持倉時間 ∆t1, . . . , ∆tN。 每次報酬 X1, . . . , XN:
報酬期望值 ∆t1µ, . . . , ∆tNµ 變異數 ∆t12σ2, . . . , ∆tN2σ2 均時報酬:
平均單位時間報酬 µ∗≡PN
n=1Xn/T 平均單位時間報酬期望值 E[µ∗] = µ
平均單位時間報酬變異數 Var[µ∗] = σ2PN
n=1∆tn2/T2
比較同策略僅持倉差異 (2/2)
考慮持倉時間均等,則柴比雪夫告訴我們如下:
Pr
"
PN n=1Xn
T − µ
≥
#
≤ σ2PN n=1∆tn2
T22 = σ2 N2.
考慮兩策略 X 與 Y ,且 NX > NY,則策略 Y 的平均報酬較不具 有參考性。
同時,我猜測這場比賽如果參加者夠多,則第一名可能是持有期 間較長者或是風險較高者。
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
風險與報酬的兌換性
Figure:風險與報酬
夏普比率比較好?
夏普比率 (Sharpe ratio) 為一種常見的績效衡量方式,且考 慮風險與報酬的兌換性 [5]。
定義為每單位總波動下的超額報酬,即 S ≡ ¯R/σ。
藉由基本定價方程 (basic pricing equation) 可推論出夏普比 率,意味著夏普比率應適合套用於具有特定效用函數的個人 之上 [8]。
股權溢價之謎 (equity premium puzzle) 的實證顯示夏普比率 仍然有問題 [34]。
風險–報酬的兌換率於風險較高時有較好的兌換比。
未考慮持有期間長短差異。
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
股票市場的困難點 (1/2)
非線性 (non-linear) 與非平穩 (non-stationary) [4]
政治事件、市場新聞、營收報告及國際事件等等 [50]
效率市場假說 (efficient market hypothesis) [5]
弱式 (weak-form)
股價充分反映了過去所有的歷史訊息,包括各種已發生的交 易資訊,如過去的成交價、交易量或短期利率水準等。
半強式 (semistrong-form)
股價已反映所有與公司前景有關的即時公開訊息。
強式 (strong-form)
股價已反映所有與公司有關的訊息,甚至包括內線交易。
相對優勢交易規則 (relative strength trading rules) 無效 [21]
股票市場的困難點 (2/2)
西元 2000 年時,全球頂尖學術期刊《Fiance》甚至對於技術分析 有如下評論 [32]:
關於基本面分析與技術分析之不同,
如同天文學與占星術的差異一般。
It has been argued that the difference between fun- damental analysis and technical analysis is not unlike the difference between astronomy and astrology.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
股票市場的希望
基本面分析在半強式下仍然有效 [35, 41]。
技術分析具有輔助效果 [6, 18, 32, 45]。
部分技術分析有效。
如,動量交易 (momentum trading) [1]。
嘗試跨領域結合。
用類神經網路 (neural networks) 改善技術分析 [9]。
類神經網路適合小範圍數據處理 [11, 50]。
總體經濟學 (macroeconomic) 數據預測方法與技術分析結
合 [39]。
市場互動技術分析 (Intermarket Technical Analysis) [36, 37]。
以某個市場的資訊分析另一個市場的狀況。
策略類型的差異
策略 時效 滑價 獲利 獲利趨勢 風險
均值 無 低 低 穩定 低
趨勢 有 高 高 下降 高
Table: 均值回復策略 (mean-reverting strategies) vs. 趨勢型策略 (trend trading strategies) [55]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
應 用原則與常見判斷依據
應用原則 [52]
選擇適當的技術指標
建立各種技術指標買賣紀錄
時常檢視各種技術指標的使用結果 擬定投資策略及資金管理模式 定期評估投資績效
常見判斷依據 [52]
技術指標交叉點
技術指標上下限值的範圍 技術指標走勢圖
技術指標分類–描述與刻度
長期 中期 短期
價格 MACD, SAR, BIAS, DMI, RSI, 當日分時走勢圖、
AR, BR, MA TOWER, MTM, 3-6日BIAS, KD, OSC, Qstick, CMO, WMS%R, Kinder%R, CCI Stoch, RSI, CDP 交易量 逆時鐘曲線、 VR, OBV, VAM, VR, OBV, VAMA,
成交量移動平均線 EOM, FI, VK EOM, FI, VK
時間 股市週期循環 ? ?
市場寬幅 ? ADL, ADR, PSY, OBOS ARMS Index, MT,
TO
其他 ? 融資融券餘額表 委託成交筆數(分)、
張數及成交值表、
當日沖銷比例 Table:技術指標分類 [52]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
技術指標分類–方法與技術 [16]
方法 (methodology)
支援系統 (decision’s support trading system) [7, 12, 46]
計算技術 (computational technique) [56]
圖表型態 (chart patterns) [40, 42]
技術 (operational tools)
隨機線 (stochastic line) [4, 30]
相對強弱指標 (relative strength index) [22, 30, 46]
基因演算法 (genetic algorithm) [7, 9, 12, 38]
加強增強學習 (evolutionary reinforcement learning) [2, 48]
統計分析 (statistical analysis) 移動平均 (moving averages) [47, 49]
計量經濟學模型 (econometric models) [25, 43, 53]
類神經網路 (neural network) [9, 11, 50, 57]
技術分析前提與調整 (1/6)
布林通道 (Bollinger Bands, BBands) [54]
令一投資組合 A 價格 PriceA(t),定義簡單移動平均
MA(t; N) ≡ 1 N
t
X
t0=t−N+1
PriceA(t)
與其於時間 t 時,近 N 筆之樣本變異數序列為 σ2N(t)。在給定了 簡單移動平均線樣本數 N (觀察範圍) 與標準差數量 K (軌道寬 度)下,BBands 可定義三條軌道 (線) 如下:
middleBB(t) ≡ MA(t; N)
lowerBB(t) ≡ middleBB(t) − K σN2(t) upperBB(t) ≡ middleBB(t) + K σN2(t).
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
技術分析前提與調整 (2/6)
Figure:布林通道 [24]
技術分析前提與調整 (3/6)
布林通道 (Bollinger Bands, BBands) [54] –續
證券於時間 t 之股價分布有一隨機分佈 D(t),而三條軌道則 提供一個參考範圍。
該 D(t) 應為對稱分佈,或其通常股價範圍應為該二軌道之 間,而於兩軌道區間外則為罕見事件。
分析與調整 [54]
lowerBB(t)與 upperBB(t) 一起向上 (或向下) 調整是可行 的 (兩軌道調整幅度並不一定相等)。
認為分佈不對稱,可對單一軌道或多個軌道進行修改。
middleBB(t)與 σN2(t) 可以替換。
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
技術分析前提與調整 (4/6)
布林通道 (Bollinger Bands, BBands) [54] –續
PriceA(t0) ≥ upperBB(t0) =⇒ PriceA(t1) ≤ middleBB(t1) PriceA(t0) ≤ lowerBB(t0) =⇒ PriceA(t1) ≥ middleBB(t1) 分析與調整
有限時間均值回復
再增加一個上下軌進行停損
藉由計量經濟學模型預測回復時間
無法有效加碼進場 均值趨勢影響獲利
技術分析前提與調整 (5/6)
注意事項 估計參數
以報酬為目標可能導致交易過長或曝險過高等 回測與未來上線使用獨立
布林通道未描述跨時間變化 直接使用效果差
不如買進持有 [28]
比移動平均差 [29]
反過來交易效果卻意外地不錯 (因單一標的多為趨勢) [28]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
技術分析前提與調整 (6/6)
所有的方法都有自己前提 以方法的意圖著手修改與改良 必要時使用其他領域技術解釋 需具體描述投資人需求
不是每一種投資人都適用一樣的技術分析
進化
參數藉由類神經網路優化
跨時間變化藉由計量經濟學模型描述 均值回復前提藉由建構投資組合完成
常 見缺點真的是缺點?
常見缺點 [52]
技術指標間常矛盾
不同指標前提不同自然會矛盾。
資料過期
估計需求樣本,以防使用過久以前的資料。
說服力低
使用統計分析評估可信度,如多重檢定方法。
歷史不一定重演
考慮使用具有時間序列的方法,如傳統的計量經濟學。
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
上市股價分佈 (1/2)
(a)全體股價分佈 (b) 150元以下股價分佈
Figure: 民國107年股價分佈
上市股價分佈 (2/2)
最小 5% 10% 50% 90% 95% 最大 價格 1.71 8.13 10.08 26.24 94.65 147.43 3940.2
(a)價格分位表
1萬 2萬 5萬 10萬 20萬 30萬 50萬 分位 10% 38% 73% 90% 97% 98% 100%
(b)投資分位表 Table: 分位表
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
組合的好處
讓風險成為可控
特定組合方法可有效避免市場風險 (market neutral) 特定市場甚至可以達成零本金 (money neutral) 達成現有交易策略的前提
對投資人偏好客製化投資組合 (下頁圖)
投資流程 (1/3)
訂定 投 資 策 略 發 展 投 資 決 策 製 作 投 資 組 合
Figure: 投資流程圖 [14]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
投資流程 (2/3)
確 認 條件
限制 偏好 目標
形成策略
環 境 考 量
市場預期 資金配置
發展策略
挑 選 配 件 完 成 組 合
選擇工具 挑選時機
多角化 需要?
Figure: 投資流程圖 [14]
投資流程 (3/3)
投資人的目標、限制與
偏好的規範及量化值 投資組合的方針與策略 監測影響投資人進 行投資的相關因素
建構及修正投資組合,
包括資產配置、投資 組合最佳化、有價證券
的挑選、轉換及買賣
衡量投資績效表現 以達成投資人目標
監 測 影 響經濟與 市 場 的 相關因素 資 本市 場 的預期
對經濟、社會、政治 及產業的各種考量
Figure: 投資流程圖 [5]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
組合範例
考慮單因子如下
priceA(t) = βA0+ βA1factor(t) + A(t) priceB(t) = βB0+ βB1factor(t) + B(t) 顯然存在組合消除因子
priceC(t) ≡ βB1priceA(t) − βA1priceB(t)
= (βA0βB1− βA1βB0) + (βB1A(t) − βA1B(t))
配對 交易的類型 [26]
距離 (distance) [13, 17]
共整合 (co-integration) [44, 51]
時間序列 (time series) [10, 15]
隨機控制 (stochastic control) [23, 31]
機器學習 (machine learning) 與綜合預測 (combined forecasts) [19, 20]
耦合 (copula) [27, 44]
主成分分析 (principal components analysis) [3]
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
組合+技術指標
Figure:共整合+布林通道
策略的測試
以組合各種模型測試現有策略,用以了解該策略不適用的場合。
迴歸:y(t) = X (t)β + (t)
平滑移動迴歸:y(t) = X (t)(tβ/T ) + (t)
向量自我迴歸:y(t) = µ(t) + Ppi =1Aiyt−1 + (t) ν(t) = 0, ν, ν1+ ν2t, . . ..
結構性變動:
(y (t) = f1(t) + (t), t ≤ t∗ y (t) = f2(t) + (t), t > t∗
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
測試 範例
以測試 共整合+布林通道 於具趨勢的自我迴歸上為例。
以向量錯誤修正模型估計自我迴歸係數 加入趨勢項於向量自我迴歸模型之中 隨機生成股價
拿現有策略應用並觀察報酬
若有淨利,則適用所加入之趨勢。
若有虧損,則不是用該情況。
詢問該情形出現時,是否有對應的處理方式。
如,即時停損或替換執行新的策略。
References (1/13)
[1] Asness, C. S., Moskowitz, T. J., and Pedersen, L. H. (2013). Value and momentum everywhere. The Journal of Finance, 68(3):929–985.
[2] Austin, M. P., Bates, G., Dempster 3, M. A. H., Leemans, V., and Williams, S. N. (2004). Adaptive systems for foreign exchange trading.
Quantitative Finance, 4(4):37–45.
[3] Avellaneda, M. and Lee, J.-H. (2010). Statistical arbitrage in the US equities market. Quantitative Finance, 10(7):761–782.
[4] Bisoi, R. and Dash, P. (2014). A hybrid evolutionary dynamic neural network for stock market trend analysis and prediction using unscented Kalman filter. Applied Soft Computing, 19:41–56.
[5] Bodie, Z., Kane, A., and Markus, A. J. (2012). Essentials of Investments. McGraw-Hill/Irwin, 9 edition.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (2/13)
[6] Brock, W., Lakonishok, J., and LeBaron, B. (1992). Simple technical trading rules and the stochastic properties of stock returns. The Journal of Finance, 47(5):1731–1764.
[7] Chavarnakul, T. and Enke, D. (2009). A hybrid stock trading system for intelligent technical analysis-based equivolume charting.
Neurocomputing, 72(16-18):3517–3528.
[8] Cochrane, J. H. (2001). Asset Pricing. Princenton, Princeton, NJ, US.
[9] Creamer, G. (2012). Model calibration and automated trading agent for Euro futures. Quantitative Finance, 12(4):531–545.
[10] Cummins, M. and Bucca, A. (2012). Quantitative spread trading on crude oil and refined products markets. Quantitative Finance,
12(12):1857–1875.
References (3/13)
[11] de Oliveira, F. A., Nobre, C. N., and Z´arate, L. E. (2013). Applying Artificial Neural Networks to prediction of stock price and improvement of the directional prediction index - Case study of PETR4, Petrobras, Brazil. Expert Systems with Applications, 40(18):7596–7606.
[12] Dempster, M. and Jones, C. (2001). A real-time adaptive trading system using genetic programming. Quantitative Finance,
1(4):397–413.
[13] Do, B. and Faff, R. (2010). Does simple pairs trading still work?
Financial Analysts Journal, 66(4):83–95.
[14] Du, J.-L. (2007). Investment. Wealth, Taipei, TW.
[15] Elliott, R. J., Van Der Hoek, J., and Malcolm, W. P. (2005). Pairs trading. Quantitative Finance, 5(3):271–276.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (4/13)
[16] Farias Naz´ario, R. T., e Silva, J. L., Sobreiro, V. A., and Kimura, H.
(2017). A literature review of technical analysis on stock markets. The Quarterly Review of Economics and Finance, 66:115–126.
[17] Gatev, E., Goetzmann, W. N., and Rouwenhorst, K. G. (2006).
Pairs trading: performance of a relative-value arbitrage rule. Review of Financial Studies, 19(3):797–827.
[18] Gunasekarage, A. and Power, D. M. (2001). The profitability of moving average trading rules in South Asian stock markets. Emerging Markets Review, 2(1):17–33.
[19] Huck, N. (2009). Pairs selection and outranking: An application to the S&P 100 index. European Journal of Operational Research, 196(2):819–825.
References (5/13)
[20] Huck, N. (2010). Pairs trading and outranking: the
multi-step-ahead forecasting case. European Journal of Operational Research, 207(3):1702–1716.
[21] Jensen, M. C. and Beningto, G. A. (1970). Random walks and technical theories: Some additional evidence. Journal of Finance, 25(2):469–482.
[22] Junqu´e de Fortuny, E., De Smedt, T., Martens, D., and Daelemans, W. (2014). Evaluating and understanding text-based stock price prediction models. Information Processing & Management, 50(2):426–441.
[23] Jurek, J. W. and Yang, H. (2007). Dynamic portfolio selection in arbitrage. SSRN Electronic Journal.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (6/13)
[24] Kabasinskas, A. and Macys, U. (2010). Calibration of Bollinger bands parameters for trading strategy development in the Baltic stock market. Inzinerine Ekonomika-Engineering Economics, 21(3):244–254.
[25] Kazem, A., Sharifi, E., Hussain, F. K., Saberi, M., and Hussain, O. K. (2013). Support vector regression with chaos-based firefly algorithm for stock market price forecasting. Applied Soft Computing, 13(2):947–958.
[26] Krauss, C. (2017). Statistical arbitrage pairs trading strategies:
review and outlook. Journal of Economic Surveys, 31(2):513–545.
[27] Krauss, C., Do, X. A., and Huck, N. (2017). Deep neural networks, gradient-boosted trees, random forests: statistical arbitrage on the S&P 500. European Journal of Operational Research, 259(2):689–702.
References (7/13)
[28] Lento, C., Gradojevic, N., and Wright, C. S. (2007). Investment information content in Bollinger Bands? Applied Financial Economics Letters, 3(4):263–267.
[29] Leung, J. M.-J. and Chong, T. T.-L. (2003). An empirical
comparison of moving average envelopes and Bollinger Bands. Applied Economics Letters, 10(6):339–341.
[30] Lin, X., Yang, Z., and Song, Y. (2011). Intelligent stock trading system based on improved technical analysis and Echo State Network.
Expert Systems with Applications, 38(9):11347–11354.
[31] Liu, J. and Timmermann, A. (2013). Optimal convergence trade strategies. Review of Financial Studies, 26(4):1048–1086.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (8/13)
[32] Lo, A. W., Mamaysky, H., and Wang, J. (2000). Foundations of technical analysis: computational algorithms, statistical inference, and empirical implementation. The Journal of Finance, 55(4):1705–1765.
[33] L¨utkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer, Berlin.
[34] Mehra, R. (2003). The equity premium: why is it a puzzle?
Financial Analysts Journal, 59(1):54–69.
[35] Metghalchi, M., Chang, Y.-H., and Marcucci, J. (2008). Is the Swedish stock market efficient? Evidence from some simple trading rules. International Review of Financial Analysis, 17(3):475–490.
[36] Murphy, J. J. (1991). Intermarket Technical Analysis: Trading Strategies for the Global Stock, Bond, Commodity, and Currency Markets. Wiley, New York, US.
References (9/13)
[37] Murphy, J. J. (2011). Intermarket Analysis: Profiting from Global Market Relationships. Wiley, New York, US.
[38] Neely, C. J. (2003). Risk-adjusted, ex ante, optimal technical trading rules in equity markets. International Review of Economics &
Finance, 12(1):69–87.
[39] Neely, C. J., Rapach, D. E., Tu, J., and Zhou, G. (2014).
Forecasting the equity risk premium: the role of technical indicators.
Management Science, 60(7):1772–1791.
[40] Omrane, W. B. and Oppens, H. V. (2006). The performance analysis of chart patterns: Monte Carlo simulation and evidence from the euro/dollar foreign exchange market. Empirical Economics, 30(4):947–971.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (10/13)
[41] Oppenheimer, H. R. and Schlarbaum, G. G. (1981). Investing with Ben Graham: an ex ante test of the efficient markets hypothesis. The Journal of Financial and Quantitative Analysis, 16(3):341.
[42] Osler, C. L. and Chang, P. H. K. (1995). Head and shoulders: not just a Flaky pattern. Technical report, Federal Reserve Bank of New York, New York, US.
[43] P´erez-cruz, F., Afonso-rodr´ıguez, J. A., and Giner, J. (2003).
Estimating GARCH models using support vector machines.
Quantitative Finance, 3(3):163–172.
[44] Rad, H., Low, R. K. Y., and Faff, R. (2016). The profitability of pairs trading strategies: distance, cointegration and copula methods.
Quantitative Finance, 16(10):1541–1558.
References (11/13)
[45] Ratner, M. and Leal, R. P. (1999). Tests of technical trading strategies in the emerging equity markets of Latin America and Asia.
Journal of Banking & Finance, 23(12):1887–1905.
[46] Rodr´ıguez-Gonz´alez, A., Garc´ıa-Crespo, ´A., Colomo-Palacios, R., Guldr´ıs Iglesias, F., and G´omez-Berb´ıs, J. M. (2011). CAST: Using neural networks to improve trading systems based on technical analysis by means of the RSI financial indicator. Expert Systems with
Applications, 38(9):11489–11500.
[47] Shynkevich, A. (2012). Performance of technical analysis in growth and small cap segments of the US equity market. Journal of Banking
& Finance, 36(1):193–208.
Kuan-Lun Wang Introduction to Technical Analysis
Chebyshev Technical Pairs References
References
References (12/13)
[48] Tan, Z., Quek, C., and Cheng, P. Y. (2011). Stock trading with cycles: A financial application of ANFIS and reinforcement learning.
Expert Systems with Applications, 38(5):4741–4755.
[49] Taylor, N. (2014). The rise and fall of technical trading rule success.
Journal of Banking & Finance, 40:286–302.
[50] Ticknor, J. L. (2013). A Bayesian regularized artificial neural network for stock market forecasting. Expert Systems with Applications, 40(14):5501–5506.
[51] Vidyamurthy, G. (2004). Pairs Trading: Quantitative Methods and Analysis. Wiley, Hoboken, NJ.
[52] Wang, K.-L. (2015). Introduction to Securities Analysis (III) Technical Index. [PDF files].
References (13/13)
[53] Wang, K.-L. (2017). Multivariate Pairs Trading with Structural Change Detections in Cointegrated Relationships (Master Thesis).
National Chiao Tung University.
[54] Wang, K.-L. (2019a). PFA320: Final Exam. [PDF files].
[55] Wang, K.-L. (2019b). PFA320: Investments, lesson 1, notes. [PDF files].
[56] Warburton, A. and Zhang, Z. G. (2006). A simple computational model for analyzing the properties of stop-loss, take-profit, and price breakout trading strategies. Computers & Operations Research, 33(1):32–42.
[57] Zhang, G., Eddy Patuwo, B., and Y. Hu, M. (1998). Forecasting with artificial neural networks:. International Journal of Forecasting, 14(1):35–62.
Kuan-Lun Wang Introduction to Technical Analysis