private async Task GetDate() { try { DateStamp _stamp = new DateStamp(); Acr.UserDialogs.UserDialogs.Instance.ShowLoading("Get date"); var result = await ServerPath.Path .AppendPathSegment("/api/calendar/jobitem/" + TechnicianModule.TenantName + "/" + Issue.IssueId) .WithOAuthBearerToken(TechnicianModule.AccessToken) .GetJsonAsync <DateStamp>(); if (result != null) { _stamp.DateStampId = result.DateStampId; _stamp.Description = result.Description; _stamp.EndDate = result.EndDate; _stamp.StartDate = result.StartDate; _stamp.Title = result.Title; DateStamp = _stamp; Acr.UserDialogs.UserDialogs.Instance.HideLoading(); } } catch (FlurlHttpException ex) { Acr.UserDialogs.UserDialogs.Instance.HideLoading(); IsVisible = true; await Acr.UserDialogs.UserDialogs.Instance.AlertAsync("No date found."); //return null; } }
public SettlementSession(IInstrument instrument, DateStamp sessionDate) { if (instrument is null) { throw new ArgumentNullException(nameof(instrument)); } if (instrument.SettlementTime.TimeOfDay.TotalHours <= 0) { throw new ArgumentException("Settlement time of day with zero or negative time is not supported."); } if (instrument.SettlementTime.TimeOfDay.TotalHours > 24) { throw new ArgumentException("Settlement time of day in early morning of following day is not yet supported."); } if (!instrument.IsTradingDay(sessionDate)) { throw new ArgumentException($"Unexpected sessionDate '{sessionDate}'. It should not be a valid trading day."); } Instrument = instrument; SessionDate = sessionDate; SessionEnd = new TimeStamp(SessionDate, instrument.SettlementTime.TimeOfDay, TimeZone); var sessionStartDate = Instrument.ThisOrPreviousTradingDay(SessionDate.AddDays(-1)); SessionStart = new TimeStamp(sessionStartDate, instrument.SettlementTime.TimeOfDay, TimeZone); }
public void ReadBinary(ESPReader reader) { Tag = reader.ReadTag(); Size = reader.ReadUInt32(); Flags = (RecordFlag)reader.ReadUInt32(); FormID = reader.Read <FormID>(); LastModified = new DateStamp(); LastModified.ReadBinary(reader); reader.ReadBytes(2); FormVersion = reader.ReadUInt16(); reader.ReadBytes(2); if (Flags.HasFlag(RecordFlag.Compressed)) { byte[] outBytes; compressionCorrupted = !TryDecompressData(reader, out outBytes); if (compressionCorrupted) { corruptedBytes = outBytes; } else { using (MemoryStream stream = new MemoryStream(outBytes)) using (ESPReader subReader = new ESPReader(stream, reader.Plugin)) ReadData(subReader, stream.Length); } } else { ReadData(reader, reader.BaseStream.Position + Size); } }
public void DateStampCompressor() { var days = new List <DateStamp>(); var day = new DateStamp(1, 1, 1); do { days.Add(day); day = day.AddMonths(1); } while (day.Year <= 5000); using (var ms = new MemoryStream()) { var writer = ms.AsIWriteBytes(); foreach (var x in days) { writer.WriteCompressedDateStamp(x); } ms.Seek(0, SeekOrigin.Begin); var reader = ms.AsIReadBytes(); var days2 = new List <DateStamp>(); for (var i = 0; i < days.Count; i++) { days2.Add(reader.ReadCompressedDateStamp()); } Assert.IsTrue(days.SequenceEqual(days2)); } }
public async Task Update_With_Datestamp(Type dataContextType) { // Arrange IDataContext dataContext = DataContextTestHelper.GetDataContext(dataContextType); // insert row DateStamp row = await dataContext.Create(new DateStamp() { Name = "Key", Value = "Value" }); // sleep so that insert date and update date will be different when update called Thread.Sleep(TimeSpan.FromMilliseconds(1000)); // Act DateTime updateDate = DateTime.Now; DateStamp updatedRow = await dataContext.Update <DateStamp>(new { row.Name, Value = "New Value" }); // Assert Assert.AreEqual(row.Name, updatedRow.Name); Assert.AreEqual("New Value", updatedRow.Value); Assert.AreEqual(0, (row.InsertDate - updatedRow.InsertDate).Seconds); Assert.AreNotEqual(row.InsertDate, updatedRow.UpdateDate); Assert.That(updatedRow.UpdateDate, Is.EqualTo(updateDate).Within(TimeSpan.FromSeconds(1))); }
public async Task Update_With_Datestamp() { using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName)) { // Arrange DateStamp row = await connection.Create(new DateStamp() { Name = "Key", Value = "Value" }) .ConfigureAwait(false); // sleep so that insert date and update date will be different when update called Thread.Sleep(TimeSpan.FromMilliseconds(100)); // Act DateTime updateDate = DateTime.Now; DateStamp updatedRow = await connection.Update <DateStamp>(new { row.Name, Value = "New Value" }) .ConfigureAwait(false); // Assert Assert.AreEqual(row.Name, updatedRow.Name); Assert.AreEqual("New Value", updatedRow.Value); Assert.AreEqual(0, (row.InsertDate - updatedRow.InsertDate).Seconds); Assert.AreNotEqual(row.InsertDate, updatedRow.UpdateDate); Assert.That(updatedRow.UpdateDate, Is.EqualTo(updateDate).Within(TimeSpan.FromSeconds(1))); } }
/// <param name="approximateFirstMoveUntilDate"> /// Provide the approximate date of the first <see cref="MoveUntil(TimeStamp)"/> method call /// so that we can initialize the iterator so that the first <see cref="MoveUntil(TimeStamp)"/> call will /// result in the conditions specified in the commenting for <see cref="ISessionIterator"/>. /// </param> public SettlementSessionIterator(IInstrument instrument, DateStamp approximateFirstMoveUntilDate) { TimeZone = instrument.SettlementTime.TimeZone; Current = new SettlementSession(instrument, instrument.ThisOrPreviousTradingDay(approximateFirstMoveUntilDate.AddDays(-10))); Previous = Current.GetPrevious(); Next = Current.GetNext(); MoveUntil(Current.SessionStart.AddTicks(1)); }
public override void MakeSchemaCompliant() { base.MakeSchemaCompliant(); foreach (CI_responsibleParty_PropertyType _c in Contact) { _c.MakeSchemaCompliant(); } DateStamp.MakeSchemaCompliant(); foreach (MD_identification_PropertyType _c in IdentificationInfo) { _c.MakeSchemaCompliant(); } }
public override int GetHashCode() { int hash = 1; if (Code.Length != 0) { hash ^= Code.GetHashCode(); } if (Open != 0F) { hash ^= Open.GetHashCode(); } if (High != 0F) { hash ^= High.GetHashCode(); } if (Low != 0F) { hash ^= Low.GetHashCode(); } if (Close != 0F) { hash ^= Close.GetHashCode(); } if (Volume != 0F) { hash ^= Volume.GetHashCode(); } if (Date.Length != 0) { hash ^= Date.GetHashCode(); } if (Amount != 0F) { hash ^= Amount.GetHashCode(); } if (DateStamp.Length != 0) { hash ^= DateStamp.GetHashCode(); } if (Preclose != 0F) { hash ^= Preclose.GetHashCode(); } if (Adj != 0F) { hash ^= Adj.GetHashCode(); } return(hash); }
/// <param name="approximateFirstMoveUntilDate"> /// Provide the approximate date of the first <see /// cref="MoveUntil(TimeStamp)"/> method call so that we can initialize the /// iterator so that the first <see cref="MoveUntil(TimeStamp)"/> call will /// result in the conditions specified in the commenting for <see /// cref="ISessionIterator"/>. /// </param> public TradingSessionIterator(TradingSessions tradingHours, DateStamp approximateFirstMoveUntilDate) { _tradingHours = tradingHours; var at = new TimeStamp(approximateFirstMoveUntilDate.AddDays(-12).DateTime.Ticks); Current = _tradingHours.GetActualSessionAt(at); Next = _tradingHours.GetActualSessionAt(Current.SessionEnd.AddTicks(1)); MoveNext(); MoveNext(); CurrentTime = Current.SessionStart.AddTicks(1); IsInSession = true; IsFirstTickOfSession = true; IsNewSession = true; }
static void TestDataStamp() { Console.WriteLine("TesttDataStamp-TestStart"); string testStr = "11/07/1995,17:38:26.663700"; var row = new DateStamp(testStr); Console.Write(row.RowToString()); testStr = "12/02/2017,11:56:01.234789";; row.StringToRow(testStr); Console.Write(row.RowToString()); Console.WriteLine("TesttDataStamp-TestEnd"); while (true) { try { Console.WriteLine(); Console.Write("Input:"); var instr = Console.ReadLine(); if (instr == "q") { return; } else { row.StringToRow(instr); Console.WriteLine("DayOfMonth:" + row.DayOfMonth); Console.WriteLine("Month:" + row.Month); Console.WriteLine("Year:" + row.Year); Console.WriteLine("Hour:" + row.Hour); Console.WriteLine("Minute:" + row.Minute); Console.WriteLine("Second:" + row.Second); Console.WriteLine("TestEnd"); Console.WriteLine(); } } catch (Exception ex) { Console.WriteLine("Exception:"); Console.WriteLine(ex.Message); } } }
public async Task Insert_With_Datestamp(Type dataContextType) { // Arrange using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType); // Act DateTime now = DateTime.Now; DateStamp row = await dataContext.Create(new DateStamp() { Name = "Key", Value = "Value" }); // Assert Assert.AreEqual("Key", row.Name); Assert.AreEqual("Value", row.Value); Assert.AreEqual(row.InsertDate, row.UpdateDate); Assert.That(row.InsertDate, Is.EqualTo(now).Within(TimeSpan.FromSeconds(1))); }
public async Task Insert_With_Datestamp() { using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName)) { // Act DateTime now = DateTime.Now; DateStamp row = await connection.Create(new DateStamp() { Name = "Key", Value = "Value" }) .ConfigureAwait(false); // Assert Assert.AreEqual("Key", row.Name); Assert.AreEqual("Value", row.Value); Assert.AreEqual(row.InsertDate, row.UpdateDate); Assert.That(row.InsertDate, Is.EqualTo(now).Within(TimeSpan.FromSeconds(1))); } }
public static DateStamp AddMarketDays(this IInstrument instrument, DateStamp date, int numMarketDays) { if (numMarketDays == 0) { return(date); } for (var i = 1; i <= numMarketDays; i++) { do { date = date.AddDays(1); } while (!instrument.IsMarketDay(date)); } for (var i = -1; i >= numMarketDays; i--) { do { date = date.AddDays(-1); } while (!instrument.IsMarketDay(date)); } return(date); }
public void ReadBinary(ESPReader reader, MemoryMappedFile source) { Tag = reader.ReadTag(); Size = reader.ReadUInt32() - 24; ReadTypeData(reader); GroupType thisType = (GroupType)reader.ReadUInt32(); Debug.Assert(thisType == type); LastModified = new DateStamp(); LastModified.ReadBinary(reader); Unknown = reader.ReadBytes(6); long offset = reader.BaseStream.Position; while (reader.BaseStream.Position < offset + Size) { if (reader.PeekTag() == "GRUP") { Group newGroup = Group.CreateGroup(reader); if (GroupAdded != null) { GroupAdded(newGroup); } newGroup.GroupAdded += (g) => { AllSubgroups.Add(g); if (GroupAdded != null) { GroupAdded(g); } }; newGroup.RecordViewAdded += (r) => { AllRecordViews.Add(r); if (RecordViewAdded != null) { RecordViewAdded(r); } }; Children.Add(newGroup); AllSubgroups.Add(newGroup); newGroup.ReadBinary(reader, source); } else { RecordView newView = new RecordView(reader, source); ChildRecordViews.Add(newView); AllRecordViews.Add(newView); if (RecordViewAdded != null) { RecordViewAdded(newView); } } } }
public static IFutureContract GetContractAtDate(this IFutureMaster futureMaster, DateStamp sessionDate) { var deliveryMonth = futureMaster.Rollovers.Where(x => sessionDate >= x.RolloverDate).OrderByDescending(x => x.RolloverDate).First().DeliveryMonth; // Can also use this, since the code exists in the Apex.Market library, but I thought it's probably easier for the reader to see what's going on if we // manually write out the symbol calculation instead. //var ntSymbol = MarketSymbol.GetFutureContractSymbol(Market.SymbolProviderType.NinjaTrader8, futureMaster.NinjaTraderSymbol(), deliveryMonth.Month, deliveryMonth.Year); var ntSymbol = $"{futureMaster.NinjaTraderSymbol()} {deliveryMonth.DateTime:MM-yy}"; return(Services.InstrumentProvider.GetFutureContract(Market.SymbolProviderType.NinjaTrader8, ntSymbol)); }
public static bool IsMarketDay(this IInstrument instrument, DateStamp date) { return(!(date.IsWeekend() || instrument.HolidayDates().Contains(date))); }
public static DateStamp SkipWeekendAndHolidaysMovingBackward(this IInstrument instrument, DateStamp date) { return(date.SkipWeekendAndTheseDatesMovingBackward(instrument.HolidayDates())); }
public List <Entry> parseFile(string file) { List <Entry> result = new List <Entry>(); if (!File.Exists(file)) { log.Error(String.Format("File \"{0}\" does not exist.", file)); } else { log.InfoFormat("Parsing file : {0}", file); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.Load(file); if (htmlDoc.DocumentNode != null) { HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body"); foreach (HtmlParseError error in htmlDoc.ParseErrors) { log.Error(String.Format("Error \nCode: {0}\nLine: {1}\nPosition : {2}\nReason : {3}\nSource Text : {4} ", error.Code, error.Line, error.LinePosition, error.Reason, error.SourceText)); } if (htmlDoc.ParseErrors.Count() == 0) { if (bodyNode != null) { int year = extractYear(bodyNode); HtmlNodeCollection monthsNodeCollection = bodyNode.SelectNodes("//h3"); foreach (HtmlNode monthNode in monthsNodeCollection) { Month month = extractMonth(monthNode); HtmlNodeCollection entryNodeCollection = monthNode.SelectNodes("following-sibling::div[1]/ul/li/h2"); // If entries exist for the month, resume ... if (entryNodeCollection != null) { foreach (HtmlNode entryNode in entryNodeCollection) { DateTime entryDate = extractEntryDate(entryNode); String entryTitle = extractEntryTitle(entryNode); DateStamp entryKey = new DateStamp() { Year = year, Month = month, Day = entryDate.Day }; String entryText = extractEntryText(entryNode); List <Image> entryImages = extractEntryImages(entryNode); result.Add( new Entry() { Key = entryKey, Title = entryTitle, Text = entryText, Images = entryImages }); } } else { log.Error(String.Format("Could not find any entries for month. Html: {0}", monthNode.InnerHtml)); } } } } } } return(result); }
public static void WriteCompressedDateStamp(this IWriteBytes stream, DateStamp value) { stream.WriteCompressedUInt((uint)((value.Year * 12 + value.Month - 1) * 100 + value.Day)); }
private void UpdateDate(DateStamp obj) { DateStamp = obj; }