Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LT-5364 - ExternalOrderWasNotExecuted as warning #536

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2019 Lykke Corp.
// See the LICENSE file in the project root for more information.

using System;
using MarginTrading.Backend.Contracts.ExchangeConnector;

namespace MarginTrading.Backend.Core.Exceptions
{
public class ExternalOrderWasNotExecuted : Exception
{
public ExternalOrderWasNotExecuted(ExecutionReport executionResult) : base($"External order was not executed. Status: {executionResult.ExecutionStatus}. Failure: {executionResult.FailureType}")
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Common;
using Common.Log;
using Lykke.Common.Log;
using MarginTrading.Backend.Contracts.ExchangeConnector;
using MarginTrading.Backend.Core;
using MarginTrading.Backend.Core.Exceptions;
Expand All @@ -23,6 +24,7 @@
using MarginTrading.Common.Extensions;
using MarginTrading.Common.Services;
using MarginTrading.Common.Settings;
using Microsoft.Extensions.Logging;
using OrderType = MarginTrading.Backend.Contracts.ExchangeConnector.OrderType;

namespace MarginTrading.Backend.Services.MatchingEngines
Expand Down Expand Up @@ -143,8 +145,7 @@ public async ValueTask<MatchedOrderCollection> MatchOrderAsync(OrderFulfillmentP

if (!executionResult.Success)
{
var ex = new Exception(
$"External order was not executed. Status: {executionResult.ExecutionStatus}. Failure: {executionResult.FailureType}");
var ex = new ExternalOrderWasNotExecuted(executionResult);
tarurar marked this conversation as resolved.
Show resolved Hide resolved
LogOrderExecutionException(order, externalOrderModel, ex);
}
else
Expand Down Expand Up @@ -198,9 +199,17 @@ private void LogOrderExecutionException(Order internalOrder, OrderModel external
? "Fake"
: _exchangeConnectorServiceClient.ServiceUrl;

_log.WriteError(
$"{nameof(StpMatchingEngine)}:{nameof(MatchOrderAsync)}:{connector}",
$"Internal order: {internalOrder.ToJson()}, External order model: {externalOrderModel.ToJson()}", ex);
var process = $"{nameof(StpMatchingEngine)}:{nameof(MatchOrderAsync)}:{connector}";
var context = $"Internal order: {internalOrder.ToJson()}, External order model: {externalOrderModel.ToJson()}";

if (ex is ExternalOrderWasNotExecuted)
{
_log.WriteWarning(process, context, string.Empty ,ex);
}
else
{
_log.WriteError(process, context, ex);
}
}

public (string externalProviderId, decimal? price) GetBestPriceForOpen(string assetPairId, decimal volume)
Expand Down
Loading