Overall Statistics
Total Orders
3
Average Win
0%
Average Loss
0%
Compounding Annual Return
0.134%
Drawdown
0.400%
Expectancy
0
Start Equity
100000
End Equity
100443.72
Net Profit
0.444%
Sharpe Ratio
-15.302
Sortino Ratio
-18.279
Probabilistic Sharpe Ratio
15.695%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.027
Beta
0.012
Annual Standard Deviation
0.002
Annual Variance
0
Information Ratio
-0.61
Tracking Error
0.14
Treynor Ratio
-2.181
Total Fees
$0.00
Estimated Strategy Capacity
$2400000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
0.00%
# region imports
from AlgorithmImports import *
# endregion

class TradierBrokerageExampleAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2021, 1, 1)
        self.set_cash(100000)

        self.set_brokerage_model(BrokerageName.TRADIER_BROKERAGE, AccountType.MARGIN)
        
        self._symbol = self.add_equity("SPY", Resolution.MINUTE).symbol

        # Set default order properties
        self.default_order_properties.time_in_force = TimeInForce.DAY

    def on_data(self, data):
        if self.portfolio.invested:
            return
        
        # Place an order with the default order properties  
        self.market_order(self._symbol, 1)
        
        # Place an order with new order properties
        order_properties = OrderProperties()
        order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED
        ticket = self.limit_order(self._symbol, 1, data[self._symbol].price * 0.9, order_properties = order_properties)
        
        # Update the order quantity
        ticket.cancel()
        ticket = self.limit_order(self._symbol, 2, data[self._symbol].price * 0.9, order_properties = order_properties)
        
        # Update the order fields that are not the quantity
        update_fields = UpdateOrderFields()
        update_fields.limit_price = data[self._symbol].price * 1.05
        update_fields.tag = "Informative order tag"
        response = ticket.update(update_fields)
        if not self.live_mode and response.is_success:
            self.debug("Order updated successfully")