Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-5.288%
Drawdown
12.600%
Expectancy
0
Net Profit
-8.257%
Sharpe Ratio
-0.635
Probabilistic Sharpe Ratio
1.225%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.042
Beta
0.005
Annual Standard Deviation
0.065
Annual Variance
0.004
Information Ratio
-1.096
Tracking Error
0.143
Treynor Ratio
-7.645
Total Fees
$1.00
namespace QuantConnect
{
    public class BuyOneSecurity : QCAlgorithm
    {
        string _ticker = "TVIX";
        private Symbol _symbol;
        private Identity _price;

        public override void Initialize()
        {
           SetStartDate(2018, 06, 01); 
           SetEndDate(2020, 01, 01);
            
            SetCash(100000);
            
            _symbol = AddEquity(_ticker, Resolution.Daily, Market.USA).Symbol;
            
            _price = Identity(_symbol);
            PlotIndicator($"{_symbol.Value} Price", _price);
        }

        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested)
            {
                SetHoldings(_symbol, 0.1);
                Log($"Purchased Security {_symbol.ID}");
            }
        }
        
        public override void OnSecuritiesChanged(SecurityChanges changes)
        {
            foreach (var securityChange in changes.RemovedSecurities)
            {
                Log(securityChange.Symbol.ID.ToString() + " - Delisted");
            }
            
        }
        
        public void OnData(Splits data)
        {
            Log($"{_ticker}: " + Securities[_ticker].Price);
            var split = data[_ticker];
            Log($"{split.Time.ToIso8601Invariant()} >> SPLIT >> {split.Symbol} - " +
                $"{split.SplitFactor.ToStringInvariant()} - " +
                $"{Portfolio.Cash.ToStringInvariant()} - " +
                $"{Portfolio[_ticker].Quantity.ToStringInvariant()}"
            );
        }
        
        public void OnData(Dividends data) // update this to Dividends dictionary
        {
            var dividend = data[_ticker];
            Debug($"{dividend.Time.ToStringInvariant("o")} >> DIVIDEND >> {dividend.Symbol} - " +
                $"{dividend.Distribution.ToStringInvariant("C")} - {Portfolio.Cash} - " +
                $"{Portfolio[_ticker].Price.ToStringInvariant("C")}"
            );
        }

        public override void OnEndOfAlgorithm()
        {
            Liquidate();
        }
    }
}