DataClient | R Documentation |
An RC class for accessing Datastream content through Datastream Web services API
DataClient object
DatastreamR::DSConnect
-> DataClient
useNaNforNotANumber
: TRUE by default. NULLs are replaced to NaN (Not a Number)
new()
Initialize method to create Datastream Object
DataClient$new( config = NULL, username = "", password = "", proxys = NULL, sslCer = NULL )
config
: Config path
username
: Your Id
password
: Your Password
proxys
: Proxy details (if any)
sslCer
: ssl Certificates path
Creates Datastream RC object for accessing Datastream content through Datastream Web Services API
DataClient object
\dontrun{ # ds = DataClient$new(NULL, "YourID", "YourPswd") # OR # Login using config file # Config file details provided in DSConnect.R ds = DataClient("Config.ini") # Timeseries requests df = tryCatch ( {ds$getData(tickers="VOD", fields=list("PH","PL"), start='2022-01-12', end='2022-07-13', kind=1)}, error = function(e) { stop (message(e))}) print(df) # Snapshot requests df = tryCatch ( { ds$getData(tickers="VOD", fields=list("PH", "PL"), start='2022-01-12', kind=0)}, error = function(e) { stop (message(e))}) print(df) }
getData()
getData posts the JSON formatted request and the JSON response is then converted to Dataframe, if dataToDF is TRUE.
DataClient$getData( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1, properties = NULL )
tickers
: Intruments Eg: "VOD,BARC"
fields
: Datatypes Eg: list('PH, 'PL', 'PI')
start
: start date in "YYYY-mm-dd" format Eg: "2019-01-20"
end
: end date in
freq
: Refer DSDateFrequencyNames in DSRequests.R
kind
: 1 - TimeSeries Request (default), 0 - Snapshot Request
properties
: properties
Response Class
getDataframe()
getDataframe posts the JSON formatted request and the JSON response is then converted to Dataframe
DataClient$getDataframe( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1, properties = NULL )
tickers
: Intruments Eg: "VOD,BARC"
fields
: Datatypes Eg: list('PH, 'PL', 'PI')
start
: start date in "YYYY-mm-dd" format Eg: "2019-01-20"
end
: end date in
freq
: Refer DSDateFrequencyNames in DSRequests.R
kind
: 1 - TimeSeries Request (default), 0 - Snapshot Request
properties
: properties
Dataframe
formatDataRequest()
This method formats the request provided by client (in form of tickers and fields) to the JSON formatted request.
DataClient$formatDataRequest( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1 )
tickers
: Instruments
fields
: Datatypes
start
: start date
end
: end date
freq
: frequency
kind
: kind = 0 for Snapshot request and Kind = 1 for Timeseries request
JSON formatted data request
getDataBundle()
getData posts the JSON formatted request and the JSON response is then converted to Dataframe, if dataToDF is TRUE.
DataClient$getDataBundle(dataRequests, properties = NULL)
dataRequests
: dataRequests should be formed using formatDataRequest method
properties
: properties
Response Class
toDataframe()
Converts the Class response into a Dataframe which can be further used to plot
DataClient$toDataframe(dataResponse)
dataResponse
: The raw data response that is ingested into Dataframe
Dataframe
clone()
The objects of this class are cloneable with this method.
DataClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## Method `DataClient$new`
## ------------------------------------------------
## Not run:
# ds = DataClient$new(NULL, "YourID", "YourPswd")
# OR
# Login using config file
# Config file details provided in DSConnect.R
ds = DataClient("Config.ini")
# Timeseries requests
df = tryCatch (
{ds$getData(tickers="VOD", fields=list("PH","PL"),
start='2022-01-12', end='2022-07-13', kind=1)},
error = function(e) { stop (message(e))})
print(df)
# Snapshot requests
df = tryCatch (
{ ds$getData(tickers="VOD", fields=list("PH", "PL"),
start='2022-01-12', kind=0)},
error = function(e) { stop (message(e))})
print(df)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.