Overall Statistics |
Total Trades 159 Average Win 0.66% Average Loss -0.32% Compounding Annual Return -9.995% Drawdown 9.200% Expectancy -0.152 Net Profit -4.004% Sharpe Ratio -0.846 Loss Rate 72% Win Rate 28% Profit-Loss Ratio 2.04 Alpha -0.114 Beta 0.227 Annual Standard Deviation 0.094 Annual Variance 0.009 Information Ratio -2.215 Tracking Error 0.105 Treynor Ratio -0.35 Total Fees $588.30 |
namespace QuantConnect { public class SmaFutures : QCAlgorithm { private SimpleMovingAverage _sma5; private SimpleMovingAverage _sma9; public override void Initialize() { SetStartDate(2017, 1, 1); var equity = AddEquity("SPY"); var future = AddFuture(Futures.Indices.SP500EMini); future.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(60)); // Indicators _sma5 = SMA(equity.Symbol, 5); _sma9 = SMA(equity.Symbol, 9); } public override void OnData(Slice slice) { if (!Portfolio.Invested) { foreach(var chain in slice.FutureChains) { var contract = ( from futuresContract in chain.Value.OrderBy(x => x.Expiry) where futuresContract.Expiry > Time.Date.AddDays(5) select futuresContract ).FirstOrDefault(); if (contract != null) { var quantity = _sma5 > _sma9 ? 2 : -2; MarketOrder(contract.Symbol, quantity); } } } } public override void OnEndOfDay() { Liquidate(); } } }