Why do people trade?
FIN AN C IAL TR AD IN G IN R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
Wh y do people trade ? FIN AN C IAL TR AD IN G IN R Il y a Kipnis - - PowerPoint PPT Presentation
Wh y do people trade ? FIN AN C IAL TR AD IN G IN R Il y a Kipnis Professional Q u antitati v e Anal y st and R programmer What is trading ? The act of BUYING or SELLING an asset BUYING tangible prod u ct SELLING nancial sec u rit
FIN AN C IAL TR AD IN G IN R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
FINANCIAL TRADING IN R
The act of BUYING or SELLING an asset BUYING → tangible product SELLING → nancial security Cash → product → cash (hopefully making a prot!)
FINANCIAL TRADING IN R
To make a prot To take on, ooad, and hedge nancial risk To protect a company from commodity price movements Systematic trading: risk/reward payo is favorable enough to bear the risk
hp://www.cntraveler.com/ hps://qzprod.les.wordpress.com
1 2
FINANCIAL TRADING IN R
Divergence (or momentum, trend trading): The movement of a quantity will continue in its current direction eg CTA (commodity trading advisors)
FINANCIAL TRADING IN R
Convergence (or reversion, cycle trading): The movement of a quantity will eventually reverse eg Warren Bue
FIN AN C IAL TR AD IN G IN R
FIN AN C IAL TR AD IN G IN R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
FINANCIAL TRADING IN R
Market data is a mix of fear, greed, and noise of millions “Past performance is not indicative of future results.” Overt on past (in-sample) data means bad performance on future (out-of-sample) data
FINANCIAL TRADING IN R
Can cause a system to fail in the future Minimize the number of moving objects! GOOD strategy BAD strategy
FINANCIAL TRADING IN R
FINANCIAL TRADING IN R
FINANCIAL TRADING IN R
Perform hypothesis tests Relationship between an indicator & future returns? Signal process to generates outperformance? Most of these are beyond the scope of the course, but keep them in mind
FIN AN C IAL TR AD IN G IN R
FIN AN C IAL TR AD IN G IN R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
FINANCIAL TRADING IN R
Every trading system relies on data (oen costly) Yahoo! Finance has free data Use the getSymbols() command in quantmod
FINANCIAL TRADING IN R
LQD:
getSymbols("LQD", from = "1990-01-01", src = "yahoo", adjusted = TR LQD.Open LQD.High LQD.Low LQD.Close LQD.Volume LQD.Adjust 2002-07-30 101.30 102.00 101.25 101.37 21200 52.168 2002-07-31 101.80 102.25 101.55 101.99 272000 52.487 2002-08-01 102.40 103.10 102.30 102.99 111700 53.002 2002-08-02 102.90 103.30 102.45 103.20 29200 53.110 2002-08-05 103.65 103.65 102.51 102.95 166500 52.982 2002-08-06 102.50 102.65 102.10 102.60 430100 52.801
Spy: see exercises
FINANCIAL TRADING IN R
Op() : Opening day prices Hi() : Maximum value traded during the day Lo() : Minimum value traded during the day Cl() : Last price that was traded Vo() : Number of trades that day Ad() : Adjusted closing price, adjust for dividends & splits
FINANCIAL TRADING IN R
Plot data using the plot() command
plot(Cl(LQD))
FIN AN C IAL TR AD IN G IN R
FIN AN C IAL TR AD IN G IN R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
FINANCIAL TRADING IN R
TTR: toolbox of classical trading indicators SMA (Simple Moving Average) Popular for CTA’s: 200-day moving average Displays where prices have been over the past 10 months
FINANCIAL TRADING IN R
# Compute a simple moving average (SMA) across 200 days sma <- SMA(x = Cl(LQD), n = 200) # Add the SMA line to your plot of LQD closing price plot(Cl(LQD)) lines(sma, col = "red")
FINANCIAL TRADING IN R
FIN AN C IAL TR AD IN G IN R