2323using QuantConnect . Algorithm . Framework . Risk ;
2424using QuantConnect . Algorithm . Framework . Selection ;
2525using QuantConnect . Data ;
26+ using QuantConnect . Interfaces ;
2627
2728namespace QuantConnect . Algorithm . CSharp . Alphas
2829{
@@ -34,8 +35,8 @@ namespace QuantConnect.Algorithm.CSharp.Alphas
3435 /// <meta name="tag" content="alphastream" />
3536 /// <meta name="tag" content="algorithm framework" />
3637 /// <meta name="tag" content="etf" />
37- public class RebalancingLeveragedETFAlpha : QCAlgorithmFramework
38- {
38+ public class RebalancingLeveragedETFAlpha : QCAlgorithmFramework , IRegressionAlgorithmDefinition
39+ {
3940 private readonly List < ETFGroup > Groups = new List < ETFGroup > ( ) ;
4041
4142 public override void Initialize ( )
@@ -45,12 +46,12 @@ public override void Initialize()
4546 SetCash ( 100000 ) ;
4647
4748 var underlying = new List < string > { "SPY" , "QLD" , "DIA" , "IJR" , "MDY" , "IWM" , "QQQ" , "IYE" , "EEM" , "IYW" , "EFA" , "GAZB" , "SLV" , "IEF" , "IYM" , "IYF" , "IYH" , "IYR" , "IYC" , "IBB" , "FEZ" , "USO" , "TLT" } ;
48- var ultra = new List < string > { "SSO" , "UGL" , "DDM" , "SAA" , "MZZ" , "UWM" , "QLD" , "DIG" , "EET" , "ROM" , "EFO" , "BOIL" , "AGQ" , "UST" , "UYM" , "UYG" , "RXL" , "URE" , "UCC" , "BIB" , "ULE" , "UCO" , "UBT" } ;
49+ var ultraLong = new List < string > { "SSO" , "UGL" , "DDM" , "SAA" , "MZZ" , "UWM" , "QLD" , "DIG" , "EET" , "ROM" , "EFO" , "BOIL" , "AGQ" , "UST" , "UYM" , "UYG" , "RXL" , "URE" , "UCC" , "BIB" , "ULE" , "UCO" , "UBT" } ;
4950 var ultraShort = new List < string > { "SDS" , "GLL" , "DXD" , "SDD" , "MVV" , "TWM" , "QID" , "DUG" , "EEV" , "REW" , "EFU" , "KOLD" , "ZSL" , "PST" , "SMN" , "SKF" , "RXD" , "SRS" , "SCC" , "BIS" , "EPV" , "SCO" , "TBT" } ;
5051
5152 for ( var i = 0 ; i < underlying . Count ; i ++ )
5253 {
53- Groups . Add ( new ETFGroup ( AddEquity ( underlying [ i ] ) . Symbol , AddEquity ( ultra [ i ] ) . Symbol , AddEquity ( ultraShort [ i ] ) . Symbol ) ) ;
54+ Groups . Add ( new ETFGroup ( AddEquity ( underlying [ i ] ) . Symbol , AddEquity ( ultraLong [ i ] ) . Symbol , AddEquity ( ultraShort [ i ] ) . Symbol ) ) ;
5455 }
5556
5657 // Manually curated universe
@@ -64,7 +65,42 @@ public override void Initialize()
6465 SetExecution ( new ImmediateExecutionModel ( ) ) ;
6566 SetRiskManagement ( new NullRiskManagementModel ( ) ) ;
6667 }
67- }
68+ /// <summary>
69+ /// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
70+ /// </summary>
71+ public bool CanRunLocally { get ; } = false ;
72+
73+ /// <summary>
74+ /// This is used by the regression test system to indicate which languages this algorithm is written in.
75+ /// </summary>
76+ public Language [ ] Languages { get ; } = { Language . CSharp , Language . Python } ;
77+
78+ /// <summary>
79+ /// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
80+ /// </summary>
81+ public Dictionary < string , string > ExpectedStatistics => new Dictionary < string , string >
82+ {
83+ { "Total Trades" , "2465" } ,
84+ { "Average Win" , "0.26%" } ,
85+ { "Average Loss" , "-0.24%" } ,
86+ { "Compounding Annual Return" , "8.143%" } ,
87+ { "Drawdown" , "17.600%" } ,
88+ { "Expectancy" , "0.036" } ,
89+ { "Net Profit" , "9.582%" } ,
90+ { "Sharpe Ratio" , "0.505" } ,
91+ { "Loss Rate" , "50%" } ,
92+ { "Win Rate" , "50%" } ,
93+ { "Profit-Loss Ratio" , "1.07" } ,
94+ { "Alpha" , "0.58" } ,
95+ { "Beta" , "-24.276" } ,
96+ { "Annual Standard Deviation" , "0.191" } ,
97+ { "Annual Variance" , "0.036" } ,
98+ { "Information Ratio" , "0.401" } ,
99+ { "Tracking Error" , "0.191" } ,
100+ { "Treynor Ratio" , "-0.004" } ,
101+ { "Total Fees" , "$9056.88" }
102+ } ;
103+ }
68104
69105 /// <summary>
70106 /// If the underlying ETF has experienced a return >= 1% since the previous day's close up to the current time at 14:15,
0 commit comments