basic R question - Matlab, R project and Python | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python

basic R question
Started:March 13th, 2010 (04:21 PM) by sam028 Views / Replies:2,454 / 2
Last Reply:March 20th, 2010 (06:32 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

basic R question

Old March 13th, 2010, 04:21 PM   #1 (permalink)
Administrator: Retired Backtester
Rennes France
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
sam028's Avatar
Posts: 3,183 since Jun 2009
Thanks: 3,427 given, 3,726 received

basic R question

I'm new to R, and after having read some examples of R code here , I tried to play a bit with it.

The first step was to get some data. I'm using Interactive Brokers, and as everybody knows, the datafeed is not very good, and you can't easily get a lot of historical data, as their have limitations.
With these limitations, you can't backtest (with NT for example) a large amount of data if you don't already have these data...
Anyway, the idea was to get 1 year of US stocks data from IB, so I used IBrokers CRAN package. This smart package know IB limits, and manage them (some sleep between each request).

The R script looks like this:

my_func <- function (connContractnb=30barSize "1 min"file, ...) {
endDateTime <- Sys.Date() - seq(nb0, -5)
duration <- "5 D"
reqHistoricalData(connContractbarSize barSizeduration durationendDateTime endDateTi
contract <- twsEquity('A','SMART','ISLAND')
fh <- file('A.dat',open='a')
contract <- twsEquity('AA','SMART','ISLAND')
fh <- file('AA.dat',open='a')
I have something like 600 symbols, and had generated this script with a Perl script, and was wondering how to do all in R.

I have a file (call it list.txt) which contains the symbol of stock I want to get, something like this:


So in R, I read the file:

my_file <- read.table("list.txt")

so then I presume that my_file[3,1] == "ABT".

Now, if want to do something like

fh <- file(my_file[i,1],open='a')
but something seems to be wrong in this.

Any idea ?
I'm sure it's a very simple problem for any R coder .

Usually in trading, those who know don't talk, and those who talk don't know. (Al Brooks)
success requires no deodorant! (Sun Tzu)
Reply With Quote

Old March 13th, 2010, 04:21 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Old March 20th, 2010, 06:32 PM   #3 (permalink)
Just starting out...
Futures Experience: Intermediate
Platform: Trading Shim + R/Matlab/Python + TWS + fxTrader
Broker/Data: Interactive Brokers, Oanda
Favorite Futures: OMXS30, EUR/USD
Posts: 3 since Mar 2010
Thanks: 22 given, 4 received

sam028 View Post

so then I presume that my_file[3,1] == "ABT".

Now, if want to do something like
fh <- file(my_file[i,1],open='a')
but something seems to be wrong in this.

Any idea ?.

fh <- file(as.character(my-file[i,1]), open = 'a') should work.

Reply With Quote
The following 3 users say Thank You to Jovis for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python > basic R question

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Very basic scalper set up Xzap Traders Hideout 25 November 18th, 2013 08:39 AM
Basic market characteristics aediaz1 The Elite Circle 4 August 10th, 2011 10:18 AM
Basic datafeed questions forexboom Brokers and Data Feeds 3 May 24th, 2011 02:56 PM
Basic MACD for NT7 jmjstrider NinjaTrader 6 February 3rd, 2011 07:28 PM
Basic TimeFrame Pattern wh The Elite Circle 0 October 8th, 2009 04:39 AM

All times are GMT -4. The time now is 02:03 PM.

Copyright © 2016 by 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 2016-10-23 in 0.08 seconds with 20 queries on phoenix via your IP