cURL
curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"endAt": "2023-04-24"
}
'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote"
payload = { "endAt": "2023-04-24" }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({endAt: '2023-04-24'})
};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'endAt' => '2023-04-24'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote"
payload := strings.NewReader("{\n \"endAt\": \"2023-04-24\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"endAt\": \"2023-04-24\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"endAt\": \"2023-04-24\"\n}"
response = http.request(request)
puts response.read_body{
"id": "6f1c2a3e-8a4b-4f0e-9b7d-2c5e1f3a9d42",
"fromCurrency": "MXN",
"toCurrency": "USD",
"fromCurrencyAmount": 32426.94,
"toCurrencyAmount": 1560,
"quote": 20.7865,
"endAt": "2023-04-24",
"settlementAt": "2023-04-25",
"validUntilTs": 1676889000,
"beforeHedgeState": {
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"quote": 20.6165,
"endAt": "2023-02-23",
"settlementAt": "2023-02-24",
"collateralAmount": 1608.09
},
"afterHedgeState": {
"fromCurrencyAmount": 32426.94,
"toCurrencyAmount": 1560,
"quote": 20.7865,
"endAt": "2023-04-24",
"settlementAt": "2023-04-25",
"collateralAmount": 1608.09
}
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}Extend Hedge
Quote
Generates a rate proposal for moving a standard hedge’s due date to a later date. The fixed side of the hedge stays unchanged and the other side is recalculated at the new rate. Once accepted, this proposal is applied to the hedge immediately.
POST
/
customers
/
{customerId}
/
hedges
/
{hedgeId}
/
extension
/
quote
cURL
curl --request POST \
--url https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"endAt": "2023-04-24"
}
'import requests
url = "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote"
payload = { "endAt": "2023-04-24" }
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({endAt: '2023-04-24'})
};
fetch('https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'endAt' => '2023-04-24'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote"
payload := strings.NewReader("{\n \"endAt\": \"2023-04-24\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"endAt\": \"2023-04-24\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.grainfinance.co/v1/customers/{customerId}/hedges/{hedgeId}/extension/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"endAt\": \"2023-04-24\"\n}"
response = http.request(request)
puts response.read_body{
"id": "6f1c2a3e-8a4b-4f0e-9b7d-2c5e1f3a9d42",
"fromCurrency": "MXN",
"toCurrency": "USD",
"fromCurrencyAmount": 32426.94,
"toCurrencyAmount": 1560,
"quote": 20.7865,
"endAt": "2023-04-24",
"settlementAt": "2023-04-25",
"validUntilTs": 1676889000,
"beforeHedgeState": {
"fromCurrencyAmount": 32161.8,
"toCurrencyAmount": 1560,
"quote": 20.6165,
"endAt": "2023-02-23",
"settlementAt": "2023-02-24",
"collateralAmount": 1608.09
},
"afterHedgeState": {
"fromCurrencyAmount": 32426.94,
"toCurrencyAmount": 1560,
"quote": 20.7865,
"endAt": "2023-04-24",
"settlementAt": "2023-04-25",
"collateralAmount": 1608.09
}
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}{
"message": "Can't perform this action",
"reason": "Supplied object is in *Cancelled* state, which prevents performing this action"
}Authorizations
Basic authentication using the partner API keys from https://console.grainfinance.co/keys
Path Parameters
Body
application/json
Information required by Grain in order to generate an extension proposal.
Response
Extension Proposal Created
An extension proposal returned by the extension-quote call.