Webinar: An Introduction To R for Trading w/Ilya Kipnis - Matlab, R project and Python | futures io social day trading
futures io futures trading


Webinar: An Introduction To R for Trading w/Ilya Kipnis
Updated: Views / Replies:26,853 / 150
Created: by Big Mike Attachments:44

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 44  
 
Thread Tools Search this Thread
 

Webinar: An Introduction To R for Trading w/Ilya Kipnis

  #71 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received

Hm, one thing I can try and recommend is this:

install.packages("foreach") . Quantstrat's installation does not naturally get this package for some reason (at least on Windows), so that may be one cause.

Beyond that, I'm running Windows 8 and R 3.1.1 and can get my packages to successfully install.

If you're running on macs, I'm afraid I can't help too much because I'm not overly familiar with macs.

Also, try the RCpp mailing list, or R-SIG finance mailing lists.

But beyond and above all else, I recommend trying to get a linux installation going.

That said, here's one last workaround: the reason I use Rcpp in my IKTrading package (thus far) is the Heiken Ashi computation (which some may be familiar with), but one that I have yet to personally tackle. However, I do use my osDollarATR function extensively, so here's the code for it and its sister function, lagATR. If IKTrading does not install for you, just copy and paste this code into a file you can source from someplace.

 
Code
"lagATR" <- function(HLC, n=14, maType, lag=1, ...) {
  ATR <- ATR(HLC, n=n, maType=maType, ...)
  ATR <- lag(ATR, lag)
  out <- ATR$atr
  colnames(out) <- "atr"
  return(out)
}

