For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
1 1 0 1

Unexpected Timestamp on TickHistoryInstradaySummaries extract

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();

}

}

}



dss-rest-apidatascope-selectdss
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @stephen.l.ellis

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.

Thanks,

AHS


Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
11.3k 25 9 14

@stephen.l.ellis,

This could be similar issue with this question. The QueryStartDate and QueryEndDate is DateTimeOffset object. If you want to specify the query dates in UTC, you can use the following code to convert DateTime to DateTimeOffset.

            DateTime startDateTimeLocal = DateTime.ParseExact(DTStart, "yyyyMMdd HHmm", CultureInfo.InvariantCulture);
            startDateTimeLocal = DateTime.SpecifyKind(startDateTimeLocal, DateTimeKind.Utc);
            DateTimeOffset startDateTime = startDateTimeLocal;

            DateTime endDateTimeLocal = DateTime.ParseExact(DTEnd, "yyyyMMdd HHmm", CultureInfo.InvariantCulture);
            endDateTimeLocal = DateTime.SpecifyKind(endDateTimeLocal, DateTimeKind.Utc);
            DateTimeOffset endDateTime = startDateTimeLocal;
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.