Skip to content

Commit

Permalink
Fixes and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Nov 19, 2024
1 parent 247b0c0 commit 10b8723
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Engine/DataFeeds/Enumerators/FillForwardEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ protected virtual bool RequiresFillForwardData(TimeSpan fillForwardResolution, B
if (_useStrictEndTime)
{
// TODO: what about extended market hours
// Not using Exchange.Hours.RegularMarketDuration so we can handle things like early closes.
expectedPeriod = Exchange.Hours.GetMarketHours(potentialBarEndTimeInExchangeTZ).MarketDuration;
// Market could be closed at end time, so let's try with the start time to get the actual market duration.
if (expectedPeriod == TimeSpan.Zero)
{
expectedPeriod = Exchange.Hours.GetMarketHours(nextFillForwardBarStartTime).MarketDuration;
Expand Down
3 changes: 2 additions & 1 deletion Engine/DataFeeds/SubscriptionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public static SubscriptionData Create(bool dailyStrictEndTimeEnabled, Subscripti
// during warmup, data might be emitted with a different span based on the warmup resolution, so let's get the actual bar span here
var barSpan = data.EndTime - data.Time;
// rounding down does not make sense for daily increments using strict end times
if (!LeanData.UseStrictEndTime(dailyStrictEndTimeEnabled, configuration.Symbol, barSpan, exchangeHours))
if (!LeanData.UseDailyStrictEndTimes(configuration.Type) ||
!LeanData.UseStrictEndTime(dailyStrictEndTimeEnabled, configuration.Symbol, barSpan, exchangeHours))
{
// Let's round down for any data source that implements a time delta between
// the start of the data and end of the data (usually used with Bars).
Expand Down
17 changes: 5 additions & 12 deletions Tests/Algorithm/AlgorithmHistoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3343,10 +3343,10 @@ public override BaseData Reader(SubscriptionDataConfig config, string line, Date
}

/// <summary>
/// Represents custom data with an optional sorting functionality. The <see cref="ExampleCustomDataWithSort"/> class
/// Represents custom data with an optional sorting functionality. The <see cref="ExampleCustomDataWithSort"/> class
/// allows you to specify a static property <seealso cref="CustomDataKey"/>, which defines the name of the custom data source.
/// Sorting can be enabled or disabled by setting the <seealso cref="Sort"/> property.
/// This class overrides <see cref="GetSource(SubscriptionDataConfig, DateTime, bool)"/> to initialize the
/// This class overrides <see cref="GetSource(SubscriptionDataConfig, DateTime, bool)"/> to initialize the
/// <seealso cref="SubscriptionDataSource.Sort"/> property based on the value of <see cref="Sort"/>.
/// </summary>
public class ExampleCustomDataWithSort : BaseData
Expand All @@ -3367,7 +3367,7 @@ public class ExampleCustomDataWithSort : BaseData
public decimal Close { get; set; }

/// <summary>
/// Returns the data source for the subscription. It uses the custom data key and sets sorting based on the
/// Returns the data source for the subscription. It uses the custom data key and sets sorting based on the
/// <see cref="Sort"/> property.
/// </summary>
/// <param name="config">Subscription configuration.</param>
Expand Down Expand Up @@ -3573,15 +3573,8 @@ private static void AssertHistoryResultResolution(IEnumerable<BaseData> history,
if (resolution == Resolution.Daily)
{
var exchange = mhdb.GetExchangeHours(data.Symbol.ID.Market, data.Symbol, data.Symbol.SecurityType);
if (!data.IsFillForward)
{
var marketHours = exchange.GetMarketHours(data.EndTime);
expectedTimeSpan = marketHours.MarketDuration;
}
else
{
expectedTimeSpan = exchange.RegularMarketDuration;
}
var marketHours = exchange.GetMarketHours(data.EndTime);
expectedTimeSpan = marketHours.MarketDuration;
}
return data.EndTime - data.Time == expectedTimeSpan;
}));
Expand Down

0 comments on commit 10b8723

Please sign in to comment.