First import the metadata into the client side from here. If you are using Microsoft Visual Studio, then you will typically add a service reference to the service and this will generate the relevant types and service client automatically for you. If you are using Java, you might choose a technique similar to this to generate your web service client code. You can then instantiate the service client and invoke the various methods. You can refer here for a description of the operations. Following are the steps you will typically use during integration:
- Obtain a secure token by calling GetToken() method passing your credentials
- Create DSDataRequest with the appropriate instrument, data types and date information.
- Invoke GetData() method passing the secure token and the data request.
- Extract data from the returned DSDataResponse.
You can also use GetDataBundle() method to retrieve data for multiple requests in a single call.
A secure token is needed in order to retrieve data from the service. You can obtain a token by calling GetToken() method. You have to pass as part of this method your Datastream Id (eg. ZABC123) and password. You will get back a secure token as part of the response and you will use this token for subsequent data access. Following code snippet shows an example token request and response:
var tokenRequest = new DSGetTokenRequest()
{
UserName = "yourDatastreamId",
Password = "yourpassword",
};
string tokenValue = null;
DateTime tokenExpiry = default(DateTime);
using (var dsclient = new DSServiceClient())
{
var tokenResponse = dsclient.GetToken(tokenRequest);
tokenValue = tokenResponse.TokenValue;
tokenExpiry = tokenResponse.TokenExpiry;
}
// Create a token request
var tokenRequest = new DSGetTokenRequest()
{
UserName = "yourDatastreamId",
Password = "yourpassword",
};
string tokenValue = null;
DateTime tokenExpiry = default(DateTime);
using (var dsclient = new DSServiceClient())
{
// Issue a call to get the token
var tokenResponse = dsclient.GetToken(tokenRequest);
// Read the token from the response
tokenValue = tokenResponse.TokenValue;
tokenExpiry = tokenResponse.TokenExpiry;
}
DSGetTokenRequest req = new DSGetTokenRequest();
req.setUserName("yourDatastreamId");
req.setPassword("yourpassword");
GetToken token = new GetToken();
token.setRequest(req);
DSGetTokenResponse resp = new DSServiceStub().getToken(token).getGetTokenResult();
System.out.println("Token: " + resp.getTokenValue());
System.out.println("Token Expiry: " + resp.getTokenExpiry().getTime());
// Create the token request
DSGetTokenRequest req = new DSGetTokenRequest();
req.setUserName("yourDatastreamId");
req.setPassword("yourpassword");
// Issue the request to server
GetToken token = new GetToken();
token.setRequest(req);
DSGetTokenResponse resp = new DSServiceStub().getToken(token).getGetTokenResult();
// Process the token response
System.out.println("Token: " + resp.getTokenValue());
System.out.println("Token Expiry: " + resp.getTokenExpiry().getTime());
Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetToken</Action>
</s:Header>
<s:Body>
<GetToken xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<UserName>yourDatastreamId</UserName>
<Password>yourpassword</Password>
<Properties i:nil="true" />
</request>
</GetToken>
</s:Body>
</s:Envelope>
Response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetTokenResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetTokenResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<TokenValue>n9IcXCXIq+ApBEe0zLBeTrU11D65F6BB2ED74E3467EA0EBE0C</TokenValue>
<TokenExpiry>2013-01-30T21:11:22.2771093Z</TokenExpiry>
<Properties i:nil="true" />
</GetTokenResult>
</GetTokenResponse>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetToken</Action>
</s:Header>
<s:Body>
<GetToken xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<UserName>yourDatastreamId</UserName>
<Password>yourpassword</Password>
<Properties i:nil="true" />
</request>
</GetToken>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetTokenResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetTokenResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<TokenValue>n9IcXCXIq+ApBEe0zLBeTrU11D65F6BB2ED74E3467EA0EBE0C</TokenValue>
<TokenExpiry>2013-01-30T21:11:22.2771093Z</TokenExpiry>
<Properties i:nil="true" />
</GetTokenResult>
</GetTokenResponse>
</s:Body>
</s:Envelope>
Note |
The tokens have an expiry time and the response contains the timestamp (in UTC) when the token will expire. You can cache the token until this expiry time and use it for data requests. You need to obtain the token again if it has expired. |
A data request consists of an instrument (eg. VOD.L), data types (eg. PH), date information (eg. Start/End dates of a time series) and optional request properties. An instrument is generally a symbol (such as RIC, Datastream Mnemonic, ISIN etc.) but it can also be a complex expression. You can specify properties for the instrument (eg. are they set of instruments rather than a single instrument). The data types contain the field codes for which you want to retrieve the data. You can lookup the instruments from here and browse the available data types from here. The expression syntax can be found here.
the service supports point-in-time data (snapshot) as well as time series data retrieval. For a snapshot date you will specify a single date, while for a time series date the start date, end date and frequency information will be specified. Note that the DateKind must be populated appropriately. You can use absolute dates (eg. 2012-11-24), relative dates (eg. -30D) or certain literals (eg. BDATE) as dates.
You can also specify additional request properties to customize your responses (eg. return expanded instrument name). If you need to specify the type of the instrument, you can use the special SYM# function. For example SYM#(VOD.L,RIC) specifies that the instrument type is a RIC. Following code snippet provides an example data request:
var request = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new[] { new DSDataType() { Value = "PL" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "2011-01-01" },
};
var singleInstr = new DSInstrument()
{
Value = "VOD"
};
var multiInstr = new DSInstrument()
{
Value = "VOD,BARC,MSFT",
Properties = new[]
{
new DSStringObjectKVPair() { Key = DSInstrumentPropertyNames.IsSymbolSet.ToString(), Value = true }
}
};
var expr = new DSInstrument()
{
Value = "VOD(PL) + VOD(PH)",
Properties = new[]
{
new DSStringObjectKVPair() { Key = DSInstrumentPropertyNames.IsExpression.ToString(), Value = true }
}
};
var singleDataType = new[] { new DSDataType() { Value = "PL" } };
var multiDataTypes = new[] { new DSDataType() { Value = "PL" }, new DSDataType() { Value = "PH" } };
var snpDate = new DSDate() { Kind = DSDateKind.Snapshot, Start = "2011-01-01" };
var snpDate2 = new DSDate() { Kind = DSDateKind.Snapshot, Start = DSDateNames.WKE.ToString() };
var tsDate = new DSDate() { Kind = DSDateKind.TimeSeries, Start = "-30D", End = "-10D",
Frequency = DSDateFrequencyNames.D.ToString() };
// A data request
var request = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new[] { new DSDataType() { Value = "PL" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "2011-01-01" },
};
//
// Different types of requests...
// Single instrument
var singleInstr = new DSInstrument()
{
Value = "VOD"
};
// Multiple instruments
var multiInstr = new DSInstrument()
{
Value = "VOD,BARC,MSFT",
Properties = new[]
{
new DSStringObjectKVPair() { Key = DSInstrumentPropertyNames.IsSymbolSet.ToString(), Value = true }
}
};
// Expressions
var expr = new DSInstrument()
{
Value = "VOD(PL) + VOD(PH)",
Properties = new[]
{
new DSStringObjectKVPair() { Key = DSInstrumentPropertyNames.IsExpression.ToString(), Value = true }
}
};
// Single datatype
var singleDataType = new[] { new DSDataType() { Value = "PL" } };
// Multiple datatypes
var multiDataTypes = new[] { new DSDataType() { Value = "PL" }, new DSDataType() { Value = "PH" } };
// Snapshot date
var snpDate = new DSDate() { Kind = DSDateKind.Snapshot, Start = "2011-01-01" };
// Snapshot date with date literals
var snpDate2 = new DSDate() { Kind = DSDateKind.Snapshot, Start = DSDateNames.WKE.ToString() };
// Timeseries date
var tsDate = new DSDate() { Kind = DSDateKind.TimeSeries, Start = "-30D", End = "-10D", Frequency = DSDateFrequencyNames.D.ToString() };
<DataRequest>
<DataTypes>
<DSDataType>
<Properties i:nil="true" />
<Value>PL</Value>
</DSDataType>
<DSDataType>
<Properties i:nil="true" />
<Value>PH</Value>
</DSDataType>
</DataTypes>
<Date>
<End>-20D</End>
<Frequency>D</Frequency>
<Kind>TimeSeries</Kind>
<Start>-30D</Start>
</Date>
<Instrument>
<Properties i:nil="true" />
<Value>VOD</Value>
</Instrument>
<Tag i:nil="true" />
</DataRequest>
<DataRequest>
<DataTypes>
<DSDataType>
<Properties i:nil="true" />
<Value>PL</Value>
</DSDataType>
<DSDataType>
<Properties i:nil="true" />
<Value>PH</Value>
</DSDataType>
</DataTypes>
<Date>
<End>-20D</End>
<Frequency>D</Frequency>
<Kind>TimeSeries</Kind>
<Start>-30D</Start>
</Date>
<Instrument>
<Properties i:nil="true" />
<Value>VOD</Value>
</Instrument>
<Tag i:nil="true" />
</DataRequest>
Note |
If you know that your request contains a symbol that is a RIC, it is better to pass the symbol decorated with <symbol>. For example, VOD.L can be passed as <VOD.L>. Alternatively, you can use the verbose syntax SYM#(VOD.L,RIC). This usually speeds up the operation in the backend. |
A data response contains all the requested data types, and, for each data type, the values corresponding to instruments. Note that even though you ask for a single instrument, if the instrument is a list symbol (eg. LFTSE100), you will get back multiple instruments in the response.
The response value is contained inside symbol response value. You can access the Value property to get the appropriate data. For example if you asked for a time series closing price, this property will contain an array of doubles.
A request failure (eg. invalid arguments) would result in a SOAP error with appropriate fault details. Further you have to check the Type property of a symbol response to see if a specific data type has errors (eg. time series information not available for requested data type).
You can also check additional response properties such as expanded symbol names etc. provided you had asked them during your request. Following code snippet provides an example data response:
DSDataResponse response = ResponseGotFromGetData();
foreach (var datatypeValue in response.DataTypeValues)
{
string requestedDataType = datatypeValue.DataType;
foreach (var symbolVal in datatypeValue.SymbolValues)
{
string symbol = symbolVal.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
double[] values = (double[]) symbolVal.Value;
}
}
}
// Access the response
DSDataResponse response = ResponseGotFromGetData();
foreach (var datatypeValue in response.DataTypeValues)
{
// This is the datatype requested
string requestedDataType = datatypeValue.DataType;
// Access the symbols for the datatype
// If the requested instrument was a list, there will be multiple symbols
foreach (var symbolVal in datatypeValue.SymbolValues)
{
string symbol = symbolVal.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
// The symbol value is an error - perhaps there is no data
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
// The symbol value is a double array
double[] values = (double[]) symbolVal.Value;
}
}
}
<DataResponse>
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>155.97</a:double>
<a:double>155.9</a:double>
<a:double>154.82</a:double>
<a:double>155.45</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>159.57</a:double>
<a:double>159.35</a:double>
<a:double>157.51</a:double>
<a:double>157.86</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:dateTime>20121217T00:00:00</a:dateTime>
<a:dateTime>20121218T00:00:00</a:dateTime>
<a:dateTime>20121219T00:00:00</a:dateTime>
<a:dateTime>20121220T00:00:00</a:dateTime>
</Dates>
<SymbolNames i:nil="true" />
<DataTypeNames i:nil="true" />
<AdditionalResponses i:nil="true" />
<Tag i:nil="true" />
</DataResponse>
<DataResponse>
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>155.97</a:double>
<a:double>155.9</a:double>
<a:double>154.82</a:double>
<a:double>155.45</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>159.57</a:double>
<a:double>159.35</a:double>
<a:double>157.51</a:double>
<a:double>157.86</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:dateTime>20121217T00:00:00</a:dateTime>
<a:dateTime>20121218T00:00:00</a:dateTime>
<a:dateTime>20121219T00:00:00</a:dateTime>
<a:dateTime>20121220T00:00:00</a:dateTime>
</Dates>
<SymbolNames i:nil="true" />
<DataTypeNames i:nil="true" />
<AdditionalResponses i:nil="true" />
<Tag i:nil="true" />
</DataResponse>
You can retrieve the data for a single request by calling GetData() method. Following code snippet provides an example GetData request and response:
var request = new DSGetDataRequest()
{
TokenValue = TokenGotThroGetToken(),
DataRequest = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new[] { new DSDataType() { Value = "PL" }, new DSDataType() { Value = "PH" } },
Date = new DSDate() { Kind = DSDateKind.TimeSeries, Start = "-30D", End = "-10D"
Frequency = DSDateFrequencyNames.D.ToString() }
}
};
DSDataResponse response = null;
using (var dsclient = new DSServiceClient())
response = dsclient.GetData(request).DataResponse;
foreach (var datatypeValue in response.DataTypeValues)
{
string requestedDataType = datatypeValue.DataType;
foreach (var symbolVal in datatypeValue.SymbolValues)
{
string symbol = symbolVal.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
double[] values = (double[]) symbolVal.Value;
}
}
}
// Create the request
var request = new DSGetDataRequest()
{
TokenValue = TokenGotThroGetToken(),
DataRequest = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new[] { new DSDataType() { Value = "PL" }, new DSDataType() { Value = "PH" } },
Date = new DSDate() { Kind = DSDateKind.TimeSeries, Start = "-30D", End = "-10D", Frequency = DSDateFrequencyNames.D.ToString() },
}
};
// Get the data
DSDataResponse response = null;
using (var dsclient = new DSServiceClient())
response = dsclient.GetData(request).DataResponse;
// Process the response
foreach (var datatypeValue in response.DataTypeValues)
{
// This is the datatype requested
string requestedDataType = datatypeValue.DataType;
// Access the symbols for the datatype
// If the requested instrument was a list, there will be multiple symbols
foreach (var symbolVal in datatypeValue.SymbolValues)
{
string symbol = symbolVal.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
// The symbol value is an error - perhaps there is no data
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
// The symbol value is a double array
double[] values = (double[])symbolVal.Value;
}
}
}
DSInstrument instr = new DSInstrument();
instr.setValue("VOD");
DSDataType[] datatypes = new DSDataType[2];
datatypes[0] = new DSDataType();
datatypes[0].setValue("PL");
datatypes[1] = new DSDataType();
datatypes[1].setValue("PH");
DSDate date = new DSDate();
date.setKind(DSDateKind.TimeSeries);
date.setStart("-30D");
date.setEnd("-10D");
date.setFrequency(DSDateFrequencyNames.D.getValue());
ArrayOfDSDataType datatypesArray = new ArrayOfDSDataType();
datatypesArray.setDSDataType(datatypes);
DSDataRequest dataReq = new DSDataRequest();
dataReq.setInstrument(instr);
dataReq.setDataTypes(datatypesArray);
dataReq.setDate(date);
DSGetDataRequest dsgetdataReq = new DSGetDataRequest();
dsgetdataReq.setTokenValue(token);
dsgetdataReq.setDataRequest(dataReq);
GetData getdataReq = new GetData();
getdataReq.setRequest(dsgetdataReq);
DSDataResponse response = new DSServiceStub().getData(getdataReq).getGetDataResult().getDataResponse();
for (DSDataTypeResponseValue datatypeValue : response.getDataTypeValues().getDSDataTypeResponseValue()) {
for (DSSymbolResponseValue symbolValue : datatypeValue.getSymbolValues().getDSSymbolResponseValue()){
if (symbolValue.getType().getValue() == DSSymbolResponseValueType.Error.getValue()){
System.out.println(String.format("DataType %s Symbol %s => Error: %s",
datatypeValue.getDataType(), symbolValue.getSymbol(),
symbolValue.getValue().toString()));
}
else if (symbolValue.getType().getValue() == DSSymbolResponseValueType.DoubleArray.getValue()){
System.out.println(String.format("DataType %s Symbol %s => Double[]: %d",
datatypeValue.getDataType(), symbolValue.getSymbol(),
((ArrayOfdouble) symbolValue.getValue()).get_double().length));
}
}
}
// Create the instrument
DSInstrument instr = new DSInstrument();
instr.setValue("VOD");
// Create the data types
DSDataType[] datatypes = new DSDataType[2];
datatypes[0] = new DSDataType();
datatypes[0].setValue("PL");
datatypes[1] = new DSDataType();
datatypes[1].setValue("PH");
// Create the date
DSDate date = new DSDate();
date.setKind(DSDateKind.TimeSeries);
date.setStart("-30D");
date.setEnd("-10D");
date.setFrequency(DSDateFrequencyNames.D.getValue());
// Create the data request
ArrayOfDSDataType datatypesArray = new ArrayOfDSDataType();
datatypesArray.setDSDataType(datatypes);
DSDataRequest dataReq = new DSDataRequest();
dataReq.setInstrument(instr);
dataReq.setDataTypes(datatypesArray);
dataReq.setDate(date);
// Issue the request to server
DSGetDataRequest dsgetdataReq = new DSGetDataRequest();
dsgetdataReq.setTokenValue(token);
dsgetdataReq.setDataRequest(dataReq);
GetData getdataReq = new GetData();
getdataReq.setRequest(dsgetdataReq);
DSDataResponse response = new DSServiceStub().getData(getdataReq).getGetDataResult().getDataResponse();
// Process the response
for (DSDataTypeResponseValue datatypeValue : response.getDataTypeValues().getDSDataTypeResponseValue()) {
for (DSSymbolResponseValue symbolValue : datatypeValue.getSymbolValues().getDSSymbolResponseValue()){
if (symbolValue.getType().getValue() == DSSymbolResponseValueType.Error.getValue()){
// The symbol value is an error - perhaps there is no data
System.out.println(String.format("DataType %s Symbol %s => Error: %s", datatypeValue.getDataType(), symbolValue.getSymbol(), symbolValue.getValue().toString()));
}
else if (symbolValue.getType().getValue() == DSSymbolResponseValueType.DoubleArray.getValue()){
// The symbol value is a double array
System.out.println(String.format("DataType %s Symbol %s => Double[]: %d", datatypeValue.getDataType(), symbolValue.getSymbol(), ((ArrayOfdouble) symbolValue.getValue()).get_double().length));
}
}
}
Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetData</Action>
</s:Header>
<s:Body>
<GetData xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataRequest>
<DataTypes>
<DSDataType>
<Value>PL</Value>
<Properties i:nil="true" />
</DSDataType>
<DSDataType>
<Value>PH</Value>
<Properties i:nil="true" />
</DSDataType>
</DataTypes>
<Date>
<Start>-30D</Start>
<End>-20D</End>
<Frequency>D</Frequency>
<Kind>TimeSeries</Kind>
</Date>
<Instrument>
<Value>VOD</Value>
<Properties i:nil="true" />
</Instrument>
<Tag i:nil="true" />
</DataRequest>
<Properties i:nil="true" />
<TokenValue>n9IcXCXIq+1h2blED74E3467EA0EBE0C</TokenValue>
</request>
</GetData>
</s:Body>
</s:Envelope>
Response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetDataResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetDataResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataResponse>
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>155.97</a:double>
<a:double>155.9</a:double>
<a:double>154.82</a:double>
<a:double>155.45</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>159.57</a:double>
<a:double>159.35</a:double>
<a:double>157.51</a:double>
<a:double>157.86</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:dateTime>20121217T00:00:00</a:dateTime>
<a:dateTime>20121218T00:00:00</a:dateTime>
<a:dateTime>20121219T00:00:00</a:dateTime>
<a:dateTime>20121220T00:00:00</a:dateTime>
</Dates>
<SymbolNames i:nil="true" />
<DataTypeNames i:nil="true" />
<AdditionalResponses i:nil="true" />
<Tag i:nil="true" />
</DataResponse>
<Properties i:nil="true" />
</GetDataResult>
</GetDataResponse>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetData</Action>
</s:Header>
<s:Body>
<GetData xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataRequest>
<DataTypes>
<DSDataType>
<Properties i:nil="true" />
<Value>PL</Value>
</DSDataType>
<DSDataType>
<Properties i:nil="true" />
<Value>PH</Value>
</DSDataType>
</DataTypes>
<Date>
<End>-20D</End>
<Frequency>D</Frequency>
<Kind>TimeSeries</Kind>
<Start>-30D</Start>
</Date>
<Instrument>
<Properties i:nil="true" />
<Value>VOD</Value>
</Instrument>
<Tag i:nil="true" />
</DataRequest>
<Properties i:nil="true" />
<TokenValue>n9IcXCXIq+1h2blED74E3467EA0EBE0C</TokenValue>
</request>
</GetData>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetDataResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetDataResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataResponse>
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>155.97</a:double>
<a:double>155.9</a:double>
<a:double>154.82</a:double>
<a:double>155.45</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>DoubleArray</Type>
<Value i:type="a:ArrayOfdouble" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:double>159.57</a:double>
<a:double>159.35</a:double>
<a:double>157.51</a:double>
<a:double>157.86</a:double>
</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:dateTime>20121217T00:00:00</a:dateTime>
<a:dateTime>20121218T00:00:00</a:dateTime>
<a:dateTime>20121219T00:00:00</a:dateTime>
<a:dateTime>20121220T00:00:00</a:dateTime>
</Dates>
<SymbolNames i:nil="true" />
<DataTypeNames i:nil="true" />
<AdditionalResponses i:nil="true" />
<Tag i:nil="true" />
</DataResponse>
<Properties i:nil="true" />
</GetDataResult>
</GetDataResponse>
</s:Body>
</s:Envelope>
If you want to combine muliple requests into a single call then you can use GetDataBundle() method to get the data for all the requests in one-go. Following code snippet provides an example Data request and response:
var req1 = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new new[] { new DSDataType() { Value = "PL" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "-10D" },
};
var req2 = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "BARC" },
DataTypes = new new[] { new DSDataType() { Value = "PH" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "-30D" },
};
var bundleReq = new DSGetDataBundleRequest()
{
TokenValue = TokenGotThroGetToken(),
DataRequests = new[] { req1, req2 },
};
DSDataResponse[] responses = null;
using (var dsclient = new DSServiceClient())
responses = dsclient.GetDataBundle(bundleReq).DataResponses;
foreach (var response in responses)
{
foreach (var datatypeValue in response.DataTypeValues)
{
string datatype = datatypeValue.DataType;
foreach (var symbolValue in datatypeValue.SymbolValues)
{
string symbol = symbolValue.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
double[] values = (double[]) symbolVal.Value;
}
}
}
}
// Create data requests
var req1 = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "VOD" },
DataTypes = new[] { new DSDataType() { Value = "PL" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "-10D" },
};
var req2 = new DSDataRequest()
{
Instrument = new DSInstrument() { Value = "BARC" },
DataTypes = new[] { new DSDataType() { Value = "PH" } },
Date = new DSDate() { Kind = DSDateKind.Snapshot, Start = "-20D" },
};
// Bundle the requests
var bundleReq = new DSGetDataBundleRequest()
{
TokenValue = TokenGotThroGetToken(),
DataRequests = new[] { req1, req2 },
};
// Get the data for multiple requests
DSDataResponse[] responses = null;
using (var dsclient = new DSServiceClient())
responses = dsclient.GetDataBundle(bundleReq).DataResponses;
// Process each request's response
foreach (var response in responses)
{
foreach (var datatypeValue in response.DataTypeValues)
{
// This is the datatype requested
string requestedDataType = datatypeValue.DataType;
// Access the symbols for the datatype
// If the requested instrument was a list, there will be multiple symbols
foreach (var symbolVal in datatypeValue.SymbolValues)
{
string symbol = symbolVal.Symbol;
if (symbolVal.Type == DSSymbolResponseValueType.Error)
{
// The symbol value is an error - perhaps there is no data
string errorMessage = symbolVal.Value.ToString();
}
else if (symbolVal.Type == DSSymbolResponseValueType.DoubleArray)
{
// The symbol value is a double array
double[] values = (double[])symbolVal.Value;
}
}
}
}
Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetDataBundle</Action>
</s:Header>
<s:Body>
<GetDataBundle xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataRequests>
<DSDataRequest>
<Instrument>
<Value>VOD</Value>
<Properties i:nil="true" />
</Instrument>
<DataTypes>
<DSDataType>
<Value>PL</Value>
<Properties i:nil="true" />
</DSDataType>
</DataTypes>
<Date>
<Start>-10D</Start>
<End />
<Frequency />
<Kind>Snapshot</Kind>
</Date>
<Tag i:nil="true" />
</DSDataRequest>
<DSDataRequest>
<Instrument>
<Value>BARC</Value>
<Properties i:nil="true" />
</Instrument>
<DataTypes>
<DSDataType>
<Value>PH</Value>
<Properties i:nil="true" />
</DSDataType>
</DataTypes>
<Date>
<Start>-20D</Start>
<End />
<Frequency />
<Kind>Snapshot</Kind>
</Date>
<Tag i:nil="true" />
</DSDataRequest>
</DataRequests>
<Properties i:nil="true" />
<TokenValue>n9IcXCXIq+1h2blED74E3467EA0EBE0C</TokenValue>
</request>
</GetDataBundle>
</s:Body>
</s:Envelope>
Response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetDataBundleResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetDataBundleResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataResponses>
<DSDataResponse>
<AdditionalResponses i:nil="true" />
<DataTypeNames i:nil="true" />
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>Double</Type>
<Value i:type="a:double" xmlns:a="http://www.w3.org/2001/XMLSchema">155.9</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<SymbolNames i:nil="true" />
<Tag i:nil="true" />
</DSDataResponse>
<DSDataResponse>
<AdditionalResponses i:nil="true" />
<DataTypeNames i:nil="true" />
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>BARC</Symbol>
<Type>String</Type>
<Value i:type="a:string" xmlns:a="http://www.w3.org/2001/XMLSchema">NA</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<SymbolNames i:nil="true" />
<Tag i:nil="true" />
</DSDataResponse>
</DataResponses>
<Properties i:nil="true" />
</GetDataBundleResult>
</GetDataBundleResponse>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://dsws.datastream.com/client/V1/IDSService/GetDataBundle</Action>
</s:Header>
<s:Body>
<GetDataBundle xmlns="http://dsws.datastream.com/client/V1/">
<request xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataRequests>
<DSDataRequest>
<Instrument>
<Value>VOD</Value>
<Properties i:nil="true" />
</Instrument>
<DataTypes>
<DSDataType>
<Value>PL</Value>
<Properties i:nil="true" />
</DSDataType>
</DataTypes>
<Date>
<Start>-10D</Start>
<End />
<Frequency />
<Kind>Snapshot</Kind>
</Date>
<Tag i:nil="true" />
</DSDataRequest>
<DSDataRequest>
<Instrument>
<Value>BARC</Value>
<Properties i:nil="true" />
</Instrument>
<DataTypes>
<DSDataType>
<Value>PH</Value>
<Properties i:nil="true" />
</DSDataType>
</DataTypes>
<Date>
<Start>-20D</Start>
<End />
<Frequency />
<Kind>Snapshot</Kind>
</Date>
<Tag i:nil="true" />
</DSDataRequest>
</DataRequests>
<Properties i:nil="true" />
<TokenValue>n9IcXCXIq+1h2blED74E3467EA0EBE0C</TokenValue>
</request>
</GetDataBundle>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<GetDataBundleResponse xmlns="http://dsws.datastream.com/client/V1/">
<GetDataBundleResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<DataResponses>
<DSDataResponse>
<AdditionalResponses i:nil="true" />
<DataTypeNames i:nil="true" />
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PL</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>VOD</Symbol>
<Type>Double</Type>
<Value i:type="a:double" xmlns:a="http://www.w3.org/2001/XMLSchema">155.9</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<SymbolNames i:nil="true" />
<Tag i:nil="true" />
</DSDataResponse>
<DSDataResponse>
<AdditionalResponses i:nil="true" />
<DataTypeNames i:nil="true" />
<DataTypeValues>
<DSDataTypeResponseValue>
<DataType>PH</DataType>
<SymbolValues>
<DSSymbolResponseValue>
<Currency>£</Currency>
<Symbol>BARC</Symbol>
<Type>String</Type>
<Value i:type="a:string" xmlns:a="http://www.w3.org/2001/XMLSchema">NA</Value>
</DSSymbolResponseValue>
</SymbolValues>
</DSDataTypeResponseValue>
</DataTypeValues>
<Dates i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<SymbolNames i:nil="true" />
<Tag i:nil="true" />
</DSDataResponse>
</DataResponses>
<Properties i:nil="true" />
</GetDataBundleResult>
</GetDataBundleResponse>
</s:Body>
</s:Envelope>
Note |
Your application will perform better if you bundle the data requests together rather than making multiple individual data requests. |
Whilst each DSDataRequest object supports multiple instruments and datatypes, request limits are imposed by the system. Any one DSDataRequest is restricted to the following limits:
- The maximum number of instruments that can be requested: 50
- The maximum number of datatypes that can be requested: 50
- The maximum number of items (instruments x datatypes) that can be requested: 100
The above limits permit the following example permutations in any one DSDataRequest:
- 50 instruments x 2 datatypes
- 2 instruments x 50 datatypes
- 1 constituent list x 50 datatypes (you can never request more than one constituent list)
- 10 instruments x 10 datatypes
When used with GetDataBundle requests, where a collection of DSDataRequest objects can be combined, there are additional limits imposed on the number of items that can be requested across the bundle:
- The maximum number of DSDataRequests per bundled request: 20
- The maximum number of items (instruments x datatypes) across all DSDataRequests: 500
The above limits permit the following example permutations in any one GetDataBundle request:
- Up to 5 DSDataRequests each requesting 100 items
- 10 DSDataRequests each requesting 50 items
- 20 DSDataRequests each requesting 25 items