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 |
namespace QuantConnect.Algorithm.CSharp { public class TestAlgo : QCAlgorithm { public RollingWindow<decimal> BidPrice = new RollingWindow<decimal>(4); public RollingWindow<decimal> AskPrice = new RollingWindow<decimal>(4); public RollingWindow<decimal> Volume = new RollingWindow<decimal>(4); public override void Initialize() { SetStartDate(2010, 01, 01); SetEndDate(DateTime.Now); SetCash(1000000); var futureSP500 = AddFuture(Futures.Indices.SP500EMini, Resolution.Daily); futureSP500.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182)); } public override void OnData(Slice slice) { if (!Portfolio.Invested) { foreach(var chain in slice.FutureChains) { // find the front contract expiring no earlier than in 90 days var contract = ( from futuresContract in chain.Value.OrderBy(x => x.Expiry) where futuresContract.Expiry > Time.Date.AddDays(90) select futuresContract ).FirstOrDefault(); // if found, perform logic if (contract != null) { BidPrice.Add(contract.BidPrice); AskPrice.Add(contract.AskPrice); Volume.Add(contract.Volume); if (!BidPrice.IsReady || !AskPrice.IsReady || !Volume.IsReady) continue; Console.WriteLine(BidPrice[0]); MarketOrder(contract.Symbol, 1); } } } } } }