diff --git a/Common/Orders/TerminalLinkOrderProperties.cs b/Common/Orders/TerminalLinkOrderProperties.cs index 44b9a43105b6..333133dc0fa0 100644 --- a/Common/Orders/TerminalLinkOrderProperties.cs +++ b/Common/Orders/TerminalLinkOrderProperties.cs @@ -74,6 +74,20 @@ public class TerminalLinkOrderProperties : OrderProperties /// public string Broker { get; set; } + /// + /// The EMSX locate broker code identifying the counterparty the shares are being borrowed + /// from for a short sale (EMSX_LOCATE_BROKER, e.g. "BMTB"). Maps to the LocBrkr field on + /// the EMSX trading ticket. Setting this (or ) on a short equity sale + /// causes the brokerage to emit EMSX_LOCATE_REQ = "Y" alongside. + /// + public string LocateBroker { get; set; } + + /// + /// The EMSX locate confirmation/ticket id returned by the lending broker (EMSX_LOCATE_ID). + /// Maps to the LocId field on the EMSX trading ticket. + /// + public string LocateId { get; set; } + /// /// The EMSX order strategy details. /// Strategy parameters must be appended in the correct order as expected by EMSX. diff --git a/Tests/Common/Orders/TerminalLinkOrderPropertiesTests.cs b/Tests/Common/Orders/TerminalLinkOrderPropertiesTests.cs index 034e5b846559..df86a02882d1 100644 --- a/Tests/Common/Orders/TerminalLinkOrderPropertiesTests.cs +++ b/Tests/Common/Orders/TerminalLinkOrderPropertiesTests.cs @@ -65,5 +65,40 @@ def getOrderProperties() -> TerminalLinkOrderProperties: Assert.IsNull(orderProperties.Strategy.Fields[3].Value); } } + + [Test] + public void LocateFieldsDefaultToEmpty() + { + // Locate fields are only meaningful for Reg SHO short equity sales; for any other + // order they must be unset so the brokerage doesn't emit EMSX_LOCATE_* on the request. + var properties = new TerminalLinkOrderProperties(); + Assert.IsNull(properties.LocateBroker); + Assert.IsNull(properties.LocateId); + } + + [Test] + public void SetsLocateFieldsFromPython() + { + using (Py.GIL()) + { + var module = PyModule.FromString("locateFieldsModule", + @" +from AlgorithmImports import * + +def getOrderProperties() -> TerminalLinkOrderProperties: + properties = TerminalLinkOrderProperties() + properties.LocateBroker = ""BMTB"" + properties.LocateId = ""LOC-123"" + return properties +"); + + dynamic getOrderProperties = module.GetAttr("getOrderProperties"); + var properties = (TerminalLinkOrderProperties)getOrderProperties(); + + Assert.IsNotNull(properties); + Assert.AreEqual("BMTB", properties.LocateBroker); + Assert.AreEqual("LOC-123", properties.LocateId); + } + } } }