> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whitebit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Margin Trading

> Leveraged trading on spot pairs with up to 10x leverage using a collateral account on WhiteBIT.

export const RegionBaseUrl = ({className = "", showBaseUrl = true}) => {
  const [region, setRegionState] = useState(() => {
    if (typeof window !== 'undefined') {
      return localStorage.getItem("api-region-preference") || "com";
    }
    return "com";
  });
  const [mounted, setMounted] = useState(false);
  const observerRef = useRef(null);
  const isSyncingRef = useRef(false);
  const updateAllContentOnPage = targetRegion => {
    try {
      const domainFrom = targetRegion === "eu" ? "whitebit.com" : "whitebit.eu";
      const domainTo = targetRegion === "eu" ? "whitebit.eu" : "whitebit.com";
      const links = document.querySelectorAll('a');
      links.forEach(link => {
        let href = link.getAttribute('href');
        if (href && href.includes(domainFrom)) {
          link.setAttribute('href', href.replace(domainFrom, domainTo));
        }
      });
      const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, {
        acceptNode: node => {
          if (node.parentElement?.closest('.region-toggle-component')) {
            return NodeFilter.FILTER_REJECT;
          }
          return node.textContent.includes(domainFrom) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
        }
      });
      let currentNode;
      while (currentNode = walker.nextNode()) {
        currentNode.textContent = currentNode.textContent.replace(new RegExp(domainFrom, 'g'), domainTo);
      }
      console.log(`[RegionSync] Global content updated to ${domainTo}`);
    } catch (e) {
      console.error("[RegionSync] Error updating content:", e);
    }
  };
  const updateRegion = (newRegion, source) => {
    if (region === newRegion) return;
    console.log(`[RegionBaseUrl] Updating to "${newRegion}" (Source: ${source})`);
    if (source === 'observer') {
      isSyncingRef.current = true;
      setTimeout(() => isSyncingRef.current = false, 1000);
    }
    setRegionState(newRegion);
    localStorage.setItem("api-region-preference", newRegion);
    updateAllContentOnPage(newRegion);
    if (source === 'user-click') {
      window.dispatchEvent(new CustomEvent("regionChange", {
        detail: newRegion
      }));
      attemptToUpdateNativeDropdown(newRegion, 0);
      setTimeout(() => attemptToUpdateNativeDropdown(newRegion, 1), 500);
      setTimeout(() => attemptToUpdateNativeDropdown(newRegion, 2), 1500);
    }
  };
  const attemptToUpdateNativeDropdown = (targetRegion, attempt) => {
    if (isSyncingRef.current) return;
    try {
      const targetUrl = targetRegion === "eu" ? "https://whitebit.eu" : "https://whitebit.com";
      const targetDesc = targetRegion === "eu" ? "EU Server" : "Production Server";
      const selects = document.querySelectorAll('select');
      for (const select of selects) {
        if (select.innerHTML.includes('whitebit.com') || select.innerHTML.includes('whitebit.eu')) {
          select.value = targetUrl;
          select.dispatchEvent(new Event('change', {
            bubbles: true
          }));
          return;
        }
      }
      const buttons = Array.from(document.querySelectorAll('button, [role="combobox"]'));
      const serverSelector = buttons.find(btn => {
        if (btn.closest('a') || btn.closest('[class*="card"]') || btn.closest('nav')) {
          return false;
        }
        const txt = btn.textContent || "";
        const isServerDropdown = (txt.includes('Production Server') || txt.includes('EU Server') || txt.includes('WhiteBIT Global Server') || txt.includes('WhiteBIT EU Server')) && !txt.includes('Run') && !txt.includes('Send') || btn.getAttribute('role') === 'combobox';
        return isServerDropdown;
      });
      if (serverSelector) {
        const currentText = serverSelector.textContent || "";
        if (currentText.includes(targetDesc)) return;
        serverSelector.click();
        setTimeout(() => {
          const options = document.querySelectorAll('[role="option"], li, button');
          for (const opt of options) {
            const optText = opt.textContent || "";
            if (optText.includes(targetDesc) || optText.includes(targetUrl)) {
              opt.click();
              return;
            }
          }
        }, 100);
      }
    } catch (e) {
      console.error("[Sync] Error:", e);
    }
  };
  useEffect(() => {
    setMounted(true);
    updateAllContentOnPage(region);
    const handleStorageChange = e => {
      if (e.key === "api-region-preference" && e.newValue) {
        updateRegion(e.newValue, 'storage');
      }
    };
    const handleRegionChange = e => {
      if (e.detail !== region) {
        updateRegion(e.detail, 'event');
      }
    };
    window.addEventListener("storage", handleStorageChange);
    window.addEventListener("regionChange", handleRegionChange);
    observerRef.current = new MutationObserver(mutations => {
      if (isSyncingRef.current) return;
      updateAllContentOnPage(region);
      for (const mutation of mutations) {
        if (mutation.type !== 'childList' && mutation.type !== 'characterData') continue;
        const target = mutation.target;
        const el = target.nodeType === Node.TEXT_NODE ? target.parentElement : target;
        if (el && (el.getAttribute('role') === 'option' || el.closest('[role="listbox"]'))) continue;
        const text = target.textContent || "";
        if (text.includes('WhiteBIT EU Server') || text.includes('https://whitebit.eu') && text.includes('Server')) {
          if (el && el.tagName !== 'A' && !el.closest('.region-toggle-component')) {
            if (region !== 'eu') updateRegion('eu', 'observer');
          }
        } else if (text.includes('WhiteBIT Global Server') || text.includes('https://whitebit.com') && text.includes('Server')) {
          if (el && el.tagName !== 'A' && !el.closest('.region-toggle-component')) {
            if (region !== 'com') updateRegion('com', 'observer');
          }
        }
      }
    });
    observerRef.current.observe(document.body, {
      childList: true,
      subtree: true,
      characterData: true
    });
    if (typeof window !== 'undefined') {
      const current = localStorage.getItem("api-region-preference");
      if (current) attemptToUpdateNativeDropdown(current, 'init');
    }
    return () => {
      window.removeEventListener("storage", handleStorageChange);
      window.removeEventListener("regionChange", handleRegionChange);
      if (observerRef.current) observerRef.current.disconnect();
    };
  }, [region]);
  const apiBaseUrl = region === "eu" ? "https://whitebit.eu" : "https://whitebit.com";
  if (!mounted) return null;
  return <div className={`flex items-center gap-2 flex-wrap my-4 region-toggle-component ${className}`}>
            <span className="text-sm text-gray-500 dark:text-gray-400 font-mono">
                Base URL
            </span>
            <span className="text-sm text-gray-400">(</span>
            <div className="inline-flex bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5 border border-gray-200 dark:border-gray-700">
                <button onClick={() => updateRegion("com", "user-click")} className={`px-2 py-0.5 text-xs font-medium rounded-md transition-all ${region === "com" ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm" : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`}>
                    .com
                </button>
                <button onClick={() => updateRegion("eu", "user-click")} className={`px-2 py-0.5 text-xs font-medium rounded-md transition-all ${region === "eu" ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm" : "text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`}>
                    .eu
                </button>
            </div>
            <span className="text-sm text-gray-400">)</span>
            {showBaseUrl && <>
                    <span className="text-sm text-gray-400">:</span>
                    <a href={apiBaseUrl} target="_blank" rel="noopener noreferrer" className="text-sm font-mono text-primary dark:text-primary-light hover:underline">
                        {apiBaseUrl}
                    </a>
                </>}
        </div>;
};

