| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 14.888% Drawdown 7.900% Expectancy 0 Net Profit 0% Sharpe Ratio 1.036 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.024 Beta 0.962 Annual Standard Deviation 0.116 Annual Variance 0.013 Information Ratio 1.093 Tracking Error 0.019 Treynor Ratio 0.125 Total Fees $2.54 |
namespace QuantConnect.Algorithm.CSharp
{
public class PastClose : QCAlgorithm
{
private Symbol _spy;
private RollingWindow<decimal> Close;
public override void Initialize()
{
SetStartDate(2016, 01, 01); //Set Start Date
SetEndDate(2016, 12, 31); //Set End Date
SetCash(100000); //Set Strategy Cash
AddEquity("SPY", Resolution.Daily);
_spy = Securities["SPY"].Symbol;
Close = new RollingWindow<decimal>(2);
}
public void OnData(TradeBars data)
{
Close.Add(data[_spy].Close);
if (!Close.IsReady) return;
if (!Portfolio.Invested && Close[0] > Close[1])
{
SetHoldings(_spy, 1);
Debug(Time + " -> Buy signal: " + Close[0] + " . " + Close[1]);
}
}
}
}