Overall Statistics
Total Trades
307
Average Win
0.07%
Average Loss
0.00%
Compounding Annual Return
-0.837%
Drawdown
17.900%
Expectancy
14.254
Net Profit
-1.668%
Sharpe Ratio
-0.026
Probabilistic Sharpe Ratio
5.301%
Loss Rate
16%
Win Rate
84%
Profit-Loss Ratio
17.23
Alpha
-0.029
Beta
0.311
Annual Standard Deviation
0.093
Annual Variance
0.009
Information Ratio
-0.63
Tracking Error
0.139
Treynor Ratio
-0.008
Total Fees
$0.00
Estimated Strategy Capacity
$7500000.00
Lowest Capacity Asset
EURUSD 8G
class VirtualYellowTapir(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2011, 1, 1)
        self.SetEndDate(2013, 1, 1)
        self.spy = self.AddForex("EURUSD", Resolution.Minute, Market.Oanda).Symbol
        self.prev = self.SMA("EURUSD", 2, Resolution.Minute)
        self.fastma = self.SMA("EURUSD", 20, Resolution.Minute)
        self.slowma = self.SMA("EURUSD", 200, Resolution.Minute)
        
        closing_prices = self.History(self.spy, 200, Resolution.Minute)["close"]
        for time, price in closing_prices.loc[self.spy].items():
            self.fastma.Update(time, price)
            self.slowma.Update(time, price)
            
        previous_value = self.History(self.spy, 2, Resolution.Minute)["close"]
        for time, price in previous_value.loc[self.spy].items():
            self.prev.Update(time, price)
        
        self.price_bought = 0
            
            
    def OnData(self, data):
        if not self.slowma.IsReady or not self.fastma.IsReady or not self.prev.IsReady:
            return
        
        price = self.Securities[self.spy].Close
        
        
        if price > self.slowma.Current.Value and self.prev.Current.Value < self.slowma.Current.Value:
            if not self.Portfolio[self.spy].Invested:
                self.SetHoldings(self.spy, 1)
                self.price_bought = price
                
        elif price < self.fastma.Current.Value and self.prev.Current.Value > self.fastma.Current.Value and price > self.slowma.Current.Value and price > self.price_bought:
            if self.Portfolio[self.spy].Invested:
                self.Liquidate()
                
        elif price < self.slowma.Current.Value and self.prev.Current.Value > self.slowma.Current.Value and price > self.fastma.Current.Value and price > self.price_bought:
            if self.Portfolio[self.spy].Invested:
                self.Liquidate()
                
        self.Plot("Benchmark", "Fast", self.fastma.Current.Value)
        self.Plot("Benchmark", "Slow", self.slowma.Current.Value)
        self.Plot("Benchmark", "Price", price)