private void fillServerTime() { lock (lockObj) { lastServerTime = WebServiceUtil.Default.GetServerTime(); lastDetectedZone = tzProvider.GetSystemDefault(); if (lastServerTime != null) { lastServerTime = lastServerTime.Value.WithZone(lastDetectedZone); } else { lastServerTime = new ZonedDateTime(clock.GetCurrentInstant(), lastDetectedZone); } measureDifference(); if (timeSinceLastServerMeasurement == null) { timeSinceLastServerMeasurement = Stopwatch.StartNew(); } else { timeSinceLastServerMeasurement.Restart(); } } }
/// <inheritdoc /> public QuoteTick[] GetTicks(Symbol symbol, ZonedDateTime?fromDateTime = null, ZonedDateTime?toDateTime = null, long?limit = null) { return(this.quoteTickDatabase.TryGetValue(symbol, out var tickList) ? tickList.ToArray() : new QuoteTick[] {}); }
/// <summary> /// Initializes a new instance of the <see cref="Order" /> class. /// </summary> /// <param name="orderId">The order identifier.</param> /// <param name="symbol">The order symbol.</param> /// <param name="side">The order side.</param> /// <param name="type">The order type.</param> /// <param name="quantity">The order quantity.</param> /// <param name="price">The order price (optional).</param> /// <param name="timeInForce">The order time in force.</param> /// <param name="expireTime">The order expire time (optional).</param> /// <param name="timestamp">The order timestamp.</param> /// <param name="initId">The order initialization event identifier.</param> /// <returns>A new order.</returns> public static Order Create( OrderId orderId, Symbol symbol, OrderSide side, OrderType type, Quantity quantity, Price?price, TimeInForce timeInForce, ZonedDateTime?expireTime, ZonedDateTime timestamp, Guid initId) { Debug.NotDefault(side, nameof(side)); Debug.NotDefault(timestamp, nameof(timestamp)); var initial = new OrderInitialized( orderId, symbol, side, type, quantity, price, timeInForce, expireTime, initId, timestamp); return(new Order(initial)); }
/// <inheritdoc /> public byte[][] ReadTickData(Symbol symbol, ZonedDateTime?fromDateTime = null, ZonedDateTime?toDateTime = null, long?limit = null) { return(this.quoteTickDatabase.TryGetValue(symbol, out var tickList) ? this.quoteSerializer.Serialize(tickList.ToArray()) : new byte[][] {}); }
public void ItShouldConvertFromNull() { var entry = converter.ToEntry(null); ZonedDateTime?val = (ZonedDateTime?)converter.FromEntry(entry); Assert.False(val.HasValue); }
public BarDataFrame GetBars( BarType barType, ZonedDateTime?fromDateTime, ZonedDateTime?toDateTime, long?limit = 0) { return(new BarDataFrame(barType, this.barsDatabase[barType].ToArray())); }
public void WinGame(UserId currentUser, ZonedDateTime finishedAt) { ValidateCanDoMove(currentUser); FinishedAt = finishedAt; Victor = Turn !.Player; Turn = null; }
ZonedDateTime ValueOrNow(ZonedDateTime?reference) { if (reference != null) { return(reference.Value); } return(Now()); }
public byte[][] ReadBarData( BarType barType, ZonedDateTime?fromDateTime, ZonedDateTime?toDateTime, long?limit = 0) { return(this.barsDatabase.TryGetValue(barType, out var barList) ? this.barSerializer.Serialize(barList.ToArray()) : new byte[][] {}); }
/// <summary> /// Get a date in the past between <paramref name="reference"/> and years past that date. /// </summary> /// <param name="daysToGoBack">Days to go back from <paramref name="reference"/>. Default is 100.</param> /// <param name="reference">The date to start calculations. Default is SystemClock.Instance.GetCurrentInstant().</param> public ZonedDateTime Past(int daysToGoBack = 100, ZonedDateTime?reference = null) { var max = ValueOrNow(reference); var totalTicks = TimeSpan.TicksPerDay * daysToGoBack; var partTicks = Random.Long(0, totalTicks); return(max.PlusTicks(-partTicks)); }
public void NullableZonedDateTimeArrayTest() { ZonedDateTime?[] zoned = new ZonedDateTime?[] { null, null, null, null, null }; Assert.Equal(TestTools.Convert(zoned), zoned); }
public GameViewModel(Game game) { Id = game.Id; Players = game.Players.Select(p => new PlayerViewModel(p)).ToList().AsReadOnly(); Turn = game.Turn; Settings = game.Settings; Victor = game.Victor; CreatedAt = game.CreatedAt; StartedAt = game.StartedAt; FinishedAt = game.FinishedAt; }
public Game(GameId id, List <Player> players, Turn?turn, GameSettings settings, Player?victor, ZonedDateTime createdAt, ZonedDateTime?startedAt, ZonedDateTime?finishedAt) { Id = id; _players = players; Turn = turn; Settings = settings; Victor = victor; CreatedAt = createdAt; StartedAt = startedAt; FinishedAt = finishedAt; }
private ZonedDateTime?ValidateExpireTime(ZonedDateTime?expireTime) { if (expireTime.HasValue) { var expireTimeValue = expireTime.Value; Condition.EqualTo(this.TimeInForce, TimeInForce.GTD, nameof(this.TimeInForce)); Condition.True(expireTimeValue.IsGreaterThanOrEqualTo(this.Timestamp), nameof(expireTime)); } else { Condition.NotEqualTo(this.TimeInForce, TimeInForce.GTD, nameof(this.TimeInForce)); } return(expireTime); }
/// <summary> /// Creates and returns a new limit order. /// </summary> /// <param name="orderId">The order identifier.</param> /// <param name="symbol">The order symbol.</param> /// <param name="side">The order side.</param> /// <param name="quantity">The order quantity.</param> /// <param name="price">The order price (optional).</param> /// <param name="timeInForce">The order time in force.</param> /// <param name="expireTime">The order expire time (optional).</param> /// <param name="timestamp">The order timestamp.</param> /// <param name="initEventId">The order initialization event GUID.</param> /// <returns>The limit order.</returns> public static Order Limit( OrderId orderId, Symbol symbol, OrderSide side, Quantity quantity, Price?price, TimeInForce timeInForce, ZonedDateTime?expireTime, ZonedDateTime timestamp, Guid initEventId) { return(Order.Create( orderId, symbol, side, OrderType.Limit, quantity, price, timeInForce, expireTime, timestamp, initEventId)); }
[TestMethod] // ReSharper disable once InconsistentNaming public void GetEnumerator_Iterating_DifferenceBetweenIterationsMatchesStepSize() { Duration length = RandomDuration(MinDuration, MaxDuration); ZonedDateTime start = RandomZonedDateTime(TestMinZonedDateTime, TestMaxZonedDateTime - length); ZonedDateTime end = start + length; // note that the number of steps is limited to 100 or fewer Duration step = Duration.FromTicks(length.Ticks / Random.Next(4, 100)); ZonedDateTimeRange zonedDateTimeRange = new ZonedDateTimeRange(start, end, step); ZonedDateTime?previous = null; foreach (ZonedDateTime d in zonedDateTimeRange) { if (previous.HasValue) { Assert.AreEqual( d.ToInstant() - previous.Value.ToInstant(), step, "Difference between iteration values should match the step value supplied"); } previous = d; } }
public GameBuilder WithFinishedAt(ZonedDateTime?finishedAt) { _finishedAt = finishedAt; return(this); }
/// <inheritdoc /> protected override bool TryDeserialize( string resultValue, [NotNullWhen(true)] out ZonedDateTime?runtimeValue) => ZonedDateTimePattern .CreateWithInvariantCulture(formatString, DateTimeZoneProviders.Tzdb) .TryParse(resultValue, out runtimeValue);
protected override bool TryDeserialize(string str, [NotNullWhen(true)] out ZonedDateTime?output) => ZonedDateTimePattern .CreateWithInvariantCulture(formatString, DateTimeZoneProviders.Tzdb) .TryParse(str, out output);
public RoleBuilder WithCreatedAt(ZonedDateTime createdAt) { _createdAt = createdAt; return(this); }
public void NullableZonedDateTimeTest() { ZonedDateTime?zoned = null; Assert.Equal(TestTools.Convert(zoned), zoned); }
public AuthUserBuilder WithCreatedAt(ZonedDateTime createdAt) { _createdAt = createdAt; return(this); }