Overall Statistics
Total Trades
87
Average Win
2.12%
Average Loss
-2.69%
Compounding Annual Return
-22.339%
Drawdown
40.000%
Expectancy
-0.149
Net Profit
-11.841%
Sharpe Ratio
0.03
Sortino Ratio
0.035
Probabilistic Sharpe Ratio
20.641%
Loss Rate
52%
Win Rate
48%
Profit-Loss Ratio
0.79
Alpha
-0.216
Beta
1.011
Annual Standard Deviation
0.645
Annual Variance
0.417
Information Ratio
-0.336
Tracking Error
0.635
Treynor Ratio
0.019
Total Fees
$153.54
Estimated Strategy Capacity
$85000000.00
Lowest Capacity Asset
TSLA UNU3P8Y3WFAD
Portfolio Turnover
15.96%
#region imports
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Globalization;
    using System.Drawing;
    using QuantConnect;
    using QuantConnect.Algorithm.Framework;
    using QuantConnect.Algorithm.Framework.Selection;
    using QuantConnect.Algorithm.Framework.Alphas;
    using QuantConnect.Algorithm.Framework.Portfolio;
    using QuantConnect.Algorithm.Framework.Execution;
    using QuantConnect.Algorithm.Framework.Risk;
    using QuantConnect.Algorithm.Selection;
    using QuantConnect.Parameters;
    using QuantConnect.Benchmarks;
    using QuantConnect.Brokerages;
    using QuantConnect.Util;
    using QuantConnect.Interfaces;
    using QuantConnect.Algorithm;
    using QuantConnect.Indicators;
    using QuantConnect.Data;
    using QuantConnect.Data.Consolidators;
    using QuantConnect.Data.Custom;
    using QuantConnect.DataSource;
    using QuantConnect.Data.Fundamental;
    using QuantConnect.Data.Market;
    using QuantConnect.Data.UniverseSelection;
    using QuantConnect.Notifications;
    using QuantConnect.Orders;
    using QuantConnect.Orders.Fees;
    using QuantConnect.Orders.Fills;
    using QuantConnect.Orders.Slippage;
    using QuantConnect.Scheduling;
    using QuantConnect.Securities;
    using QuantConnect.Securities.Equity;
    using QuantConnect.Securities.Future;
    using QuantConnect.Securities.Option;
    using QuantConnect.Securities.Forex;
    using QuantConnect.Securities.Crypto;   
    using QuantConnect.Securities.Interfaces;
    using QuantConnect.Storage;
    using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm;
    using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm;
#endregion
using QuantConnect.DataSource;

namespace QuantConnect
{
    public class USEquityCoarseUniverseConstituentsDataAlgorithm : QCAlgorithm
    {
        private int _numberOfSymbols = 3;
        private SecurityChanges _changes = SecurityChanges.None;
        
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetEndDate(2021, 7, 1);
            SetCash(100000);
        
            // Set Asynchronous to true to improve speed performance 
            UniverseSettings.Asynchronous = true;
            // Requesting data
            AddUniverse(FundamentalSelectionFunction);
        }

        public IEnumerable<Symbol> FundamentalSelectionFunction(IEnumerable<Fundamental> fundamental)
        {
            return fundamental.OrderByDescending(x => x.DollarVolume)
                .Take(_numberOfSymbols).Select(x => x.Symbol);
        }

        public override void OnData(Slice slice)
        {
            // if we have no changes, do nothing
            if (_changes == SecurityChanges.None) return;

            // liquidate removed securities
            foreach (var security in _changes.RemovedSecurities)
            {
                if (security.Invested)
                {
                    Liquidate(security.Symbol);
                }
            }

            // we want 1/N allocation in each security in our universe
            foreach (var security in _changes.AddedSecurities)
            {
                SetHoldings(security.Symbol, 1m / _numberOfSymbols);
            }

            _changes = SecurityChanges.None;
        }
        
        public override void OnSecuritiesChanged(SecurityChanges changes)
        {
            _changes = changes;


            foreach (var security in changes.AddedSecurities)
            {
                // Historical data
                var history = History(security.Symbol, 7, Resolution.Daily);
                Debug($"We got {history.Count()} from our history request for {security.Symbol}");
            }
        }
    }
}