# Foreign Exchange

## Overview

This document describes how to integrate the foreign exchange (FX) feature to perform currency conversions between different currencies. The FX process includes two steps: quotation and confirmation, supporting multiple major currencies.

## Business Process

### FX Pre-order (Quotation) Phase

- [FX Pre-order (Quotation)](/collection/apis/openapi/foreign-exchange/fx_preorder): This API retrieves real-time exchange rate quotes and generates an FX order.
- Call the FX pre-order API to get an exchange rate quote
- Confirmation must be completed within the quote validity period; otherwise, a new quotation is required
- Returns an FX order number `order_no` for tracking the business process


### Confirmation Phase

- [FX Confirmation](/collection/apis/openapi/foreign-exchange/fx_confirm): This API confirms and executes the FX transaction.
- Call the FX confirmation API within the quote validity period
- The `order_no` parameter is the FX order number `order_no` returned from the pre-order


### Result Query

- [Query FX Result](/collection/apis/openapi/foreign-exchange/fx_inquiry): This API queries the execution result of an FX transaction.
- Periodically call the query API to obtain the FX result
- The `order_no` parameter is the FX order number `order_no` returned from the pre-order


### Listen for FX Result Notifications

- [FX Result Notification](/collection/apis/openapi/foreign-exchange/fx_notify): **webhook** for receiving asynchronous notifications.
- Listen for callback notifications of type `FOREX`
- The `order_no` in the notification content is the FX order number `order_no` returned from the pre-order


## Notes

- Amount Unit Notes
  - All amounts use the minimum currency unit
  - For example: 100.50 USD should be submitted as 10050
- Exchange Rate Notes
  - The exchange rate represents how many units of the buy currency can be exchanged for 1 unit of the sell currency
  - Exchange rates are kept to 6 decimal places