Overall Statistics |
Total Trades 473 Average Win 0.47% Average Loss -0.60% Compounding Annual Return -8.156% Drawdown 22.200% Expectancy -0.048 Net Profit -8.149% Sharpe Ratio -0.181 Loss Rate 47% Win Rate 53% Profit-Loss Ratio 0.78 Alpha -0.058 Beta 0.073 Annual Standard Deviation 0.265 Annual Variance 0.07 Information Ratio -0.631 Tracking Error 0.285 Treynor Ratio -0.661 Total Fees $473.00 |
namespace QuantConnect { public class ConsolidatorAlgorithm : QCAlgorithm { public Dictionary<Symbol, SymbolData> _symbolData = new Dictionary<Symbol, SymbolData>(); public string[] tickers = new string[] { "WFM", "SPY" }; public DateTime sampledToday = DateTime.Now; //Initialize the data and resolution you require for your strategy: public override void Initialize() { SetStartDate(2014, 01, 01); SetEndDate(2015, 01, 01); SetCash(25000); foreach(var ticker in tickers) { var security = AddSecurity(SecurityType.Equity, ticker, Resolution.Minute); var fifteenMinute = new TradeBarConsolidator(TimeSpan.FromMinutes(15)); fifteenMinute.DataConsolidated += OnFifteenMinuteData; SubscriptionManager.AddConsolidator(security.Symbol, fifteenMinute); // define our 15 minute money flow indicator var mfi15M = new MoneyFlowIndex(14); RegisterIndicator(security.Symbol, mfi15M, fifteenMinute); _symbolData.Add(security.Symbol, new SymbolData( security.Symbol, MFI(security.Symbol, 14, Resolution.Daily), mfi15M)); } } // THis is 15 minute activities public void OnFifteenMinuteData(object sender, TradeBar bar) { if (!_symbolData[bar.Symbol].IsReady) return; var mfi15m = _symbolData[bar.Symbol].Fifteen; if (mfi15m < 20) { Order(bar.Symbol, 100); Debug(string.Format("Buy {0}. Below 20 mfi15 is {1}", bar.Symbol, mfi15m)); } if (mfi15m > 80) { Order(bar.Symbol, -100); Debug(string.Format("Sell {0}. Above 80 mfi15 is {1}", bar.Symbol, mfi15m)); } } //THis is every one minute activities public void OnData(TradeBars data) { } } public class SymbolData { public Symbol Symbol; public MoneyFlowIndex Daily; public MoneyFlowIndex Fifteen; public bool IsReady { get { return Daily.IsReady && Fifteen.IsReady; } } public SymbolData(Symbol symbol, MoneyFlowIndex daily, MoneyFlowIndex fifteen) { Symbol = symbol; Daily = daily; Fifteen = fifteen; } public override string ToString() { return IsReady ? string.Format("SymbolData for {0}: Daily: {1}. M15: {2}", Symbol, Daily, Fifteen) : "Indicators are not ready for " + Symbol; } } }