diff --git a/Algorithm.CSharp/AddFutureContractWithContinuousRegressionAlgorithm.cs b/Algorithm.CSharp/AddFutureContractWithContinuousRegressionAlgorithm.cs index 5439d92d7696..1f5328a7a998 100644 --- a/Algorithm.CSharp/AddFutureContractWithContinuousRegressionAlgorithm.cs +++ b/Algorithm.CSharp/AddFutureContractWithContinuousRegressionAlgorithm.cs @@ -49,7 +49,7 @@ public override void Initialize() contractDepthOffset: 0 ); - _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First().Symbol); + _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First()); } /// diff --git a/Algorithm.CSharp/AutomaticIndicatorWarmupDataTypeRegressionAlgorithm.cs b/Algorithm.CSharp/AutomaticIndicatorWarmupDataTypeRegressionAlgorithm.cs index 514ec3b2de77..affb1ab04716 100644 --- a/Algorithm.CSharp/AutomaticIndicatorWarmupDataTypeRegressionAlgorithm.cs +++ b/Algorithm.CSharp/AutomaticIndicatorWarmupDataTypeRegressionAlgorithm.cs @@ -38,7 +38,7 @@ public override void Initialize() SetEndDate(2013, 10, 10); var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME); - _symbol = FuturesChain(SP500).First().Symbol; + _symbol = FuturesChain(SP500).First(); // Test case: custom IndicatorBase indicator using Future unsubscribed symbol var indicator1 = new CustomIndicator(); diff --git a/Algorithm.CSharp/ConsolidateRegressionAlgorithm.cs b/Algorithm.CSharp/ConsolidateRegressionAlgorithm.cs index 501158441842..24b20c03d5e9 100644 --- a/Algorithm.CSharp/ConsolidateRegressionAlgorithm.cs +++ b/Algorithm.CSharp/ConsolidateRegressionAlgorithm.cs @@ -47,7 +47,7 @@ public override void Initialize() SetEndDate(2020, 01, 20); var SP500 = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME); - var symbol = FuturesChain(SP500).First().Symbol; + var symbol = FuturesChain(SP500).First(); _future = AddFutureContract(symbol); var tradableDatesCount = QuantConnect.Time.EachTradeableDayInTimeZone(_future.Exchange.Hours, diff --git a/Algorithm.CSharp/ContinuousFutureImmediateUniverseSelectionRegressionAlgorithm.cs b/Algorithm.CSharp/ContinuousFutureImmediateUniverseSelectionRegressionAlgorithm.cs index ea698f77f51a..b406cc41dd58 100644 --- a/Algorithm.CSharp/ContinuousFutureImmediateUniverseSelectionRegressionAlgorithm.cs +++ b/Algorithm.CSharp/ContinuousFutureImmediateUniverseSelectionRegressionAlgorithm.cs @@ -78,7 +78,7 @@ public override void Initialize() } - return universe.Select(x => x.Symbol); + return universe; }); _milk.SetFilter(universe => @@ -94,7 +94,7 @@ public override void Initialize() } } - return universe.Select(x => x.Symbol); + return universe; }); } diff --git a/Algorithm.CSharp/FuturesChainFullDataRegressionAlgorithm.cs b/Algorithm.CSharp/FuturesChainFullDataRegressionAlgorithm.cs index 8115d146d2c8..ef99599955e6 100644 --- a/Algorithm.CSharp/FuturesChainFullDataRegressionAlgorithm.cs +++ b/Algorithm.CSharp/FuturesChainFullDataRegressionAlgorithm.cs @@ -44,8 +44,7 @@ public override void Initialize() // Get the contract with the latest expiration date, and lowest price .OrderByDescending(x => x.Expiry) .ThenBy(x => x.LastPrice) - .First() - .Symbol; + .First(); AddFutureContract(_futureContract); } diff --git a/Algorithm.CSharp/FuturesChainsMultipleFullDataRegressionAlgorithm.cs b/Algorithm.CSharp/FuturesChainsMultipleFullDataRegressionAlgorithm.cs index b7040d428c5a..d670aa4b19a8 100644 --- a/Algorithm.CSharp/FuturesChainsMultipleFullDataRegressionAlgorithm.cs +++ b/Algorithm.CSharp/FuturesChainsMultipleFullDataRegressionAlgorithm.cs @@ -61,8 +61,7 @@ private Symbol GetContract(FuturesChains chains, Symbol canonical) // Get the contract with the latest expiration date, and lowest price .OrderByDescending(x => x.Expiry) .ThenBy(x => x.LastPrice) - .First() - .Symbol; + .First(); } public override void OnData(Slice slice) diff --git a/Algorithm.CSharp/FuturesDailySettlementLongRegressionAlgorithm.cs b/Algorithm.CSharp/FuturesDailySettlementLongRegressionAlgorithm.cs index 5b4c460e547d..dcd12dbb7f34 100644 --- a/Algorithm.CSharp/FuturesDailySettlementLongRegressionAlgorithm.cs +++ b/Algorithm.CSharp/FuturesDailySettlementLongRegressionAlgorithm.cs @@ -62,7 +62,7 @@ public override void Initialize() var future = QuantConnect.Symbol.Create(Futures.Indices.SP500EMini, SecurityType.Future, Market.CME); - _contractSymbol = FuturesChain(future).OrderBy(x => x.ID.Date).FirstOrDefault().Symbol; + _contractSymbol = FuturesChain(future).OrderBy(x => x.ID.Date).First(); _future = AddFutureContract(_contractSymbol); _future.Holdings.SetHoldings(1600, 1 * OrderSide); diff --git a/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs b/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs index 353176526303..258790f106ec 100644 --- a/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/LimitOrdersAreFilledAfterHoursForFuturesRegressionAlgorithm.cs @@ -48,7 +48,7 @@ public override void Initialize() contractDepthOffset: 0, extendedMarketHours: true ); - _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First().Symbol, extendedMarketHours: true); + _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First(), extendedMarketHours: true); } public override void OnWarmupFinished() diff --git a/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs b/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs index 05dfe8fd0829..e12df5f1027d 100644 --- a/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs +++ b/Algorithm.CSharp/MarketOrdersAreSupportedOnExtendedHoursForFuturesRegressionAlgorithm.cs @@ -43,7 +43,7 @@ public override void Initialize() contractDepthOffset: 0, extendedMarketHours: true ); - _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First().Symbol, + _futureContract = AddFutureContract(FuturesChain(_continuousContract.Symbol).First(), extendedMarketHours: true); } public override void OnData(Slice slice) diff --git a/Algorithm.CSharp/StatisticsResultsAlgorithm.cs b/Algorithm.CSharp/StatisticsResultsAlgorithm.cs index 1c312c378fd8..6b89219fe1c2 100644 --- a/Algorithm.CSharp/StatisticsResultsAlgorithm.cs +++ b/Algorithm.CSharp/StatisticsResultsAlgorithm.cs @@ -229,8 +229,8 @@ private void CheckMostTradedSecurityStatistic(Dictionary statist {"Estimated Strategy Capacity", "$1100000.00"}, {"Lowest Capacity Asset", "IBM R735QTJ8XC9X"}, {"Portfolio Turnover", "549.26%"}, - {"Most Traded Security", "IBM"}, {"Most Traded Security Trade Count", "63"}, + {"Most Traded Security", "IBM"}, {"OrderListHash", "8dd77e35338a81410a5b68dc8345f402"} }; } diff --git a/Algorithm.Python/BasicTemplateFuturesDailyAlgorithm.py b/Algorithm.Python/BasicTemplateFuturesDailyAlgorithm.py index 038a9c4fa28e..fd4ec9c24f4f 100644 --- a/Algorithm.Python/BasicTemplateFuturesDailyAlgorithm.py +++ b/Algorithm.Python/BasicTemplateFuturesDailyAlgorithm.py @@ -12,7 +12,6 @@ # limitations under the License. from AlgorithmImports import * -import QuantConnect.Data.UniverseSelection ### ### This example demonstrates how to add futures with daily resolution. diff --git a/Algorithm.Python/ConsolidateRegressionAlgorithm.py b/Algorithm.Python/ConsolidateRegressionAlgorithm.py index 6967694a707a..aff1a04783f0 100644 --- a/Algorithm.Python/ConsolidateRegressionAlgorithm.py +++ b/Algorithm.Python/ConsolidateRegressionAlgorithm.py @@ -25,7 +25,7 @@ def initialize(self): self.set_end_date(2020, 1, 20) SP500 = Symbol.create(Futures.Indices.SP_500_E_MINI, SecurityType.FUTURE, Market.CME) - symbol = list(self.futures_chain(SP500))[0].symbol + symbol = list(self.futures_chain(SP500))[0] self._future = self.add_future_contract(symbol) tradable_dates_count = len(list(Time.each_tradeable_day_in_time_zone(self._future.exchange.hours, diff --git a/Algorithm.Python/FutureOptionChainFullDataRegressionAlgorithm.py b/Algorithm.Python/FutureOptionChainFullDataRegressionAlgorithm.py index f65c664af885..147a908d377e 100644 --- a/Algorithm.Python/FutureOptionChainFullDataRegressionAlgorithm.py +++ b/Algorithm.Python/FutureOptionChainFullDataRegressionAlgorithm.py @@ -12,7 +12,6 @@ # limitations under the License. from AlgorithmImports import * -from datetime import timedelta ### ### Regression algorithm illustrating the usage of the method diff --git a/Algorithm.Python/FutureOptionChainsMultipleFullDataRegressionAlgorithm.py b/Algorithm.Python/FutureOptionChainsMultipleFullDataRegressionAlgorithm.py index 2bf1f655f4b3..21f083d57343 100644 --- a/Algorithm.Python/FutureOptionChainsMultipleFullDataRegressionAlgorithm.py +++ b/Algorithm.Python/FutureOptionChainsMultipleFullDataRegressionAlgorithm.py @@ -12,7 +12,6 @@ # limitations under the License. from AlgorithmImports import * -from datetime import timedelta ### ### Regression algorithm illustrating the usage of the method diff --git a/Algorithm.Python/FuturesChainFullDataRegressionAlgorithm.py b/Algorithm.Python/FuturesChainFullDataRegressionAlgorithm.py index 07b9759bddb2..171dfd1ef45d 100644 --- a/Algorithm.Python/FuturesChainFullDataRegressionAlgorithm.py +++ b/Algorithm.Python/FuturesChainFullDataRegressionAlgorithm.py @@ -12,7 +12,6 @@ # limitations under the License. from AlgorithmImports import * -from datetime import timedelta ### ### Regression algorithm illustrating the usage of the diff --git a/Algorithm.Python/FuturesChainsMultipleFullDataRegressionAlgorithm.py b/Algorithm.Python/FuturesChainsMultipleFullDataRegressionAlgorithm.py index b336bddf5808..3f1c48d7408a 100644 --- a/Algorithm.Python/FuturesChainsMultipleFullDataRegressionAlgorithm.py +++ b/Algorithm.Python/FuturesChainsMultipleFullDataRegressionAlgorithm.py @@ -12,7 +12,6 @@ # limitations under the License. from AlgorithmImports import * -from datetime import timedelta ### ### Regression algorithm illustrating the usage of the diff --git a/Common/Data/Market/FuturesContract.cs b/Common/Data/Market/FuturesContract.cs index 89c6e2729156..2c854117674a 100644 --- a/Common/Data/Market/FuturesContract.cs +++ b/Common/Data/Market/FuturesContract.cs @@ -151,6 +151,15 @@ public FuturesContract(FutureUniverse contractData) /// public override string ToString() => Symbol.Value; + /// + /// Implicit conversion into + /// + /// The option contract to be converted + public static implicit operator Symbol(FuturesContract contract) + { + return contract.Symbol; + } + /// /// Updates the future contract with the new data, which can be a or or ///