Hi, I'm trying to download some prices at a single point in time 28-Jun-2019 16:30. However the results I'm getting are timestamped 2019-06-28T04:30:00.000000000Z.
My code is attached below :
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ThomsonReuters.Dss.Api;
using ThomsonReuters.Dss.Api.Content;
using ThomsonReuters.Dss.Api.Extractions;
using ThomsonReuters.Dss.Api.Extractions.ExtractionRequests;
using ThomsonReuters.Dss.Api.Extractions.ReportExtractions;
using ThomsonReuters.Dss.Api.Extractions.ReportTemplates;
using ThomsonReuters.Dss.Api.Extractions.Schedules;
using ThomsonReuters.Dss.Api.Extractions.SubjectLists;
using ThomsonReuters.Dss.Api.Search;
using ThomsonReuters.Dss.Api.Users;
using ThomsonReuters.Dss.Core.RestApi;
namespace Reuters
{
class Program
{
static void Main(string[] args)
//string password, string UserID, string instruments,string startDateTime,string endDateTime, string path, string FileName
{
// Set Variables
int numOfArgs = args.Length;
string password = (numOfArgs > 0) ? args[0] : "******";
string UserID = (numOfArgs > 1) ? args[1] : "******";
string instruments = (numOfArgs > 2) ? args[2] : "NZD=, EUR=, AUD=";
string DTStart = (numOfArgs > 3) ? args[3] : "20190628 1630";
string DTEnd = (numOfArgs > 4) ? args[4] : "20190628 1630";
string path = (numOfArgs > 5) ? args[5] : @"S:\Financial Risk\FRM\MVD OTC\Datascope\Output\";
string fileName = (numOfArgs > 6) ? args[6] : DTStart.Replace(" ","") + "_" + DTEnd.Replace(" ", "") + "_" + DateTime.Now.ToString("yyyyMMddHmmss") + ".csv";
//if multiple instruments provided create an array
string[] instrumentSplit = instruments.Split(',');
DateTime startDateTime = DateTime.ParseExact(DTStart, "yyyyMMdd HHmm", CultureInfo.InvariantCulture);
DateTime endDateTime = DateTime.ParseExact(DTEnd, "yyyyMMdd HHmm", CultureInfo.InvariantCulture);
string fullFilePath = path + fileName;
//Console.WriteLine(password + ", " + UserID + ", " + instruments + ", " + yyymmdd.ToString() + ", " + time.ToString() + ", " + fullFilePath);
//Console.WriteLine(startDate + " - " + endDate);
///////////////////////////////////////////////////////////// Authenticate connection /////////////////////////////////////////////////////////
var extractionsContext = new ExtractionsContext(new Uri("https://hosted.datascopeapi.reuters.com/RestApi/v1/"), UserID, password);
//Reduce the poll time for the purposes of the example
//extractionsContext.Preferences.WaitSeconds = 5;
var sessionToken = extractionsContext.SessionToken;
//create the available fields (From example)
var availableFields = extractionsContext.GetValidContentFieldTypes(ReportTemplateTypes.TickHistoryIntradaySummaries);
Array fieldNames = availableFields.Select(x => x.Name).ToArray();
int fieldNamesCount = availableFields.Select(x => x.Name).ToArray().Count();
extractionsContext.Options.AutomaticDecompression = true; //Decompress gzip to plain text
// create the list of Identifier
var instrumentIdentifierList = new DssCollection<InstrumentIdentifier> { };
foreach (string ins in instrumentSplit)
{
instrumentIdentifierList.Add(InstrumentIdentifier.Create(IdentifierType.Ric, ins.Trim()));
};
//Console.WriteLine("authentication process done at " + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
/////////////////////////////////////////////////////////// Request an extraction (loop through Instruments) //////////////////////////////////////////
//Console.WriteLine("request started at " + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
var result = extractionsContext.ExtractRaw(
new TickHistoryIntradaySummariesExtractionRequest
{
Condition = new TickHistoryIntradaySummariesCondition
{
SortBy = TickHistorySort.SingleByRic,
MessageTimeStampIn = TickHistoryTimeOptions.GmtUtc,
ReportDateRangeType = ReportDateRangeType.Range,
TimeRangeMode = TickHistoryTimeRangeMode.Inclusive,
QueryStartDate = startDateTime,
QueryEndDate = endDateTime,
DateRangeTimeZone = "UTC",
//Possible values: OneSecond, FiveSeconds, OneMinute, FiveMinutes, TenMinutes, FifteenMinutes, OneHour
SummaryInterval = TickHistorySummaryInterval.FifteenMinutes,
Preview = PreviewMode.None,
ExtractBy = TickHistoryExtractByMode.Ric,
TimebarPersistence = false,
DisplaySourceRIC = false
},
ContentFieldNames = availableFields.Select(x => x.Name).ToArray(),
IdentifierList = new InstrumentIdentifierList
{
InstrumentIdentifiers = instrumentIdentifierList
},
}
);
//Console.WriteLine("request completed at " + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
/////////////////////////////////////////////////////////// Download the results /////////////////////////////////////////////////////////
using (var response = extractionsContext.RawExtractionResultOperations.GetReadStream(result))
using (var stream = response.Stream)
using (var reader = new StreamReader(stream))
{
while (!reader.EndOfStream) //Limit to ten rows for the example. Remove when prod ready.&& lineCount++ < 10
{
string records = reader.ReadToEnd();
string[] RecordsList = records.Split(new string[] { "\\n", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
File.AppendAllText(fullFilePath, records);
}
}
//Console.WriteLine("File completed for: in " + fullFilePath + " at " + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss"));
//foreach (var note in result.Notes)
// Console.WriteLine(note);
//Console.ReadLine();
}
}
}