Treasury¶
In this chapter we will show examples of making a forex trade
Schedule Currency Trading¶
Create a new trade by using the scheduleCurrencyTrading
mutation. This mutation will create a new trade in the 360t system.
xxxxxxxxxx
mutation ScheduleCurrencyTrading($schedule: ScheduleCurrencyTradingInput!) {
scheduleCurrencyTrading(schedule: $schedule) {
waitToken
}
}
xxxxxxxxxx
{
"schedule":
{
"idempotencyKey": "4197648852711",
"nominalCurrency": "EUR",
"currencyToBuy": "EUR",
"currencyToPayWith": "USD",
"amount": 100000000
}
}
{
"data": {
"scheduleCurrencyTrading": {
"waitToken": "56f33e27-0469-46d1-9e4f-352e4e1948c6"
}
}
}
For details of what each input field means, you can check ScheduleCurrencyTradingInput.
The waitToken
in the response can be used to check for the status of the trade.
By using the fxForward
query, you can get the status and execution details.
xxxxxxxxxx
query FxForwardDetails($waitToken: bigint!) {
fxForward(where: {id: {_eq: $waitToken}}) {
amount
createdAt
currencyToBuy
currencyToPayWith
errorMessage
fxForwardExecutions {
executedQuoteId
executedRate
spotRate
forwardPoints
id
orderId
settleDate
}
nominalCurrency
settlementDate
status
id
}
}
xxxxxxxxxx
{
"waitToken": "12345"
}
xxxxxxxxxx
{
"data": {
"fxForward": [{
"amount": "100000000",
"createdAt": "2024-11-11T14:42:45.315318+00:00",
"currencyToBuy": "EUR",
"currencyToPayWith": "USD",
"errorMessage": null,
"fxForwardExecutions": [
{
"executedQuoteId": "2-000004",
"executedRate": "1.05031",
"spotRate": "1.05031",
"forwardPoints": null,
"id": "2",
"orderId": "2",
"settleDate": "2024-11-18"
}
],
"nominalCurrency": "EUR",
"settlementDate": "2024-11-18",
"status": "success",
"id": "12345"
}]
}
}
Webhook Notifications¶
Kronor will send notifications to the webhook URL provided by the merchant. The notification will be sent when the trade status changes.
The notification will be a POST request with the following payload:
{
"events": [
{
"event": "fxForwardUpdateEvent",
"id": "123456",
"triggeredAt": "2024-11-11T14:42:45.315318+00:00",
"additionalData": [{
"amount": 100000000,
"createdAt": "2024-11-11T14:42:45.315318+00:00",
"currencyToBuy": "EUR",
"currencyToPayWith": "USD",
"desiredQuotes": 4,
"errorMessage": null,
"fxForwardExecutionDetail": {
"executedQuoteId": "2-000004",
"executedRate": "1.05031",
"spotRate": "1.05031",
"forwardPoints": null,
"executionId": "457021057",
"id": 2,
"orderId": "2",
"settleDate": "2024-11-18"
}],
"nominalCurrency": "EUR",
"settlementDate": "2024-11-18",
"status": "success",
"id": 12345
}
}
]
}