Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 8.470% Drawdown 8.400% Expectancy 0 Net Profit 0% Sharpe Ratio 1.1 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.005 Beta 0.61 Annual Standard Deviation 0.076 Annual Variance 0.006 Information Ratio -1.262 Tracking Error 0.049 Treynor Ratio 0.137 Total Fees $1.00 |
namespace QuantConnect { public class ConsolidatorAlgorithm : QCAlgorithm { private TradeBar _spyDaily; private TradeBar _gldDaily; public override void Initialize() { SetStartDate(2013, 1, 1); SetEndDate(DateTime.Now.Date.AddDays(-1)); SetCash(25000); AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute); AddSecurity(SecurityType.Equity, "GLD", Resolution.Minute); var spyDailyConsolidator = new TradeBarConsolidator(TimeSpan.FromDays(1)); var gldDailyConsolidator = new TradeBarConsolidator(TimeSpan.FromDays(1)); spyDailyConsolidator.DataConsolidated += OnDataDaily; gldDailyConsolidator.DataConsolidated += OnDataDaily; SubscriptionManager.AddConsolidator("SPY", spyDailyConsolidator); SubscriptionManager.AddConsolidator("GLD", gldDailyConsolidator); } private void OnDataDaily(object sender, TradeBar consolidated) { if(consolidated.Symbol == "SPY") _spyDaily = consolidated; if(consolidated.Symbol == "GLD") _gldDaily = consolidated; Log(consolidated.ToString()); } public void OnData(TradeBars data) { if (!Portfolio.HoldStock) { Order("SPY", 100); } } } }