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
14 changes: 14 additions & 0 deletions Common/Orders/TerminalLinkOrderProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ public class TerminalLinkOrderProperties : OrderProperties
/// </summary>
public string Broker { get; set; }

/// <summary>
/// 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 <see cref="LocateId"/>) on a short equity sale
/// causes the brokerage to emit EMSX_LOCATE_REQ = "Y" alongside.
/// </summary>
public string LocateBroker { get; set; }

/// <summary>
/// The EMSX locate confirmation/ticket id returned by the lending broker (EMSX_LOCATE_ID).
/// Maps to the LocId field on the EMSX trading ticket.
/// </summary>
public string LocateId { get; set; }

/// <summary>
/// The EMSX order strategy details.
/// Strategy parameters must be appended in the correct order as expected by EMSX.
Expand Down
35 changes: 35 additions & 0 deletions Tests/Common/Orders/TerminalLinkOrderPropertiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Loading