@@ -30,16 +30,14 @@ namespace QuantConnect.Algorithm.CSharp
30
30
/// </summary>
31
31
public class OptionChainedUniverseSelectionModelRegressionAlgorithm : QCAlgorithm , IRegressionAlgorithmDefinition
32
32
{
33
- Symbol _aapl ;
34
33
public override void Initialize ( )
35
34
{
36
35
UniverseSettings . Resolution = Resolution . Minute ;
37
36
SetStartDate ( 2014 , 6 , 6 ) ;
38
37
SetEndDate ( 2014 , 6 , 6 ) ;
39
38
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" } ) ;
43
41
44
42
AddUniverseSelection ( new OptionChainedUniverseSelectionModel ( universe , u => u . Strikes ( - 2 , + 2 )
45
43
// Expiration method accepts TimeSpan objects or integer for days.
@@ -49,10 +47,11 @@ public override void Initialize()
49
47
50
48
public override void OnData ( Slice slice )
51
49
{
52
- if ( ! Portfolio . Invested && IsMarketOpen ( _aapl ) )
50
+ if ( ! Portfolio . Invested && IsMarketOpen ( "AAPL" ) && IsMarketOpen ( "TWX" ) )
53
51
{
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 )
56
55
{
57
56
// we find at the money (ATM) put contract with farthest expiration
58
57
var atmContract = chain
@@ -84,7 +83,7 @@ public override void OnData(Slice slice)
84
83
/// <summary>
85
84
/// Data Points count of all timeslices of algorithm
86
85
/// </summary>
87
- public long DataPoints => 936646 ;
86
+ public long DataPoints => 1033404 ;
88
87
89
88
/// <summary>
90
89
/// Data Points count of the algorithm history
@@ -96,7 +95,7 @@ public override void OnData(Slice slice)
96
95
/// </summary>
97
96
public Dictionary < string , string > ExpectedStatistics => new Dictionary < string , string >
98
97
{
99
- { "Total Trades" , "2 " } ,
98
+ { "Total Trades" , "4 " } ,
100
99
{ "Average Win" , "0%" } ,
101
100
{ "Average Loss" , "0%" } ,
102
101
{ "Compounding Annual Return" , "0%" } ,
@@ -116,11 +115,11 @@ public override void OnData(Slice slice)
116
115
{ "Information Ratio" , "0" } ,
117
116
{ "Tracking Error" , "0" } ,
118
117
{ "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" } ,
121
120
{ "Lowest Capacity Asset" , "AAPL 2ZTXYLO9EQPZA|AAPL R735QTJ8XC9X" } ,
122
- { "Portfolio Turnover" , "8.01 %" } ,
123
- { "OrderListHash" , "3c4bef29d95bf4c3a566bca7531b1df0 " }
121
+ { "Portfolio Turnover" , "8.85 %" } ,
122
+ { "OrderListHash" , "6a8e72c22752967e0d5d4e344e794dc4 " }
124
123
} ;
125
124
}
126
125
}
0 commit comments