| Overall Statistics |
|
Total Trades 7 Average Win 8.62% Average Loss 0% Compounding Annual Return 6.439% Drawdown 13.200% Expectancy 0 Net Profit 26.753% Sharpe Ratio 0.746 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.006 Beta 0.466 Annual Standard Deviation 0.088 Annual Variance 0.008 Information Ratio -0.652 Tracking Error 0.094 Treynor Ratio 0.141 Total Fees $7.00 |
namespace QuantConnect
{
/*
* QuantConnect University: Full Basic Template:
*
* The underlying QCAlgorithm class is full of helper methods which enable you to use QuantConnect.
* We have explained some of these here, but the full algorithm can be found at:
* https://github.com/QuantConnect/QCAlgorithm/blob/master/QuantConnect.Algorithm/QCAlgorithm.cs
*/
public class BasicTemplateAlgorithm : QCAlgorithm
{
private int periodCounter = 0;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
//Start and End Date range for the backtest:
SetStartDate(2013, 1, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));
//Cash allocation
SetCash(25000);
//Add as many securities as you like. All the data will be passed into the event handler:
AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
}
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
{
if (!Portfolio.Invested)
{
if (Time.Month==10)
{
SetHoldings("SPY", 1);
Debug("Purchased Stock:"+Time.ToLongDateString());
}
}
else
{
if (Time.Month == 4)
{
SetHoldings("SPY", 0);
Debug("Sold Stock"+Time.ToLongDateString());
}
}
}
}
}