Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,11 @@ public void SetTags(HashSet<string> tags)
/// <returns>The command result</returns>
public CommandResultPacket RunCommand(CallbackCommand command) => _baseAlgorithm.RunCommand(command);

/// <summary>
/// Gets the default order properties
/// </summary>
public IOrderProperties DefaultOrderProperties => _baseAlgorithm.DefaultOrderProperties;

/// <summary>
/// Dispose of this instance
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Common/Commands/OrderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class OrderCommand : BaseCommand
public override CommandResultPacket Run(IAlgorithm algorithm)
{
Symbol = GetSymbol(Ticker, SecurityType, Market, Symbol);
var request = new SubmitOrderRequest(OrderType, Symbol.SecurityType, Symbol, Quantity, StopPrice, LimitPrice, DateTime.UtcNow, Tag);
var request = new SubmitOrderRequest(OrderType, Symbol.SecurityType, Symbol, Quantity, StopPrice, LimitPrice, DateTime.UtcNow, Tag, algorithm.DefaultOrderProperties);
var ticket = algorithm.SubmitOrderRequest(request);
var response = ticket.GetMostRecentOrderResponse();
var message = Messages.OrderCommand.CommandInfo(OrderType, Symbol, Quantity, response);
Expand Down
5 changes: 5 additions & 0 deletions Common/Interfaces/IAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -952,5 +952,10 @@ Security AddSecurity(Symbol symbol, Resolution? resolution = null, bool fillForw
/// <param name="command">The callback command instance</param>
/// <returns>The command result</returns>
CommandResultPacket RunCommand(CallbackCommand command);

/// <summary>
/// Gets the default order properties
/// </summary>
IOrderProperties DefaultOrderProperties { get; }
}
}
25 changes: 25 additions & 0 deletions Tests/Common/Commands/OrderCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using QuantConnect.Commands;
using QuantConnect.Data.Market;
using QuantConnect.Tests.Engine.DataFeeds;
using System.Linq;

namespace QuantConnect.Tests.Common.Commands
{
Expand Down Expand Up @@ -73,5 +74,29 @@ public void RunOrderCommand(bool warminUp, bool hasData, bool securityAdded, int
Assert.IsFalse(response.Success);
}
}

[Test]
public void OrderCommandUsesDefaultOrderProperties()
{
var command = new OrderCommand
{
Symbol = Symbols.AAPL,
Quantity = 10,
OrderType = OrderType.Market,
};

var algorithm = new AlgorithmStub();
algorithm.SetFinishedWarmingUp();
var security = algorithm.AddEquity("AAPL");
security.SetMarketPrice(new Tick { Value = 100 });

var response = command.Run(algorithm);
Assert.IsTrue(response.Success);
var ticket = algorithm.Transactions.GetOrderTickets().FirstOrDefault();
Assert.NotNull(ticket);
var orderProperties = ticket.SubmitRequest.OrderProperties;
Assert.NotNull(orderProperties);
Assert.AreEqual(TimeInForce.GoodTilCanceled, orderProperties.TimeInForce);
}
}
}
Loading