diff --git a/src/QuikSharp/DataStructures/Transaction/Transaction.cs b/src/QuikSharp/DataStructures/Transaction/Transaction.cs index ee8bedf2..412098d4 100644 --- a/src/QuikSharp/DataStructures/Transaction/Transaction.cs +++ b/src/QuikSharp/DataStructures/Transaction/Transaction.cs @@ -32,7 +32,8 @@ internal void OnTransReplyCall(TransactionReply reply) /// /// TransactionReply /// - public TransactionReply TransactionReply { get; set; } + volatile TransactionReply _transactionReply; + public TransactionReply TransactionReply { get => _transactionReply; set { _transactionReply = value; } } /// /// Функция вызывается терминалом QUIK при получении новой заявки или при изменении параметров существующей заявки. diff --git a/src/QuikSharp/OrderFunctions.cs b/src/QuikSharp/OrderFunctions.cs index 23c3ceb7..84649559 100644 --- a/src/QuikSharp/OrderFunctions.cs +++ b/src/QuikSharp/OrderFunctions.cs @@ -115,14 +115,22 @@ async Task SendOrder(string classCode, string securityCode, string accoun { if (res > 0) { - try - { - order_result = await Quik.Orders.GetOrder_by_transID(classCode, securityCode, res).ConfigureAwait(false); - } - catch - { - order_result = new Order {RejectReason = "Неудачная попытка получения заявки по ID-транзакции №" + res}; - } + if (newOrderTransaction.TransactionReply != null && newOrderTransaction.TransactionReply.ErrorSource != 0) + order_result = new Order + { + RejectReason = + newOrderTransaction.TransactionReply.ResultMsg + ?? $"Transaction {res} error: code {newOrderTransaction.TransactionReply.ErrorCode}, source {newOrderTransaction.TransactionReply.ErrorSource}" + }; + else + try + { + order_result = await Quik.Orders.GetOrder_by_transID(classCode, securityCode, res).ConfigureAwait(false); + } + catch + { + order_result = new Order {RejectReason = "Неудачная попытка получения заявки по ID-транзакции №" + res}; + } } else { @@ -131,6 +139,8 @@ async Task SendOrder(string classCode, string securityCode, string accoun } if (order_result != null && (order_result.RejectReason != "" || order_result.OrderNum > 0)) set = true; + + Thread.Sleep(10); } return order_result;