Skip to content

Commit

Permalink
feat: generic example of GetHistory (#18)
Browse files Browse the repository at this point in the history
feat: several test cases where specific implementation should validate it
  • Loading branch information
Romazes authored Mar 1, 2024
1 parent 2146341 commit ddc3616
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ private static TestCaseData[] TestParameters
new TestCaseData(Symbols.BTCUSD, Resolution.Tick, TimeSpan.FromMinutes(1), TickType.Trade, typeof(Tick), false),
new TestCaseData(Symbols.BTCUSD, Resolution.Minute, TimeSpan.FromMinutes(10), TickType.Trade, typeof(TradeBar), false),
new TestCaseData(Symbols.BTCUSD, Resolution.Daily, TimeSpan.FromDays(10), TickType.Trade, typeof(TradeBar), false),

// invalid parameter, validate SecurityType more accurate
new TestCaseData(Symbols.SPY, Resolution.Hour, TimeSpan.FromHours(14), TickType.Quote, typeof(QuoteBar), true),

/// New Listed Symbol on Brokerage <see cref="Slice.SymbolChangedEvents"/>
new TestCaseData(Symbol.Create("SUSHIGBP", SecurityType.Crypto, Market.Coinbase), Resolution.Minute, TimeSpan.FromHours(2), TickType.Trade, typeof(TradeBar), false),

/// Symbol was delisted form Brokerage (can return history data or not) <see cref="Slice.Delistings"/>
new TestCaseData(Symbol.Create("SNTUSD", SecurityType.Crypto, Market.Coinbase), Resolution.Daily, TimeSpan.FromDays(14), TickType.Trade, typeof(TradeBar), true),
};
}
}
Expand Down Expand Up @@ -87,11 +96,11 @@ public void GetsHistory(Symbol symbol, Resolution resolution, TimeSpan period, T
Log.Debug($"{tick}");
}
}
else if(slice.QuoteBars.TryGetValue(symbol, out var quoteBar))
else if (slice.QuoteBars.TryGetValue(symbol, out var quoteBar))
{
Log.Debug($"{quoteBar}");
}
else if(slice.Bars.TryGetValue(symbol, out var tradeBar))
else if (slice.Bars.TryGetValue(symbol, out var tradeBar))
{
Log.Debug($"{tradeBar}");
}
Expand Down
20 changes: 18 additions & 2 deletions QuantConnect.TemplateBrokerage/TemplateBrokerage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public TemplateBrokerage()
}

/// <summary>
/// Creates a new instance
/// </summary>
/// Creates a new instance
/// </summary>
/// <param name="aggregator">consolidate ticks</param>
public TemplateBrokerage(IDataAggregator aggregator) : base("TemplateBrokerage")
{
Expand Down Expand Up @@ -241,5 +241,21 @@ private bool Unsubscribe(IEnumerable<Symbol> symbols)
{
throw new NotImplementedException();
}

/// <summary>
/// Gets the history for the requested symbols
/// <see cref="IBrokerage.GetHistory(Data.HistoryRequest)"/>
/// </summary>
/// <param name="request">The historical data request</param>
/// <returns>An enumerable of bars covering the span specified in the request</returns>
public override IEnumerable<BaseData> GetHistory(Data.HistoryRequest request)
{
if (!CanSubscribe(request.Symbol))
{
return null; // Should consistently return null instead of an empty enumerable
}

throw new NotImplementedException();
}
}
}

0 comments on commit ddc3616

Please sign in to comment.