| Overall Statistics |
|
Total Trades 66 Average Win 9.29% Average Loss -5.17% Compounding Annual Return 8.129% Drawdown 36.700% Expectancy 1.118 Net Profit 473.984% Sharpe Ratio 0.543 Probabilistic Sharpe Ratio 0.675% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 1.80 Alpha 0.082 Beta -0.062 Annual Standard Deviation 0.143 Annual Variance 0.02 Information Ratio 0.018 Tracking Error 0.237 Treynor Ratio -1.251 Total Fees $780.04 |
using System;
using System.Collections;
using System.Collections.Generic;
namespace QuantConnect
{
using QuantConnect.Securities;
using QuantConnect.Models;
//Sell in May Algorithm Example:
public partial class QCUSellInMay : QCAlgorithm, IAlgorithm {
private string symbol = "SPY";
private string symbol2 = "TLT";
private decimal cash = 100000;
//Initialize the Strategy
public override void Initialize() {
SetCash(cash);
SetStartDate(1998, 01, 01);
AddSecurity(SecurityType.Equity, symbol, Resolution.Daily);
AddSecurity(SecurityType.Equity, symbol2, Resolution.Daily);
}
//Handle the data events:
public void OnData(TradeBars data) {
/*if (!Portfolio.Invested) {
SetHoldings(symbol, 1);
}
return;*/
if (Time.ToString("MMM") == "May") {
if (Securities[symbol].Invested) {
SetHoldings(symbol, 0);
SetHoldings(symbol2, 1);
Debug("QCU Sell In May: Flat " + Time.ToString("Y"));
}
} else {
if (!Securities[symbol].Invested && Time.ToString("MMM") == "Nov") {
SetHoldings(symbol, 1);
SetHoldings(symbol2, 0);
Debug("QCU Sell In May: Long " + Time.ToString("Y"));
}
}
}
}
}