Transcript
Page 1: 20160827 open community camp

Be A GambleR

Chia-Chi@OpenCommunityCamp

20160827

Page 2: 20160827 open community camp

大家好 ... 我是家齊 ...

TW.R & MLDM Monday 共同創辦人木刻思股份有限公司 共同創辦人

Page 3: 20160827 open community camp

TW.R & MLDM Monday成立於 2012/09 ... 第一次聚會在 2012/10/15

每年 10 月週年慶時 ... 都總會回顧一下 ...

這個社群 &聚會 ... 是怎樣開始的 ... ?

Page 4: 20160827 open community camp

今天比較特別 ... 所以 ... 想分享一個比較少人知道的故事 ...

Page 5: 20160827 open community camp

一開始 ... 其實 ... 我是看了一本書 ...

看到另一個社群 ...

Page 6: 20160827 open community camp
Page 7: 20160827 open community camp

所以 ... 我決定仿照它弄一個 ...

Page 8: 20160827 open community camp
Page 9: 20160827 open community camp

Logo 很像吧 !有點想去做新版 Logo 的貼紙

如果有人認識優質貼紙店請推薦給我 ... !

Page 10: 20160827 open community camp

快四年了 ... TW.R & MLDM Monday

有著數不盡的人所共同付出而達成的

沒有他們 ... 就沒有社群 ...

Page 11: 20160827 open community camp

11

http://www.meetup.com/Taiwan-R/

Page 12: 20160827 open community camp

後來有一天 ... 出現了 RLadies ...

詳細情形大家去問主持人 Yen + 1 (共同創辦人)

Page 13: 20160827 open community camp
Page 14: 20160827 open community camp

14

Page 15: 20160827 open community camp

特別感謝 ... George哥@木刻思 ... 長期在社群付出奉獻 ... 大家才有穩定的影片能看 ...

Page 16: 20160827 open community camp

我不會運彩 ... 雖然 ... 木刻思危險基金會投注運彩 ... XD

以個人來說 ... 我主要的投資標的是選擇權 ... 然後偶爾玩玩樂透 ...

Page 17: 20160827 open community camp

所以 ... 今天的主題 ... 會 Cover 到一點點 quantmod & quantstrat

還有很多很多的樂透機率算 !

Page 18: 20160827 open community camp

在開始演講前想先調查一下現場聽眾

Page 19: 20160827 open community camp

近一年內 ... 有買過樂透的朋友 ?

Page 20: 20160827 open community camp

你買彩卷時 ... 不知道當年度最常出現的號碼的 ?

一向都用電腦選號的 ?

Page 21: 20160827 open community camp

你相信 ... 彩卷的號碼是有規律的 ?

Page 22: 20160827 open community camp

你相信 ... 彩卷的號碼是沒有規律的 ?

Page 23: 20160827 open community camp

對於,不相信的朋友 ...

是驗證過,嘗試過,發現沒有 pattern,才不相信?

還是是沒驗證過,沒嘗試過,直接不相信?

Page 24: 20160827 open community camp

對賭徒來說 ... 最重要的兩件事

瘋險控管不對稱資訊

Page 25: 20160827 open community camp

瘋險的種類 ?● 猜錯行情 (Prediction)

○ 在該下注時,不下

○ 再不該下時,拼命下

● 下注數量控制失衡 (Position Sizing)○ 輸的時候,下注過大

○ 贏得時候,下注太小

● 陷入負期望值,而未自覺

Page 26: 20160827 open community camp

瘋險控管的核心(1) 套利 Versus 套損(2) 勝率 Versus 賠率

Page 27: 20160827 open community camp

以股票為例什模是賺錢的唯一法則呢 ?

Page 28: 20160827 open community camp

賺錢的唯一法則 ?

低買高賣

Page 29: 20160827 open community camp

賺錢的唯一法則 ?● 行情向上時,先低買,後高賣

● 行情向下時,先高賣,後低買

Page 30: 20160827 open community camp

市場上有兩種 TraderBuy-Side / Sell-Side

Trend Follower / Mean Reversionhigh p, low WLR / low p, High WLR

Page 31: 20160827 open community camp

什麼是高?什麼是低?標準是 ...... ?

Page 32: 20160827 open community camp

兩種 Traders:● Type I (Trend Follower)

○ 順勢操作,追高殺低

○ 低勝率,高報酬

● Type II (Mean Reversion)○ 逆勢操作,買黑賣紅

○ 高勝率,低報酬

Page 33: 20160827 open community camp
Page 34: 20160827 open community camp

