Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 6.842% Drawdown 55.300% Expectancy 0 Net Profit 339.140% Sharpe Ratio 0.409 Probabilistic Sharpe Ratio 0.083% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.08 Beta -0.093 Annual Standard Deviation 0.178 Annual Variance 0.032 Information Ratio 0 Tracking Error 0.264 Treynor Ratio -0.784 Total Fees $7.68 |
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 (Portfolio.HoldStock) { SetHoldings(symbol, 0); SetHoldings(symbol2, 1); Debug("QCU Sell In May: Flat " + Time.ToString("Y")); } } else { if (!Portfolio.HoldStock && Time.ToString("MMM") == "Nov") { SetHoldings(symbol, 1); SetHoldings(symbol2, 0); Debug("QCU Sell In May: Long " + Time.ToString("Y")); } } } } }