[R-SIG-Finance] Fwd: dataset to xts conversion issue with timeseries data
Brian G. Peterson
brian at braverock.com
Fri May 13 12:02:04 CEST 2016
Please make it easy for someone else to help you. Provide a minimal
example, e.g. use dput to export a small copy of your object showing us
what you're trying to do and the code you are trying.
Ilya's advice was correct, so your problem is unquestionably user error,
but it will be hard for anyone to help you if you don't show us
precisely what you are trying by providing a reproducible example
including a copy of your input data.
On 05/13/2016 12:17 AM, Aritra Pan wrote:
> Hi Ilya,
>
> Thanks for the suggestion. But when I try with the dataset containing
> only timestamp, value and size columns; then also if I try to convert
> from dataset to xts, the timestamp column is becoming index and
> further I am not able to access timestamp matching between objects.
>
On 05/13/2016 12:09 AM, Ilya Kipnis wrote:
> Aritra,
>
> The underlying data structure of an xts is a matrix. If you have a
> character vector inside that matrix, the entire thing will become
> characters. In your example, you have stockName and type vectors,
which are
> character vectors, whereas in the excel example, you don't. Hope
> that
helps.
>
> -Ilya
>
> On Fri, May 13, 2016 at 12:31 AM, Aritra Pan <
> aritrapan at vgsom.iitkgp.ernet.in> wrote:
>
>> Sorry, if it is becoming duplicate message. Any suggestion will be
>> highly appreciated.
>>
>> -- Thanks, Aritra
>>
>> ----- Original Message -----
>>
>> From: "Aritra Pan" <aritrapan at vgsom.iitkgp.ernet.in> To:
>> "R-SIG-Finance" <r-sig-finance-bounces at r-project.org> Sent:
>> Thursday, May 12, 2016 11:28:41 AM Subject: [R-SIG-Finance] dataset
>> to xts conversion issue with timeseries data
>>
>> Hello Members,
>>
>> I am hoping if I can get few suggestions on the issue I am facing.
>>
>> I am taking data from server using Rblpapi package for 40-50
>> securities. The data looks like below:
>>
>> times askValue askSize stockName Type
>> 01/02/2016 9:15 91.8 500 ABCD IS Equity Ask
>> 01/02/2016 9:15 92.4 1420 ABCD IS Equity Ask
>> 01/02/2016 9:15 92.2 5000 ABCD IS Equity Ask
>> 01/02/2016 9:15 91.9 6524 ABCD IS Equity Ask
>> 01/02/2016 9:15 91.9 11524 ABCD IS Equity Ask
>> 01/02/2016 9:15 92.05 6824 ABCD IS Equity Ask
>>
>> ABCD IS - any security (assume).
>>
>> Now this data is coming in standard dataset format to R from data
>> server. When I try to convert it to XTS it becomes like below
>>
>> askValue askSize stockName askType 01/02/2016
>> 9:15 " 91.80" " 500" "ABCD IS Equity" "Ask"
>> 01/02/2016 9:15 "474.45" " 300" "EFGH IS Equity"
>> "Ask" 01/02/2016 9:15 "455.00" " 100" "XYZW IS
>> Equity" "Ask" 01/02/2016 9:15 "101.50" " 2799"
>> "MNP IS Equity" "Ask" 01/02/2016 9:15 "194.95" "
>> 1600" "IJK IS Equity" "Ask" 01/02/2016 9:15
>> "293.45" " 13" "PQRS IS Equity" "Ask"
>>
>> You can see the the column name "times" is becoming here index.
>> And
that's
>> why after data conversion to xts object I am not able to match my
>> quote data which are bid dataset and ask dataset.
>>
>> Can anyone please suggest on this data set to xts conversion.
>>
>> PS: When I am downloading data in excel and then transforming data
>> from excel to xts then it is working fine.
>>
>> Date Type Price Size 1 01/03/2016 9:15 ASK
>> 538.9 50 2 01/03/2016 9:15 ASK 538.8 75 3
>> 01/03/2016 9:15 ASK 538.7 50 4 01/03/2016 9:15
>> ASK 538.3 75 5 01/03/2016 9:15 ASK 538.85
>> 798 6 01/03/2016 9:15 ASK 538.9 93
>>
>> But as I am trying to run for multiple stocks data download script
>> at
same
>> time and it is high-frequency data, so I am using R script to
download data
>> from server to R directly skipping excel using Rblpapi package.
>>
>> -- Thanks, Aritra
>>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list