adfad475cc
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* refactor: adding OrderId in GroupOrderManger * feat: new support of OrderTypes in TradeStationBrokerageModel feat: unSupported OrderTypes in CanUpdateOrder's TradeStationBrokerageModel * feat: AllOrNone property in TradeStationOrderProperties * feat: unsupported SubmitCrossZero of Combo Order in TSBrokerageModel * test:feat: submit / update CrossZero Combo Orders * feat: new Message Brokerage error message refactor: use new Message in TradeStationBrokerageModel * feat: setter of Id in GroupOrderManager * feat: new constructor of GroupOrderManager * feat: develop GroupOrderCacheManager service * fix: groupOrderManger.Id in OrderProvider * fix: incrementOrderGroupOrderManagerID in BrokerageTransactionHandler feat: add _groupOrderManagerId in OrderProvider * remove: extra semicolon * refactor: prevent increment GroupOrderID * feat: add new Exchanges * feat: Try Get Group Combo Orders extension * refactor: ComboORderType in TSBrokerageModel * remove: implementing of prop ID in GroupOrderManager * refactor: UnsupportedCrossZeroByOrderType message * fix: warning of UnsupportedCrossZeroByOrderType * fix: several exchanges code based on tradier docs https://documentation.tradier.com/brokerage-api/reference/exchanges * feat: add missed Exchange in Global class * refactor: possible update LimitPrice in TSBrokerageModel test:feat: validate upddate LimitPrice of ComboLimit Order * refactor: GroupOrderCacheManager remove: TryGetGroupCachedOrders from extension * refactor: exchange SPHR to MIAX_SAPPHIRE * remove: Exchange BYX cuz It is BATS_Y * refactor: change position of Exchange C2 * refactor: change constructor's access modifier in class Exchange
118 lines
4.0 KiB
C#
118 lines
4.0 KiB
C#
/*
|
|
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
|
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
using System;
|
|
using Newtonsoft.Json;
|
|
using System.Collections.Generic;
|
|
|
|
namespace QuantConnect.Orders
|
|
{
|
|
/// <summary>
|
|
/// Manager of a group of orders
|
|
/// </summary>
|
|
public class GroupOrderManager
|
|
{
|
|
/// <summary>
|
|
/// The unique order group Id
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "id")]
|
|
public int Id { get; internal set; }
|
|
|
|
/// <summary>
|
|
/// The group order quantity
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "quantity")]
|
|
public decimal Quantity { get; internal set; }
|
|
|
|
/// <summary>
|
|
/// The total order count associated with this order group
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "count")]
|
|
public int Count { get; }
|
|
|
|
/// <summary>
|
|
/// The limit price associated with this order group if any
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "limitPrice")]
|
|
public decimal LimitPrice { get; set; }
|
|
|
|
/// <summary>
|
|
/// The order Ids in this group
|
|
/// </summary>
|
|
/// <remarks>In live trading we process orders in a dedicated thread so we need to be thread safe</remarks>
|
|
[JsonProperty(PropertyName = "orderIds")]
|
|
public HashSet<int> OrderIds { get; }
|
|
|
|
/// <summary>
|
|
/// Order Direction Property based off Quantity.
|
|
/// </summary>
|
|
[JsonProperty(PropertyName = "direction")]
|
|
public OrderDirection Direction
|
|
{
|
|
get
|
|
{
|
|
if (Quantity > 0)
|
|
{
|
|
return OrderDirection.Buy;
|
|
}
|
|
if (Quantity < 0)
|
|
{
|
|
return OrderDirection.Sell;
|
|
}
|
|
return OrderDirection.Hold;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the absolute quantity for this combo order
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public decimal AbsoluteQuantity => Math.Abs(Quantity);
|
|
|
|
/// <summary>
|
|
/// Creates a new empty instance
|
|
/// </summary>
|
|
public GroupOrderManager()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of <see cref="GroupOrderManager"/>
|
|
/// </summary>
|
|
/// <param name="id">This order group unique Id</param>
|
|
/// <param name="legCount">The order leg count</param>
|
|
/// <param name="quantity">The group order quantity</param>
|
|
/// <param name="limitPrice">The limit price associated with this order group if any</param>
|
|
public GroupOrderManager(int id, int legCount, decimal quantity, decimal limitPrice = 0) : this(legCount, quantity, limitPrice)
|
|
{
|
|
Id = id;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of <see cref="GroupOrderManager"/>
|
|
/// </summary>
|
|
/// <param name="legCount">The order leg count</param>
|
|
/// <param name="quantity">The group order quantity</param>
|
|
/// <param name="limitPrice">The limit price associated with this order group if any</param>
|
|
public GroupOrderManager(int legCount, decimal quantity, decimal limitPrice = 0)
|
|
{
|
|
Count = legCount;
|
|
Quantity = quantity;
|
|
LimitPrice = limitPrice;
|
|
OrderIds = new(capacity: legCount);
|
|
}
|
|
}
|
|
}
|