Hi,
I am trying to create Bid/Ask for each second from a high volume stock and
the only way I have been able to solve this is using loops to create the
target matrix from the source tick data matrix. Looping is too slow and
not practical to use on multiple stocks. For example:
Bids Matrix (a r
Duncan and Martin,
Thank you for your replies.
I went with Martin's suggestion as it did not require loops and is probably
the fastest...though it did take me 3 hours to figure out exactly how it was
working !!!
Here is what I am now using:
bids = cbind(bids, timeCalc)
orderBids = bids[order(
Hi,
With a vector like:
x = c (22, 23, 22.5, 0,0,24, 0, 23.2, 23.5, 0,0,0, 26)
How can I replace the 0's with the previous last value without looping
through the vector ?
Something tells me I am missing the obvious.
Thanks,
Chris
--
View this message in context:
http://r.789695.n4.nabble.co
Petr and Bill,
Thanks for your replies.
I have gone with Petr use of na.locf(), but expect I can use Bill's full
function in the near future.
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/Vector-replace-0-elements-without-using-a-loop-tp2966191p2968909.html
Sent from th
Losing time offset from GMT:
> sTime = as.POSIXct(paste("2008-03-03","09:30:01"), origin="1970-01-01")
> sTime
[1] "2008-03-03 09:30:01 EST" < 9.31am EST
> sTime
[1] 1204554601
> t = as.numeric(sTime)
> as.POSIXct(t, origin="1970-01-01")
[1] "2008-03-03 14:30:01 EST" <- no tz option
Hi,
I am trying to find the best way to read 85 tick data files of format:
> head(nbbo)
1 bid CON 09:30:00.72209:30:00.722 32.71 98
2 ask CON 09:30:00.78209:30:00.810 33.14 300
3 ask CON 09:30:00.80909:30:00.810 33.14 414
4 bid CON 09:30:00.78309:30:00.810 33.06
That is embarrassingthanks for pointing out my mistake.
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/Time-OffSet-From-GMT-Losing-it-tp2968940p2990987.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@
Hi,
I am trying to find the total number of rows for a list of data.frames and
want to know if there is a better way than using a loop like:
>df = { list of data.frame with varying number of rows...each one has a
column called "COL" }
>r = 0
> for (i in 1:length(df)) {
+ r = r + length(n[[i]]$CO
Hi,
Have been having trouble trying to figure out the right regex parameters to
remove the last "." in timestamp with the following format:
Convert 09:30:00.377.853 to 09:30:00.377853
Thanks,
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/Regex-to-remove-last-charact
Hi,
Please can you tell me what I am doing wrong. When trying to merge two xts
objects, one of which has multiple character vectors for columns...I am just
getting NAs.
> str(t)
POSIXct[1:1], format: "2011-01-04 11:45:37"
> y2 = xts(matrix(c(letters[1:10]),5), order.by=as.POSIXct(c(t + 1:5)))
Have 40,000 rows of buy/sell trade data and am trying to add up the buys for
each second, the code works but it is very slow. Any suggestions how to
improve the sapply function ?
secEP = endpoints(xSym$Direction, "secs") # vector of last second on an XTS
timeseries object with multiple entries
Is there a easy way to create the time index for a zoo/xts object for every
100 milliseconds.
eg. time Index would be:
10:00:00:100
10:00:00:200
10:00:00:300
10:00:00:400
I am looking to build an empty zoo/xts object with time index from 10am to
3pm, index jumps by 100ms each row.
Thanks,
Chri
Hi,
Trying to create a POSIXct index for an xts object that will display the
POSIXct index as HH:MM:SS.MMM.
First of all, I am trying to get the as.POSIXct to work with format...
> as.POSIXct(paste("2011-03-02 09:00:00.000", sep=""), tz="EST",
> format="%H:%M:%OS3")
[1] NA
Why is this returning
Hi,
I cannot figure out how to change the index format when displaying POSIXct
objects.
Would like the xts index to display as %H:%M:%OS3 when doing viewing the xts
object.
Think I am missing the obvious.
Cheers,
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/xts-POSIX
Thank you for your help.
indexFormat(x) solved the problem nicely.
> head(a)
2011-03-04 09:30:00.0 22.10
2011-03-04 09:30:00.1 22.09
2011-03-04 09:30:00.2 22.10
2011-03-04 09:30:00.3 22.09
2011-03-04 09:30:00.4 22.10
2011-03-04 09:30:00.5 22.09
> indexFormat(a) <- "%H:%M:%OS3"
> head(a)
Hi,
I am missing something obvious.
Need to create vector as:
(0, i-1 + TheoP(i) - TheoP(i-1), repeat) Where i is the index position
in the vector and i[1] is always 0.
Found myself having to use a For Loop because I could not get sapply
working. Any suggestions ?
delta <- function(x)
Hope this clarifies my Q.
Creating a vector where each element is (except the first which is 0) is:
the previous element + a calculation from another vector theoP[i] -
theoP[i-1]
I could not figure out how to do this without a for loop, as the vector had
to reference itself for the next eleme
Hi,
Thanks for your replies.
In summary:
1. Replace code with c(0, cumsum(diff(theoP)) ). This is indeed correct
and I had not realized it !!
>> d = vector(mode = "numeric", length= len)
>> d[1] = 0
>> if (len>1) for (i in 2:len) { d[i] = d[i-1] + theoP[i] - theoP[i-1] }
2. How to create
Hi,
I am processing tick data and my code has stopped working as I have
increased the size of data being processed. Now I am receiving error for
basic tasks in RConsole:
> a = c(1:1000)
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
My R code worked fine with 5
For further info, I cannot check my memory usage or even use ls() :
> memory.limit
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
> ?memory.limit
Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?
> ls()
Error: evaluation nested too d
Have timestamp in format HH:MM:SS.MMM.UUU and need to remove the last "." so
it is in format HH:MM:SS.MMMUUU.
What is the fastest way to do this, since it has to be repeated on millions
of rows. Should I use regex ?
Currently doing it with a string split, which is slow:
>head(ts)
[1] 09:30:00
Thanks for your suggestions.
Cheers,
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/Replace-split-with-regex-for-speed-tp3386098p3388958.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailin
Is there anyway to query an object to find its source code file ? Created
object F from file F.r, can object F tell me this ?
Thanks,
Chris
--
View this message in context:
http://r.789695.n4.nabble.com/Source-Code-File-For-an-Object-tp3461566p3461566.html
Sent from the R help mailing list arch
Hi,
When I am editing a command using default R console in Linux, sometimes it
is going into "vi mode"...not too sure how/why this happening. It then
requires me to use vi commands to edit the line, which is very frustrating
when I just want to use the delete key instead of "x" to delete a charac
24 matches
Mail list logo