| Overall Statistics |
|
Total Trades 19 Average Win 0.14% Average Loss 0% Compounding Annual Return 16.831% Drawdown 7.400% Expectancy 0 Net Profit 36.488% Sharpe Ratio 1.798 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.164 Beta -0.033 Annual Standard Deviation 0.088 Annual Variance 0.008 Information Ratio -0.292 Tracking Error 0.143 Treynor Ratio -4.846 Total Fees $19.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
{
SimpleMovingAverage _smaAAPL;
SimpleMovingAverage _smaSPY;
CompositeIndicator<IndicatorDataPoint> _smaRatio;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
SetCash(25000);
SetStartDate(2013, 1, 1);
SetEndDate(2015, 1 ,1);
AddSecurity(SecurityType.Equity, "AAPL", Resolution.Minute);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
_smaAAPL = SMA("AAPL", 100);
_smaSPY = SMA("SPY", 100);
_smaRatio = _smaAAPL.Over(_smaSPY);
}
public void OnData(TradeBars data)
{
if (_smaRatio > 1)
{
SetHoldings("AAPL", 0.8, true);
}
else
{
SetHoldings("SPY", 0.8, true);
}
}
}
}