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 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
namespace QuantConnect { /* * Basic Template Algorithm * * The underlying QCAlgorithm class has many methods which enable you to use QuantConnect. * We have explained some of these here, but the full base class can be found at: * https://github.com/QuantConnect/Lean/tree/master/Algorithm */ public class BasicTemplateAlgorithm : QCAlgorithm { private Symbol symbol; private SimpleMovingAverage fastSma; private SimpleMovingAverage slowSma; private ExponentialMovingAverage fastEma; private ExponentialMovingAverage slowEma; public override void Initialize() { // backtest parameters SetStartDate(2019, 11, 15); SetEndDate(DateTime.Now); // cash allocation SetCash(25000); // request specific equities // including forex. Options and futures in beta. // AddEquity("SPY", Resolution.Minute); var equity = AddEquity("AAPL", Resolution.Minute); symbol = equity.Symbol; var thirtyMinutes = new TradeBarConsolidator(TimeSpan.FromMinutes(30)); thirtyMinutes.DataConsolidated += OnHalfHour; fastSma = SMA(symbol, 3); RegisterIndicator(symbol, fastSma, thirtyMinutes); SubscriptionManager.AddConsolidator(symbol, thirtyMinutes); SetWarmUp(30 * 3); // slowSma = SMA(symbol, 34); // fastSma = SMA(symbol, 3, thirtyMinutes); // slowSma = SMA(symbol, 34, thirtyMinutes); // fastEma = EMA(symbol, 21, thirtyMinutes); // slowEma = EMA(symbol, 55, thirtyMinutes); } public void OnHalfHour(object sender, TradeBar bar) { fastSma.Update(bar.EndTime, bar.Close); Debug(Time.ToString("u") + " " + fastSma); // slowSma.Update(bar.EndTime, bar.Close); // Debug(fastSma + " " + slowSma); // Plot("SMA", slowSma); } // def OnDataConsolidated(self, sender, bar): // self.ema_very_fast_five_min.Update(bar.EndTime, bar.Close); // self.Debug(str(self.Time) + " > New 5 Min Bar!") // self.Plot("EMA", self.ema_very_fast_one_min) // self.Plot("EMA", self.ema_very_fast_five_min) /* * New data arrives here. * The "Slice" data represents a slice of time, it has all the data you need for a moment. */ public override void OnData(Slice data) { // Debug(Time.ToString("u") + " " + data.Bars["SPY"]); // PlotIndicator("SMA", fastSma); // slice has lots of useful information // TradeBars bars = data.Bars; // Splits splits = data.Splits; // Dividends dividends = data.Dividends; //Get just this bar. // TradeBar bar; // if (bars.ContainsKey("SPY")) bar = bars["SPY"]; // if (!Portfolio.HoldStock) // { // place an order, positive is long, negative is short. // Order("SPY", quantity); // or request a fixed fraction of a specific asset. // +1 = 100% long. -2 = short all capital with 2x leverage. // SetHoldings("SPY", 1); // debug message to your console. Time is the algorithm time. // send longer messages to a file - these are capped to 10kb // Debug("Purchased SPY on " + Time.ToShortDateString()); //Log("This is a longer message send to log."); // } } } }