Overall Statistics
Total Trades
16
Average Win
0.66%
Average Loss
0%
Compounding Annual Return
13.599%
Drawdown
1.000%
Expectancy
0
Net Profit
6.566%
Sharpe Ratio
3.473
Probabilistic Sharpe Ratio
96.440%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.112
Beta
-0.027
Annual Standard Deviation
0.03
Annual Variance
0.001
Information Ratio
-1.647
Tracking Error
0.104
Treynor Ratio
-3.939
Total Fees
$16.00
class ParticleTachyonCompensator(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 8, 17)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.AddEquity("AAPL", Resolution.Daily)
        
        
        self.entryTicket = None
        self.stoplossTicket = None
        self.profit1Ticket = None
        self.profit2Ticket = None
        
        
    def OnData(self, data):
        
        if self.entryTicket == None:
            
            self.stopBuyPrice = data["AAPL"].Close + 3
            self.stopLossPrice = self.stopBuyPrice - 10
            self.profitTarget1 = self.stopBuyPrice + 10
            self.profitTarget2 = self.stopBuyPrice + 20
            
            self.entryTicket = self.StopMarketOrder("AAPL", 100, self.stopBuyPrice)
    
    
    def OnOrderEvent(self, orderevent):
        if orderevent.Status != OrderStatus.Filled:
            return
        
        if self.entryTicket != None and self.entryTicket.OrderId == orderevent.OrderId:
           # Enter stop loss order
           self.stoplossTicket = self.StopMarketOrder("AAPL",-100,self.stopLossPrice)
           # Enter limit order 1
           self.profit1Ticket = self.LimitOrder("AAPL",-50,self.profitTarget1)
           # Enter limit order 2
           self.profit2Ticket = self.LimitOrder("AAPL",-50,self.profitTarget2)
        
        if self.profit1Ticket != None and self.profit1Ticket.OrderId == orderevent.OrderId:
            self.stoplossTicket.UpdateQuantity(-50)
            
        if self.stoplossTicket != None and self.stoplossTicket.OrderId == orderevent.OrderId:
            self.profit1Ticket.Cancel()
            self.profit2Ticket.Cancel()
            self.entryTicket = None
        
        if self.profit2Ticket != None and self.profit2Ticket.OrderId == orderevent.OrderId:
            self.stoplossTicket.Cancel()
            self.entryTicket = None