Skip to main content
POST
/
contracts
/
margin
Get Margin
curl --request POST \
  --url https://api-options.sandbox.rails.xyz/contracts/margin \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "market": "BTC-3JUL26-62000-C",
  "side": "buy",
  "orderPrice": "150.00",
  "indexPrice": "61665.11",
  "availableBalance": "10000.00"
}
'
import requests

url = "https://api-options.sandbox.rails.xyz/contracts/margin"

payload = {
    "market": "BTC-3JUL26-62000-C",
    "side": "buy",
    "orderPrice": "150.00",
    "indexPrice": "61665.11",
    "availableBalance": "10000.00"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    market: 'BTC-3JUL26-62000-C',
    side: 'buy',
    orderPrice: '150.00',
    indexPrice: '61665.11',
    availableBalance: '10000.00'
  })
};

fetch('https://api-options.sandbox.rails.xyz/contracts/margin', 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-options.sandbox.rails.xyz/contracts/margin",
  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([
    'market' => 'BTC-3JUL26-62000-C',
    'side' => 'buy',
    'orderPrice' => '150.00',
    'indexPrice' => '61665.11',
    'availableBalance' => '10000.00'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "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-options.sandbox.rails.xyz/contracts/margin"

	payload := strings.NewReader("{\n  \"market\": \"BTC-3JUL26-62000-C\",\n  \"side\": \"buy\",\n  \"orderPrice\": \"150.00\",\n  \"indexPrice\": \"61665.11\",\n  \"availableBalance\": \"10000.00\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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-options.sandbox.rails.xyz/contracts/margin")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"market\": \"BTC-3JUL26-62000-C\",\n  \"side\": \"buy\",\n  \"orderPrice\": \"150.00\",\n  \"indexPrice\": \"61665.11\",\n  \"availableBalance\": \"10000.00\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api-options.sandbox.rails.xyz/contracts/margin")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"market\": \"BTC-3JUL26-62000-C\",\n  \"side\": \"buy\",\n  \"orderPrice\": \"150.00\",\n  \"indexPrice\": \"61665.11\",\n  \"availableBalance\": \"10000.00\"\n}"

response = http.request(request)
puts response.read_body
{
  "costPerUnit": "193.245",
  "maxQty": "51"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
market
string
required

Option contract name, e.g. BTC-19JUN26-62000-C.

side
string
required

Order side: buy or sell.

orderPrice
string
required

Order price per contract (positive decimal).

indexPrice
string
required

Current index price of the underlying (positive decimal).

availableBalance
string
required

Balance available to allocate to the order.

Response

200 - application/json

Per-unit cost and maximum affordable quantity

costPerUnit
string

Cost per contract — initial margin plus taker fee.

maxQty
string

Maximum whole quantity affordable: floor(availableBalance / costPerUnit).