Overall Statistics |
Total Trades 1 Average Win 93.15% Average Loss 0% Compounding Annual Return 14.086% Drawdown 19.900% Expectancy 0 Net Profit 93.151% Sharpe Ratio 0.912 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.002 Beta 1 Annual Standard Deviation 0.158 Annual Variance 0.025 Information Ratio 0.107 Tracking Error 0.014 Treynor Ratio 0.144 Total Fees $9.26 |
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using QuantConnect.Data; using QuantConnect.Data.Market; using QuantConnect.Data.Consolidators; namespace QuantConnect.Algorithm.Examples { /// <summary> /// Algorithm that plots data in the past /// </summary> public class PastPlottingAlgorithm : QCAlgorithm { Series pastData; /// <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(2010, 05, 03); SetEndDate(2015, 04, 30); AddSecurity(SecurityType.Equity, "SPY"); var chart = new Chart("SPY"); pastData = new Series("past-data"); chart.AddSeries(pastData); AddChart(chart); } /// <summary> /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// </summary> /// <param name="data">TradeBars IDictionary object with your stock data</param> public void OnData(TradeBars data) { if (!Portfolio.Invested) { SetHoldings("SPY", 0.5m); } // plot every morning at 930 if (data["SPY"].Time.TimeOfDay.TotalHours == 9.5 && Time.Date > new DateTime(2010, 06, 01)) { pastData.AddPoint(Time.Subtract(TimeSpan.FromDays(15)), data["SPY"].Price); } } } }