SlideShare une entreprise Scribd logo
1  sur  25
How to design quant strategies
using R
Saturday, May 16, 2015
Anil Yadav
(Head, Algorithm strategy advisory team at iRageCapital)
Content
 What is R?
 How can we use R packages in writing quantitative trading strategies?
 Steps in development of a quantitative trading strategy
 Optimizing the quantitative trading strategy
Disclaimer: The information in this presentation is intended to be general in nature and is
not financial product advice.
Introduction to R
 R is an open source software. It is free!
 Popular because it has packages with readymade functions
 Easy to find help for queries or code on internet
Installation: Download and install R-studio from (http://cran.r-project.org)
Help guide: (http://www.rseek.org/)
Packages in R
• We will use the package ‘quantstrat’ for writing our strategy today
– Install the package
install.packages("quantstrat", repos=http://R-Forge.R-project.org)
– Install the dependencies (FinancialInstrument, blotter, foreach, doParallel)
install.packages("FinancialInstrument", repos=http://R-Forge.R-project.org)
• Other useful CRAN packages: TTR, quantmod, etc
Writing a quant strategy
The steps are:
1. Hypothesis Formation – what is the idea for trade
2. Testing - statistically testing the hypothesis with data, how much
confidence do you have on your strategy
3. Refining – Optimizing the strategy parameters and paper trading
4. Production - Implementing the strategy in a live trading
environment. This would involve writing the strategy on a trading
platform.
Step 1: Hypothesis
What is a hypothesis? This is your trading idea. It could be any
combination of technical trading rules/it could be your “feel” for the market
regime. It is the first thing to be derived out of the trading data.
Hypothesis for our strategy:
Market is mean reverting
Step 2: Testing
To test the hypothesis, we will have to write it as a strategy which has
statistical methods to compute the indicators, signals and calculate the
profits for the given data.
The steps for the testing part are:
1. Get the data
2. Write the strategy (indicators, signals, trades, PnL)
3. Analyze the output
Data
• Nifty-Bees (ETF) Data from from NSE
(It is a Goldman Sachs managed ETF which trades on the Indian Stock
exchanges. National Stock Exchange has higher volumes for the instrument
and therefore the data)
• OHLC data Snapshot below:
Date OPEN HIGH LOW CLOSE
11/18/2014 9:15 850.15 853 850.15 852
11/18/2014 9:19 853.89 853.89 851.8 851.8
11/18/2014 9:20 853.97 853.97 853.97 853.97
11/18/2014 9:21 853.97 853.98 853.97 853.98
11/18/2014 9:22 853.98 853.98 853.98 853.98
11/18/2014 9:23 853.97 853.97 853.97 853.97
11/18/2014 9:24 852.51 854.45 852.51 854
11/18/2014 9:25 854 854 854 854
Plot the data
We take a look at the data and plot Bollinger bands to get the first
verification on our hypothesis.
chart_Series(NSEI)
zoom_Chart("2014-11-19")
addBBands(n=20, sd =2)
Writing the strategy
These are the steps in writing the strategy.
Install the
packages
Read the data
file
Initialize of
variables,
parameters
Create
Indicators
Generate
Signal
Trading rule for
execution
Output
Optimize
For our discussion today, we will focus on the parts which are highlighted.
Indicator
•For each row, we check & compare the closing price with threshold value (Thresh)
•If price increases or decreases, threshold is updated accordingly in column THT
•The indicator prices for comparison are updated using Thresh2, saved in UP and DOWN to
be used for selling and buying respectively
Signal
•For each row, the closing price is compared with UP (upper band price) and with DOWN
(lower band price).
•As per the logic of in-built in ‘sigCrossover’ function, the output is ‘TRUE’ or ‘FALSE’
•If TRUE, trading rule is applied
Trading Rule
•When upper band is crossed, it generates a market order for ‘sell’ position. Orderqty = -1
•When lower band is crossed, it generates a market order for ‘buy’ position. Orderqty = 1
Writing the strategy
Indicator
Indicator
•For each row, we check & compare the closing price with threshold value (Thresh)
•If price increases or decreases, threshold(Thresh) is updated accordingly in column THT
•The indicator prices for comparison are updated using band limit (Thresh2), saved in UP
and DOWN to be used for selling and buying respectively
THTFunc<-function(CompTh=NSEI,Thresh=6, Thresh2=3){
numRow<- nrow(CompTh)
xa<-coredata(CompTh)[,4]
xb<-xa
tht<-xa[1]
for(i in 2:numRow){
if(xa[i]>(tht+Thresh)){ tht<-xa[i]}
if(xa[i]<(tht-Thresh)){ tht<-xa[i]}
xb[i]<-tht
}
up <- xb + Thresh2
dn<- xb-Thresh2
res <- cbind(xb, dn,up)
colnames(res) <- c("THT", "DOWN", "UP")
reclass(res,CompTh)
}
THTFunc()
Signal
Signal
•For each row, the closing price is compared with UP (upper band price) and with
DOWN (lower band price).
•As per the logic of in-built in ‘sigCrossover’ function, the output is ‘TRUE’ or ‘FALSE’
•If TRUE, trading rule is applied
#add your signal
stratMR <- add.signal(stratMR,name="sigCrossover",arguments =
list(columns=c("Close","UP"),relationship="gt"),label="Cl.gt.UpperBand")
stratMR <- add.signal(stratMR,name="sigCrossover",arguments =
list(columns=c("Close","DOWN"),relationship="lt"),label="Cl.lt.LowerBand")
Trading Rule
Trading Rule
• When upper band is crossed, it generates a market order for ‘sell’
position. Orderqty = -1
• When lower band is crossed, it generates a market order for ‘buy’
position. Orderqty = 1
#add trading rule long short stop_loss, take_profit
stratMR <- add.rule(stratMR,name='ruleSignal', arguments =
list(sigcol="Cl.gt.UpperBand",sigval=TRUE, prefer = 'close', orderqty=-1, ordertype='market',
orderside=NULL, threshold=NULL,osFUN=osMaxPos),type='enter')
stratMR <- add.rule(stratMR,name='ruleSignal', arguments =
list(sigcol="Cl.lt.LowerBand",sigval=TRUE, prefer = 'close', orderqty= 1, ordertype='market',
orderside=NULL, threshold=NULL,osFUN=osMaxPos),type='enter')
Summarizing the code
Implementation Steps
• Function Block
• Adding Indicator
• Adding Signal
• Adding Rules
Run Strategy
Indicator
• Calls THTFunc
• Updates Up/Down/Thresh
Signal
• Crossover
• Updates Cl.gt.UpperBand
and Cl.lt.LowerBand
Trading Rule
• Signal Value True
• Order Details
Analyze output
row.names NSEI
Portfolio MeanRev
Symbol NSEI
Num.Txns 102
Num.Trades 51
Net.Trading.PL 5.02
Avg.Trade.PL 0.098431
Med.Trade.PL 0.1
Largest.Winner 3.8
Largest.Loser -3
Gross.Profits 26.81
Gross.Losses -21.79
Std.Dev.Trade.PL 1.252465
Percent.Positive 54.90196
Percent.Negative 45.09804
#run the strategy
out<-try(applyStrategy(strategy=stratMR , portfolios='MeanRev') )
# look at the order book
getOrderBook('MeanRev')
updatePortf('MeanRev', stock.str)
chart.Posn(Portfolio='MeanRev',Symbol=stock.str)
Strategy output uses tradeStats
tradeStats('MeanRev', stock.str)
View(t(tradeStats('MeanRev')))
Output Blotter::Functions `
chart.Posn(Portfolio='MeanRev',Symbol=stock.str)
Writing a strategy
The steps are:
 Hypothesis Formation – what is the idea for trade
 Testing - statistically testing the hypothesis with data,
how much confidence do you have on your strategy
 Refining – Optimizing the strategy parameters and paper
trading
 Production - Implementing the strategy in a live trading
environment. This would involve writing the strategy on a
trading platform.
Step 3: Optimization
.Th2 = c(.3,.4)
.Th1 = c(.5,.6)
results <- apply.paramset(stratMR, paramset.label='THTFunc', portfolio.st=portfolio.st, account.st=account.st,
nsamples=4, verbose=TRUE)
Step 3: Refining
 What other techniques can you use for further refining your
strategy?
 Run the code with more data
 Bayesian update for threshold
 Threshold 1, 2 can take volatility into account
Writing a strategy
The steps are:
 Hypothesis Formation – what is the idea for trade
 Testing - statistically testing the hypothesis with data,
how much confidence do you have on your strategy
 Refining – Optimizing the strategy parameters and paper
trading
 Production - Implementing the strategy in a live trading
environment. This would involve writing the strategy on a
trading platform.
About QI & EPAT
Quantinsti Quantitative Pvt Ltd. -
Quantinsti developed the curriculum for the first dedicated educational program
on Algorithmic and High-Frequency Trading globally (EPAT) in 2009.
Launched with an aim to introduce its course participants to a world class
exposure in the domain of Algorithmic Trading,it provides participants with in-
house proprietary tools and other globally renowned applications to rise steeply
on the learning curve that they witness during the program.
Executive Program in Algorithmic Trading (EPAT)-
• 6-months long comprehensive course in Algorithmic and Quantitative Trading.
• Primary focus on financial technology trends and solutions.
• It is an online live interactive course aimed at working professionals from diverse
backgrounds such as trading-brokerage services, Analytics, Quantitative roles, and
Programming & IT industry.
• Get placement assistance and internship opportunities with leading global firms
after the program
Program Delivery
• Next EPAT batch starting from 10th January, 2015.
• Weekends only program
– 3 hrs sessions on Saturday & Sunday both
– 4 months long program + 2 months project / internship
– Practical Oriented
– 100 contact hours including practical sessions
• Convenience – Conducted online
• Open Source
• Virtual Classroom integration
• Student Portal
• Faculty supervision
• Placement assistance
Thank you!
Next steps
 Watch QI youtube videos for more learning
 Read more at
http://www.rinfinance.com/agenda/2013/workshop/Hum
me+Peterson.pdf
 Contact us if you wish to learn R for Algo trading
 Questions?
Contact us at @ contact@quantinsti.com or sales@quantinsti.com or @: +91-22-61691400, +91-9920448877
Contact Us
To Learn Automated Trading
Email: contact@quantinsti.com
Connect With Us:
SINGAPORE
11 Collyer Quay,
#10-10, The Arcade,
Singapore - 049317
Phone: +65-6221-3654
INDIA
A-309, Boomerang,
Chandivali Farm Road, Powai,
Mumbai - 400 072
Phone: +91-022-61691400

Contenu connexe

Tendances

Order book dynamics in high frequency trading
Order book dynamics in high frequency tradingOrder book dynamics in high frequency trading
Order book dynamics in high frequency tradingQuantInsti
 
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...Quantopian
 
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...Quantopian
 
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle..."Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...Quantopian
 
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016Quantopian
 
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas..."Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...Quantopian
 
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D..."From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...Quantopian
 
Modeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic StrategiesModeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic StrategiesQuantopian
 
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob..."Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...Quantopian
 
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C..."Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...Quantopian
 
Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...
	 Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...	 Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...
Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...Fernando A. B. Sabino da Silva
 
Making Netflix Machine Learning Algorithms Reliable
Making Netflix Machine Learning Algorithms ReliableMaking Netflix Machine Learning Algorithms Reliable
Making Netflix Machine Learning Algorithms ReliableJustin Basilico
 
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...Quantopian
 
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016Quantopian
 
Conference on Option Trading Techniques - Option Trading Strategies
Conference on Option Trading Techniques - Option Trading StrategiesConference on Option Trading Techniques - Option Trading Strategies
Conference on Option Trading Techniques - Option Trading StrategiesQuantInsti
 
Paradigms of trading strategies formulation
Paradigms of trading strategies formulationParadigms of trading strategies formulation
Paradigms of trading strategies formulationQuantInsti
 
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...Quantopian
 
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe..."Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...Quantopian
 

Tendances (20)

Order book dynamics in high frequency trading
Order book dynamics in high frequency tradingOrder book dynamics in high frequency trading
Order book dynamics in high frequency trading
 
Algo trading
Algo tradingAlgo trading
Algo trading
 
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
Automated Selection and Robustness for Systematic Trading Strategies by Dr. T...
 
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
 
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle..."Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
"Build Effective Risk Management on Top of Your Trading Strategy" by Danielle...
 
Quantitative Trading
Quantitative TradingQuantitative Trading
Quantitative Trading
 
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
Should You Build Your Own Backtester? by Michael Halls-Moore at QuantCon 2016
 
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas..."Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
"Quant Trading for a Living – Lessons from a Life in the Trenches" by Andreas...
 
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D..."From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
"From Alpha Discovery to Portfolio Construction: Pitfalls and Solutions" by D...
 
Modeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic StrategiesModeling Transaction Costs for Algorithmic Strategies
Modeling Transaction Costs for Algorithmic Strategies
 
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob..."Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
"Portfolio Optimisation When You Don’t Know the Future (or the Past)" by Rob...
 
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C..."Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
"Deep Q-Learning for Trading" by Dr. Tucker Balch, Professor of Interactive C...
 
Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...
	 Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...	 Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...
Pairs Trading: Optimizing via Mixed Copula versus Distance Method for S&P 5...
 
Making Netflix Machine Learning Algorithms Reliable
Making Netflix Machine Learning Algorithms ReliableMaking Netflix Machine Learning Algorithms Reliable
Making Netflix Machine Learning Algorithms Reliable
 
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...
Algorithmic trading and Machine Learning by Michael Kearns, Professor of Comp...
 
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
A Guided Tour of Machine Learning for Traders by Tucker Balch at QuantCon 2016
 
Conference on Option Trading Techniques - Option Trading Strategies
Conference on Option Trading Techniques - Option Trading StrategiesConference on Option Trading Techniques - Option Trading Strategies
Conference on Option Trading Techniques - Option Trading Strategies
 
Paradigms of trading strategies formulation
Paradigms of trading strategies formulationParadigms of trading strategies formulation
Paradigms of trading strategies formulation
 
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
Beware of Low Frequency Data by Ernie Chan, Managing Member, QTS Capital Mana...
 
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe..."Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
"Trading Strategies That Are Designed Not Fitted" by Robert Carver, Independe...
 

Similaire à How to design quant strategies using R

Traders Cockpit Product Details
Traders Cockpit Product DetailsTraders Cockpit Product Details
Traders Cockpit Product DetailsTraders Cockpit
 
Quant trading with artificial intelligence
Quant trading with artificial intelligenceQuant trading with artificial intelligence
Quant trading with artificial intelligenceRoger Lee, CFA
 
Algo trading(Minor Project) strategy EMA with Ipython
Algo trading(Minor Project) strategy EMA with IpythonAlgo trading(Minor Project) strategy EMA with Ipython
Algo trading(Minor Project) strategy EMA with IpythonDeb prakash ganguly
 
Stock-market-prediction.pptx
Stock-market-prediction.pptxStock-market-prediction.pptx
Stock-market-prediction.pptxrikritiKoirala1
 
Predictive automated marginal trading technology pamtt part 1
Predictive automated marginal trading technology   pamtt part 1 Predictive automated marginal trading technology   pamtt part 1
Predictive automated marginal trading technology pamtt part 1 Yuri Martemianov
 
Industry internship project report presentation (IIFL)
Industry internship project report presentation (IIFL)Industry internship project report presentation (IIFL)
Industry internship project report presentation (IIFL)Debashish sahoo
 
Stock Market Prediction
Stock Market Prediction Stock Market Prediction
Stock Market Prediction SalmanShezad
 
Market basket analysis
Market basket analysisMarket basket analysis
Market basket analysisVermaAkash32
 
iRage - Campus Roles and Work Culture
iRage - Campus Roles and Work CultureiRage - Campus Roles and Work Culture
iRage - Campus Roles and Work CultureZeba Malik
 
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...NUS-ISS
 
IRJET- Stock Market Prediction using Machine Learning
IRJET- Stock Market Prediction using Machine LearningIRJET- Stock Market Prediction using Machine Learning
IRJET- Stock Market Prediction using Machine LearningIRJET Journal
 
Predicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector RegressionPredicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector RegressionChittagong Independent University
 
MMT-04The-Algorithmic-Trading-Process.pdf
MMT-04The-Algorithmic-Trading-Process.pdfMMT-04The-Algorithmic-Trading-Process.pdf
MMT-04The-Algorithmic-Trading-Process.pdfSiddharthKumar701604
 
Exante algotrading
Exante algotradingExante algotrading
Exante algotradingEXANTE
 

Similaire à How to design quant strategies using R (20)

Traders Cockpit Product Details
Traders Cockpit Product DetailsTraders Cockpit Product Details
Traders Cockpit Product Details
 
Quant trading with artificial intelligence
Quant trading with artificial intelligenceQuant trading with artificial intelligence
Quant trading with artificial intelligence
 
Algorithmic trading
Algorithmic tradingAlgorithmic trading
Algorithmic trading
 
Algo trading(Minor Project) strategy EMA with Ipython
Algo trading(Minor Project) strategy EMA with IpythonAlgo trading(Minor Project) strategy EMA with Ipython
Algo trading(Minor Project) strategy EMA with Ipython
 
Stock-market-prediction.pptx
Stock-market-prediction.pptxStock-market-prediction.pptx
Stock-market-prediction.pptx
 
Predictive automated marginal trading technology pamtt part 1
Predictive automated marginal trading technology   pamtt part 1 Predictive automated marginal trading technology   pamtt part 1
Predictive automated marginal trading technology pamtt part 1
 
Industry internship project report presentation (IIFL)
Industry internship project report presentation (IIFL)Industry internship project report presentation (IIFL)
Industry internship project report presentation (IIFL)
 
Dynamic stopcharts
Dynamic stopchartsDynamic stopcharts
Dynamic stopcharts
 
Algo Trading
Algo TradingAlgo Trading
Algo Trading
 
Stock Market Prediction
Stock Market Prediction Stock Market Prediction
Stock Market Prediction
 
Market basket analysis
Market basket analysisMarket basket analysis
Market basket analysis
 
iRage - Campus Roles and Work Culture
iRage - Campus Roles and Work CultureiRage - Campus Roles and Work Culture
iRage - Campus Roles and Work Culture
 
Algorithmic Trading
Algorithmic TradingAlgorithmic Trading
Algorithmic Trading
 
Adaptix_2013
Adaptix_2013Adaptix_2013
Adaptix_2013
 
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
AI in Finance: An Ensembling Architecture Incorporating Machine Learning Mode...
 
IRJET- Stock Market Prediction using Machine Learning
IRJET- Stock Market Prediction using Machine LearningIRJET- Stock Market Prediction using Machine Learning
IRJET- Stock Market Prediction using Machine Learning
 
Predicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector RegressionPredicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector Regression
 
MMT-04The-Algorithmic-Trading-Process.pdf
MMT-04The-Algorithmic-Trading-Process.pdfMMT-04The-Algorithmic-Trading-Process.pdf
MMT-04The-Algorithmic-Trading-Process.pdf
 
StrategyDB Introductory Presentation English
StrategyDB Introductory Presentation EnglishStrategyDB Introductory Presentation English
StrategyDB Introductory Presentation English
 
Exante algotrading
Exante algotradingExante algotrading
Exante algotrading
 

Plus de QuantInsti

ChatGPT and Machine Learning in Trading
ChatGPT and Machine Learning in TradingChatGPT and Machine Learning in Trading
ChatGPT and Machine Learning in TradingQuantInsti
 
Introduction to Quantitative Factor Investing
Introduction to Quantitative Factor InvestingIntroduction to Quantitative Factor Investing
Introduction to Quantitative Factor InvestingQuantInsti
 
Machine Learning for Options Trading
Machine Learning for Options TradingMachine Learning for Options Trading
Machine Learning for Options TradingQuantInsti
 
Portfolio Assets Allocation with Machine Learning
Portfolio Assets Allocation with Machine LearningPortfolio Assets Allocation with Machine Learning
Portfolio Assets Allocation with Machine LearningQuantInsti
 
Price Action Trading - An Introduction
Price Action Trading - An IntroductionPrice Action Trading - An Introduction
Price Action Trading - An IntroductionQuantInsti
 
Introduction to Systematic Options Trading
Introduction to Systematic Options TradingIntroduction to Systematic Options Trading
Introduction to Systematic Options TradingQuantInsti
 
Competitive Edges in Algorithmic Trading
Competitive Edges in Algorithmic TradingCompetitive Edges in Algorithmic Trading
Competitive Edges in Algorithmic TradingQuantInsti
 
Volatility Trading: Trading The Fear Index VIX
Volatility Trading: Trading The Fear Index VIXVolatility Trading: Trading The Fear Index VIX
Volatility Trading: Trading The Fear Index VIXQuantInsti
 
Big Data And The Future Of Retail Investing
Big Data And The Future Of Retail InvestingBig Data And The Future Of Retail Investing
Big Data And The Future Of Retail InvestingQuantInsti
 
Backtest of Short Straddles on SPX Index
Backtest of Short Straddles on SPX IndexBacktest of Short Straddles on SPX Index
Backtest of Short Straddles on SPX IndexQuantInsti
 
Pairs Trading In the Brazilian Stock Market
Pairs Trading In the Brazilian Stock MarketPairs Trading In the Brazilian Stock Market
Pairs Trading In the Brazilian Stock MarketQuantInsti
 
How To Set Up Automated Trading
How To Set Up Automated TradingHow To Set Up Automated Trading
How To Set Up Automated TradingQuantInsti
 
How To Set Up Automated Trading
How To Set Up Automated TradingHow To Set Up Automated Trading
How To Set Up Automated TradingQuantInsti
 
Quantitative Data Analysis of Cryptocurrencies
Quantitative Data Analysis of CryptocurrenciesQuantitative Data Analysis of Cryptocurrencies
Quantitative Data Analysis of CryptocurrenciesQuantInsti
 
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...Introduction to Quantitative Trading - Investment Management Club of Yale Uni...
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...QuantInsti
 
How to automate an options day trading strategy
How to automate an options day trading strategyHow to automate an options day trading strategy
How to automate an options day trading strategyQuantInsti
 
Predict daily stock prices with random forest classifier, technical indicator...
Predict daily stock prices with random forest classifier, technical indicator...Predict daily stock prices with random forest classifier, technical indicator...
Predict daily stock prices with random forest classifier, technical indicator...QuantInsti
 
How Pandemics Impact the Financial Markets - A Quantitative Analysis
How Pandemics Impact the Financial Markets - A Quantitative AnalysisHow Pandemics Impact the Financial Markets - A Quantitative Analysis
How Pandemics Impact the Financial Markets - A Quantitative AnalysisQuantInsti
 
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...QuantInsti
 
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...QuantInsti
 

Plus de QuantInsti (20)

ChatGPT and Machine Learning in Trading
ChatGPT and Machine Learning in TradingChatGPT and Machine Learning in Trading
ChatGPT and Machine Learning in Trading
 
Introduction to Quantitative Factor Investing
Introduction to Quantitative Factor InvestingIntroduction to Quantitative Factor Investing
Introduction to Quantitative Factor Investing
 
Machine Learning for Options Trading
Machine Learning for Options TradingMachine Learning for Options Trading
Machine Learning for Options Trading
 
Portfolio Assets Allocation with Machine Learning
Portfolio Assets Allocation with Machine LearningPortfolio Assets Allocation with Machine Learning
Portfolio Assets Allocation with Machine Learning
 
Price Action Trading - An Introduction
Price Action Trading - An IntroductionPrice Action Trading - An Introduction
Price Action Trading - An Introduction
 
Introduction to Systematic Options Trading
Introduction to Systematic Options TradingIntroduction to Systematic Options Trading
Introduction to Systematic Options Trading
 
Competitive Edges in Algorithmic Trading
Competitive Edges in Algorithmic TradingCompetitive Edges in Algorithmic Trading
Competitive Edges in Algorithmic Trading
 
Volatility Trading: Trading The Fear Index VIX
Volatility Trading: Trading The Fear Index VIXVolatility Trading: Trading The Fear Index VIX
Volatility Trading: Trading The Fear Index VIX
 
Big Data And The Future Of Retail Investing
Big Data And The Future Of Retail InvestingBig Data And The Future Of Retail Investing
Big Data And The Future Of Retail Investing
 
Backtest of Short Straddles on SPX Index
Backtest of Short Straddles on SPX IndexBacktest of Short Straddles on SPX Index
Backtest of Short Straddles on SPX Index
 
Pairs Trading In the Brazilian Stock Market
Pairs Trading In the Brazilian Stock MarketPairs Trading In the Brazilian Stock Market
Pairs Trading In the Brazilian Stock Market
 
How To Set Up Automated Trading
How To Set Up Automated TradingHow To Set Up Automated Trading
How To Set Up Automated Trading
 
How To Set Up Automated Trading
How To Set Up Automated TradingHow To Set Up Automated Trading
How To Set Up Automated Trading
 
Quantitative Data Analysis of Cryptocurrencies
Quantitative Data Analysis of CryptocurrenciesQuantitative Data Analysis of Cryptocurrencies
Quantitative Data Analysis of Cryptocurrencies
 
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...Introduction to Quantitative Trading - Investment Management Club of Yale Uni...
Introduction to Quantitative Trading - Investment Management Club of Yale Uni...
 
How to automate an options day trading strategy
How to automate an options day trading strategyHow to automate an options day trading strategy
How to automate an options day trading strategy
 
Predict daily stock prices with random forest classifier, technical indicator...
Predict daily stock prices with random forest classifier, technical indicator...Predict daily stock prices with random forest classifier, technical indicator...
Predict daily stock prices with random forest classifier, technical indicator...
 
How Pandemics Impact the Financial Markets - A Quantitative Analysis
How Pandemics Impact the Financial Markets - A Quantitative AnalysisHow Pandemics Impact the Financial Markets - A Quantitative Analysis
How Pandemics Impact the Financial Markets - A Quantitative Analysis
 
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
 
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...
Webinar on Algorithmic Trading - Why make the move? with Vivek Krishnamoorthy...
 

Dernier

Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Call Girls in Nagpur High Profile
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptxFinTech Belgium
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Pooja Nehwal
 
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure serviceCall US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure servicePooja Nehwal
 
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Delhi Call girls
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfSaviRakhecha1
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfGale Pooley
 
Stock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfStock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfMichael Silva
 
The Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfThe Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfGale Pooley
 
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Pooja Nehwal
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...Call Girls in Nagpur High Profile
 
Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.Vinodha Devi
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja Nehwal
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...Call Girls in Nagpur High Profile
 

Dernier (20)

Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...Top Rated  Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
Top Rated Pune Call Girls Viman Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Sex...
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
 
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
VIP Call Girl in Mira Road 💧 9920725232 ( Call Me ) Get A New Crush Everyday ...
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
 
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
 
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure serviceCall US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
Call US 📞 9892124323 ✅ Kurla Call Girls In Kurla ( Mumbai ) secure service
 
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdf
 
The Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdfThe Economic History of the U.S. Lecture 25.pdf
The Economic History of the U.S. Lecture 25.pdf
 
Stock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfStock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdf
 
The Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfThe Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdf
 
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
 
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(DIYA) Bhumkar Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
 
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(INDIRA) Call Girl Mumbai Call Now 8250077686 Mumbai Escorts 24x7
 
Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 

How to design quant strategies using R

  • 1. How to design quant strategies using R Saturday, May 16, 2015 Anil Yadav (Head, Algorithm strategy advisory team at iRageCapital)
  • 2. Content  What is R?  How can we use R packages in writing quantitative trading strategies?  Steps in development of a quantitative trading strategy  Optimizing the quantitative trading strategy Disclaimer: The information in this presentation is intended to be general in nature and is not financial product advice.
  • 3. Introduction to R  R is an open source software. It is free!  Popular because it has packages with readymade functions  Easy to find help for queries or code on internet Installation: Download and install R-studio from (http://cran.r-project.org) Help guide: (http://www.rseek.org/)
  • 4. Packages in R • We will use the package ‘quantstrat’ for writing our strategy today – Install the package install.packages("quantstrat", repos=http://R-Forge.R-project.org) – Install the dependencies (FinancialInstrument, blotter, foreach, doParallel) install.packages("FinancialInstrument", repos=http://R-Forge.R-project.org) • Other useful CRAN packages: TTR, quantmod, etc
  • 5. Writing a quant strategy The steps are: 1. Hypothesis Formation – what is the idea for trade 2. Testing - statistically testing the hypothesis with data, how much confidence do you have on your strategy 3. Refining – Optimizing the strategy parameters and paper trading 4. Production - Implementing the strategy in a live trading environment. This would involve writing the strategy on a trading platform.
  • 6. Step 1: Hypothesis What is a hypothesis? This is your trading idea. It could be any combination of technical trading rules/it could be your “feel” for the market regime. It is the first thing to be derived out of the trading data. Hypothesis for our strategy: Market is mean reverting
  • 7. Step 2: Testing To test the hypothesis, we will have to write it as a strategy which has statistical methods to compute the indicators, signals and calculate the profits for the given data. The steps for the testing part are: 1. Get the data 2. Write the strategy (indicators, signals, trades, PnL) 3. Analyze the output
  • 8. Data • Nifty-Bees (ETF) Data from from NSE (It is a Goldman Sachs managed ETF which trades on the Indian Stock exchanges. National Stock Exchange has higher volumes for the instrument and therefore the data) • OHLC data Snapshot below: Date OPEN HIGH LOW CLOSE 11/18/2014 9:15 850.15 853 850.15 852 11/18/2014 9:19 853.89 853.89 851.8 851.8 11/18/2014 9:20 853.97 853.97 853.97 853.97 11/18/2014 9:21 853.97 853.98 853.97 853.98 11/18/2014 9:22 853.98 853.98 853.98 853.98 11/18/2014 9:23 853.97 853.97 853.97 853.97 11/18/2014 9:24 852.51 854.45 852.51 854 11/18/2014 9:25 854 854 854 854
  • 9. Plot the data We take a look at the data and plot Bollinger bands to get the first verification on our hypothesis. chart_Series(NSEI) zoom_Chart("2014-11-19") addBBands(n=20, sd =2)
  • 10. Writing the strategy These are the steps in writing the strategy. Install the packages Read the data file Initialize of variables, parameters Create Indicators Generate Signal Trading rule for execution Output Optimize For our discussion today, we will focus on the parts which are highlighted.
  • 11. Indicator •For each row, we check & compare the closing price with threshold value (Thresh) •If price increases or decreases, threshold is updated accordingly in column THT •The indicator prices for comparison are updated using Thresh2, saved in UP and DOWN to be used for selling and buying respectively Signal •For each row, the closing price is compared with UP (upper band price) and with DOWN (lower band price). •As per the logic of in-built in ‘sigCrossover’ function, the output is ‘TRUE’ or ‘FALSE’ •If TRUE, trading rule is applied Trading Rule •When upper band is crossed, it generates a market order for ‘sell’ position. Orderqty = -1 •When lower band is crossed, it generates a market order for ‘buy’ position. Orderqty = 1 Writing the strategy
  • 12. Indicator Indicator •For each row, we check & compare the closing price with threshold value (Thresh) •If price increases or decreases, threshold(Thresh) is updated accordingly in column THT •The indicator prices for comparison are updated using band limit (Thresh2), saved in UP and DOWN to be used for selling and buying respectively THTFunc<-function(CompTh=NSEI,Thresh=6, Thresh2=3){ numRow<- nrow(CompTh) xa<-coredata(CompTh)[,4] xb<-xa tht<-xa[1] for(i in 2:numRow){ if(xa[i]>(tht+Thresh)){ tht<-xa[i]} if(xa[i]<(tht-Thresh)){ tht<-xa[i]} xb[i]<-tht } up <- xb + Thresh2 dn<- xb-Thresh2 res <- cbind(xb, dn,up) colnames(res) <- c("THT", "DOWN", "UP") reclass(res,CompTh) } THTFunc()
  • 13. Signal Signal •For each row, the closing price is compared with UP (upper band price) and with DOWN (lower band price). •As per the logic of in-built in ‘sigCrossover’ function, the output is ‘TRUE’ or ‘FALSE’ •If TRUE, trading rule is applied #add your signal stratMR <- add.signal(stratMR,name="sigCrossover",arguments = list(columns=c("Close","UP"),relationship="gt"),label="Cl.gt.UpperBand") stratMR <- add.signal(stratMR,name="sigCrossover",arguments = list(columns=c("Close","DOWN"),relationship="lt"),label="Cl.lt.LowerBand")
  • 14. Trading Rule Trading Rule • When upper band is crossed, it generates a market order for ‘sell’ position. Orderqty = -1 • When lower band is crossed, it generates a market order for ‘buy’ position. Orderqty = 1 #add trading rule long short stop_loss, take_profit stratMR <- add.rule(stratMR,name='ruleSignal', arguments = list(sigcol="Cl.gt.UpperBand",sigval=TRUE, prefer = 'close', orderqty=-1, ordertype='market', orderside=NULL, threshold=NULL,osFUN=osMaxPos),type='enter') stratMR <- add.rule(stratMR,name='ruleSignal', arguments = list(sigcol="Cl.lt.LowerBand",sigval=TRUE, prefer = 'close', orderqty= 1, ordertype='market', orderside=NULL, threshold=NULL,osFUN=osMaxPos),type='enter')
  • 15. Summarizing the code Implementation Steps • Function Block • Adding Indicator • Adding Signal • Adding Rules Run Strategy Indicator • Calls THTFunc • Updates Up/Down/Thresh Signal • Crossover • Updates Cl.gt.UpperBand and Cl.lt.LowerBand Trading Rule • Signal Value True • Order Details
  • 16. Analyze output row.names NSEI Portfolio MeanRev Symbol NSEI Num.Txns 102 Num.Trades 51 Net.Trading.PL 5.02 Avg.Trade.PL 0.098431 Med.Trade.PL 0.1 Largest.Winner 3.8 Largest.Loser -3 Gross.Profits 26.81 Gross.Losses -21.79 Std.Dev.Trade.PL 1.252465 Percent.Positive 54.90196 Percent.Negative 45.09804 #run the strategy out<-try(applyStrategy(strategy=stratMR , portfolios='MeanRev') ) # look at the order book getOrderBook('MeanRev') updatePortf('MeanRev', stock.str) chart.Posn(Portfolio='MeanRev',Symbol=stock.str) Strategy output uses tradeStats tradeStats('MeanRev', stock.str) View(t(tradeStats('MeanRev')))
  • 18. Writing a strategy The steps are:  Hypothesis Formation – what is the idea for trade  Testing - statistically testing the hypothesis with data, how much confidence do you have on your strategy  Refining – Optimizing the strategy parameters and paper trading  Production - Implementing the strategy in a live trading environment. This would involve writing the strategy on a trading platform.
  • 19. Step 3: Optimization .Th2 = c(.3,.4) .Th1 = c(.5,.6) results <- apply.paramset(stratMR, paramset.label='THTFunc', portfolio.st=portfolio.st, account.st=account.st, nsamples=4, verbose=TRUE)
  • 20. Step 3: Refining  What other techniques can you use for further refining your strategy?  Run the code with more data  Bayesian update for threshold  Threshold 1, 2 can take volatility into account
  • 21. Writing a strategy The steps are:  Hypothesis Formation – what is the idea for trade  Testing - statistically testing the hypothesis with data, how much confidence do you have on your strategy  Refining – Optimizing the strategy parameters and paper trading  Production - Implementing the strategy in a live trading environment. This would involve writing the strategy on a trading platform.
  • 22. About QI & EPAT Quantinsti Quantitative Pvt Ltd. - Quantinsti developed the curriculum for the first dedicated educational program on Algorithmic and High-Frequency Trading globally (EPAT) in 2009. Launched with an aim to introduce its course participants to a world class exposure in the domain of Algorithmic Trading,it provides participants with in- house proprietary tools and other globally renowned applications to rise steeply on the learning curve that they witness during the program. Executive Program in Algorithmic Trading (EPAT)- • 6-months long comprehensive course in Algorithmic and Quantitative Trading. • Primary focus on financial technology trends and solutions. • It is an online live interactive course aimed at working professionals from diverse backgrounds such as trading-brokerage services, Analytics, Quantitative roles, and Programming & IT industry. • Get placement assistance and internship opportunities with leading global firms after the program
  • 23. Program Delivery • Next EPAT batch starting from 10th January, 2015. • Weekends only program – 3 hrs sessions on Saturday & Sunday both – 4 months long program + 2 months project / internship – Practical Oriented – 100 contact hours including practical sessions • Convenience – Conducted online • Open Source • Virtual Classroom integration • Student Portal • Faculty supervision • Placement assistance
  • 24. Thank you! Next steps  Watch QI youtube videos for more learning  Read more at http://www.rinfinance.com/agenda/2013/workshop/Hum me+Peterson.pdf  Contact us if you wish to learn R for Algo trading  Questions? Contact us at @ contact@quantinsti.com or sales@quantinsti.com or @: +91-22-61691400, +91-9920448877
  • 25. Contact Us To Learn Automated Trading Email: contact@quantinsti.com Connect With Us: SINGAPORE 11 Collyer Quay, #10-10, The Arcade, Singapore - 049317 Phone: +65-6221-3654 INDIA A-309, Boomerang, Chandivali Farm Road, Powai, Mumbai - 400 072 Phone: +91-022-61691400

Notes de l'éditeur

  1. You might have heard a lot about R especially in context of big data. In quant trading, R has gained a lot of popularity as it is free and open sourced. That reduces our task for re-writing the functions which are already there. For instance, with only one line of code BBands(prices, n=60,"SMA",sd=2) you have created bollinger bands for your data.
  2. Here can mention the difference between Cran packages and other packages
  3. Pls write 3-4 words explaining the jargon.
  4. Pls add the content – based on data that we will see. This is strategy that we intend to test.
  5. Pls add the content
  6. Pls provide the answers for international audience
  7. Define a time-varying Threshold Price Create a UP/DOWN band around the Threshold Price THTFunc() does this in the Code Threshold Price (Thresh1) Band Limits (Thresh2)
  8. sigCrossover is an in-built function
  9. Pls write 3-4 words explaining the jargon.
  10. Pls write 3-4 words explaining the jargon.