Overall Statistics
Total Trades
7
Average Win
0%
Average Loss
-3.01%
Compounding Annual Return
396.419%
Drawdown
45.600%
Expectancy
-1
Net Profit
121.019%
Sharpe Ratio
2.475
Probabilistic Sharpe Ratio
85.084%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
2.056
Beta
1.097
Annual Standard Deviation
0.764
Annual Variance
0.584
Information Ratio
2.946
Tracking Error
0.693
Treynor Ratio
1.725
Total Fees
$14.17
namespace QuantConnect.Algorithm.CSharp
{
    public class NadionParticleAtmosphericScrubbers : QCAlgorithm
    {
		Symbol _tsla;
		decimal entryPrice;
        public override void Initialize()
        {
            SetStartDate(2019, 9, 15);  //Set Start Date
            SetCash(100000);             //Set Strategy Cash
            
            _tsla = AddEquity("TSLA", Resolution.Minute).Symbol;


        }

        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// Slice object keyed by symbol containing the stock data
        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested)
            {
                SetHoldings(_tsla, 1);
                entryPrice = Securities[_tsla].Price;
                Debug("Purchased TSLA Stock");
            }
            
            
            var pnl = Securities[_tsla].Holdings.UnrealizedProfitPercent;
            
            if ( pnl < (decimal)-0.03) // 3% loss margin 
			{	
				var exitPrice = Securities[_tsla].Price;
				var change = (exitPrice - entryPrice)/entryPrice;
				Debug($"UnrealizedProfitPercent: {pnl}, with entry {entryPrice} and exit {exitPrice} with change {change}");
			    Liquidate(_tsla,"3% loss margin reached");
			}
        }

    }
}