Create an FX forward deal
POST
: /amsin/api/v1/business/fund/createDeal
The Partner can use this API to create a forward deal.
The process is asynchronous. WorldFirst responds to the Partner that the forward deal is being processed, rather than the final result of the forward deal.
To query the forward deal result, a Partner can utilize the inquiryDeal interface.
WorldFirst sends the notification about the forward deal result with the notifyDeal interface.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description |
customerId | String | Yes | The unique ID that is assigned by WorldFirst to identify a Customer. More information:
|
dealRequestId | String | Yes | The unique ID that is assigned by the Partner to identify a deal request. Note:
More information:
|
sell | Amount object | Yes | The amount to sell. |
buy | Amount object | Yes | The amount to buy. |
marginCurrency | String | Yes | 3-character ISO 4217 currency code that represents the margin currency used. For example, More information:
|
quote | Quote object | Yes | Information with regard to the quote, such as the currency pair used, the expiry time of the quote, etc. |
forwardType | String | Yes | The type of the forward quote. Possible values are:
For the full list, refer to forwardType. |
windowStartTime | DateTime object | Yes(Conditional) | Indicates the start time of the window. Note:
|
expiredTime | DateTime object | Yes | Ending time of a valid transaction time period. The value of this field is the same as Note:
|
Response parameters
Result processing logic
After calling the API, a response is returned. The possible responses for result.resultStatus
are:
Result status | Description |
S | This indicates the API call succeeded.
|
F | This indicates the API call failed. For more information on why the call failed, see |
U | This indicates the API call result is unknown. Call the inquiryDeal API to check the deal status. |
Result codes
result.resultCode
System-related result codes
resultCode | resultStatus | resultMessage | Further action |
PROCESSING | S | Request is processing. | The forward deal is created successfully and being processed. Call the inquiryDeal API for the forward deal result. |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. | Check and verify whether the request fields, including the header fields and body fields, are correct and valid. For details on the fields of each API, see the specific API Structure section. |
PROCESS_FAIL | F | A general business failure occurred. Do not retry. | Human intervention is usually needed. It is recommended that you contact our Technical Support Team to resolve the issue. |
UNKNOWN_EXCEPTION | U | The API call is failed, which is caused by unknown reasons. | The service might be down, retry later. If the issue persists, contact our Technical Support Team. |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. | Call the interface again to resolve the issue. If the issue persists, contact our Technical Support Team. |
OAUTH_FAIL | F | OAuth process failed. | Contact WorldFirst Technical Support for detailed reasons. |
INVALID_API | F | The called API is invalid or not active. | Check whether the correct API is being called. |
INVALID_CLIENT | F | The client is invalid. | The Client ID does not exist or is invalid. |
INVALID_SIGNATURE | F | The signature is invalid. | Make sure the request is properly signed with a valid signature. |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. | Ensure the HTTP method is |
Business-related result codes
resultCode | resultStatus | resultMessage | Further action |
INVALID_ACCESS_TOKEN | F | Invalid access token | Check whether the accessToken is correct. |
UN_SUPPORT_BUSINESS | F | Unsupported business. | Invalid parameters are used e.g. currency is incorrect. Retry with the correct information. |
REPEAT_REQ_INCONSISTENT | F | Repeated requests are inconsistent. | Ensure all the fields in the requests are the same. |
CONTRACT_CHECK_FAIL | F | The contract check has failed. | Check the contract status before retrying. |
Samples
Request
Request body sample
{
"customerId": "*****",
"dealRequestId": "*****",
"sell": {
"currency": "USD",
"value": 1000
},
"buy": {
"currency": "EUR",
"value": 588
},
"marginCurrency": "USD",
"quote": {
"quoteCurrencyPair": "EUR/USD",
"quoteExpiryTime": "2022-07-26T11:32:22Z",
"quoteId": "******",
"quotePrice": "1.7",
"quoteStartTime": "2022-07-26T09:32:22Z"
},
"expiredTime": "20220819",
"forwardType": "WINDOWED",
"windowStartTime": "20220801"
}
Request calling samples
var jsonStr="{\"customerId\":\"*****\",\"dealRequestId\":\"*****\",\"sell\":{\"currency\":\"USD\",\"value\":1000},\"buy\":{\"currency\":\"EUR\",\"value\":588},\"marginCurrency\":\"USD\",\"quote\":{\"quoteCurrencyPair\":\"EUR/USD\",\"quoteExpiryTime\":\"2022-07-26T11:32:22Z\",\"quoteId\":\"*****\",\"quotePrice\":\"1.7\",\"quoteStartTime\":\"2022-07-26T09:32:22Z\"},\"expiredTime\":\"20220819\",\"forwardType\":\"WINDOWED\",\"windowStartTime\":\"20220801\"}";
var client = new RestClient("http://{domain_name}.com/amsin/api/v1/business/fund/createDeal");
var request = new RestRequest(Method.POST);
request.AddHeader("client-id","*****");
request.AddHeader("request-time","2022-05-17T11:19:20+08:00");
request.AddHeader("Content-Type","application/json");
request.AddHeader("signature","algorithm=RSA256,keyVersion=1,signature=RckSOIrxy%2FKqC%2FZQOO0t74U9U4TFVYKmW%2FZflFRut7W1hipos3NLBGdpzbulcc5Q7XwZP1t3qgTZMFrC%2FlzOQCOsBhUgelvEAuACu49PEGiAus8sU%2FFJa1HOIUmst3oWjLT%2BDqY083mR7jVwc5O2JYP08wNCLu55PFZtXHBUfwEAYoZInhgRoLtQTr%2F7Bphd7L9cS3xD3tluxbgkcaFr7NQVrfWJuQKp%2BFrabo6xZr%2FRHZRd%2FijALuUYYjXH92n4VFwSXSO%2B%2BUBVPoGyWWz1q3QJ2tHNVU7wpc3wtCwwB76pNfGTbJit%2BdylGU8O5UkW3TwSkNnpzepRABM8bBQpgQ%*****");
request.AddParameter("application/json; charset=utf-8", jsonStr, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
url = "http://{domain_name}.com/amsin/api/v1/business/fund/createDeal"
headers = {
"client-id": "*****",
"request-time": "2022-05-17T11:19:20+08:00",
"Content-Type": "application/json",
"signature": "algorithm=RSA256,keyVersion=1,signature=RckSOIrxy%2FKqC%2FZQOO0t74U9U4TFVYKmW%2FZflFRut7W1hipos3NLBGdpzbulcc5Q7XwZP1t3qgTZMFrC%2FlzOQCOsBhUgelvEAuACu49PEGiAus8sU%2FFJa1HOIUmst3oWjLT%2BDqY083mR7jVwc5O2JYP08wNCLu55PFZtXHBUfwEAYoZInhgRoLtQTr%2F7Bphd7L9cS3xD3tluxbgkcaFr7NQVrfWJuQKp%2BFrabo6xZr%2FRHZRd%2FijALuUYYjXH92n4VFwSXSO%2B%2BUBVPoGyWWz1q3QJ2tHNVU7wpc3wtCwwB76pNfGTbJit%2BdylGU8O5UkW3TwSkNnpzepRABM8bBQpgQ%*****"
}
datas ={"customerId":"*****","dealRequestId":"*****","sell":{"currency":"USD","value":1000},"buy":{"currency":"EUR","value":588},"marginCurrency":"USD","quote":{"quoteCurrencyPair":"EUR/USD","quoteExpiryTime":"2022-07-26T11:32:22Z","quoteId":"*****","quotePrice":"1.7","quoteStartTime":"2022-07-26T09:32:22Z"},"expiredTime":"20220819","forwardType":"WINDOWED","windowStartTime":"20220801"}
res = requests.post(url=url, data=json.dumps(datas), headers=headers)
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("http://{domain_name}.com/amsin/api/v1/business/fund/createDeal");
httpPost.addHeader("client-id", "******");
httpPost.addHeader("request-time", "2022-05-17T11:19:20+08:00");
httpPost.addHeader("signature","algorithm=RSA256,keyVersion=1,signature=RckSOIrxy%2FKqC%2FZQOO0t74U9U4TFVYKmW%2FZflFRut7W1hipos3NLBGdpzbulcc5Q7XwZP1t3qgTZMFrC%2FlzOQCOsBhUgelvEAuACu49PEGiAus8sU%2FFJa1HOIUmst3oWjLT%2BDqY083mR7jVwc5O2JYP08wNCLu55PFZtXHBUfwEAYoZInhgRoLtQTr%2F7Bphd7L9cS3xD3tluxbgkcaFr7NQVrfWJuQKp%2BFrabo6xZr%2FRHZRd%2FijALuUYYjXH92n4VFwSXSO%2B%2BUBVPoGyWWz1q3QJ2tHNVU7wpc3wtCwwB76pNfGTbJit%2BdylGU8O5UkW3TwSkNnpzepRABM8bBQpgQ%*****" );
httpPost.addHeader("Content-Type","application/json");
StringEntity entity = new StringEntity("{\"customerId\":\"*****\",\"dealRequestId\":\"*****\",\"sell\":{\"currency\":\"USD\",\"value\":1000},\"buy\":{\"currency\":\"EUR\",\"value\":588},\"marginCurrency\":\"USD\",\"quote\":{\"quoteCurrencyPair\":\"EUR/USD\",\"quoteExpiryTime\":\"2022-07-26T11:32:22Z\",\"quoteId\":\"******\",\"quotePrice\":\"1.7\",\"quoteStartTime\":\"2022-07-26T09:32:22Z\"},\"expiredTime\":\"20220819\",\"forwardType\":\"WINDOWED\",\"windowStartTime\":\"20220801\"}");
httpPost.setEntity(entity);
CloseableHttpResponse response = client.execute(httpPost);
var xhr = new XMLHttpRequest;
xhr.open("POST","http://{domain_name}.com/amsin/api/v1/business/fund/createDeal",true)
xhr.setRequestHeader("client-id","*****");
xhr.setRequestHeader("request-time","2022-05-17T11:19:20+08:00");
xhr.setRequestHeader("Content-Type","application/json");
xhr.setRequestHeader("signature","algorithm=RSA256,keyVersion=1,signature=RckSOIrxy%2FKqC%2FZQOO0t74U9U4TFVYKmW%2FZflFRut7W1hipos3NLBGdpzbulcc5Q7XwZP1t3qgTZMFrC%2FlzOQCOsBhUgelvEAuACu49PEGiAus8sU%2FFJa1HOIUmst3oWjLT%2BDqY083mR7jVwc5O2JYP08wNCLu55PFZtXHBUfwEAYoZInhgRoLtQTr%2F7Bphd7L9cS3xD3tluxbgkcaFr7NQVrfWJuQKp%2BFrabo6xZr%2FRHZRd%2FijALuUYYjXH92n4VFwSXSO%2B%2BUBVPoGyWWz1q3QJ2tHNVU7wpc3wtCwwB76pNfGTbJit%2BdylGU8O5UkW3TwSkNnpzepRABM8bBQpgQ%*****");
xhr.send("{\"customerId\":\"*****\",\"dealRequestId\":\"*****\",\"sell\":{\"currency\":\"USD\",\"value\":1000},\"buy\":{\"currency\":\"EUR\",\"value\":588},\"marginCurrency\":\"USD\",\"quote\":{\"quoteCurrencyPair\":\"EUR/USD\",\"quoteExpiryTime\":\"2022-07-26T11:32:22Z\",\"quoteId\":\"*****\",\"quotePrice\":\"1.7\",\"quoteStartTime\":\"2022-07-26T09:32:22Z\"},\"expiredTime\":\"20220819\",\"forwardType\":\"WINDOWED\",\"windowStartTime\":\"20220801\"}");
Response
Response body sample
{
"deal": {
"buy": {
"currency": "EUR",
"value": 588
},
"creditLine": {
"currency": "USD",
"value": 0
},
"creditLineBase": {
"currency": "GBP",
"value": 0
},
"dealId": "*****",
"dealRequestId": "*****",
"expiredTime": "20220819",
"forwardType": "WINDOWED",
"margin": {
"currency": "USD",
"value": 50
},
"quote": {
"quoteCurrencyPair": "EUR/USD",
"quoteExpiryTime": "2022-07-26T11:32:22Z",
"quoteId": "*****",
"quotePrice": "1.7",
"quoteStartTime": "2022-07-26T09:32:22Z"
},
"sell": {
"currency": "USD",
"value": 1000
},
"windowStartTime": "20220801"
},
"responseId": "*****",
"result": {
"resultCode": "PROCESSING",
"resultMessage": "request is processing.",
"resultStatus": "S"
}
}