Overall Statistics |
Total Trades 19 Average Win 1.08% Average Loss -1.98% Compounding Annual Return -12.507% Drawdown 16.700% Expectancy -0.313 Net Profit -12.507% Sharpe Ratio -0.741 Loss Rate 56% Win Rate 44% Profit-Loss Ratio 0.55 Alpha -0.086 Beta 0.19 Annual Standard Deviation 0.115 Annual Variance 0.013 Information Ratio -0.572 Tracking Error 0.154 Treynor Ratio -0.449 Total Fees $0.00 |
using System; using System.Globalization; using QuantConnect.Data; using QuantConnect.Data.Market; using QuantConnect.Indicators.CandlestickPatterns; namespace QuantConnect.Algorithm.CSharp { /// <summary> /// Basic template algorithm simply initializes the date range and cash /// </summary> public class CandlestickClosingMarubozuDailyESData : QCAlgorithm { private string _symbol = "ES"; private ClosingMarubozu _pattern3 = new ClosingMarubozu(); /// <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, 01, 01); //Set Start Date SetEndDate(2016, 01, 01); //Set End Date SetCash(100000); //Set Strategy Cash AddData<CloseMarib>(_symbol); _pattern3 = CandlestickPatterns.ClosingMarubozu(_symbol); } /// <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 void OnData(CloseMarib data) { // Debug("Close: " + data.Close + " - AdjustedClose: " + data.AdjustedClose + " - Value: " + data.Value); if (_pattern3 == 1) { // Bullish ClosingMarubozu, go long Debug(Time + " -> found Bullish ClosingMarubozu"); SetHoldings(_symbol, 1); } else if (_pattern3 == -1) { // Bearish ClosingMarubozu, go short Debug(Time + " -> found Bearish ClosingMarubozu"); SetHoldings(_symbol, -1); } } } public class CloseMarib : TradeBar { public override DateTime EndTime { get { return Time + Period; } set { Time = value - Period; } } public new TimeSpan Period { get { return QuantConnect.Time.OneDay; } } /// <summary> /// Return the URL external source for the data: QuantConnect will download it an read it line by line automatically: /// </summary> public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLive) { return new SubscriptionDataSource("https://www.dropbox.com/s/bpk2i3hmzaa0c6t/ES%20daily%202015-01-01%20-%202015-12-31.csv?dl=1", SubscriptionTransportMedium.RemoteFile); } /// <summary> /// Convert each line of the file above into an object. /// </summary> public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLive) { CloseMarib cmBar = new CloseMarib(); try { var data = line.Split(','); //Required. cmBar.Symbol = config.Symbol; cmBar.Time = DateTime.ParseExact(data[0], "yyyyMMdd", CultureInfo.InvariantCulture); //User configured / optional data on each bar: cmBar.Open = Convert.ToDecimal(data[1]); cmBar.High = Convert.ToDecimal(data[2]); cmBar.Low = Convert.ToDecimal(data[3]); cmBar.Close = Convert.ToDecimal(data[4]); cmBar.Volume = Convert.ToInt32(data[5]); //This is the value the engine uses for portfolio calculations cmBar.Value = cmBar.Close; } catch (Exception exception) { Console.WriteLine(exception.Message); } return cmBar; } } }