From 755f0ab834760c90504ba49bb28a80891481f4fb Mon Sep 17 00:00:00 2001 From: oleg-dixon <199400373+oleg-dixon@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:11:31 +0500 Subject: [PATCH] =?UTF-8?q?Tinvest.new=5Forder:=20=D0=BF=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B8=D0=BC=D0=B0=D1=82=D1=8C=20=D1=81=D1=82=D0=B0=D1=82=D1=83?= =?UTF-8?q?=D1=81=D1=8B=20FILL=20=D0=B8=20PARTIALLYFILL=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=B3=D0=BD=D0=BE=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=BC=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit На боевом контуре PostOrder для рыночной заявки сразу возвращает EXECUTION_REPORT_STATUS_FILL. Раньше успехом считался только статус NEW, поэтому new_order возвращал False для уже исполненной заявки, а BackTrader/Broker.py помечал её как отклонённую при открытой позиции. Ветка лимитной заявки приведена к тому же правилу. --- Brokers/Tinvest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Brokers/Tinvest.py b/Brokers/Tinvest.py index 254f206..ffd3a76 100644 --- a/Brokers/Tinvest.py +++ b/Brokers/Tinvest.py @@ -176,7 +176,7 @@ def new_order(self, order): request = PostOrderRequest(instrument_id=symbol.broker_info['figi'], quantity=quantity, direction=direction, account_id=self.account_id, order_type=OrderType.ORDER_TYPE_MARKET, order_id=order_id) response: PostOrderResponse = self.provider.call_function(self.provider.stub_orders.PostOrder, request) # Отправляем рыночную заявку брокеру - if response.execution_report_status == OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_NEW: # Должен вернуться статус "Новая" + if response.execution_report_status in (OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_NEW, OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_FILL, OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_PARTIALLYFILL): # Новая, а при мгновенном исполнении - исполнена или частично исполнена order.id = response.order_id # Уникальный код заявки order.status = Order.Submitted # Заявка отправлена брокеру self.orders.append(order) # Добавляем новую заявку в список заявок @@ -186,7 +186,7 @@ def new_order(self, order): request = PostOrderRequest(instrument_id=symbol.broker_info['figi'], quantity=quantity, price=price, direction=direction, account_id=self.account_id, order_type=OrderType.ORDER_TYPE_LIMIT, order_id=order_id) response: PostOrderResponse = self.provider.call_function(self.provider.stub_orders.PostOrder, request) # Отправляем лимитную заявку брокеру - if response.execution_report_status == OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_NEW: # Должен вернуться статус "Новая" + if response.execution_report_status in (OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_NEW, OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_FILL, OrderExecutionReportStatus.EXECUTION_REPORT_STATUS_PARTIALLYFILL): # Новая, а при мгновенном исполнении - исполнена или частично исполнена order.id = response.order_id # Уникальный код заявки order.status = Order.Submitted # Заявка отправлена брокеру self.orders.append(order) # Добавляем новую заявку в список заявок