private void ReadOrderStatus(IBSocket socket, ServerVersions version) { var id = socket.ReadInt(); var status = socket.ReadOrderStatus(); /* filled */ socket.ReadInt(); var balance = socket.ReadDecimal(); var avgPrice = socket.ReadDecimal(); var permId = version >= ServerVersions.V2 ? socket.ReadInt() : (int?)null; var parentId = version >= ServerVersions.V3 ? socket.ReadInt() : (int?)null; var lastTradePrice = version >= ServerVersions.V4 ? socket.ReadDecimal() : (decimal?)null; var clientId = version >= ServerVersions.V5 ? socket.ReadInt() : (int?)null; var whyHeld = version >= ServerVersions.V6 ? socket.ReadStr() : null; var execMsg = new ExecutionMessage { ExecutionType = ExecutionTypes.Transaction, OriginalTransactionId = id, Balance = balance, OrderStatus = status, OrderState = status.ToOrderState(), HasOrderInfo = true, }; execMsg.SetAveragePrice(avgPrice); if (permId != null) execMsg.SetPermId(permId.Value); if (parentId != null) execMsg.Condition = new IBOrderCondition { ParentId = parentId.Value }; if (lastTradePrice != null) execMsg.SetLastTradePrice(lastTradePrice.Value); if (clientId != null) execMsg.SetClientId(clientId.Value); if (whyHeld != null) execMsg.SetWhyHeld(whyHeld); SendOutMessage(execMsg); }