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 y Cash → prod u ct → cash ( hopef u ll y making a pro � t !) FINANCIAL TRADING IN R
Wh y do people trade ? To make a pro � t To take on , o � oad , and hedge � nancial risk To protect a compan y from commodit y price mo v ements S y stematic trading : risk / re w ard pa y o � is fa v orable eno u gh to bear the risk 1 2 h � p ://www. cntra v eler . com / h � ps :// q z prod .� les .w ordpress . com FINANCIAL TRADING IN R
T y pes of trading Di v ergence ( or moment u m , trend trading ): The mo v ement of a q u antit y w ill contin u e in its c u rrent direction eg CTA ( commodit y trading ad v isors ) FINANCIAL TRADING IN R
T y pes of trading Con v ergence ( or re v ersion , c y cle trading ): The mo v ement of a q u antit y w ill e v ent u all y re v erse eg Warren B u� e � FINANCIAL TRADING IN R
Let ' s practice ! FIN AN C IAL TR AD IN G IN R
Pitfalls of v ario u s trading s y stems 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
Pitfalls in trading s y stem de v elopment Market data is a mi x of fear , greed , and noise of millions “ Past performance is not indicati v e of f u t u re res u lts .” O v er � t on past ( in - sample ) data means bad performance on f u t u re ( o u t - of - sample ) data FINANCIAL TRADING IN R
Ho w to not o v erfit Can ca u se a s y stem to fail in the f u t u re Minimi z e the n u mber of mo v ing objects ! GOOD strateg y BAD strateg y FINANCIAL TRADING IN R
Stabilit y w ith s y stem settings - S y stem sho u ld beha v e similarl y for similar se � ings le v els FINANCIAL TRADING IN R
Stabilit y w ith s y stem settings - S y stem sho u ld beha v e similarl y for similar se � ings le v els FINANCIAL TRADING IN R
H y pothesis testing Perform h y pothesis tests Relationship bet w een an indicator & f u t u re ret u rns ? Signal process to generates o u tperformance ? Most of these are be y ond the scope of the co u rse , b u t keep them in mind FINANCIAL TRADING IN R
Let ' s practice ! FIN AN C IAL TR AD IN G IN R
Getting financial data 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
Obtaining data from Yahoo ! E v er y trading s y stem relies on data ( o � en costl y) Yahoo ! Finance has free data Use the getSymbols() command in q u antmod FINANCIAL TRADING IN R
2 ETFs in this co u rse 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 Sp y: see e x ercises FINANCIAL TRADING IN R
q u antmod f u nctions Op() : Opening da y prices Hi() : Ma x im u m v al u e traded d u ring the da y Lo() : Minim u m v al u e traded d u ring the da y Cl() : Last price that w as traded Vo() : N u mber of trades that da y Ad() : Adj u sted closing price , adj u st for di v idends & splits FINANCIAL TRADING IN R
Plotting financial data Plot data u sing the plot() command plot(Cl(LQD)) FINANCIAL TRADING IN R
Let ' s practice ! FIN AN C IAL TR AD IN G IN R
Adding indicators to financial data 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
Trading indicators TTR : toolbo x of classical trading indicators SMA ( Simple Mo v ing A v erage ) Pop u lar for CTA ’ s : 200- da y mo v ing a v erage Displa y s w here prices ha v e been o v er the past 10 months FINANCIAL TRADING IN R
Using SMA () # 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
The trend line FINANCIAL TRADING IN R
Let ' s practice ! FIN AN C IAL TR AD IN G IN R
Recommend
More recommend