Receiving error SE199 on XTB close order api

186 Views Asked by At

I am trying to do close order with xtb api. But I am still receiving error An exception occured: SE199: Internal error and I have no idea what this error means.

public void Sell(long? orderNumber)
{
    TradesResponse tradesResponse = APICommandFactory.ExecuteTradesCommand(connector, true);
    TradeRecord tradeRecordToClose = null;
    foreach (TradeRecord tradeRecord in tradesResponse.TradeRecords)
    {
        if (tradeRecord.Order2 == orderNumber)
        {
            tradeRecordToClose = tradeRecord;
        }
    }

    TradeTransInfoRecord tradeTransInfoRecord = new(
        TRADE_OPERATION_CODE.BUY,
        TRADE_TRANSACTION_TYPE.ORDER_CLOSE,
        tradeRecordToClose.Close_price.GetValueOrDefault(),
        0.0,
        0.0,
        tradeRecordToClose.Symbol,
        0.1,
        tradeRecordToClose.Order.GetValueOrDefault(),
        "close trade",
        0
    );

    var test = APICommandFactory.ExecuteTradeTransactionCommand(connector, tradeTransInfoRecord, true);
}

I am doing it like is shown in docs. But without success. Volume is hardcoded but it corresponds with amount in existing order. I am just getting error response from server and I have no idea why. Thanks for any hints.

1

There are 1 best solutions below

1
Piroozeh On

The error SE199: Internal error means that there is an unexpected problem on the server side that prevents the execution of your command. This could happen because of several reasons, such as:

• The server is overloaded or under maintenance. You can check the status of the server by using the ping command or the serverTime command. You can also contact the XTB support team to report the issue and get more information.

• The command is invalid or incomplete. You can check the syntax and the parameters of the tradeTransaction command and the TradeTransInfoRecord object. You can also use the tradeTransactionStatus command to get the details of the error and the request.

• The account or the order is not valid or authorized. You can check the credentials and the permissions of your account by using the login command and the getMarginLevel command. You can also check the status and the details of your order by using the getTrades command and the getTradeRecords command.

To troubleshoot the issue, you can also enable the debug mode of XTB API by setting the configuration key xtb.api.debug to true. This will print more information about the error and the request details in the log.