Overall Statistics |
Total Trades 103 Average Win 0.78% Average Loss -0.48% Compounding Annual Return 0.010% Drawdown 7.200% Expectancy -0.121 Net Profit 0.005% Sharpe Ratio 0.052 Probabilistic Sharpe Ratio 25.138% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 1.64 Alpha 0.042 Beta 0.31 Annual Standard Deviation 0.103 Annual Variance 0.011 Information Ratio 0.835 Tracking Error 0.149 Treynor Ratio 0.017 Total Fees $103.00 |
using System.Drawing; namespace QuantConnect { class BotAverageTangent { QCAlgorithm algo; string fund; Indicator indicator; decimal prevIndicator; int indicatorPeriod = 100; Resolution resolution = Resolution.Hour; public BotAverageTangent(QCAlgorithm _algo, string _fund, Resolution _resolution, int _indicatorPeriod) { algo = _algo; fund = _fund; resolution = _resolution; indicatorPeriod = _indicatorPeriod; algo.AddEquity(fund, resolution); indicator = algo.EMA(fund, indicatorPeriod, resolution); var stockPlot = new Chart("Trade Plot"); var assetPrice = new Series("Price", SeriesType.Line, "$", Color.Gray); var assetDEMA = new Series("DEMA", SeriesType.Line, "$", Color.Blue); var buyOrders = new Series("Buy", SeriesType.Scatter, "$", Color.Green, ScatterMarkerSymbol.Triangle); var sellOrders = new Series("Sell", SeriesType.Scatter, "$", Color.Red, ScatterMarkerSymbol.Diamond); stockPlot.AddSeries(buyOrders); stockPlot.AddSeries(sellOrders); stockPlot.AddSeries(assetPrice); stockPlot.AddSeries(assetDEMA); algo.AddChart(stockPlot); } public void OnData(Slice data) { // Make sure our indicators aready to use. if (algo.IsWarmingUp) return; decimal fundPrice = algo.Securities[fund].Close; algo.Plot("Trade Plot", "Price", fundPrice); //if(indicator < fundPrice) if(indicator > prevIndicator) { // Positive signal if(!algo.Portfolio.Invested) { algo.Plot("Trade Plot", "Buy", fundPrice); algo.SetHoldings(fund, 1.0); } } else { // Negative signal if(algo.Portfolio[fund].Invested) { algo.Plot("Trade Plot", "Sell", fundPrice); algo.Liquidate(fund); } } algo.Plot("Trade Plot", "DEMA", indicator); prevIndicator = indicator; } } }
using System.Drawing; namespace QuantConnect { public partial class BootCampTask : QCAlgorithm { private BotAverageTangent bot; string fundA = "SPY"; string fundB = "SH"; int indicatorPeriod = 20; Resolution resolution = Resolution.Hour; public override void Initialize() { SetStartDate(2018, 7, 1); SetEndDate(2018, 12, 31); SetCash(10000); bot = new BotAverageTangent(this, fundA, resolution, indicatorPeriod); SetBenchmark(fundA); SetWarmUp(indicatorPeriod); } public override void OnData(Slice data) { // Make sure our indicators aready to use. if (IsWarmingUp) return; bot.OnData(data); } } }