Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
0.436%
Drawdown
0.100%
Expectancy
0
Start Equity
100000
End Equity
100192.91
Net Profit
0.193%
Sharpe Ratio
-37.332
Sortino Ratio
-48.731
Probabilistic Sharpe Ratio
82.442%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.054
Beta
0.015
Annual Standard Deviation
0.001
Annual Variance
0
Information Ratio
-2.341
Tracking Error
0.091
Treynor Ratio
-3.471
Total Fees
$2.00
Estimated Strategy Capacity
$6200000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
0.01%
#region imports
from AlgorithmImports import *
#endregion

class QCPaperTradingBrokerageExampleAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2024, 1, 1)
        self.SetCash(100000)

        self.SetBrokerageModel(BrokerageName.QuantConnectBrokerage, AccountType.Margin)
        
        # Set resolution to second
        self.symbol = self.AddEquity("SPY", Resolution.Second).Symbol

        # Set default order properties
        self.DefaultOrderProperties.TimeInForce = TimeInForce.Day

    def OnData(self, data):
        if self.Portfolio.Invested:
            return
        
        # Place an order with the default order properties  
        self.MarketOrder(self.symbol, 1)
        
        # Place an order with new order properties
        order_properties = OrderProperties()
        order_properties.TimeInForce = TimeInForce.GoodTilCanceled
        ticket = self.LimitOrder(self.symbol, 1, data[self.symbol].Price * 1.002, orderProperties = order_properties)
        
        # Update the order
        update_fields = UpdateOrderFields()
        update_fields.Quantity = 2
        update_fields.LimitPrice = data[self.symbol].Price * 1.005
        update_fields.Tag = "Informative order tag"
        response = ticket.Update(update_fields)

        if not self.LiveMode and response.IsSuccess:
            self.Debug("Order updated successfully")