setting u p a strateg y i
play

Setting u p a strateg y I FIN AN C IAL TR AD IN G IN R Il y a - PowerPoint PPT Presentation

Setting u p a strateg y I 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 Three important dates Q u antstrat needs an initDate , a from date , and a to date . YYYY - MM - DD , eg


  1. Setting u p a strateg y I 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

  2. Three important dates Q u antstrat needs an initDate , a from date , and a to date . YYYY - MM - DD , eg “2000-01-01” initdate <- "1999-01-01" from <- "2003-01-01" to <- "2015-12-31" FINANCIAL TRADING IN R

  3. Setting u p q u antstrat # Set system environment timezone: Sys.setenv(TZ = "UTC") # Set currency (we’ll use USD for now): currency("USD") # Obtain financial data: getSymbols("LQD", from = from, to = to, src = "yahoo", adjust = TRUE) # Treat as basic equity stock("LQD", currency = "USD", multiplier = 1) FINANCIAL TRADING IN R

  4. O v er v ie w initDate = "1999-01-01" from = "2003-01-01" to = “2015-12-31" Sys.setenv(TZ = "UTC") currency("USD") getSymbols("LQD", from = from, to = to, src = "yahoo", adjust = TRUE) FINANCIAL TRADING IN R

  5. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

  6. Setting u p a strateg y II 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

  7. Trade si z e and initial eq u it y In order to w ork w ith ret u rns , y o u need to de � ne trade si z e and initial eq u it y to calc u late pro � t and loss tradesize <- 100000 initeq <- 100000 tradesi z e sho u ld not be more than initeq FINANCIAL TRADING IN R

  8. Three important objects Acco u nt Portfolio Strateg y FINANCIAL TRADING IN R

  9. Naming acco u nt , portfolio , and strateg y Naming the acco u nt , portfolio , and strateg y all the same name s u� ces for basic strategies strategy.st <- portfolio.st <- account.st <- "firststrat" FINANCIAL TRADING IN R

  10. Remo v ing e x isting strateg y If y o u ran the strateg y alread y, y o u need to remo v e it from y o u r en v ironment rm.strat(strategy.st) FINANCIAL TRADING IN R

  11. Initiali z e … Portfolio Acco u nt Orders Strateg y FINANCIAL TRADING IN R

  12. Initiali z ing portfolio Portfolio initiali z ation is called w ith initPortf() initPortf() req u ires portfolio name , s y mbols , initiali z ation date , and c u rrenc y initPortf(portfolio.st, symbols = "LQD", initDate = initdate, currency = "USD") FINANCIAL TRADING IN R

  13. Initiali z ing acco u nt Acco u nt initiali z ation is called w ith initAcct() initAcct() req u ires acco u nt name , portfolios , initiali z ation date , c u rrenc y, and initial eq u it y initAcct(account.st, portfolios = portfolio.st, initDate = initdate, currency = "USD", initEq = initeq) FINANCIAL TRADING IN R

  14. Initiali z ing orders Order initiali z ation is called w ith initOrders() initOrders() req u ires portfolio name and initiali z ation date initOrders(portfolio.st, initDate = initdate) FINANCIAL TRADING IN R

  15. Initiali z ing strateg y Strateg y initiali z ation is called w ith strategy() strategy(strategy.st, store = TRUE) FINANCIAL TRADING IN R

  16. O v er v ie w tradesize <- 100000 initeq <- 100000 strategy.st <- portfolio.st <- account.st <- "firststrat" rm.strat(strategy.st) initPortf(portfolio.st, symbols = "LQD", initDate = initdate, currency = "USD") initAcct(account.st, portfolios = portfolio.st, initDate = initdate, currency = "USD", initEq = initeq) initOrders(portfolio.st, initDate = initdate) strategy(strategy.st, store = TRUE) FINANCIAL TRADING IN R

  17. Let ' s practice ! FIN AN C IAL TR AD IN G IN R

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend