Overall Statistics |
Total Trades 15 Average Win 3.62% Average Loss -2.86% Annual Return 1.442% Drawdown 12.600% Expectancy 0.663 Net Profit 31.340% Sharpe Ratio 0.4 Loss Rate 27% Win Rate 73% Profit-Loss Ratio 1.27 Trade Frequency Weekly trades |
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 { //Algorithm Variables int quantity = 400; private string symbol = "SPY"; private decimal cash = 100000; //Initialize the Strategy public override void Initialize() { SetCash(cash); SetStartDate(1998, 01, 01); SetEndDate(2012, 12, 30); AddSecurity(SecurityType.Equity, symbol, Resolution.Minute); } //Handle the data events: public void OnData(TradeBars data) { if (Time.ToString("MMM") == "May") { if (Portfolio.HoldStock) { Order(symbol, -Portfolio[symbol].Quantity); Debug("QCU Sell In May: Flat " + Time.ToString("Y")); } } else { if (!Portfolio.HoldStock && Time.ToString("MMM") == "Nov") { Order(symbol, quantity); Debug("QCU Sell In May: Long " + Time.ToString("Y")); } } } } }