Overall Statistics
Total Trades
1874
Average Win
0.23%
Average Loss
-0.24%
Compounding Annual Return
-0.313%
Drawdown
10.400%
Expectancy
-0.011
Net Profit
-3.073%
Sharpe Ratio
-0.056
Probabilistic Sharpe Ratio
0.003%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0.98
Alpha
-0.001
Beta
-0.004
Annual Standard Deviation
0.03
Annual Variance
0.001
Information Ratio
-0.661
Tracking Error
0.148
Treynor Ratio
0.464
Total Fees
$4196.30
Estimated Strategy Capacity
$120000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
/*
 * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
 * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Selection;
using RiskLibrary;

namespace QuantConnect.Algorithm.CSharp
{
    /// <summary>
    /// Framework algorithm that uses the <see cref="EmaCrossUniverseSelectionModel"/> to
    /// select the universe based on a moving average cross.
    /// </summary>
    public class EmaCrossUniverseSelectionFrameworkAlgorithm : QCAlgorithm
    {
        public override void Initialize()
        {
            SetStartDate(2013, 01, 01);
            SetCash(100000);

            var fastSMAPeriod = 20;
            var slowSMAPeriod= 60;
            Resolution resolution = Resolution.Hour;

            UniverseSettings.Leverage = 2.0m;
            UniverseSettings.Resolution = resolution;

            SetUniverseSelection(new ManualUniverseSelectionModel(QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)));
            SetAlpha(new EmaCrossAlphaModel(fastSMAPeriod,slowSMAPeriod,resolution));
            SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
            AddRiskManagement(new ATRTrailingStopRiskManagementModel(20,3,resolution));
        }
    }
}