Overall Statistics
Total Trades
12
Average Win
0.03%
Average Loss
-0.07%
Compounding Annual Return
-14.078%
Drawdown
0.400%
Expectancy
-0.751
Net Profit
-0.318%
Sharpe Ratio
-11.541
Loss Rate
83%
Win Rate
17%
Profit-Loss Ratio
0.49
Alpha
-0.156
Beta
-0.007
Annual Standard Deviation
0.014
Annual Variance
0
Information Ratio
-6.356
Tracking Error
0.132
Treynor Ratio
22.336
Total Fees
$12.00
using System;
using System.Collections.Generic;
using QuantConnect.Data.Market;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
using QuantConnect.Orders.Fills;
using QuantConnect.Orders.Slippage;
using QuantConnect.Securities;
using System.Net;
using System.Linq;
using System.Text.RegularExpressions;
using QuantConnect.Scheduling;
namespace QuantConnect
{
    public class Algo3 : QCAlgorithm
    {
        TradeBars lastData = null;
        TradeBar lastBar = null;
        decimal minimumPurchase = 500m;
        string tickersString;
        string tickers;
        bool timereached = true;
    	int increment = 0;
    	bool split = false;
    	string symbol;
    	
        public override void Initialize()
        {
            SetStartDate(2016, 7, 1);
			SetEndDate(2016, 7, 10);
            SetCash(5000);
            SetBrokerageModel(BrokerageName.TradierBrokerage, AccountType.Cash);
			AddSecurity(SecurityType.Equity,"SPY",Resolution.Minute);
        }
    
        public void OnData(TradeBars data)
        {
        	if (Time.Hour >= 9 && Time.Minute >= 30 && timereached)
			{
				const string url = @"https://docs.google.com/spreadsheets/d/1-q3Y5la6Dekz8-ZDL8c8AvfXk-p_cshA3udqK1KKbAI/export?format=csv&id=1-q3Y5la6Dekz8-ZDL8c8AvfXk-p_cshA3udqK1KKbAI";
			
			using (var client = new WebClient())
			{
				tickersString = client.DownloadString(url);
				Log("Scan");
			}
				timereached = false;
			}
			
			if(timereached == false && split == false)
			{
				tickers = tickersString.Split(',')[increment];
				split = true;
				//tickers = tickersString.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries);
				//String.Format("{0} \nAmount: {1} \nPrice: {2} \nProfit: {3}", symbol, shareCount, price, profits);
			}
			
			if (tickers.Any(char.IsLetter))
			{
				//increment++;
				//split = false;
				symbol = tickers.Replace("\"","");
				AddSecurity(SecurityType.Equity,symbol,Resolution.Minute);
				Notify.Sms("+15126454560", "Symbol Found : " + symbol);
				Log(symbol);
			}
			
			if (symbol == null)
			{
				timereached = true;
			}
			
            if (lastData != null & Portfolio.Values.Count > 0)
            {
                foreach (TradeBar bar in data.Values)
                {
                    if (Portfolio.Cash < minimumPurchase)
                    {
                        break;
                    }
                    if (!Portfolio[bar.Symbol].HoldStock && bar.Symbol != "SPY")
                    {
                        if (lastData.ContainsKey(bar.Symbol))
                        {
                            lastBar = lastData[bar.Symbol];
                            var shareCount = CalculateOrderQuantity(bar.Symbol, 1m/3);

                                if (bar.Close>lastBar.Close)
                                {
                                    Order(bar.Symbol, shareCount);
                                    Notify.Sms("+15126454560", "Buy Order : " + bar.Close);
                                }
                            }
                        }
                    }
                
                TradeBar bar2;
                foreach (SecurityHolding stock in Portfolio.Values)
                {
                    if (Portfolio[stock.Symbol].Quantity > 0 & lastData.ContainsKey(stock.Symbol) & Portfolio.ContainsKey(stock.Symbol) & data.ContainsKey(stock.Symbol))
                    {
                        lastBar = lastData[stock.Symbol];
                        bar2 = data[stock.Symbol];
                        if (bar2.Close < lastBar.Close)
                        {
                            Order(stock.Symbol, -Portfolio[stock.Symbol].Quantity);
                            Notify.Sms("+15126454560", "Sell Order : " + bar2.Close);
                        }
                    }
                }
            }
            lastData = data;
        }
    }
}