Overall Statistics |
Total Trades 2332 Average Win 0.18% Average Loss -0.20% Compounding Annual Return -9.110% Drawdown 40.100% Expectancy -0.208 Net Profit -38.004% Sharpe Ratio -2.08 Probabilistic Sharpe Ratio 0.000% Loss Rate 59% Win Rate 41% Profit-Loss Ratio 0.94 Alpha -0.075 Beta 0.051 Annual Standard Deviation 0.036 Annual Variance 0.001 Information Ratio -1.246 Tracking Error 0.072 Treynor Ratio -1.453 Total Fees $6519.60 Estimated Strategy Capacity $12000000.00 Lowest Capacity Asset EURUSD 5O |
namespace QuantConnect { public class BootCampTask : QCAlgorithm { Minimum lowBeforeOpen; Maximum highBeforeOpen; public override void Initialize() { SetStartDate(2016, 6, 1); SetEndDate(2021, 6, 1); SetCash(100000); AddEquity("SPY", Resolution.Minute); AddForex("EURUSD", Resolution.Minute, Market.FXCM); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.AfterMarketOpen("SPY", 0), MarketOpen); Schedule.On(DateRules.EveryDay("SPY"), TimeRules.BeforeMarketClose("SPY", 5), ClosePosition); SetTimeZone(TimeZones.NewYork); SetBrokerageModel(BrokerageName.FxcmBrokerage); } public override void OnData(Slice data) { if (lowBeforeOpen == null || highBeforeOpen == null) return; if (Time.Hour >= 10 || Time.Minute < 31) return; if (data.ContainsKey("EURUSD") && !Portfolio.Invested) { decimal currentPrice = data["EURUSD"].Close; if (currentPrice > highBeforeOpen) { SetHoldings("EURUSD", 1); } else if (currentPrice < lowBeforeOpen) { SetHoldings("EURUSD", -1); } } } public void MarketOpen() { lowBeforeOpen = new Minimum(15); highBeforeOpen = new Maximum(15); var history = History<QuoteBar>("EURUSD", 15, Resolution.Minute); foreach (var quoteBar in history) { lowBeforeOpen.Update(quoteBar.Time, quoteBar.Low); highBeforeOpen.Update(quoteBar.Time, quoteBar.High); } } public void ClosePosition() { Liquidate("EURUSD"); lowBeforeOpen = null; highBeforeOpen = null; } } }