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 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
using System; using System.Collections.Generic; using System.Diagnostics; namespace QuantConnect { public class BasicTemplateAlgorithm : QCAlgorithm { private List<CoarseFundamental> lst = new List<CoarseFundamental>(); public override void Initialize() { SetCash(100000); SetStartDate(2017, 9, 6); SetEndDate(2017, 9, 7); AddUniverse(coarse => { List<string> testSymbolSet = new List<string>(); testSymbolSet.Add("A"); testSymbolSet.Add("AA"); //testSymbolSet.Add("AAAP"); //testSymbolSet.Add("AAC"); //testSymbolSet.Add("AADR"); //testSymbolSet.Add("AAL"); //testSymbolSet.Add("AAMC"); //testSymbolSet.Add("AAME"); //testSymbolSet.Add("AAOI"); //testSymbolSet.Add("AAON"); lst = coarse.Where(c => testSymbolSet.Contains(c.Symbol.Value)).ToList(); Debug(" ---- Prices when adding universe, " + Time + " ----"); foreach (CoarseFundamental x in lst) { Debug(x.Symbol.ToString() + ", price: " + x.Price.ToString() + ", volume: " + x.Volume.ToString() + " at " + Time.ToString() ); } var selected_coarse = lst.Select(c => c.Symbol).ToList(); return selected_coarse; }); var spy = AddEquity("SPY", Resolution.Minute).Symbol; Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 0), showCurrentPrices); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 1), showCurrentPrices); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 5), showCurrentPrices); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 5), showHistory5min); } private void showCurrentPrices() { Debug(" ---- Prices at " + Time + " ----"); foreach (var x in Portfolio.Values) { Debug("Portfolio: " + x.Symbol.ToString() + ", price: " + x.Price.ToString() + " at " + Time.ToString()); } foreach (var x in Portfolio.Values) { Debug("Securities: " + x.Symbol.ToString() + ", price: " + (Securities[x.Symbol]).Price.ToString() + ", volume: " + (Securities[x.Symbol]).Volume.ToString() + " at " + Time.ToString()); } foreach (CoarseFundamental x in lst) { Debug("CoarseFundamental: " + x.Symbol.ToString() + ", price: " + x.Price.ToString() + ", volume: " + x.Volume.ToString() + " at " + Time.ToString() ); } } private void showHistory5min() { Debug(" ---- History data at " + Time + " ----"); foreach (var x in Portfolio.Values) { var hist = History(x.Symbol, 6); // additional minute represente the currnt one, this takes close price of last minute of previous day //foreach(var tradeBar in hist) { // Debug( tradeBar.EndTime.ToString() + ", close price: " + tradeBar.Close.ToString() ); //} Debug("History, 5' ago, " + x.Symbol.ToString() + ": " + hist.First().EndTime.ToString() + ", price: " + hist.First().Price.ToString() ); Debug("History, 5' ago, " + x.Symbol.ToString() + ": " + hist.First().EndTime.ToString() + ", close price: " + hist.First().Close.ToString() ); Debug("History, 5' ago, " + x.Symbol.ToString() + ": " + hist.First().EndTime.ToString() + ", volume: " + hist.First().Volume.ToString() ); Debug("History, last, " + x.Symbol.ToString() + ": " + hist.Last().EndTime.ToString() + ", price: " + hist.Last().Price.ToString() ); Debug("History, last, " + x.Symbol.ToString() + ": " + hist.Last().EndTime.ToString() + ", close price: " + hist.Last().Close.ToString() ); Debug("History, last, " + x.Symbol.ToString() + ": " + hist.Last().EndTime.ToString() + ", volume: " + hist.Last().Volume.ToString() ); } } } }