Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-13.596
Tracking Error
0.033
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
using System;
using QuantConnect.Data.Market;
using QuantConnect.Data;
using QuantConnect.Securities;
using System.Collections.Generic;

namespace QuantConnect.Algorithm.CSharp
{
   public class ExampleRS : QCAlgorithm
   {
      // Contains all of our equity symbols
      public readonly IReadOnlyList<string> EquitySymbols = new List<string>
        {
         "NIO"
      };

      public readonly IReadOnlyList<string> FSIPSymbols = new List<string>
     {
         "AMD","CCL","AAL","PLTR"
      };

      private readonly DateTime startDate = new DateTime(2021, 4, 12, 0, 0, 0);
      private readonly DateTime endDate = new DateTime(2021, 4, 13, 0, 0, 0);

      private readonly decimal startingCash = 100000;
      private bool add = true;

      public override void Initialize()
      {
         SetStartDate(startDate.Date);  // Set Start Date
         SetEndDate(endDate.Date);      // Set End Date
         SetCash(startingCash);         // Set Strategy Cash

		UniverseSettings.MinimumTimeInUniverse = new TimeSpan(0, 1, 0);

         foreach (var symbol in EquitySymbols)
         {
            const bool fillDataForward = true; // returns the last available data even if none in that timeslice
            const bool extendedMarketHours = true; // Show pre/post market data

            var equity = AddEquity(symbol, Resolution.Minute, Market.USA, fillDataForward,
                                    Security.NullLeverage, extendedMarketHours);


         }
         
         for (int i = -20; i < 0; i += 5)
         {
        	Schedule.On(DateRules.Every(DayOfWeek.Tuesday), TimeRules.AfterMarketOpen(EquitySymbols[0], i), FindStocksToTrade);
         }
      }

      public void FindStocksToTrade()
      {
         Log("--- FindStocksToTrade ENTRY ---");

         const bool fillDataForward = true; // returns the last available data even if none in that timeslice
         const bool extendedMarketHours = true; // Show pre/post market data

         foreach (var fsip in FSIPSymbols)
         {
            var symbol = QuantConnect.Symbol.Create(fsip, SecurityType.Equity, Market.USA);
            var histBars = History<TradeBar>(symbol, 60, Resolution.Minute);
            foreach (var histBar in histBars)
            {
               // Do stuff
            }
            
            if (add) // If we want to add the symbol
            {
            	Log($"     Add {symbol}");
            	AddEquity(fsip, Resolution.Minute, Market.USA, fillDataForward, Security.NullLeverage, extendedMarketHours);
            } else {
            	Log($"     Remove {symbol}");
            	RemoveSecurity(symbol);	
            }
         }
         add = !add; 
         Log("--- FindStocksToTrade EXIT ---");
      }

      public override void OnData(Slice data)
      {
    	 //RemoveSecurity(Symbol.Create("PLTR", SecurityType.Equity, Market.USA));	
         if (Time.Hour == 9 && Time.Minute >= 20 && Time.Minute <= 35)
         {
            foreach (var kvp in Securities)
            {
               Log($"OnData: symbol = {kvp.Key}, hasData = {kvp.Value.HasData}");
            }
            if (data.HasData)
            {
               foreach (var kvp in data)
               {
                  Log($"OnData: symbol = {kvp.Key}, Price = {kvp.Value.Price}, EndTime = {kvp.Value.EndTime}");
               }
            }
         }
      }
      
		public override void OnSecuritiesChanged(SecurityChanges changes)
		{
		    if (changes.AddedSecurities.Count > 0)
		    {
		        Debug("Securities added: " + 
		              string.Join(",", changes.AddedSecurities.Select(x => x.Symbol.Value)));
		    }
		    if (changes.RemovedSecurities.Count > 0)
		    {
		        Debug("Securities removed: " + 
		              string.Join(",", changes.RemovedSecurities.Select(x => x.Symbol.Value)));
		    }
		}
   }
}