"osDollarATR" <- function(orderside, tradeSize, pctATR, maxPctATR=pctATR, data, timestamp, symbol,
                        prefer="Open", portfolio, integerQty=TRUE, atrMod="", rebal=FALSE, ...) {
  if(tradeSize > 0 & orderside == "short"){
    tradeSize <- tradeSize*-1
  }
  pos <- getPosQty(portfolio, symbol, timestamp)
  atrString <- paste0("atr",atrMod)
  atrCol <- grep(atrString, colnames(mktdata))
  if(length(atrCol)==0) {
    stop(paste("Term", atrString, "not found in mktdata column names."))
  }
  atrTimeStamp <- mktdata[timestamp, atrCol]
  if(is.na(atrTimeStamp) | atrTimeStamp==0) {
    stop(paste("ATR corresponding to",atrString,"is invalid at this point in time. 
               Add a logical operator to account for this."))
  }
  dollarATR <- pos*atrTimeStamp
  desiredDollarATR <- pctATR*tradeSize
  remainingRiskCapacity <- tradeSize*maxPctATR-dollarATR
  
  if(orderside == "long"){
    qty <- min(tradeSize*pctATR/atrTimeStamp, remainingRiskCapacity/atrTimeStamp)
  } else {
    qty <- max(tradeSize*pctATR/atrTimeStamp, remainingRiskCapacity/atrTimeStamp)
  }
  
  if(integerQty) {
    qty <- trunc(qty)
  }
  if(!rebal) {
    if(orderside == "long" & qty < 0) {
      qty <- 0
    }
    if(orderside == "short" & qty > 0) {
      qty <- 0
    }
  }
  if(rebal) {
    if(pos == 0) {
      qty <- 0
    }
  }
  return(qty)
}
I'm hoping someone else more familiar with the intricacies of the various operating systems can help the packages install, since I can't replicate the installation issues on my end.


Last edited by Big Mike; September 6th, 2014 at 07:37 PM. Reason: wrapped code in code bbcode
Reply With Quote
 
  #72 (permalink)
Trading Apprentice
New York City, New York
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS
Favorite Futures: Options, Equities, Futures
 
Posts: 18 since Sep 2014
Thanks: 2 given, 5 received


IlyaKipnis View Post
Concerns with R-forge seem to be a more common occurrence than I thought. Here's a good link on starting to resolve the problems:

This Link clears it up a bit, but it keeps referring to Windows. How do you go about the SVN process onward in a mac system? I'm guessing you follow the SVN commands, but then what do you do about the build/install. Thanks!

Reply With Quote
 
  #73 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received



CaptainNegatory View Post
This Link clears it up a bit, but it keeps referring to Windows. How do you go about the SVN process onward in a mac system? I'm guessing you follow the SVN commands, but then what do you do about the build/install. Thanks!

When I used macs at my last official job, there was an application called terminal that brought up the bash terminal. IIRC that terminal functions exactly as a linux/unix command line OS would, allowing you to use the R CMD BUILD and R CMD INSTALL commands to build R packages from their .tar.gz source. I don't remember precisely what I did, but it involved using those two commands quite a bit.

Reply With Quote
 
  #74 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


IlyaKipnis View Post
Hm, one thing I can try and recommend is this:

install.packages("foreach") . Quantstrat's installation does not naturally get this package for some reason (at least on Windows), so that may be one cause.

Beyond that, I'm running Windows 8 and R 3.1.1 and can get my packages to successfully install.

If you're running on macs, I'm afraid I can't help too much because I'm not overly familiar with macs.

Also, try the RCpp mailing list, or R-SIG finance mailing lists.

But beyond and above all else, I recommend trying to get a linux installation going.

That said, here's one last workaround: the reason I use Rcpp in my IKTrading package (thus far) is the Heiken Ashi computation (which some may be familiar with), but one that I have yet to personally tackle. However, I do use my osDollarATR function extensively, so here's the code for it and its sister function, lagATR. If IKTrading does not install for you, just copy and paste this code into a file you can source from someplace.

 
Code
"lagATR" <- function(HLC, n=14, maType, lag=1, ...) {
  ATR <- ATR(HLC, n=n, maType=maType, ...)
  ATR <- lag(ATR, lag)
  out <- ATR$atr
  colnames(out) <- "atr"
  return(out)
}

"osDollarATR" <- function(orderside, tradeSize, pctATR, maxPctATR=pctATR, data, timestamp, symbol,
                        prefer="Open", portfolio, integerQty=TRUE, atrMod="", rebal=FALSE, ...) {
  if(tradeSize > 0 & orderside == "short"){
    tradeSize <- tradeSize*-1
  }
  pos <- getPosQty(portfolio, symbol, timestamp)
  atrString <- paste0("atr",atrMod)
  atrCol <- grep(atrString, colnames(mktdata))
  if(length(atrCol)==0) {
    stop(paste("Term", atrString, "not found in mktdata column names."))
  }
  atrTimeStamp <- mktdata[timestamp, atrCol]
  if(is.na(atrTimeStamp) | atrTimeStamp==0) {
    stop(paste("ATR corresponding to",atrString,"is invalid at this point in time. 
               Add a logical operator to account for this."))
  }
  dollarATR <- pos*atrTimeStamp
  desiredDollarATR <- pctATR*tradeSize
  remainingRiskCapacity <- tradeSize*maxPctATR-dollarATR
  
  if(orderside == "long"){
    qty <- min(tradeSize*pctATR/atrTimeStamp, remainingRiskCapacity/atrTimeStamp)
  } else {
    qty <- max(tradeSize*pctATR/atrTimeStamp, remainingRiskCapacity/atrTimeStamp)
  }
  
  if(integerQty) {
    qty <- trunc(qty)
  }
  if(!rebal) {
    if(orderside == "long" & qty < 0) {
      qty <- 0
    }
    if(orderside == "short" & qty > 0) {
      qty <- 0
    }
  }
  if(rebal) {
    if(pos == 0) {
      qty <- 0
    }
  }
  return(qty)
}
I'm hoping someone else more familiar with the intricacies of the various operating systems can help the packages install, since I can't replicate the installation issues on my end.


Thank Ilya I got it to install. Glad you responded so quickly, i really appreciate it.

Reply With Quote
The following user says Thank You to treydog999 for this post:
 
  #75 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received


treydog999 View Post
Thank Ilya I got it to install. Glad you responded so quickly, i really appreciate it.

Was it the foreach installation?

Reply With Quote
 
  #76 (permalink)
Elite Member
seoul, Korea
 
Futures Experience: Intermediate
Platform: Multicharts
Broker/Data: CQG, DTN IQfeed
Favorite Futures: YM 6E
 
treydog999's Avatar
 
Posts: 894 since Jul 2012
Thanks: 291 given, 1,006 received


IlyaKipnis View Post
Was it the foreach installation?

I did not do a foreach installation. I had it installed seperately already with redis. However I did install Rtools for windows and then I restarted my Rstudio session. I did not actually access anything or run anything specifically through R tools. But maybe it helped? To be honest No idea but it works now.

Reply With Quote
 
  #77 (permalink)
Elite Member
Philadelphia + NJ/US
 
Futures Experience: Beginner
Platform: quantstrat
Favorite Futures: ETFs
 
Posts: 52 since Aug 2014
Thanks: 4 given, 39 received


treydog999 View Post
I did not do a foreach installation. I had it installed seperately already with redis. However I did install Rtools for windows and then I restarted my Rstudio session. I did not actually access anything or run anything specifically through R tools. But maybe it helped? To be honest No idea but it works now.

As far as I understand, Rtools is critical for getting some unix-like functionality into windows to allow the R CMD BUILD and R CMD INSTALL commands to execute properly. Since both of my packages use a sprinkling of Rcpp (R/C++ hybrid), Rtools is necessary.

Reply With Quote
 
  #78 (permalink)
Trading Apprentice
New York City, New York
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS
Favorite Futures: Options, Equities, Futures
 
Posts: 18 since Sep 2014
Thanks: 2 given, 5 received


IlyaKipnis View Post
When I used macs at my last official job, there was an application called terminal that brought up the bash terminal. IIRC that terminal functions exactly as a linux/unix command line OS would, allowing you to use the R CMD BUILD and R CMD INSTALL commands to build R packages from their .tar.gz source. I don't remember precisely what I did, but it involved using those two commands quite a bit.

The cmd line does work, as well as in R Studio with the following code:

 
Code
install.packages("/Users/TheProfitcy/Desktop/quantstrat_0.6.1.tar.gz", repos = NULL, type="source")
However, you have to specify the packages you want to install from quantstrat, FinancialInstrument, and blotter, and there are apparently some dependencies, so order is important here. This leaves me with a couple questions:

1) What packages do I need, and how do I look inside the .tar.gz to see what they are named for the command prompt?
2) How do I install the dependencies first?
3) How do I get the "TTR" package? I can't seem to find this in R-Forge?
4) Please tell me this only has to be done one time?

