Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
0.279%
Drawdown
0.100%
Expectancy
0
Net Profit
0.260%
Sharpe Ratio
1.466
Probabilistic Sharpe Ratio
70.005%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0
Beta
0.012
Annual Standard Deviation
0.001
Annual Variance
0
Information Ratio
-1.698
Tracking Error
0.104
Treynor Ratio
0.156
Total Fees
$2.00
Estimated Strategy Capacity
$2700000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
namespace QuantConnect.Algorithm.CSharp
{
    public class QCPaperTradingBrokerageExampleAlgorithm : QCAlgorithm
    {
        private Symbol _symbol;
        
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetCash(100000);

            SetBrokerageModel(BrokerageName.QuantConnectBrokerage, AccountType.Margin);
            
            _symbol = AddEquity("SPY", Resolution.Minute).Symbol;

            // Set default order properties
            DefaultOrderProperties.TimeInForce = TimeInForce.Day;
        }

        public override void OnData(Slice data)
        {
            if (Portfolio.Invested)
            {
                return;
            }
            
            // Place an order with the default order properties 
            MarketOrder(_symbol, 1);
            
            // Place an order with new order properties
            var orderProperties = new OrderProperties { TimeInForce = TimeInForce.GoodTilCanceled };
            var ticket = LimitOrder(_symbol, 1, data[_symbol].Price * 0.9m, orderProperties: orderProperties);
            
            // Update the order
            var orderFields = new UpdateOrderFields { 
                Quantity = 2,
                LimitPrice = data[_symbol].Price * 1.05m,
                Tag = "Informative order tag"
            };
            var response = ticket.Update(orderFields);
            if (!LiveMode && response.IsSuccess)
            {
                Debug("Order updated successfully");
            }
        }
    }
}