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
class BootCampTask(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2016, 6, 1)
        self.SetEndDate(2021, 6, 1)
        self.SetCash(100000)
        
        self.lowBeforeOpen = None
        self.highBeforeOpen = None
        
        self.AddEquity("SPY", Resolution.Minute)
        self.AddForex("EURUSD", Resolution.Minute, Market.FXCM)

        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 0), Action(self.MarketOpen));
        self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", 5), Action(self.ClosePosition));
        
        self.SetTimeZone(TimeZones.NewYork);
        self.SetBrokerageModel(BrokerageName.FxcmBrokerage);

    def OnData(self, data):
        if self.lowBeforeOpen == None or self.highBeforeOpen == None:
            return
        
        if self.Time.hour >= 10 or self.Time.minute < 31:
            return
        
        if data.ContainsKey("EURUSD") and self.Portfolio.Invested == False:
            currentPrice = data["EURUSD"].Close
            if currentPrice > self.highBeforeOpen.Current.Value:    
                self.SetHoldings("EURUSD", 1)
            elif (currentPrice < self.lowBeforeOpen.Current.Value):
                self.SetHoldings("EURUSD", -1)
                
    def MarketOpen(self):
        self.lowBeforeOpen = Minimum(15)
        self.highBeforeOpen = Maximum(15)
        history = self.History(["EURUSD"], 15, Resolution.Minute)
        if "EURUSD" in history.index:
            for index, row in history.loc["EURUSD"].iterrows():
                self.lowBeforeOpen.Update(index, row["low"])
                self.highBeforeOpen.Update(index, row["high"])
            
    def ClosePosition(self):
        self.Liquidate("EURUSD")
        self.lowBeforeOpen = None
        self.highBeforeOpen = None