Overall Statistics
Total Trades
48
Average Win
1.48%
Average Loss
-1.66%
Compounding Annual Return
2.744%
Drawdown
16.100%
Expectancy
0.209
Net Profit
14.515%
Sharpe Ratio
0.378
Probabilistic Sharpe Ratio
5.925%
Loss Rate
36%
Win Rate
64%
Profit-Loss Ratio
0.89
Alpha
0.024
Beta
0.003
Annual Standard Deviation
0.064
Annual Variance
0.004
Information Ratio
-0.702
Tracking Error
0.18
Treynor Ratio
8.136
Total Fees
$0.00
Estimated Strategy Capacity
$570000.00
Lowest Capacity Asset
EURUSD 8G
import math

class BootCampTask(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2016, 6, 9)
        self.SetEndDate(2021, 6, 9)
        self.SetCash(100000)
        
        self.AddForex("EURUSD", Resolution.Daily)
        self.ema = self.EMA("EURUSD", 20, Resolution.Daily)
        self.SetWarmup(20)

    def OnData(self, data):
        if self.IsWarmingUp:
            return
        
        buy_price = round(self.ema.Current.Value * 0.99, 2)
        sell_price = round(self.ema.Current.Value * 1.01, 2)
        
        self.Transactions.CancelOpenOrders()
        
        if self.Portfolio["EURUSD"].Quantity <= 0:
            quantity = self.Portfolio.TotalPortfolioValue / buy_price - self.Portfolio["EURUSD"].Quantity
            quantity = math.floor(quantity);
            self.LimitOrder("EURUSD", quantity, buy_price);
        elif self.Portfolio["EURUSD"].Quantity > 0:
            quantity = -self.Portfolio.TotalPortfolioValue / sell_price - self.Portfolio["EURUSD"].Quantity
            quantity = math.ceil(quantity)
            self.LimitOrder("EURUSD", quantity, sell_price)