Thanks Again,
CaptainNegatory

Reply With Quote
 
  #79 (permalink)
Elite Member
Munich Germany
 
Futures Experience: Beginner
Platform: MultiCharts .NET,MultiCharts,Amibroker
Broker/Data: Interactive Brokers IQFeed
Favorite Futures: Stocks,Index CFDs
 
Posts: 149 since Aug 2012
Thanks: 81 given, 77 received

Thanks for the slides

Hello and thank you very much for that webinar.

At first I was sceptical about the speed of R compared to Matlab.
However, R has a definite advantage about reading large CSV files about Matlab this is a
crucial feature in case I want to investigate price action on a minute data or even tick data file.
I had to write my own extension for reading CSV efficiently in Matlab.
I realized that R is as fast as my plugin for reading large CSV in Matlab.
So this is a big plus for R in my opinion.

Therefore, I will keep on learning R.
However in my opinion I would like to use it for maybe intraday seasonalities e.g. average all minute trade data for only mondays and see if there is a distinctive price pattern. I think for those investigations R is very well suited and
this is something one can only hardly do with standard commercial charting software packages.

Or maybe to investigate how much do the today highs penetrate yesterday highs in an uptrend (defined by close above EMA or any trend indicator), by plotting an histogram of those data.
So I would use it more for the first steps of developing a trading system, than for backtesting.

I will enjoy the next webinar and I am very curious what Ilya can do with R.
So overall a great start in my opinion.

Reply With Quote
The following user says Thank You to FB2012 for this post:
 
  #80 (permalink)
Elite Member
Cary, NC
 
Futures Experience: Advanced
Platform: MC, NT, Python, R
Broker/Data: FXCM, IB, Oanda, IQFeed
Favorite Futures: 6E, CL, EUR/USD
 
Fu510n's Avatar
 
Posts: 96 since Oct 2009
Thanks: 729 given, 81 received



Big Mike View Post
What did everyone think of the webinar?

Mike

I was away on business so didn't get a chance to watch until today but it was an excellent intro and glad he kept things moving along .

Going to try out a few things now especially given I'm taking a look recently at ETFs for my 401k (vs. constant focus on futures trading 6E/CL/NG).

Thanks as always for providing us all great learning resources Mike!

-Guy

Reply With Quote
The following user says Thank You to Fu510n for this post:

Reply



futures io > > > > Webinar: An Introduction To R for Trading w/Ilya Kipnis

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webinar: Introduction to C# and Ninjascript Programming, Feb 23rd @ 1:00PM Eastern shodson The Elite Circle 67 December 2nd, 2014 08:44 PM
Webinar: FuturePath Trading and PhotonTrader introduction w/Damon Pavlatos Big Mike Reviews of Brokers and Data Feeds 47 February 7th, 2014 12:03 PM
Webinar: MultiCharts and Zen-Fire Introduction Big Mike MultiCharts 12 October 4th, 2012 02:15 PM
Webinar Trading Video: Live Trading and Technical Analysis of EuroStoxx 50 max-td Trading Reviews and Vendors 1 March 13th, 2010 07:35 AM
Introduction: Sim trading S&P with Ninja traders SOM123 Traders Hideout 5 December 13th, 2009 11:27 AM


All times are GMT -4. The time now is 10:58 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-14 in 0.15 seconds with 20 queries on phoenix via your IP 54.90.207.75