Overall Statistics |
Total Trades 24 Average Win 0.41% Average Loss -0.15% Compounding Annual Return 0.620% Drawdown 0.700% Expectancy 1.345 Net Profit 2.298% Sharpe Ratio 0.887 Probabilistic Sharpe Ratio 40.421% Loss Rate 36% Win Rate 64% Profit-Loss Ratio 2.68 Alpha 0.002 Beta 0.019 Annual Standard Deviation 0.006 Annual Variance 0 Information Ratio -0.869 Tracking Error 0.162 Treynor Ratio 0.264 Total Fees $44.40 |
using QuantConnect.Securities.Future; namespace QuantConnect { public partial class BootCampTask : QCAlgorithm { private decimal notionalValue; private decimal contractsToBuy; private FuturesChain contractChain; private Future future; private FuturesContract liquidContract; public override void Initialize() { SetStartDate(2009, 5, 1); SetEndDate(2012, 12, 31); SetCash(1000000); AddEquity("SPY"); future = AddFuture("NQ"); future.SetFilter(0, 190); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 30), () => { if(liquidContract != null) { var oldFuture = (Future)Securities[liquidContract.Symbol]; if (future.Holdings.Quantity != 0) { MarketOrder(liquidContract.Symbol, -oldFuture.Holdings.Quantity); } } if(contractChain != null && contractChain.Count() >= 1) { var contracts = contractChain.OrderBy(x => x.Expiry); liquidContract = contracts.First(); if (liquidContract.Expiry <= Time.Date.AddDays(8) & contractChain.Count() >= 2) { liquidContract = contracts.Skip(1).First(); } var ContractFuture = (Future)Securities[liquidContract.Symbol]; if (ContractFuture.Holdings.Quantity == 0) { MarketOrder(liquidContract.Symbol, 1); } } }); } public override void OnMarginCallWarning() { Error("You received a Margin Call Warning! The assets will be liquidated to cover losses."); } public void OnData(Slice slice) { FuturesChain chain; if (slice.FuturesChains.TryGetValue(future.Symbol, out chain)) { contractChain = chain; } } } }