Overall Statistics |
Total Trades 12 Average Win 1.60% Average Loss -3.01% Compounding Annual Return -9.772% Drawdown 17.500% Expectancy -0.387 Net Profit -9.772% Sharpe Ratio -0.551 Probabilistic Sharpe Ratio 4.042% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 0.53 Alpha -0.074 Beta 0.027 Annual Standard Deviation 0.133 Annual Variance 0.018 Information Ratio -0.492 Tracking Error 0.19 Treynor Ratio -2.71 Total Fees $38.89 Estimated Strategy Capacity $730000000.00 |
using System; using System.Linq; using QuantConnect; using QuantConnect.Algorithm; using QuantConnect.Brokerages; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Indicators.CandlestickPatterns; using QuantConnect.Orders; using QuantConnect.Parameters; namespace cristian { /// <summary> /// Basic template algorithm simply initializes the date range and cash /// </summary> public class TestCandlestickAlgorithm : QCAlgorithm { private RollingWindow<TradeBar> _window; private string _symbol = "SPY"; /// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> public override void Initialize() { SetStartDate(2015, 1, 1); //Set Start Date SetEndDate(2015, 12, 31); //Set End Date SetCash(100000); //Set Strategy Cash // Find more symbols here: http://quantconnect.com/data AddEquity(_symbol, Resolution.Daily); _window = new RollingWindow<TradeBar>(2); } /// <summary> /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// </summary> /// <param name="data">Slice object keyed by symbol containing the stock data</param> public override void OnData(Slice data) { if(data.ContainsKey(_symbol)) { _window.Add(data[_symbol]); } if (!_window.IsReady) { return; } var currBar = _window[0]; var pastBar = _window[1]; int _pattern; if ((pastBar.Open > pastBar.Close && currBar.Close > currBar.Open) && (pastBar.Open - pastBar.Close < currBar.Close - currBar.Open) && (pastBar.Open <= currBar.Close && pastBar.Close >= currBar.Open)) { // Bullish Engulfing, go long _pattern = 1; SetHoldings(_symbol, 1); Log(_pattern); } if ((pastBar.Open < pastBar.Close && currBar.Close < currBar.Open) && (pastBar.Close - pastBar.Open < currBar.Open - currBar.Close) && (pastBar.Open >= currBar.Close && pastBar.Close <= currBar.Open)) { // Bearish Engulfing, go short _pattern = -1; SetHoldings(_symbol, -1); Log(_pattern); } } } }