public void TestAddNegativeSeconds() { timestamp = new TimeStamp(); timestamp.AddSeconds(-3); Assert.Equal(0, timestamp.Seconds); Assert.Equal(0, timestamp.Minutes); Assert.Equal(0, timestamp.Hours); }
public void TestAddSeconds() { timestamp = new TimeStamp(); timestamp.AddSeconds(10); Assert.Equal(10, timestamp.Seconds); Assert.Equal(0, timestamp.Minutes); Assert.Equal(0, timestamp.Hours); timestamp.AddSeconds(100); Assert.Equal(50, timestamp.Seconds); Assert.Equal(1, timestamp.Minutes); Assert.Equal(0, timestamp.Hours); timestamp.AddSeconds(60 * 60 + 60 + 1); Assert.Equal(51, timestamp.Seconds); Assert.Equal(2, timestamp.Minutes); Assert.Equal(1, timestamp.Hours); timestamp.AddSeconds(60 * 60 * 22); Assert.Equal(51, timestamp.Seconds); Assert.Equal(2, timestamp.Minutes); Assert.Equal(23, timestamp.Hours); }
private Yield TimerTask() { if (isDisposed) { return(Yield.NoWork.Repeat); } TimeStamp currentTime = TimeStamp.UtcNow; currentTime.AddSeconds(timeSeconds); taskTimer.Start(currentTime); if (debug) { log.Debug("Created timer. (Default startTime: " + taskTimer.StartTime + ")"); } return(Invoke()); }
/// <inheritdoc/> public void SetTime(TimeStamp utcTime) { binary.UtcTime = utcTime.Internal; if (dst == null) { if (binary.Symbol == 0) { throw new ApplicationException("Please call SetSymbol() prior to SetTime() method."); } SymbolInfo symbol = Factory.Symbol.LookupSymbol(binary.Symbol); dst = new DaylightSavings(symbol); } var offset = dst.GetOffset(utcTime); localTime = new TimeStamp(binary.UtcTime); localTime.AddSeconds(offset); }
public void Start(EventItem eventItem) { this.ClientAgent = eventItem.Agent; log.Info(providerName + " Startup"); TimeStamp currentTime = TimeStamp.UtcNow; currentTime.AddSeconds(timeSeconds); taskTimer.Start(currentTime); if (debug) { log.Debug("Created timer. (Default startTime: " + taskTimer.StartTime + ")"); } CreateNewSocket(); retryTimeout = Factory.Parallel.TickCount + retryDelay * 1000; log.Info("Connection will timeout and retry in " + retryDelay + " seconds."); isStarted = true; }
private void writeATick(double insertPrice, int volume) { if (tsBits[1].Length <= 3) { tickTime = new TimeStamp(tsBits[0] + " " + tsBits[1] + ":00"); } else { tickTime = new TimeStamp(tsBits[0] + " " + tsBits[1]); } utcTime = tickTime; utcTime.AddSeconds(-GetUtcOffset(tickTime)); double price = insertPrice; tickIO.SetTime(utcTime); if (volume >= 1) { tickIO.SetTrade(price, volume); } else { // tickIO.SetQuote(price, price); tickIO.SetTrade(price, volume); } if (tickWriter == null) { tickWriter = Factory.TickUtil.TickWriter(true); tickWriter.KeepFileOpen = true; string folder = "DataCache"; tickWriter.Initialize(folder, symbol.Symbol); } // Console.WriteLine(tickIO); tickWriter.Add(tickIO); countTicksOut++; }
/// <inheritdoc/> public void SetTime(TimeStamp utcTime) { binary.UtcTime = utcTime.Internal; if (utcTime.Internal >= nextUtcOffsetUpdate.Internal) { if (timeZone == null) { if (binary.Symbol == 0) { throw new ApplicationException("Please call SetSymbol() prior to SetTime() method."); } SymbolInfo symbol = Factory.Symbol.LookupSymbol(binary.Symbol); timeZone = new SymbolTimeZone(symbol); } utcOffset = timeZone.UtcOffset(UtcTime); nextUtcOffsetUpdate = utcTime; int dayOfWeek = nextUtcOffsetUpdate.GetDayOfWeek(); nextUtcOffsetUpdate.AddDays(7 - dayOfWeek); nextUtcOffsetUpdate.SetDate(nextUtcOffsetUpdate.Year, nextUtcOffsetUpdate.Month, nextUtcOffsetUpdate.Day); } localTime = new TimeStamp(binary.UtcTime); localTime.AddSeconds(utcOffset); }
private void IncreaseHeartbeat(TimeStamp currentTime) { heartbeatTimer = currentTime; heartbeatTimer.AddSeconds(30); }
public void AddSeconds(int seconds) { TimeStamp = TimeStamp.AddSeconds(seconds); YPoint = (TimeStamp - StartOfCycle).TotalSeconds; SetDataPointProperties(); }
private Yield HeartbeatTimerEvent() { if (isDisposed) { return(Yield.Terminate); } var currentTime = TimeStamp.UtcNow; if (verbose) { log.Verbose("Heartbeat occurred at " + currentTime); } if (isConnectionLost) { if (debug) { log.Debug("FIX connection was lost, closing FIX socket."); } CloseFIXSocket(); return(Yield.NoWork.Repeat); } if (fixState != ServerState.Startup) { var now = TimeStamp.UtcNow; if (now > isHeartbeatPending) { log.Error("HeartBeat response was never received.\n" + Factory.Parallel.GetStats()); log.Error("All stack traces follow..."); Factory.Parallel.StackTrace(); throw new ApplicationException("HeartBeat response was never received."); } isHeartbeatPending = TimeStamp.UtcNow; isHeartbeatPending.AddSeconds(heartbeatResponseTimeoutSeconds); if (SyncTicks.Frozen) { frozenHeartbeatCounter++; if (frozenHeartbeatCounter > 3) { if (debug) { log.Debug("More than 3 heart beats sent after frozen. Ending heartbeats."); } } else { OnHeartbeat(); } } else { OnHeartbeat(); } } else { if (debug) { log.Debug("Skipping heartbeat because fix state: " + fixState); } } IncreaseHeartbeat(); return(Yield.DidWork.Repeat); }