Skip to content

Commit

Permalink
Filter extended market hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero committed Jul 19, 2024
1 parent 1ac8f3c commit 9dd02b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions QuantConnect.AlpacaBrokerage/AlpacaBrokerage.HistoryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

using System;
using System.Linq;
using Alpaca.Markets;
using QuantConnect.Util;
using QuantConnect.Data;
Expand Down Expand Up @@ -75,17 +76,26 @@ public override IEnumerable<BaseData> GetHistory(HistoryRequest request)

var brokerageSymbol = _symbolMapper.GetBrokerageSymbol(request.Symbol);

IEnumerable<BaseData> data;
switch (request.Symbol.SecurityType)
{
case SecurityType.Equity:
return GetEquityHistory(request, brokerageSymbol);
data = GetEquityHistory(request, brokerageSymbol);
break;
case SecurityType.Option:
return GetOptionHistory(request, brokerageSymbol);
data = GetOptionHistory(request, brokerageSymbol);
break;
case SecurityType.Crypto:
return GetCryptoHistory(request, brokerageSymbol);
data = GetCryptoHistory(request, brokerageSymbol);
break;
default:
return null;
}
if (data != null)
{
return data.Where(x => request.ExchangeHours.IsOpen(x.Time, x.EndTime, request.IncludeExtendedMarketHours));
}
return data;
}

/// <summary>
Expand Down

0 comments on commit 9dd02b2

Please sign in to comment.