XTB icon

XTB

Interact with XTB Trading API. Supports Account resources.

Overview

This node interacts with the XTB Trading API to perform various trading-related calculations. Specifically, for the Calculation resource and the Get Profit Calculation operation, it calculates the profit or loss of a trade based on parameters such as symbol, volume, open price, close price, and command type.

Typical use cases include:

  • Determining the profit or loss of a completed trade.
  • Automating trade performance analysis within workflows.
  • Integrating real-time profit calculation into trading bots or dashboards.

For example, a trader could input the details of a closed position (symbol, volume, open/close prices, and trade command) to instantly get the profit result without manual calculation.

Properties

Name Meaning
Symbol The trading symbol (e.g., currency pair or asset) for which to calculate profit.
Volume The size or amount of the trade position.
Close Price The closing price of the trade position.
Command The command type of the trade (e.g., buy or sell).
Open Price The opening price of the trade position.

Output

The node outputs an array of JSON objects where each object contains the result of the profit calculation for the corresponding input item.

The json output field typically includes:

  • Calculated profit or loss value.
  • Possibly additional metadata related to the calculation (depending on the underlying API response).

No binary data output is produced by this operation.

Dependencies

  • Requires connection to the XTB Trading API via a WebSocket manager.
  • Needs valid API credentials (an API key or authentication token) configured in n8n to authenticate requests.
  • Depends on the external package @sharplygroup/xtb-api-js for API operations.

Troubleshooting

  • Connection errors: Ensure that the API credentials are correct and that the network allows WebSocket connections to the XTB API endpoint.
  • Invalid parameters: Verify that all required properties (symbol, volume, open price, close price, command) are provided and correctly formatted.
  • Unknown resource or operation errors: Confirm that the Resource is set to "Calculation" and Operation to "Get Profit Calculation".
  • API rate limits or downtime: If the API returns errors related to limits or service availability, retry after some time or check the API status.

Links and References

Discussion