I'm getting the following error in my unmanaged strategy:
"Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock."
This strategy has been working for several days under Playback connection while under development, and this error just started appearing. Below is code snippet showing where it's occurring. This is in OnExecutionUpdate:
...
(ShortEntryOrder1 != null) && (ShortEntryOrder1 == execution.Order))
if ((execution.Order.OrderState == OrderState.Filled) ||
(execution.Order.OrderState == OrderState.PartFilled) ||
(execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
// book keeping code
...
if (execution.Order.Name == ShortTag1)
{
// more book keeping code, e.g. set target and stop values, ensure above/below current bid ask, etc.
...
// Submit exit orders for partial fills
if (execution.Order.OrderState == OrderState.PartFilled)
{
string _ocoString = string.Format("unmamangedexitoco{0}", DateTime.Now.ToString("hhmmssffff"));
try
{
TargetOrder1 = SubmitOrderUnmanaged(
0,
OrderAction.BuyToCover,
OrderType.Limit,
execution.Order.Filled,
execution.Order.AverageFillPrice - (targetTicks * TickSize),
0,
_ocoString,
TargetTag1);
}
catch (Exception e)
{
ERROR CAUGHT HERE
Debugger.Break();
if (State >= State.Terminated) return;
}
try
{
StopOrder1 = SubmitOrderUnmanaged(
0,
OrderAction.BuyToCover,
OrderType.StopMarket,
execution.Order.Filled,
0,
LastSetStop1Price,
_ocoString,
StopTag1);
}
catch (Exception e)
{
Debugger.Break();
if (State >= State.Terminated) return;
}
Short1OrderFilled += execution.Order.Filled;
}
else
if (execution.Order.OrderState == OrderState.Filled && SumFilledOrder1 == execution.Order.Filled)
{
... same as PartFilled with adjustments for quantities already filled
Apologies for lack of indentions, your portal seems to strip them out.
Any ideas what might be causing this and what to look at?
Thanks.
Comment