public static Transaction CreateCancelFuturesTransaction(this IMessageSessionHolder sessionHolder, OrderGroupCancelMessage message) { if (sessionHolder == null) { throw new ArgumentNullException("sessionHolder"); } if (message == null) { throw new ArgumentNullException("message"); } if (message.PortfolioName.IsEmpty()) { throw new ArgumentException("message"); } if (message.SecurityId.SecurityCode.IsEmpty()) { throw new ArgumentException("message"); } var underlyingSecurityCode = message.GetValue <string>("UnderlyingSecurityCode"); if (underlyingSecurityCode.IsEmpty()) { throw new ArgumentException(LocalizedStrings.Str1850, "message"); } var secType = message.SecurityId.SecurityType; if (secType != SecurityTypes.Future) { throw new ArgumentException(LocalizedStrings.Str1851Params.Put(secType), "message"); } var transaction = new Transaction(TransactionTypes.CancelGroup, message); transaction .SetAccount(message.PortfolioName) .SetBaseContract(underlyingSecurityCode) .SetAction(TransactionActions.KillAllFuturesOrders) .SetClassCode(sessionHolder.GetSecurityClass(message.SecurityId)); if (message.Side != null) { transaction.SetSide(message.Side.Value); } return(transaction); }
public static Transaction CreateCancelFuturesTransaction(this OrderGroupCancelMessage message, IDictionary <string, RefPair <SecurityTypes, string> > securityClassInfo) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (message.PortfolioName.IsEmpty()) { throw new ArgumentException(nameof(message)); } if (message.SecurityId.SecurityCode.IsEmpty()) { throw new ArgumentException(nameof(message)); } var underlyingSecurityCode = message.GetValue <string>("UnderlyingSecurityCode"); if (underlyingSecurityCode.IsEmpty()) { throw new ArgumentException(LocalizedStrings.Str1850, nameof(message)); } var secType = message.SecurityId.SecurityType; if (secType != SecurityTypes.Future) { throw new ArgumentException(LocalizedStrings.Str1851Params.Put(secType), nameof(message)); } var transaction = new Transaction(TransactionTypes.CancelGroup, message); transaction .SetAccount(message.PortfolioName) .SetBaseContract(underlyingSecurityCode) .SetAction(TransactionActions.KillAllFuturesOrders) .SetClassCode(securityClassInfo.GetSecurityClass(message.SecurityId)); if (message.Side != null) { transaction.SetSide(message.Side.Value); } if (!message.BrokerCode.IsEmpty()) { transaction.SetFirmId(message.BrokerCode); } return(transaction); }