problem with code
help me, please.
RIC: ESM0m downloaded
code:
dynamic lastDate = new DateTimeOffset(2020, 04, 14, 0, 0, 0, TimeSpan.Zero);
dynamic startDate = new DateTimeOffset(2020, 04, 13, 0, 0, 0, TimeSpan.Zero);
The RIC: ESM0m is not downloaded, but the active RIC:ESH1m is downloaded.
Why can't I download RIC:ESM0m? the file is empty.
dynamic lastDate = srcLastDate ?? new DateTimeOffset(DateTime.UtcNow);
dynamic startDate = lastDate.AddMonths(-1);
code:
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
using ThomsonReuters.Dss.Api.StandardExtractions;
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.Core.RestApi;
using System.Text;
using ICSharpCode.SharpZipLib.GZip;
namespace RefinitivHistoryTesting
{
class Program
{
static void Main(string[] args)
{
//-----------------------------------------------------------------
//Connect and authenticate to the DSS server:
//-----------------------------------------------------------------
Uri dssUri = new Uri("https://hosted.datascopeapi.reuters.com/RestApi/v1/");
string dssUserName = "***";
string dssUserPassword = "***";
var out_dir = @.\Storage\;
var SearchContext = new SearchContext(dssUri, dssUserName, dssUserPassword);
var ExtractionsContext = new ExtractionsContext(dssUri, dssUserName, dssUserPassword);
ExtractionsContext.Options.AutomaticDecompression = false;
try
{
ExtractionsContext.DefaultRequestHeaders.Add("x-direct-download", "true");
}
catch (Exception)
{ }
var availableMbPFields = ExtractionsContext.GetValidContentFieldTypes(ReportTemplateTypes.TickHistoryRaw);
var availableTnSFields = ExtractionsContext.GetValidContentFieldTypes(ReportTemplateTypes.TickHistoryTimeAndSales);
var dateRange = DateTimeRange.Create(
new DateTimeOffset(2008, 01, 01, 0, 0, 0, TimeSpan.Zero),
new DateTimeOffset(2020, 12, 22, 0, 0, 0, TimeSpan.Zero));
var request = new HistoricalChainResolutionRequest
{
ChainRics = new[] { "0#ESM0" },
Range = dateRange
};
var chain_results = SearchContext.HistoricalChainResolution(request);
foreach (var chain in chain_results)
{
Console.WriteLine("Chain Identifier: {0} {1}, Constituents: {2}", chain.IdentifierType, chain.Identifier, chain.Constituents.Count());
foreach (var constituent in chain.Constituents)
{
var searchResults = SearchContext.HistoricalSearch(
HistoricalSearchRequest.Create(
constituent.Identifier, constituent.IdentifierType, dateRange, HistoricalResultsBy.Ric, null));
var result = searchResults.FirstOrDefault(pos => pos.Identifier.Equals("ESM0m"));
if (result != null)
{
var extractionDatesResult = ExtractionsContext.Extract(
new HistoricalReferenceExtractionRequest
{
ContentFieldNames = new DssCollection<string>()
{
"RIC", "Start date", "Change Date", "Expiration Date"
},
Condition = new HistoricalReferenceCondition
{
StartDate = result.FirstDate,
EndDate = result.LastDate
},
IdentifierList = new InstrumentIdentifierList
{
InstrumentIdentifiers = new[]
{
InstrumentIdentifier.Create(result.IdentifierType, result.Identifier)
},
ValidationOptions = new InstrumentValidationOptions
{
AllowHistoricalInstruments = true
},
UseUserPreferencesForValidationOptions = false
}
});
object srcLastDate = null;
foreach (var content in extractionDatesResult)
foreach (var prop in content.DynamicProperties)
{
Console.WriteLine("{0}\t {1},\r", prop.Key, prop.Value);
if (srcLastDate == null && prop.Key == "Expiration Date" && prop.Value != null) srcLastDate = prop.Value;
}
dynamic lastDate = srcLastDate ?? new DateTimeOffset(DateTime.UtcNow);
dynamic startDate = lastDate.AddMonths(-1);
Console.WriteLine("{0},\t {1},\t {2},\t {3},\t {4}", result.Identifier, result.IdentifierType, startDate, lastDate, result.DomainCode);
var extractionResult = ExtractionsContext.ExtractRaw(
new TickHistoryMarketDepthExtractionRequest
{
Condition = new TickHistoryMarketDepthCondition
{
ReportDateRangeType = ReportDateRangeType.Range,
QueryStartDate = startDate, //new DateTimeOffset(2016, 07, 25, 20, 0, 0, TimeSpan.Zero),
QueryEndDate = lastDate, //new DateTimeOffset(2016, 08, 02, 19, 59, 59, TimeSpan.Zero),
ExtractBy = TickHistoryExtractByMode.Ric,
MessageTimeStampIn = TickHistoryTimeOptions.GmtUtc,
SortBy = TickHistorySort.SingleByRic,
View = TickHistoryMarketDepthViewOptions.LegacyLevel2,
DisplaySourceRIC = true
},
IdentifierList = new InstrumentIdentifierList
{
InstrumentIdentifiers = new[]
{
InstrumentIdentifier.Create(result.IdentifierType, result.Identifier)
},
ValidationOptions = new InstrumentValidationOptions
{
AllowHistoricalInstruments = true
}
},
});
string line;
var fileName = out_dir + "_" + result.Identifier + "_" + startDate.DateTime.ToString("dd.MM.yyyy") + "_" + lastDate.DateTime.ToString("dd.MM.yyyy") + "_RawLegacyMarketDepth.csv";
var sw = new StreamWriter(fileName, false);
var streamResponse = ExtractionsContext.GetReadStream(extractionResult);
using (GZipInputStream gzip = new GZipInputStream(streamResponse.Stream))
{
using (StreamReader reader = new StreamReader(gzip, Encoding.UTF8))
{
while ((line = reader.ReadLine()) != null)
{
sw.WriteLine(line);
}
}
}
sw.Close();
}
}
}
try
{
ExtractionsContext.DefaultRequestHeaders.Remove("x-direct-download");
}
catch (Exception)
{ }
Console.WriteLine("Press Enter to exit");
Console.ReadLine();
}
}
}
Best Answer
-
Hello @s61670,
If you submit the same request for two instruments of the same type, and one of them returns the data paints as expected, while the other one does not, we can safely assume, with a good degree of certainty, that the request you issue is correct, and the code that implements the request is valid.
Therefore, the question becomes a question on content, why certain content is not returned in result as expected. This forum is best suited for and most helpful with general API usage questions and discussions.
For a Refinitiv customer, the best approach to get a definitive answer on the specific content's availability from a Refinitv content expert, is to submit it directly, to Refinitiv Helpdesk Online -> Content, please include all the specifics on the content that you are requesting.
---
I would not recommend using HistoricalReferenceExtractionRequest on expanded chains, as automated programmatic extraction approach, I can think of several reasons:
1. HistoricalSearch is more appropriate, it would just let you know the interval when the instrument was valid, and that is the interval you can request the extraction for.
2. HistoricalReferenceExtractionRequest is the most in-depth, it is more intended to use for research, during design stage. It returns multiple changes and updates, some of which require in-depth understanding of the content to interpret correctly. There are exceptions as well, as some information can only be found in HistoricalReference.
3. In a few cases, I find that this info is not available. In these cases, the best way to clarify would be by directly contacting Refinitiv content experts.
4. This is an extraction request, rather then search, your id's extraction request quota is applied ( searches are not counted toward your quotas)
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 37 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 698 Datastream
- 1.5K DSS
- 633 Eikon COM
- 5.2K Eikon Data APIs
- 14 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 6 Trading API
- 2.9K Elektron
- 1.5K EMA
- 257 ETA
- 564 WebSocket API
- 40 FX Venues
- 16 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 283 Open PermID
- 47 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2.1K Refinitiv Data Platform
- 799 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 122 Open DACS
- 1.1K RFA
- 107 UPA
- 194 TREP Infrastructure
- 232 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 101 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