I am using the .NET SDK to make on demand extractions.
Because I set the AutomaticDecompression option to false, I would expect to receive compressed data (gzipped).
Instead :
1/ Without the "X-Direct-Download"
header:
- TimeAndSalesExtractionRequest : I receive
uncompressed data
- CorporateActionsStandardExtractionRequest : I receive
uncompressed data
2/ With the "X-Direct-Download" header:
- TimeAndSalesExtractionRequest : I receive gzipped
data (as expected)
- CorporateActionsStandardExtractionRequest : I receive
uncompressed data
Here is my code :
public static class Cases
{
public static void Run()
{
Uri dssUri = new Uri("https://hosted.datascopeapi.reuters.com/RestApi/1/");
string dssUserName = "myUsername";
string dssUserPassword = "myPassword";
ExtractionsContext extractionsContext = new ExtractionsContext(dssUri, dssUserName, dssUserPassword);
//extractionsContext.DefaultRequestHeaders.Add("X-Direct-Download", "true");
extractionsContext.Options.AutomaticDecompression = false;
//-----------------------------------------------------------------
//Define Extraction Request
//-----------------------------------------------------------------
ExtractionRequestBase extractionRequest = GetTimeAndSalesExtractionRequest();
//ExtractionRequestBase extractionRequest = GetCorporateActionsStandardExtractionRequest();
//-----------------------------------------------------------------
//Extraction
//NOTE: if the extraction request takes more than 30 seconds the async mechanism will be used,
//the SDK handles this automatically for you.
//-----------------------------------------------------------------
RawExtractionResult extractionResult = extractionsContext.ExtractRaw(extractionRequest);
//-----------------------------------------------------------------
//Write data to file:
//-----------------------------------------------------------------
DssStreamResponse response = extractionsContext.GetReadStream(extractionResult);
using (var fileStream = File.Create("data.csv.gz"))
{
response.Stream.CopyTo(fileStream);
}
}
public static ExtractionRequestBase GetTimeAndSalesExtractionRequest()
{
var instru1 = InstrumentIdentifier.Create(IdentifierType.Ric, "SOGN.PA");
var instru2 = InstrumentIdentifier.Create(IdentifierType.Ric, "BNPP.PA");
var instru3 = InstrumentIdentifier.Create(IdentifierType.Ric, "CAGR.PA");
var instru4 = InstrumentIdentifier.Create(IdentifierType.Ric, "HSBA.L");
InstrumentIdentifier[] instrumentIdentifierArray = new InstrumentIdentifier[] { instru1, instru2, instru3, instru4 };
string[] requestedFieldNames = {
"Trade - Price", "Trade - Volume", "Trade - Qualifiers",
"Quote - Bid Price", "Quote - Bid Size", "Quote - Number of Buyers",
"Quote - Ask Price", "Quote - Ask Size", "Quote - Number of Sellers",
"Auction - Price", "Auction - Volume"
};
TickHistoryTimeAndSalesCondition condition = new TickHistoryTimeAndSalesCondition
{
ReportDateRangeType = ReportDateRangeType.Range,
QueryStartDate = new DateTimeOffset(2017, 01, 10, 6, 0, 0, TimeSpan.FromHours(0)),
QueryEndDate = new DateTimeOffset(2017, 01, 10, 10, 0, 0, TimeSpan.FromHours(0)),
ApplyCorrectionsAndCancellations = false,
ExtractBy = TickHistoryExtractByMode.Ric,
MessageTimeStampIn = TickHistoryTimeOptions.LocalExchangeTime,
SortBy = TickHistorySort.SingleByTimestamp,
DisplaySourceRIC = false
};
TickHistoryTimeAndSalesExtractionRequest extractionRequest = new TickHistoryTimeAndSalesExtractionRequest
{
IdentifierList = InstrumentIdentifierList.Create(instrumentIdentifierArray),
ContentFieldNames = requestedFieldNames,
Condition = condition
};
return extractionRequest;
}
public static ExtractionRequestBase GetCorporateActionsStandardExtractionRequest()
{
var instru1 = InstrumentIdentifier.Create(IdentifierType.Ric, "SOGN.PA");
var instru2 = InstrumentIdentifier.Create(IdentifierType.Ric, "BNPP.PA");
var instru3 = InstrumentIdentifier.Create(IdentifierType.Ric, "CAGR.PA");
var instru4 = InstrumentIdentifier.Create(IdentifierType.Ric, "HSBA.L");
InstrumentIdentifier[] instrumentIdentifierArray = new InstrumentIdentifier[] { instru1, instru2, instru3, instru4 };
string[] requestedFieldNames = {
"RIC", "Dividend Ex Date", "Dividend Rate", "Dividend Currency"
};
CorporateActionsStandardCondition condition = new CorporateActionsStandardCondition
{
PreviousDays = 90,
ReportDateRangeType = ReportDateRangeType.Delta,
CorporateActionsCapitalChangeType = CorporateActionsCapitalChangeType.CapitalChangeExDate,
CorporateActionsDividendsType = CorporateActionsDividendsType.DividendPayDate,
CorporateActionsEarningsType = CorporateActionsEarningsType.PeriodEndDate,
CorporateActionsEquityOfferingsType = CorporateActionsEquityOfferingsType.AllPendingDeals,
CorporateActionsMergersAcquisitionsType = CorporateActionsMergersAcquisitionsType.DealAnnouncementDate,
CorporateActionsNominalValueType = CorporateActionsNominalValueType.NominalValueDate,
CorporateActionsSharesType = CorporateActionsSharesType.SharesAmountDate,
CorporateActionsStandardEventsType = CorporateActionsStandardEventsType.None,
CorporateActionsVotingRightsType = CorporateActionsVotingRightsType.VotingRightsDate,
QueryStartDate = null,
NextDays = null,
QueryEndDate = null,
PendingEventsHours = null,
PendingEventsMinutes = null,
IncludeInstrumentsWithNoEvents = null,
IncludeNullDates = null,
ExcludeDeletedEvents = true,
IncludeCapitalChangeEvents = true,
IncludeDividendEvents = true,
IncludeEarningsEvents = true,
IncludeMergersAndAcquisitionsEvents = true,
IncludeNominalValueEvents = true,
IncludePublicEquityOfferingsEvents = true,
IncludeSharesOutstandingEvents = true,
IncludeVotingRightsEvents = true
};
CorporateActionsStandardExtractionRequest extractionRequest = new CorporateActionsStandardExtractionRequest
{
IdentifierList = InstrumentIdentifierList.Create(instrumentIdentifierArray),
ContentFieldNames = requestedFieldNames,
Condition = condition
};
return extractionRequest;
}
}