Profile Picture

TWS ignored partial fills code fix

Posted By alpha23 5 Years Ago
Message
Posted Thursday December 13 2012
Others may have experience partial fills that are ignored when they shouldn't be. After talking with IB, the problem lies in the commented 'if' statement below which is in the client_ExecDetails method of the TWS plugin. Below that, I've included a suggested fix for the issue which includes the cumulative quantity in the check. This check needs to be deferred after the fills in OpenOrders have been looped though because there is no guarantee of the fill ordering. The new code has not been fully tested, and there is no guarantee on the new code, but its at least a place for you to start if you are experiencing the same issue.

Duane

//foreach (Fill fill in openOrder.Fills)
//{
// if (fill.FillDateTime == execDateTime && fill.Price.SymbolPrice == e.Execution.Price && fill.Quantity == e.Execution.Shares)
// {
// alreadyReported = true;
// Log(openOrder, "ExecDetails", "### Execution Ignored - this fill appears to have been reported already");
// }
//}

bool alreadyReported = false;
long cumQuantity = 0;
bool similarFill = true;
foreach (Fill fill in openOrder.Fills){
cumQuantity += fill.Quantity;
if (fill.FillDateTime != execDateTime || fill.Price.SymbolPrice != e.Execution.Price || fill.Quantity != e.Execution.Shares){
similarFill = false;
}
}
if (similarFill && cumQuantity != e.Execution.CumQuantity){
Log(openOrder, "ExecDetails", "### Execution Ignored - this fill appears to have been reported already");
}


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems