| Overall Statistics |
|
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 0.319% Drawdown 0.100% Expectancy 0 Net Profit 0.318% Sharpe Ratio 1.621 Probabilistic Sharpe Ratio 76.746% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0 Beta 0.013 Annual Standard Deviation 0.001 Annual Variance 0 Information Ratio -1.855 Tracking Error 0.107 Treynor Ratio 0.176 Total Fees $0.00 Estimated Strategy Capacity $2600000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
namespace QuantConnect.Algorithm.CSharp
{
public class TradierBrokerageExampleAlgorithm : QCAlgorithm
{
private Symbol _symbol;
public override void Initialize()
{
SetStartDate(2021, 1, 1);
SetCash(100000);
SetBrokerageModel(BrokerageName.TradierBrokerage, 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 quantity
ticket.Cancel();
ticket = LimitOrder(_symbol, 2, data[_symbol].Price * 0.9m, orderProperties: orderProperties);
// Update the order fields that are not the quantity
var orderFields = new UpdateOrderFields {
LimitPrice = data[_symbol].Price * 1.05m,
Tag = "Informative order tag"
};
var response = ticket.Update(orderFields);
if (!LiveMode && response.IsSuccess)
{
Debug("Order updated successfully");
}
}
}
}