Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-32.539%
Drawdown
1.000%
Expectancy
0
Net Profit
-0.502%
Sharpe Ratio
-7.38
Probabilistic Sharpe Ratio
6.044%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.089
Beta
0.396
Annual Standard Deviation
0.048
Annual Variance
0.002
Information Ratio
4.314
Tracking Error
0.073
Treynor Ratio
-0.893
Total Fees
$1.00
Estimated Strategy Capacity
$57000000.00
class CalculatingTanGuanaco(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 3, 15)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        self.AddEquity("SPY", Resolution.Minute)
        self.orders = {}
        self.stage = 0
        self.ticket = None

    def OnData(self, data):
        # get orders in list
        ordersList = list(self.orders.keys())
        
        if len(self.orders) > 0:
            self.Log(list(self.orders.values())[0])
        
        if self.stage == 0:
            self.ticket = self.LimitOrder('SPY', 100, 50000)
            self.stage = 1
        elif self.stage == 1:
            updateSettings = UpdateOrderFields()
            updateSettings.LimitPrice = 600000
            updateSettings.Tag = "Limit Price Updated for SPY Trade"
            response = self.ticket.Update(updateSettings)
            self.stage = 2
        
        
    def OnOrderEvent(self, orderEvent):
        orderTicket = self.Transactions.GetOrderById(orderEvent.OrderId)
        if orderTicket not in self.orders:
            self.orders[orderTicket] = orderTicket.Time