套損 Versus 套利E = pW - (1-p)L - T > 0

Page 35: 20160827 open community camp

套損 Versus 套利假設 T = 0, WLR = W/L

p > 1 / (1+WLR)

Page 36: 20160827 open community camp

對賭徒來說 ... 最重要的兩件事

瘋險控管不對稱資訊

Page 37: 20160827 open community camp

以 coin tossing 為例 ...

Page 38: 20160827 open community camp

你相信 ... 投擲硬幣正面和反面的機率是平均的 ?

Page 39: 20160827 open community camp

你覺得 ... 投擲硬幣正面和反面的機率是多少呢 ?

這些機率,受到什模影響呢 ?

Page 40: 20160827 open community camp

大家覺得 ... P(H) = ? and P(T) = ?

P(H| ?? ) = ? and P(T | ??) = ?

Page 41: 20160827 open community camp

大家覺得 ... 什模是 "機率" ?

(這其實是今天演講中,最重要的問題之一 !)

Page 42: 20160827 open community camp

樂透的空間 pattern各個號碼出現的次數 ?

Page 43: 20160827 open community camp

tidyr:: gather -> <- spread

Page 44: 20160827 open community camp

<- Spread

Page 45: 20160827 open community camp
Page 46: 20160827 open community camp
Page 47: 20160827 open community camp

平均 ... ? 但如果看條件機率呢 ?

Page 48: 20160827 open community camp
Page 49: 20160827 open community camp

利用條件機率進行預測P(Xt | Xt-1)

Page 50: 20160827 open community camp

利用條件機率進行預測P(Xt | Xt-k)

Page 51: 20160827 open community camp
Page 52: 20160827 open community camp

策略回測E = W*p - L*(1-p)

Page 53: 20160827 open community camp

首先 ... 要知道 W =? L =?

Page 54: 20160827 open community camp
Page 55: 20160827 open community camp

Avoid OverfittingWalk Forward Analysis

Page 56: 20160827 open community camp

Walk Forward Analysis

Page 57: 20160827 open community camp

樂透的時間 pattern各個號碼出現的 Stopping Time ?

Page 59: 20160827 open community camp

怎樣才是 ... 正確的週期 ?正確的時間尺度 ?

來看空間的 pattern !

Page 60: 20160827 open community camp
Page 61: 20160827 open community camp
Page 62: 20160827 open community camp

進擊的條件機率進行預測P(DISTt | DISTt-1)

Page 63: 20160827 open community camp

如果您覺得 ... 以上內容還不錯精彩 ...希望自己也能擁有相關的概念和技能 …

歡迎到木刻思粉絲團許願開爬蟲課 或是報名正在招生的 ETL & DataViz 課程

Page 64: 20160827 open community camp

quantmod 101zoo / xts / TTR

Page 65: 20160827 open community camp

Key Features in quantmod● Time Series Object: zoo, xts● Data Importers: getSymbols● Technical Analysis: TTR● Draw Candlestick Lines: chartSeries

Page 66: 20160827 open community camp

quantstrat 101quantmod / blotter / FinancialInstrument /

PerformanceAnalytics / foreach

https://r-forge.r-project.org/R/?group_id=316

Page 67: 20160827 open community camp

Key Features in quantstrat● Strategy Construction Tools:

○ Indicator○ Signal○ Rule

● Transaction-Oriented Trading Systems: ○ [blotter] Portiforlio○ [blotter] Account○ [quantstrat] Order

Page 68: 20160827 open community camp

在國內 ... 蒐集金融資料 ... 如果要跟 R 對接 ... 通常都少不了 …

R.NET & MRO & MRS

(因為國內期貨商都只有 Win APIs)

Page 70: 20160827 open community camp
Page 71: 20160827 open community camp

可以選擇 ... microsoft-r-open-blas

或是intel MKL (RevoMath in ArchLinux)

Page 72: 20160827 open community camp
Page 73: 20160827 open community camp
Page 75: 20160827 open community camp
Page 76: 20160827 open community camp

感謝大家 [email protected]

Page 77: 20160827 open community camp

如果想學習更多 ... 關於多機器 Cluster 的架構與部屬的話 ...

可以參考一下 PhillipZ 之後的 Docker 進階課 ...

不過 ... 這門課的內容真的非常進階唷 ... !

Page 78: 20160827 open community camp

聽說會學到很潮的 Docker Swarm Cluster …好像還有 Nvidia Docker 可以跑 Deep Learning ...


Recommended