Lean
$LEAN_TAG$
LiveFutureChainProvider.cs
1
/*
2
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
using
System;
17
using
System.Linq;
18
using
QuantConnect
.
Logging
;
19
using
QuantConnect
.
Interfaces
;
20
using
System.Collections.Generic;
21
22
namespace
QuantConnect.Lean.Engine.DataFeeds
23
{
24
/// <summary>
25
/// An implementation of <see cref="IFutureChainProvider"/> that fetches the list of contracts
26
/// from an external source
27
/// </summary>
28
public
class
LiveFutureChainProvider
:
BacktestingFutureChainProvider
29
{
30
/// <summary>
31
/// Gets the list of future contracts for a given underlying symbol
32
/// </summary>
33
/// <param name="symbol">The underlying symbol</param>
34
/// <param name="date">The date for which to request the future chain (only used in backtesting)</param>
35
/// <returns>The list of future contracts</returns>
36
public
override
IEnumerable<Symbol>
GetFutureContractList
(
Symbol
symbol, DateTime date)
37
{
38
var result = Enumerable.Empty<
Symbol
>();
39
try
40
{
41
result = base.GetFutureContractList(symbol, date);
42
}
43
catch
(Exception ex)
44
{
45
// this shouldn't happen but just in case let's log it
46
Log
.
Error
(ex);
47
}
48
49
bool
yielded =
false
;
50
foreach
(var symbols
in
result)
51
{
52
yielded =
true
;
53
yield
return
symbols;
54
}
55
56
if
(!yielded)
57
{
58
throw
new
NotImplementedException(
"LiveFutureChainProvider.GetFutureContractList() has not been implemented yet."
);
59
}
60
}
61
}
62
}
Engine
DataFeeds
LiveFutureChainProvider.cs
Generated by
1.8.17