question

Upvotes
Accepted
27 3 2 3

How to use Data Type "WC07015 - Inactive date (Security)" output

Hello,

When I run a query for datatype WC07015 in a snapshot request (in R) the value it gives me is a character value of numbers that I cannot translate into a date. This data type is supposed to be the day that a company was delisted. How do I convert this value into a date?


sf <- dsws$snapshotRequest(instrument = c("A:EVMX", "A:CBAX"), datatype = c("ISIN", "NAME", "WC07015"), requestDate = "0D")

Running this gives me these outputs:


However if I run the query without the CBA company ticker I get the result I'd expect like this:

Can someone please help me understand why it is doing this, and let me know how to get it to give me a proper date when I run more than one company query.

Thanks,
Ed.

datastream-apidsws-apirdater-studio
1573617880435.png (9.1 KiB)
1573617929202.png (6.9 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
38.1k 71 35 53

@Ed_J

The column type of WC07015 is converted to <chr> when requesting two items c("A:EVMX", "A:CBAX") because the WC07015 of A:CBAX is "NA".

The workaround is checking if the column of WC07015 is a date, or not.

If it is not date, first you need to remove the "NA" values and then convert the numeric values to date.

The example code is:

sf <- mydsws$snapshotRequest(instrument = c("A:EVMX", "A:CBAX"),
                             datatype = c("ISIN", "NAME", "WC07015"),
                             requestDate = "0D")
if("FALSE"%in%sapply(sf$WC07015, function(x) !all(is.na(as.Date(as.character(x),format="%Y-%m-%d"))))){
    sf[sf == "NA"] <- ""
    sf <- mutate(sf, WC07015= as.Date(as.numeric(WC07015), origin= "1970-1-1"))
}
                     
sf

This code may not cover all use cases.

Otherwise, you may report this issue at DatastreamDSWS2R GitHub.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea