createDeal
POST
: /amsin/api/v1/business/fund/createDeal
集成商调用此接口创建远期外汇交易。
远期外汇交易为异步。调用此接口后,万里汇返回集成商本次API调用结果。集成商需调用inquiryDeal接口查询远期交易结果,或等待万里汇用notifyDeal接口发送通知。
接口结构
万里汇接口报文结构包括:请求头,请求体。关于头信息,详见:
请求参数
字段名 | 数据类型 | 是否必填 | 描述 |
customerId | 字符串 | 是 | 由万里汇定义,用于唯一标识某万里汇账户。 更多信息:
|
dealRequestId | 字符串 | 是 | 由集成商定义的外汇交易唯一单号 更多信息:
|
sell | Amount 对象 | 是 | 外汇交易卖出金额 |
buy | Amount 对象 | 是 | 外汇交易购买金额 |
exchangeTradeType | 字符串 | 否 | 外汇交易类型。可选值如下:
如果该字段未赋值,则默认为 |
marginCurrency | 字符串 | 否(有使用条件) | 代表保证金币种,为符合ISO-4217规范的三字母货币代码。如: 更多信息:
|
quote | Quote 对象 | 是 | 本次外汇交易的汇率信息 |
forwardType | 字符串 | 是 | 远期外汇交易的汇率类型。当 exchangeTradeType =
关于字段枚举值,详见:ForwardType |
windowStartTime | DateTime 对象 | 否(有使用条件) | 窗口模式下汇率的开始时间。当 更多信息:
|
expiredTime | DateTime 对象 | 是 | 汇率过期时间,也即完成本次外汇交易的最晚时间。 更多信息:
|
响应参数
字段名 | 数据类型 | 是否必填 | 描述 |
result | Result 对象 | 是 | 代表接口调用结果 |
responseId | 字符串 | 是 | 由万里汇定义,用于唯一标识某次响应的ID。 更多信息:
|
deal | Deal 对象 | 是 | 远期外汇交易的交易明细 |
响应处理
集成商调用接口后,万里汇返回集成商API调用结果。result.resultStatus
字段取值范围为:
result.resultStatus | 描述 |
S | API请求成功。
|
F | API请求失败。 失败原因参见结果码(即 |
U | API响应结果为 |
结果码
result.resultCode
系统结果码
resultCode | resultStatus | resultMessage | 处理建议 |
PROCESSING | S | Create deal successfully. | |
PARAM_ILLEGAL | F | Illegal parameters exist. For example, a non-numeric input, or an invalid date. | 参考API文档页面,确认请求头和传参是否正确 |
PROCESS_FAIL | F | A general business failure occurred. Do not retry. | 需要人工介入,联系万里汇技术支持以解决此问题 |
UNKNOWN_EXCEPTION | U | API failed due to unknown reason. | 服务器错误,若稍后重试问题依旧,联系万里汇技术支持以解决问题 |
REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. | 重试,若问题依旧,联系万里汇技术支持 |
INVALID_API | F | The called API is invalid or not active. | 确认是否调用正确的API |
INVALID_CLIENT | F | The client is invalid. | Client ID不存在或无效 |
INVALID_SIGNATURE | F | The signature is invalid. | 确认请求正确加签,具体参见: |
METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. | 确认HTTP请求方法为 |
业务结果码
resultCode | resultStatus | resultMessage | Further action |
UN_SUPPORT_BUSINESS | F | Unsupported business. | 包含无效参数(如货币代码错误),使用正确的参数重试 |
AUTHORIZATION_NOT_EXIST | F | The authorization does not exist. | 当前授权关系不存在,请联系万里汇技术支持检查授权关系 |
REPEAT_REQ_INCONSISTENT | F | Repeated requests are inconsistent. | 确认请求中所有参数一致重试 |
CONTRACT_CHECK_FAIL | F | The contract check has failed. | 检查合约状态后重试 |
范例
请求
请求体范例
{
"customerId": "2121120000837133",
"dealRequestId": "05a3a751-fbae-4885-ba57-020ad5f86968",
"sell": {
"currency": "USD",
"value": 1000
},
"buy": {
"currency": "EUR",
"value": 913
},
"exchangeTradeType": "UNFUNDED_SPOT",
"expiredTime": "20230412",
"quote": {
"quoteCurrencyPair": "EUR/USD",
"quoteExpiryTime": "2023-04-10T13:31:09Z",
"quoteId": "2023041009141210000131304678347",
"quotePrice": "1.09585",
"quoteStartTime": "2023-04-10T13:30:39Z"
}
}
请求代码范例
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\"}");
响应
响应体范例
{
"deal": {
"buy": {
"currency": "EUR",
"value": 913
},
"dealId": "2023041019121000110130000080299",
"dealRequestId": "05a3a751-fbae-4885-ba57-020ad5f86968",
"exchangeTradeType": "UNFUNDED_SPOT",
"expiredTime": "20230412",
"quote": {
"quoteCurrencyPair": "EUR/USD",
"quoteExpiryTime": "2023-04-10T13:31:09Z",
"quoteId": "2023041009141210000131304678347",
"quotePrice": "1.09585",
"quoteStartTime": "2023-04-10T13:30:39Z"
},
"sell": {
"currency": "USD",
"value": 1000
}
},
"responseId": "06030b7a1681133444461282121786",
"result": {
"resultStatus": "S",
"resultCode": "PROCESSING",
"resultMessage": "request is processing."
}
}