| Overall Statistics |
|
Total Trades 1415 Average Win 1.43% Average Loss -0.65% Compounding Annual Return 57.240% Drawdown 19.700% Expectancy 0.265 Net Profit 861.987% Sharpe Ratio 2.355 Probabilistic Sharpe Ratio 96.936% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 2.19 Alpha 0.645 Beta -0.071 Annual Standard Deviation 0.268 Annual Variance 0.072 Information Ratio 1.3 Tracking Error 0.334 Treynor Ratio -8.895 Total Fees $2673.74 Estimated Strategy Capacity $35000000.00 Lowest Capacity Asset AMZN R735QTJ8XC9X |
//Copyright HardingSoftware.com, 2021. Granted to the public domain.
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;
namespace QuantConnect.Algorithm.CSharp
{
public class MomentumSingle : QCAlgorithm
{
string ticker = "AMZN";
Symbol symbol;
Resolution resolution=Resolution.Minute;
int period = 6;
MomentumPercent momentum;
public override void Initialize()
{
UniverseSettings.Resolution = resolution;
SetStartDate(2016, 7, 02);
SetCash(100000);
symbol = AddEquity(ticker, resolution).Symbol;
momentum = new MomentumPercent(period);
}
public void OnData(TradeBars data)
{
if ((Time.Minute == 0 && Time.Second < 15) || (Time.Minute == 59 && Time.Second > 55))
{
if (data.ContainsKey(symbol))
{
TradeBar bar = data[symbol];
momentum.Update(bar.EndTime, bar.Close);
if (momentum > 0 && Portfolio[symbol].Quantity <= 0)
{
SetHoldings(symbol, 0.99m);
}
else if (momentum < 0 && Portfolio[symbol].Quantity >= 0)
{
SetHoldings(symbol, -0.99m);
}
}
}
}
}
}