You can use the which.i argument to [.xts:
> is.null(SPY["2009-01-18",which.i=TRUE])
[1] TRUE
Best,
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
On Sat, Jan 25, 2014 at 9:27 AM, ce wrote:
> Dear all
>
>
> How to test if xts date
>> as.numeric(SPY["2007-01-03"]$SPY.Adjusted) >
>> as.numeric(SPY["2007-01-04"]$SPY.Adjusted)
> [1] FALSE
>
>
> Is this the expected behavior ?
>
Yes, see: http://stackoverflow.com/q/7097437/271616
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Tr
This is related to:
http://stackoverflow.com/q/21393866/271616
http://stackoverflow.com/q/21484267/271616
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
On Tue, Feb 4, 2014 at 6:07 PM, Jairaj Gupta wrote:
> Hi,
>
> I have done the following:
>
>
will work if you drop
the dimensions of your single-column xts object:
testt <- cpt.mean(drop(testTSRad))
> My data is below. Is there a way to convert it to ts?
>
Yes, as is generally the case, use the "as" method:
as.ts(testTSRad)
Best,
--
Joshua Ulrich | about.me/joshua
wrote:
>>
>> Hello,
>>
>> On Tue, Mar 11, 2014 at 8:45 PM, Joshua Ulrich
>> wrote:
>> > On Tue, Mar 11, 2014 at 12:14 AM, Bill wrote:
>> >>
>> >> Hello. I have a dataframe that has a date column. The intervals between
>> >
Have you read these instructions?
http://cran.r-project.org/bin/linux/ubuntu/README.html
They say to run
sudo apt-get install r-base-dev
which should install 'build-essential' (which is an Ubuntu package,
not an R package).
--
Joshua Ulrich | about.me/joshuaulrich
FO
n common, so there's nothing to
compare.
Convert series1's index to yearmon, and the comparison works.
> index(series1) <- as.yearmon(index(series1))
> tail(series1 > series2)
GSPC
2013-06-01 TRUE
2013-07-01 TRUE
2013-08-01 TRUE
2013-09-01 TRUE
2013-10-01 TRUE
or
> expected for xts objects?
>
xts doesn't have a $<- method, so $<-.zoo is dispatched. I'm not
familiar with the function, but the behavior you found is explicitly
defined, so that seems to suggest it was intended.
>From "$<-.zoo":
wi <- match(x, colnames(o
9
>> #2013-11-07 -0.004390787 -0.0188959585NA
>> #2013-11-07 NANA 0.0068094113
>> #2013-11-080.0 0.0136779259NA
>> #2013-11-10 NANA 0.0010398246
>> #2013-11-110.003
s the end of it.
> Does anyone know if it is possible to run quantstrat with the current version
> of R?
Yep, see here: http://stackoverflow.com/q/11105131/271616
Best,
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
_
esume that if it
> were that simple, why would the version crated a week ago not work?
>
I don't know; that's a question for the R-Forge maintainers. It looks
like they're building with 3.0.2, but I'm not sure that matters. The
easiest thing to do it just check out
69-12-31 20:30:009
1969-12-31 21:30:00 13
1969-12-31 22:30:00 17
1969-12-31 23:00:00 10
> period.apply(x, endpoints(x,"hours"), mean)
[,1]
1969-12-31 18:30:00 1.0
1969-12-31 19:30:00 2.5
1969-12-31 20:30:00 4.5
1969-12-31 21:30:00 6.
[,1]) # assumes "date" in first column
You will need to ensure that Data[,"date"] is a time-based class (e.g.
Date, POSIXt). If it is character, you will need to convert it to a
time-based class before calling xts().
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.co
> A1b <- rollapply(A1a,4,mean, na.rm=TRUE, na.pad=FALSE, align="right")
> cbind(A1a,A1b)
A1a A1b
1 NA NA
2 NA NA
31 1.0
42 1.5
53 2.0
6 4 3.0
75 4.0
86 5.0
9 NA 5.5
10 NA 6.0
HTH,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
>
onnection(con) :
> unable to connect to 'quote.yahoo.com' on port 80.
>
The example works for me. Are you behind a firewall or proxy?
> 2. How can I download Key Statistics Data from Yahoo Finance
>
> A. http://finance.yahoo.com/
>
> B. ASH.AX (Using GET QUOTES)
>
lease help me to use the function as.xts correctly.
>>
I recommend you use Gabor's solution, but I would like to expand on
what as.xts is doing.
as.xts.data.frame and as.xts.matrix attempt to coerce the object's
rownames into the index attribute, unless specified otherwise via
or
NA NA
> 2011-01-04 11:45:42 5 NA NA
>
> Warning message:
> In merge.xts(y1, y2) : NAs introduced by coercion
>
> Why do I lose the character columns ?
>
Because zoo / xts objects are matrices with an ordered index (a time
index in the case of xts). You can't mix types i
Use na.approx:
set.seed(21)
x <- xts(rnorm(10), Sys.time()-10:1)
is.na(x) <- 2:4
is.na(x) <- 8:9
na.approx(x)
na.spline(x)
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Tue, Jan 11, 2011 at 12:08 AM, Rustamali Manesiya
wrote:
> Hello,
>
> I have a x
Hi Chris,
This seems to work on the sample data you provided.
FUN <- function(x) {
x <- xts(as.numeric(x),index(x))
period.apply(x, endpoints(x,"secs"), sum)
}
lapply(split.default(xSym$Size,xSym$Direction), FUN)
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
Please do not cross post: http://stackoverflow.com/q/4720076/271616
At the minimum, it would be polite to respond here with the answer you
accepted on Stack Overflow.
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Mon, Jan 17, 2011 at 8:59 AM, Daniel Wu wrote:
> days=Sys.Date(
See ?plot.zoo, specifically plot.type="single".
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sat, Jan 22, 2011 at 8:02 PM, Nick Torenvliet
wrote:
> So I've got a 154 column wide xts time series object and I want to plot the
> 154 series on a single plot and h
ion"
manual to see how method dispatch is normally done.
But you've been writing quite sophisticated code for a fairly long
time, so I'm not telling you anything you don't know... you just don't
think you should have to do the legwork.
> -- Russ
>
>
--
Joshua Ulri
stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
__
R-
TTR::runSD will do what you want and the same call will work on
data.frame, matrix, vector, xts/zoo, or any other time-series object.
Note that time-series objects will generally put time periods in
ascending order.
library(TTR)
d$st.dev <- runSD(d$Close,4)
z <- zoo(d[,2,FALS
t. I would appreciate patches.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sat, Jan 29, 2011 at 7:39 PM, Anyi Zhu wrote:
> Hi,
>
> Just wondering for the SMA and EMA in package TTR, is it possible to me to
> code it so that, say if I need to calculate SMA (x, n=100)
data analysis, statistical
modeling, visualization, and programming. Anyone with a background or
interest in R is welcome!
The group will use meetup.com to communicate with members. Please sign
up to receive updates and RSVP to events:
http://www.meetup.com/Saint-Louis-RUG/
Best,
--
Joshua Ulrich
Hi Chris,
Perhaps something like this?
require(xts)
ds <- options(digits.secs=6) # so we can see sub-seconds
x <- xts(1:10, as.POSIXct("2011-01-21") + c(1,1,1,2:8)/1e3)
x
indexFormat(x) <- "%H:%M:%OS3"
x
Hope that helps,
--
Joshua Ulrich | FOSS Trading: www.fos
Hi David,
On Sat, Mar 5, 2011 at 11:00 PM, David Winsemius wrote:
>
> On Mar 5, 2011, at 11:28 AM, Joshua Ulrich wrote:
>
>> Hi Chris,
>>
>> Perhaps something like this?
>>
>> require(xts)
>> ds <- options(digits.secs=6) # so we can see sub-second
-01-05 31.36 19.90 57.87 137.2938.40
# 2011-01-06 32.04 19.79 57.49 138.0737.23
# 2011-01-07 31.95 19.77 57.20 138.3537.30
# 2011-01-10 31.55 19.76 58.22 142.69 37.04
Hope that helps,
--
Joshua Ulrich | FOSS
roject.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
_
>
> How can I change the name of that column within my big loop? Any
> ideas? Thanks!
>
I usually make a copy of the object, change it, then overwrite the original:
tmp <- get(i)
colnames(tmp)[7] <- "foo"
assign(i,tmp)
Hope that helps.
> Best regards,
>
>
&g
NYSE:F
works, while
http://www.google.com/finance?fstype=ii&q=F
results in a 400 'Bad request' error.
This seems to work for this one symbol, maybe it will work for others as well.
getFin("NYSE:F")
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Thu, Mar 17,
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinf
Please don't cross-post.
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Fri, Mar 25, 2011 at 8:33 AM, William Mok wrote:
> Hi All,
>
> I am trying to plot 4 graphs on to 1 page using layout(...), or par(mfcol =
> c(...)); with the function QQplot
t;, buildTimeSeriesFromDataFrame,
> env = e1)
> return(get("xx", e1)) # return xx from env
> }
>
> ##replicate 100 times
> #Time03 <- replicate(100,
> # system.time(tsDaply(X, X$ID))[[1]])
> #median(Time03)
>
> # result
> tsDaply(X, X$ID)
>
>
Hi Mauricio,
A Windows binary is now available on CRAN:
http://dirk.eddelbuettel.com/blog/2011/04/04/#rquantlib_0.3.7
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Tue, Mar 29, 2011 at 10:38 AM, Mauricio Romero
wrote:
> Dear R users,
>
> I have been trying to use
WMA.
>
SMA still calls Fortran code, so that's why it's slower than
caTools::runmean. I've moved the EMA code to C, so it's about as fast
as it can be.
Noah, use EMA's ratio argument to replicate your for loop.
> Hope this helps,
>
> Michael Weylandt
>
Be
faster language?
>
As I said, the function is in C. You could also use the compiler
package to compile your pure R function for a 3-4x speedup.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
>
> --
> Noah Silverman
> UCLA Department of Statistics
> 8117 Math Sciences
? I have tried googling it
> to no avail.
>
See the R Internals manual:
http://cran.r-project.org/doc/manuals/R-ints.html
> cheers
> Worik
>
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
__
R-help@r-project.org mailing list
h
Eric,
I'd be happy to help. Please follow the posting guide (specifically
the "Surprising behavior and bugs" section) and provide a *minimal*,
reproducible example and the output from sessionInfo().
http://www.r-project.org/posting-guide.html
Best,
--
Joshua Ulrich
. '2010-01-01' is a character string.
>
> I am sure i am missing something - what is .indexDate() supposed to do?
>
Though it's not well documented, what it's doing is pretty clear from
the source:
R> .indexDate
function (x)
{
.index(x)%/%86400L
}
>
> than
=lower,
upper=upper, control=controlDE, fnMap=mappingFun)
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Fri, Jun 15, 2012 at 3:24 AM, David-Michael Lincke
wrote:
> Function DEoptim in package DEoptim for differential evolution defines an
> optional parameter fnMap:
>
> fn
meant that the mapping example near the end
of slimLargeN_map.R uses the objective function in the vignette.
> Best regards,
> David
>
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
> -Original Message-
> From: Joshua Ulrich [mailto:josh.m.ulr...@gmail.co
On Tue, Jun 19, 2012 at 6:07 PM, Bert Gunter wrote:
> 1. Don't double post. (obviously belongs on finance list)
> 2. Homework? (we don't do homework on r-help)
>
We don't do homework on R-SIG-Finance either...
> -- Bert
>
Best,
--
Joshua Ulrich | FOSS Trading:
Load the data into an environment, then merge them using do.call():
series.env <- new.env()
getSymbols(ticker.list, src='FRED', env=series.env)
series <- do.call(merge, as.list(series.env))
HTH,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sat, Jul 7, 2012 at 7:00
$time), format="%d.%m.%y
> %H:%M:%S"))
> w03_11temp_y <- merge(w03_11temp_z, zoo(order.by=seq(start(w03_11temp_z),
> end(w03_11temp_z), by=1)))
> w03_11temp_x <- na.approx(w03_11temp_y)
> w03_11temp_w <- data.frame(date=format(index(w03_11temp_x), "%d.%m.%y&qu
Please don't cross-post:
https://mailman.stat.ethz.ch/pipermail/r-sig-finance/2011q3/008230.html
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Wed, Jul 13, 2011 at 11:11 AM, Marcin P?�ciennik wrote:
> Dear list members,
>
> I am trying to estimate parameters of the A
; d <- as.xts(d,order.by =year, frequency = 1)
>
> #Error in xts(coredata(x), order.by = order.by, frequency = frequency, :
> # order.by requires an appropriate time-based object
>
>
> Peter Maclean
> Department of Economics
> UDSM
>
Best,
--
Joshua Ulrich | FOSS Tra
What's your problem? What have you tried?
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Mon, Jul 18, 2011 at 11:39 PM, kev946 wrote:
> Hello, I'm new to R and am having trouble plotting intraday data on a chart.
> I haven't had any success with using ideas fro
)
>
This is not a plot command. What plot command are you using?
Dates don't have "H:M:S"; they're all zero. You don't provide a
sample of Dataset, so we don't know what your data look like.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
- index(SPY)[endpoints(SPY, "months")[-1]-3]
> Thanks in advance,
>
> John B. Nicholas, Ph.D
> 650-315-9895
>
HTH,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
__
R-help@r-project.org mailing list
https://stat.ethz.ch
le to give
you what you want.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Sat, Jul 30, 2011 at 9:10 AM, Eduardo M. A. M.Mendes
wrote:
> Dear R-users
>
>
>
> I am new to R and struggling not to bother the list with silly questions.
>
>
>
> I read
Cross-posted on Stack Overflow:
http://stackoverflow.com/q/11567745/271616
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Thu, Jul 19, 2012 at 12:23 PM, cursethiscure
wrote:
> I am working with xts dependent data, and my code is as follows (the problem
> is explained thro
Same post on Stack Overflow (again):
http://stackoverflow.com/q/11567745/271616
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Thu, Jul 19, 2012 at 11:15 AM, cursethiscure
wrote:
> I think the code is part of the RTAQ package but is not included in it, as I
> obtained it from
&
"))
unclass(y1)
(z1 <- as.POSIXct(y1, tz="GMT"))
do_asPOSIXct is at line 733 of main/datetime.c, for anyone interested
in digging further.
Best,
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
On Wed, Aug 1, 2012 at 6:10 PM, Jeff Newmiller wro
<- ind
# label column with year of last obs
colnames(x) <- paste(colnames(x),xyear,sep=".")
x
}
# split data into a list of xts objects by year
tmp_dat_yr_list <- split(temp_data, "years")
# convert each list element to be "2011"
tmp_dat_yr_list <-
nd between R-help and R-devel.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Wed, Oct 12, 2011 at 9:05 PM, R. Michael Weylandt
wrote:
> To be honest, I don't frequently have occasion to wander over to R-devel and
> most of what goes on over there is over my leve
NA
2010-04-02 7.6343 NA
2010-04-03 7.5458 NA
2010-04-04 7.4532 28.30
2010-04-05 7.4040 28.38
2010-04-06 7.3317 28.21
2010-04-07 NA 28.31
2010-04-08 NA 28.47
Jeff's answer on StackOverflow explains why this works.
Best,
--
Joshua
Deb,
See getQuote in the quantmod package. For example:
getQuote("SPY")
Be sure to read ?getQuote.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Thu, Nov 3, 2011 at 5:05 PM, Deb Midya wrote:
> Michael,
>
> Thanks for your response.
>
> The
Deb,
Sorry, you can't do that with getQuote because Yahoo does not make
those data available historically. Generally, you will need to pay
for historical bid/ask (tick) data.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Fri, Nov 4, 2011 at 6:10 AM, Deb Midya
Hi Sergey,
Internally, xts objects are a matrix with an index attribute. While
you *can* make a matrix of lists, that is not supported in zoo or xts.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
R/Finance 2012: Applied Finance with R
www.RinFinance.com
On Sun, Mar 4, 2012 at
l', got 'M'"
>
> What is "M"? Is that matrix? Any clarification of the issue and solution is
There is an "M" in your data at line 9954:
1/3/2012 9:53 48
1/3/2012 10:53 M
1/3/2012 11:53 51
> appreciated. I apologize in advance for any noob mistake
t; class(Time)
> [1] "POSIXct" "POSIXt"
>
> Browse[2]> class(index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]))
> [1] "POSIXct" "POSIXt"
>
> So the variable 'Time' should be good to index DATA.ba[[p]]. I am
> hopeles
asing the objects in and out of matrices and vectors.
>
No need for it to be huge. dput(DATA.ba[[p]]["2012-03-20
00:59:57","bid"]) would be a sufficient start.
> Using R version 2.12.1
>
> The zoo documentation (?zoo) does not include a version. Where can I find
&
On Thu, Mar 29, 2012 at 3:56 PM, Worik R wrote:
> I have a reproducible example of my problem below
>
> On Mon, Mar 26, 2012 at 9:22 AM, Joshua Ulrich
> wrote:
>>
>> > Given two identical string representations of POSIXct objects, can the
>> > two
&g
mpt
> assistance.
>
>
I would be happy to help you with your project at my regular consulting
rate.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
R/Finance 2012: Applied Finance with R www.RinFinance.com
[[alternative HTML version deleted]]
__
>
Please provide a reproducible example (your file was not attached).
Use dput() to include a _small_ sample of your data. My guess is that
Excel is not saving the dates to the CSV in a standard date format.
> Apparently, I do not understand exactly how
.
>
> It seems everything works adequately until I try the plotOHLC function
> itself, which gives me the error in the subject line.
>
> I would ask for two things:
> 1) what the fix is to get rid of that error plotOHLC gives me
> 2) some tips on the 'walk-forward' method I am looking at
rtSeries(to.minutes3(z, OHLC=TRUE)). I'm
not familiar with the charting capabilities in the tseries package,
but those in quantmod are quite extensive. See also www.quantmod.com.
> Thanks again,
>
> Ted
>
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
___
I bet you're using an
incompatible version of R.
It will probably work if you build from source, which is also provided
on the site.
> Greetings.
>
> Carlos
>
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
> --
> View this message in context:
> http
HTH,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Wed, Feb 8, 2012 at 3:50 AM, yuanwei wrote:
> Hi Joshua,
>
> Before I found your post here, I have viewed your source code for
> 'wilderSum'<http://cran.r-project.org/src/contrib/TTR_0.21-0.tar.gz> to
>
Alex,
You may find an answer to your question by searching the R-SIG-Finance
archives (via rseek.org). If not, you may want to consider asking
your question on the R-SIG-Finance list.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
R/Finance 2012: Applied Finance with R
SIXct(paste(d$V1, d$V2)))
to.minutes3(x)
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
R/Finance 2012: Applied Finance with R
www.RinFinance.com
On Tue, May 8, 2012 at 3:14 AM, oswi3605 wrote:
>
> Hello,
>
> Im currently writing my bachelor thesis in statistical finance and i
sn't, then using
the default value of n = 252 may also be an issue (giving misleading
results, if not an error).
> But if I do this (fetch the data from yahoo):
>
> getSymbols("SDL.AX")
> dvi <- DVI(Cl(SDL.AX))
> print(dvi)
>
> All seems to work fine, but I c
all out of whack, My guess was it
> was the date format that postgres returns (being mm/dd/) but no luck,
> any ideas?
>
See above. If my assumptions aren't correct, then please provide a
small sample of the result from dbGetQuery.
> Thanks!
> Max
>
>
rame so
> that all the data are the correct type??
>
You can't. xts/zoo objects are a matrix with an index attribute.
Since you can't mix types in a matrix, you can't mix types in an
xts/zoo object. That said, part of the xts Google Summer of Code
project is to create an xts-lik
101 - 176 of 176 matches
Mail list logo