Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
40.229%
Drawdown
7.800%
Expectancy
0
Net Profit
43.204%
Sharpe Ratio
2.49
Probabilistic Sharpe Ratio
92.749%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.017
Beta
1.139
Annual Standard Deviation
0.14
Annual Variance
0.02
Information Ratio
2.347
Tracking Error
0.024
Treynor Ratio
0.306
Total Fees
$2.41
class TransdimensionalParticleThrustAssembly(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 1, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash

        self.AddEquity("SPY")

        self.stopBuyTicket = None
        self.stopSellTicket = None

    def OnData(self, data):
        if self.stopBuyTicket is None and self.stopSellTicket is None:
            price = data["SPY"].Close
            self.stopBuyTicket = self.StopMarketOrder("SPY", price * 1.01, 100)
            self.stopSellTicket = self.StopMarketOrder("SPY", price * 0.99, 100)

    def OnOrderEvent(self, orderevent):
        
        if orderevent.Status != OrderStatus.Filled:
            return
        
        if orderevent.OrderId == self.stopBuyTicket.OrderId:
           history = self.History(orderevent.Symbol, 5, Resolution.Daily).close
           self.stopSellTicket.UpdateStopPrice(history.min())