Skip to main content

Create your first hedge

After sharing your historical business transactions and creating your customers, you can start hedging transactions. At Grain, hedging is a two steps process - Get quote, and then Accept quote, as follows

1. Get quote

First, get a quote for your cross currency business transaction. The quote can be used to display a product price to your customers in a local currency. Grain’s offers 2 methods for pulling the quotes:

a. Single quote

Pull an online quote on demand for a specific due date, with a default expiration of 5 minutes. Get the local currency price using the get quote endpoint:

curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/quote \
--header "Content-Type: application/json" \
--header 'Authorization: Basic CLIENT_ID:CLIENT_SECRET' \
--header "'X-Customer-IP': IP_OF_YOUR_CUSTOMER" \
--data '{
"fromCurrency": "{fromCurrency}",
"toCurrency": "{toCurrency}",
"toCurrencyAmount": "{toCurrencyAmount}",
"endAt": "{endAt}"
}'

b. Offline Quotes

Retrieve quotes for all operational currencies and supported tenors at the same call. You’ll receive a complete quote table, which allows offline quote selection based on each transaction’s currency pair, due date, and corresponding tenor. This approach eliminates the need to call Grain individually for each transaction, and reduces system load by multiple calls. The table’s expiration time is configurable, with a default of 1 hour. Retrieve bulk offline quotes using the offline quote endpoint:

curl --request GET \
--url https://api.grainfinance.co/v1/offline-rates \
--header "Content-Type: application/json" \
--header 'Authorization: Basic CLIENT_ID:CLIENT_SECRET'

2. Accept quote

In this step, you will accept a quote you received in the previous step and create the hedge. Identically to the get quote step, there are also two methods for accepting a quote:

a. Accept quote - if you used the "Get Single Quote" call, send the quote ID received in that call (as hedgeProposalId) using the accept quote endpoint:

curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-quote \
--header "Content-Type: application/json" \
--header 'Authorization: Basic CLIENT_ID:CLIENT_SECRET' \
--header "'X-Customer-IP': IP_OF_YOUR_CUSTOMER" \
--data '{
"hedgeProposalId": "{hedgeProposalId}",
"transactionId": "{transactionId}"
}'

b. Accept offline quote - in case you used the offline option to get the quotes, send the calculated rate and its revision, along with the from and to currencies, the amount in the to currency, and the end date. Use the accept offline quote endpoint to submit all the details and create the hedge:

curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/accept-offline-quote \
--header "Content-Type: application/json" \
--header 'Authorization: Basic CLIENT_ID:CLIENT_SECRET' \
--header "'X-Customer-IP': IP_OF_YOUR_CUSTOMER" \
--data '{
"revision": "{revision}",
"fromCurrency": "{fromCurrency}",
"toCurrency": "{toCurrency}",
"toCurrencyAmount": "{toCurrencyAmount}",
"endAt": "{endAt}",
"rate": "{rate}"
}'