Hello, When I try to extract the Time and Sales Data to a file I only get partial data. I've attached a snippet of my code for the extraction request which writes to a file on my local machine. Am I missing a step like aggregating files?
StreamWriter clear = new StreamWriter(dataOutputFile, false);
clear.Close();
Console.WriteLine("Cleared data output file " + dataOutputFile + "\n");
TickHistoryTimeAndSalesExtractionRequest extractionRequest = new TickHistoryTimeAndSalesExtractionRequest {
IdentifierList = InstrumentIdentifierList.Create(instrumentIdentifiers),
Condition = reportTemplate.Condition,
ContentFieldNames = { "Trade - Price", "Trade - Volume", "Quote - Bid Price", "Quote - Bid Size", "Quote - Ask Price", "Quote - Ask Size" }
};
extractionsContext.Options.AutomaticDecompression = true; //Decompress gzip to plain text
RawExtractionResult extractionResult = extractionsContext.ExtractRaw(extractionRequest);
Console.Write("{0:T} Extraction complete ... ", DateTime.Now);
DebugPrintAndWaitForEnter("");
sw = new StreamWriter(dataOutputFile, true);
Console.WriteLine("==================================== DATA =====================================");
DssStreamResponse streamResponse = extractionsContext.GetReadStream(extractionResult);
using (StreamReader reader = new StreamReader(streamResponse.Stream)) {
string line = reader.ReadLine();
if (string.IsNullOrEmpty(line)) {
Console.WriteLine("WARNING: no data returned. Check your request dates.");
sw.WriteLine("WARNING: no data returned. Check your request dates.");
} else {
//The first line is the list of field names:
sw.WriteLine(line);
Console.WriteLine(line);
//The remaining lines are the data:
//Variant 1: write all lines individually to file and console (and set a limit on number of lines)
for (int lineCount = 0; lineCount < maxDataLines && !reader.EndOfStream; lineCount++) {
line = reader.ReadLine();
sw.WriteLine(line);
Console.WriteLine(line);
}
//Variant 2: write all lines to either file or console (not both !):
//sw.WriteLine(line = reader.ReadToEnd());
//Console.WriteLine(line = reader.ReadToEnd());
}
}
sw.Close();
DebugPrintAndWaitForEnter("===============================================================================");
}