<RegionBaseUrl />

Leveraged trading on [spot pairs](/concepts/markets) with up to 10x leverage using a collateral account. Margin Trading provides access to the same liquid spot markets (e.g., BTC\_USDT, ETH\_USDT) with amplified exposure through borrowed funds.

## Capabilities

* **Up to 10x leverage** — Adjustable per account via the [leverage endpoint](/api-reference/collateral-trading/change-collateral-account-leverage)
* **Isolated Margin mode** — Limit risk to the margin allocated to a specific position, preventing cross-position liquidation cascades
* **6 order types** — Limit, Market, Stop-Limit, Trigger-Market, OCO, Bulk-Limit ([details](/concepts/order-types))
* **Bulk orders** — Place up to 20 collateral limit orders in a single call ([endpoint](/api-reference/collateral-trading/collateral-bulk-limit-order))
* **Position management** — Open, monitor, and close positions programmatically ([open positions](/api-reference/collateral-trading/open-positions), [close](/api-reference/collateral-trading/close-position))

<Note>
  **API naming convention:** WhiteBIT's API uses "collateral" endpoints for both
  Margin and Futures trading. The market pair determines the product:
  spot pairs (e.g., `BTC_USDT`) for Margin, perpetual pairs (e.g., `BTC_PERP`)
  for Futures. All endpoints under `/api/v4/order/collateral/` and
  `/api/v4/collateral-account/` serve both products.
  See [Compare Trading Products](/products/compare-trading) for a full side-by-side comparison.
