@@ -30,16 +30,14 @@ namespace QuantConnect.Algorithm.CSharp
3030 /// </summary>
3131 public class OptionChainedUniverseSelectionModelRegressionAlgorithm : QCAlgorithm , IRegressionAlgorithmDefinition
3232 {
33- Symbol _aapl ;
3433 public override void Initialize ( )
3534 {
3635 UniverseSettings . Resolution = Resolution . Minute ;
3736 SetStartDate ( 2014 , 6 , 6 ) ;
3837 SetEndDate ( 2014 , 6 , 6 ) ;
3938 SetCash ( 100000 ) ;
40- _aapl = QuantConnect . Symbol . Create ( "AAPL" , SecurityType . Equity , Market . USA ) ;
41- var config = new SubscriptionDataConfig ( typeof ( TradeBar ) , _aapl , Resolution . Minute , TimeZones . NewYork , TimeZones . NewYork , false , false , true ) ;
42- var universe = AddUniverse ( new ManualUniverse ( config , UniverseSettings , new [ ] { _aapl } ) ) ;
39+
40+ var universe = AddUniverse ( "my-minute-universe-name" , time => new List < string > { "AAPL" , "TWX" } ) ;
4341
4442 AddUniverseSelection ( new OptionChainedUniverseSelectionModel ( universe , u => u . Strikes ( - 2 , + 2 )
4543 // Expiration method accepts TimeSpan objects or integer for days.
@@ -49,10 +47,11 @@ public override void Initialize()
4947
5048 public override void OnData ( Slice slice )
5149 {
52- if ( ! Portfolio . Invested && IsMarketOpen ( _aapl ) )
50+ if ( ! Portfolio . Invested && IsMarketOpen ( "AAPL" ) && IsMarketOpen ( "TWX" ) )
5351 {
54- OptionChain chain ;
55- if ( slice . OptionChains . TryGetValue ( "?AAPL" , out chain ) )
52+ var values = slice . OptionChains . Where ( x => ( x . Key == "?AAPL" || x . Key == "?TWX" ) ) . Select ( x => x . Value ) ;
53+
54+ foreach ( var chain in values )
5655 {
5756 // we find at the money (ATM) put contract with farthest expiration
5857 var atmContract = chain
@@ -84,7 +83,7 @@ public override void OnData(Slice slice)
8483 /// <summary>
8584 /// Data Points count of all timeslices of algorithm
8685 /// </summary>
87- public long DataPoints => 936646 ;
86+ public long DataPoints => 1033404 ;
8887
8988 /// <summary>
9089 /// Data Points count of the algorithm history
@@ -96,7 +95,7 @@ public override void OnData(Slice slice)
9695 /// </summary>
9796 public Dictionary < string , string > ExpectedStatistics => new Dictionary < string , string >
9897 {
99- { "Total Trades" , "2 " } ,
98+ { "Total Trades" , "4 " } ,
10099 { "Average Win" , "0%" } ,
101100 { "Average Loss" , "0%" } ,
102101 { "Compounding Annual Return" , "0%" } ,
@@ -116,11 +115,11 @@ public override void OnData(Slice slice)
116115 { "Information Ratio" , "0" } ,
117116 { "Tracking Error" , "0" } ,
118117 { "Treynor Ratio" , "0" } ,
119- { "Total Fees" , "$2 .00" } ,
120- { "Estimated Strategy Capacity" , "$100000 .00" } ,
118+ { "Total Fees" , "$4 .00" } ,
119+ { "Estimated Strategy Capacity" , "$110000 .00" } ,
121120 { "Lowest Capacity Asset" , "AAPL 2ZTXYLO9EQPZA|AAPL R735QTJ8XC9X" } ,
122- { "Portfolio Turnover" , "8.01 %" } ,
123- { "OrderListHash" , "3c4bef29d95bf4c3a566bca7531b1df0 " }
121+ { "Portfolio Turnover" , "8.85 %" } ,
122+ { "OrderListHash" , "6a8e72c22752967e0d5d4e344e794dc4 " }
124123 } ;
125124 }
126125}
0 commit comments