Skip to content

Commit

Permalink
Add requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinovsky committed Jan 18, 2024
1 parent 9f2134d commit 3550d72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 1 addition & 7 deletions Engine/RealTime/LiveTradingRealTimeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ protected virtual IEnumerable<MarketHoursSegment> GetMarketHours(DateTime time,
}

var entry = MarketHoursDatabase.GetEntry(symbol.ID.Market, symbol, symbol.ID.SecurityType);
var securityExchangeHours = new SecurityExchangeHours(
entry.DataTimeZone,
entry.ExchangeHours.Holidays,
entry.ExchangeHours.MarketHours.ToDictionary(),
entry.ExchangeHours.EarlyCloses,
entry.ExchangeHours.LateOpens);
var hours = securityExchangeHours.GetMarketHours(time);
var hours = entry.ExchangeHours.GetMarketHours(time);

foreach (var segment in hours.Segments)
{
Expand Down
9 changes: 5 additions & 4 deletions Tests/Engine/RealTime/LiveTradingRealTimeHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ public void ThreadSafety()
[TestCaseSource(typeof(ExchangeHoursDataClass), nameof(ExchangeHoursDataClass.TestCases))]
public void RefreshesMarketHoursCorrectly(SecurityExchangeHours securityExchangeHours, MarketHoursSegment expectedSegment)
{
Security security;
var algorithm = new AlgorithmStub();
security = algorithm.AddEquity("SPY");
var security = algorithm.AddEquity("SPY");

var realTimeHandler = new TestLiveTradingRealTimeHandler();
realTimeHandler.Setup(algorithm,
Expand Down Expand Up @@ -145,7 +144,9 @@ public void ResetMarketHoursCorrectly()
Assert.IsTrue(orderTicket.Status == OrderStatus.Submitted);
broker.Scan();
Assert.IsTrue(orderTicket.Status != OrderStatus.Filled);

realTimeHandler.Exit();
broker.Dispose();
}

private class TestTimeLimitManager : IIsolatorLimitResultProvider
Expand Down Expand Up @@ -192,7 +193,7 @@ public void AssertMarketHours(Security security, DateTime time, MarketHoursSegme
var marketHours = security.Exchange.Hours.MarketHours[time.DayOfWeek];
var segment = marketHours.Segments.SingleOrDefault();

if (segment == null)
if (expectedSegment == null)
{
Assert.AreEqual(expectedSegment, segment);
}
Expand All @@ -212,7 +213,7 @@ public void AssertMarketHours(Security security, DateTime time, MarketHoursSegme
}
}

public class TestLiveTradingRealTimeHandlerReset : LiveTradingRealTimeHandler
private class TestLiveTradingRealTimeHandlerReset : LiveTradingRealTimeHandler
{
private static AutoResetEvent OnSecurityUpdated = new AutoResetEvent(false);

Expand Down

0 comments on commit 3550d72

Please sign in to comment.