</Note>

## Who Uses This

* **Hedge funds** — Hedging spot holdings or amplifying directional exposure with controlled risk
* **Prop trading firms** — Leveraged strategies on liquid spot pairs with isolated margin for risk containment
* **Experienced algo traders** — Programmatic margin management through the collateral account API

## Common Integration Patterns

**Hedging** — Open opposing margin positions to offset risk on existing spot holdings. For example, short BTC\_USDT on margin while holding BTC in a spot wallet. Use the [collateral account balance](/api-reference/collateral-trading/collateral-account-balance) endpoint to monitor margin utilization.

**Leveraged directional trading** — Amplify exposure with controlled risk via isolated margin. Set leverage via the [leverage endpoint](/api-reference/collateral-trading/change-collateral-account-leverage), place orders, and monitor positions through the [open positions endpoint](/api-reference/collateral-trading/open-positions). The API returns a `liquidationPrice` field in position responses for risk monitoring.

## Risk Context

**Borrowed funds fee:** A commission is charged for using borrowed funds — only applied when an order is at least partially executed. Unexecuted orders incur no borrowing fee. See the [trading fees page](https://whitebit.com/trading-data/trading-fees) for the current rate.

Liquidation can occur when the maintenance margin threshold is breached. Key details:

* **Partial liquidation** is the primary mechanism: only a portion (e.g., 20–30%) of the position is closed first to restore margin. If partial liquidation is insufficient, full liquidation follows.
* **Liquidation sequence:** margin positions first (smallest to largest initial margin value) → crypto borrowings → futures positions last
* **Maintenance Margin Rate (MMR):** 3% for leverage 1x–10x. Per-market leverage limits and collateral brackets: [collateral brackets page](https://whitebit.com/trading-data/collateral-brackets)
* The API returns a `liquidationPrice` field in position responses — monitor the liquidation price alongside the collateral account balance to manage risk

> **Coming soon:** Detailed mark price methodology and liquidation price formulas will be published here. For institutional inquiries, contact [institutional@whitebit.com](mailto:institutional@whitebit.com).

<Tip>
  **WBT holder benefit:** Holding WBT (WhiteBIT Token) can reduce the maker commission by up to
  100% on margin orders. See the [VIP program](https://whitebit.com/vip-program) for current tier details.
</Tip>

<Note>
  **Portfolio Margin** is available for institutional clients with a minimum 200,000 USDT collateral balance.
  Portfolio Margin provides up to 10x leverage with portfolio-level risk assessment.
  Contact [institutional@whitebit.com](mailto:institutional@whitebit.com) or see the
  [Institutional Overview](/institutional/overview) for details.
</Note>

## Technical Overview

| Detail         | Value                                                     |
| -------------- | --------------------------------------------------------- |
| Endpoints      | 19 shared with Futures (all `POST`, all authenticated)    |
| Authentication | HMAC-SHA512 ([guide](/api-reference/authentication))      |
| Rate limits    | Vary per endpoint ([details](/api-reference/rate-limits)) |
| Pair format    | Spot pairs: `BTC_USDT`, `ETH_USDT`, etc.                  |

Endpoint categories (shared with Futures Trading):

* **Account & Balance** — Balance, balance summary, account summary, leverage, hedge mode (6 endpoints)
* **Order Management** — Limit, bulk-limit, market, stop-limit, trigger-market, OCO, cancel (7 endpoints)
* **Order Queries** — Conditional orders, OCO orders (2 endpoints)
* **Position Management** — Open positions, close position, position history, funding history (4 endpoints)

The pair name determines whether an order is Margin or Futures. Spot pairs (e.g., `BTC_USDT`) route to Margin. Perpetual pairs (e.g., `BTC_PERP`) route to Futures.

For full endpoint documentation, see the [Collateral Trading API Reference](/api-reference/collateral-trading/overview).

For Go and PHP examples, see [SDKs](/sdks).

## What's Next

<CardGroup cols={3}>
  <Card title="Margin & Futures Quickstart" icon="rocket" href="/products/margin-futures/quickstart">
    Open a first leveraged position in 5 minutes.
  </Card>

  <Card title="Futures Trading" icon="chart-candlestick" href="/products/futures/overview">
    Compare with perpetual contracts — up to 100x leverage and Hedge Mode.
  </Card>

  <Card title="API Reference" icon="square-terminal" href="/api-reference/collateral-trading/overview">
    Full endpoint documentation for all 19 collateral trading endpoints.
  </Card>
</CardGroup>
