DataClient {DatastreamR} | R Documentation |
DataClient
Description
An RC class for accessing Datastream content through Datastream Web services API
Value
DataClient object
Super class
DatastreamR::DSConnect
-> DataClient
Public fields
useNaNforNotANumber
: TRUE by default. NULLs are replaced to NaN (Not a Number)
Methods
Public methods
Inherited methods
Method new()
Initialize method to create Datastream Object
Usage
DataClient$new( config = NULL, username = "", password = "", proxys = NULL, sslCer = NULL )
Arguments
config
: Config path
username
: Your Id
password
: Your Password
proxys
: Proxy details (if any)
sslCer
: ssl Certificates path
Details
Creates Datastream RC object for accessing Datastream content through Datastream Web Services API
Returns
DataClient object
Examples
\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) }
Method getData()
getData posts the JSON formatted request and the JSON response is then converted to Dataframe, if dataToDF is TRUE.
Usage
DataClient$getData( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1, properties = NULL )
Arguments
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
Returns
Response Class
Method getDataframe()
getDataframe posts the JSON formatted request and the JSON response is then converted to Dataframe
Usage
DataClient$getDataframe( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1, properties = NULL )
Arguments
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
Returns
Dataframe
Method formatDataRequest()
This method formats the request provided by client (in form of tickers and fields) to the JSON formatted request.
Usage
DataClient$formatDataRequest( tickers, fields = NULL, start = "", end = "", freq = "D", kind = 1 )
Arguments
tickers
: Instruments
fields
: Datatypes
start
: start date
end
: end date
freq
: frequency
kind
: kind = 0 for Snapshot request and Kind = 1 for Timeseries request
Returns
JSON formatted data request
Method getDataBundle()
getData posts the JSON formatted request and the JSON response is then converted to Dataframe, if dataToDF is TRUE.
Usage
DataClient$getDataBundle(dataRequests, properties = NULL)
Arguments
dataRequests
: dataRequests should be formed using formatDataRequest method
properties
: properties
Returns
Response Class
Method toDataframe()
Converts the Class response into a Dataframe which can be further used to plot
Usage
DataClient$toDataframe(dataResponse)
Arguments
dataResponse
: The raw data response that is ingested into Dataframe
Returns
Dataframe
Method clone()
The objects of this class are cloneable with this method.
Usage
DataClient$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## 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)