20161110 quantstrat in seattle
-
Upload
chia-chi-chang -
Category
Data & Analytics
-
view
47 -
download
1
Transcript of 20161110 quantstrat in seattle
![Page 1: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/1.jpg)
Today’s Slideshttps://goo.gl/xkH9QY
go to the 5th page and click out all links on the page
And reserved your port on the spreadsheet
![Page 2: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/2.jpg)
Mining Trading Strategies with R
using quantstrat and R packages
George (Chia-Chi) Chang20161110
![Page 3: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/3.jpg)
Copyright © 2016 木刻思股份有限公
司. All rights reserved.
Unless otherwise indicated, all materials on these pages are copyrighted by 木刻思股份有限公司. All rights reserved. No part of these pages, either text or image may be used for any purpose other than personal use. Therefore, reproduction, modification, storage in a retrieval system or retransmission, in any form or by any means, electronic, mechanical or otherwise, for reasons other than personal use, is strictly prohibited without prior written permission.
![Page 4: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/4.jpg)
Quick Surveys● How many of you use R ? ● How many of you did have some REAL trading experience in financial market
? ● What kind of signals & strategies did you use in trading ? (your intuition is also
one kind of useful signal too)
● Did anyone use MultiChart ? AmiBroker ? Interactive Broker APIs ?● Did anyone use quantmod ? blotter ? quantstrat ?
![Page 5: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/5.jpg)
Learning By HackingLAB / Collaborative Notes / Broadcasting Notes
![Page 6: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/6.jpg)
Sample Codeshttps://github.com/c3h3/quantstrat-seattle-20161110
![Page 7: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/7.jpg)
● Quick Surveys● Architecture of Trading System● [Hands-on] quantmod 101● History of Backtesting with R
○ [Hands-on] PerformanceAnalytics 101○ [Hands-on] blotter 101○ [Hands-on] quantstrat 101
● Basic Concepts of Quantitative Trading● [Hands-on] quantstrat 102● [Hands-on] quantmod with ML● Blindness of ML● Two kind of Backtesting● Self Introduction & TW.R & MLDM Monday
Outlines
![Page 8: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/8.jpg)
Architecture of Trading SystemData -> Signals & Strategy ->
Transaction & Actions -> Rewards & Results
![Page 9: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/9.jpg)
Architecture of Trading System● Data
○ Real-time Data○ Historical Data
● Signals & Strategy○ Rule-Based○ Model-Based○ Human-Based (Intuition-Based)
● Transaction & Actions○ Enter & Exit ○ Long & Short○ Position Sizing
● Rewards & Results○ Win | Lose○ Metrics (winning prob, WLR, DrawDown, … )
![Page 10: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/10.jpg)
Real-Time Trading Backtesting & Mining
Real-Time Data
Signals & Strategy
Transactions & Actions
Rewards & Results
Historical Data
Mining Strategies & Objectives
(human brain)
Indicators & Signals & Action Rules(Bottom-Up Versus Top-Down)
Strategy Metrics & Backtesting Results
Parameter Search & Optimization
Final Results & Strategy
![Page 11: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/11.jpg)
History of Backtesting with R
PerformanceAnalytics (2007)blotter (2008)
quantstrat (2010)
![Page 12: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/12.jpg)
quantmod 101Hands-on LAB
![Page 13: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/13.jpg)
quantmod 101: getSymbols & ChartSeries
![Page 15: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/15.jpg)
Yahoo! Finance
![Page 16: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/16.jpg)
PerformanceAnalytics101
Hands-on LAB
![Page 17: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/17.jpg)
PerformanceAnalytics:● Data Retrieving & Technical Indicator
○ quantmod:: getSymbol○ quantmod:: ChartSeries○ TTR:: SMA
● Performance analysis○ PerformanceAnalytics:: CalculateReturns○ PerformanceAnalytics::charts.PerformanceSummary○ PerformanceAnalytics::chart.RollingPerformance○ chart.RelativePerformance○ PerformanceAnalytics::chart.Drawdown○ PerformanceAnalytics::chart.RiskReturnScatter○ PerformanceAnalytics::SharpeRatio○ PerformanceAnalytics::VaR
![Page 18: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/18.jpg)
blottor 101Hands-on LAB
![Page 19: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/19.jpg)
Blotter Important Functions: ● initializtion:
○ blotter::initPort○ blotter::initAcct
● simulation:○ blotter::addTxn○ blotter::updatePortf○ blotter::updateAcct○ blotter::updateEndEq○ blotter::getPosQty
● plot & summary:○ blotter::chart.Posn○ blotter::chart.ME○ blotter::PortfReturns○ blotter::getAccount○ blotter::getPortflio○ blotter::getTxns○ blotter::tradeStats
![Page 20: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/20.jpg)
quantstrat 101Hands-on LAB
![Page 21: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/21.jpg)
Quantstrat: ● init strategy object:
○ quantstrat::strategy
● define strategies:○ quantstrat::add.indicator○ quantstrat::add.signal○ quantstrat::add.rule
● Execution in Backtesting Process:○ quantstrat::sigCrossover○ quantstrat::sigComparison○ quantstrat::ruleSignal○ quantstrat::addOrder
● get Strategy & Order Book○ quantstrat::getStrategy○ quantstrat::getOrderBook
![Page 22: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/22.jpg)
Architecture of quantstratcreated by
C.Y. Yen
who is the Founder of RLadies.TW
![Page 23: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/23.jpg)
Basic Concepts of making quantitative trading strategy
![Page 24: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/24.jpg)
What is the only wayto make money from market ?
![Page 25: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/25.jpg)
The Only Way is ... ● Buy Low and Sell High● Trends up: Buy first, then sell● Trends down: Sell first, then buy
![Page 26: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/26.jpg)
Arbitrage or Anti-arbitrageE = pW - (1-p)L - T > 0
![Page 27: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/27.jpg)
Arbitrage or Anti-arbitrageAssum T = 0, WLR = W/L
p > 1 / (1+WLR)
![Page 28: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/28.jpg)
Signals in Trading System● Entry Signals
○ Primary Signals○ Filters
● Exit Signals○ Stop Signals○ Limit Signals○ Time-out Signals○ Filters
Stop Price
Limit Price
Exit Signal
Timeout Signal
Entry Signal & Price
Signal Filters
![Page 29: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/29.jpg)
quantstrat 102create indicators by yourself
create signals by yourself
![Page 30: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/30.jpg)
quantmod with MLClassification
Principle Component AnalysisClustering
![Page 31: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/31.jpg)
Blindness of MLBlindness from PCA
Blindness from Vector Quantization
![Page 32: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/32.jpg)
![Page 33: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/33.jpg)
![Page 34: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/34.jpg)
![Page 35: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/35.jpg)
![Page 36: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/36.jpg)
![Page 37: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/37.jpg)
![Page 38: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/38.jpg)
![Page 39: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/39.jpg)
![Page 40: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/40.jpg)
![Page 41: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/41.jpg)
The two keysHelp you apply machine learning
in the real world
![Page 42: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/42.jpg)
Can Learn ONLYThrough Real
Practice
Can Learn fromSchool or Practice
![Page 43: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/43.jpg)
Modeling Procedures:● Choose a Real Problem● Collecting Related Data● Choose a method convert Data to Vectors (or Tensors)● Decompose Real Problem into several ML or Math Problems● Solve each ML or Math Problem individually ● Combine the Solutions of all ML or Math Problems● Check is that truly solve the Real Problem ?
(ref: Moving Forward through the Darkness)
![Page 44: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/44.jpg)
Machine could NOT Learn by itself.
It just like a child.It learn by training data !
sometimes would learn badly!
![Page 45: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/45.jpg)
When orange-apple classifier meet an banana?
![Page 46: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/46.jpg)
Two Kind of BacktestingTop-Down & Button-Up
![Page 47: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/47.jpg)
Entry Signal & Price
Timeout SignalStop Price
Exit Signal
After Event:How to evaluate event?
Before Event:How to predict event?
Limit Price
![Page 48: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/48.jpg)
Entry Signal & Price
Timeout SignalStop Price
Exit Signal
Before Event:How to predict event?
Limit Price
X Y
After Event:How to evaluate event?
Button-Up: P(e(Y)|X)
![Page 49: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/49.jpg)
Entry Signal & Price
Timeout SignalStop Price
Exit Signal
Before Event:How to predict event?
Limit Price
X Y
After Event:How to evaluate event?
Top-Down: P(X|e(Y))
![Page 50: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/50.jpg)
Entry Signal & Price
Timeout SignalStop Price
Exit Signal
Before Event:How to predict event?
Limit Price
X Y
After Event:How to evaluate event?
ML & DL: Y = f(X)
![Page 51: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/51.jpg)
Button-UpProbabilistic Modeling
![Page 52: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/52.jpg)
Exit Signal
After Event:How to evaluate event?
Before Event:How to predict event?
Limit Price
Timeout Signal
Entry Signal & Price
Stop Price
![Page 53: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/53.jpg)
Limit = 0.06 / Stop = 0.02
![Page 54: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/54.jpg)
Limit = 0.06 / Stop = 0.06
![Page 55: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/55.jpg)
![Page 56: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/56.jpg)
Self Introductionand TW.R & MLDM Monday
![Page 57: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/57.jpg)
About Chia-Chi (George) ● Organizer of Taiwan R User Group and MLDM Monday● 7 years experience in quantitative trading in future & option market● 5 years consultant experience in machine learning & data mining● 4 years experience in e-commerce (consultant & join SaaS teams)● 4 years experience in building of recommendation and search engine ● Volunteer in PyCon APAC 2014 (program officer)● Volunteer in PyCon APAC 2015 (program officer)
![Page 58: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/58.jpg)
4 Years agoI read a Book ……
I started a community
![Page 59: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/59.jpg)
Welcome to MLDM Monday
when you visit Taiwan next time !
Welcome to join us !
![Page 60: 20161110 quantstrat in seattle](https://reader030.fdocument.pub/reader030/viewer/2022021506/588a52f91a28abd3088b72bb/html5/thumbnails/60.jpg)
Thank youfor your attention !