Automated strategies
Build trading bots and algorithmic strategies that send trades to your account automatically. Run signal-driven execution, portfolio rebalancing, or custom risk management logic.
Compatible with XBTFX MetaTrader 5® accounts
Programmatically trade, manage positions, monitor account state, and stream real-time market data on compatible XBTFX MetaTrader 5® accounts through REST and WebSocket. Build automated strategies, connect AI agents, and integrate your account into custom workflows. Start with docs, working examples, AI skills, or the XBTFX MCP server. Designed for developers and users with experience in programming or AI coding assistants.
# Send a trade to your XBTFX account
curl -X POST https://interface.xbtfx.com/v1/trade \
-H "Authorization: Bearer xbtfx_live_..." \
-H "Content-Type: application/json" \
-d '{
"symbol": "EURUSD",
"side": "buy",
"volume": 0.10,
"sl": 1.08200,
"tp": 1.09000
}'
# Response
{
"status": "filled",
"retcode": 10009,
"deal": 184729,
"price": 1.08650,
"volume": 0.10
} The XBTFX Trading API lets you send instructions to your compatible XBTFX MetaTrader 5® account. Open positions, modify stops, query balances, and stream live quotes through standard REST and WebSocket calls.
Build trading bots and algorithmic strategies that send trades to your account automatically. Run signal-driven execution, portfolio rebalancing, or custom risk management logic.
Connect AI assistants to your account via the XBTFX Skills Hub or MCP server. Issue trading commands in natural language through Claude Code, Cursor, Windsurf, or other compatible clients.
Build dashboards, connect to external data sources, pipe trade signals from other platforms, or integrate account data into your own reporting and analytics systems.
Open and close positions, set stop loss and take profit, query account balances, retrieve trade history, and stream live forex and crypto quotes via WebSocket.
Send market orders to your account with stop loss and take profit. Supports both hedging and netting margin modes.
/v1/trade Close positions fully or partially. Update SL/TP on open positions. Close all, close by symbol, or net opposing positions.
/v1/close · /v1/modify · /v1/close-all Retrieve all open positions and pending orders in real time. Filter by symbol. Responses served from cache with live push updates.
/v1/positions · /v1/orders Real-time balance, equity, margin, free margin, floating PnL, and leverage. One call for a complete snapshot.
/v1/account Full symbol list with live bid/ask, spread, contract size, volume min/max/step, digits, and margin requirements.
/v1/symbols · /v1/symbols/:symbol Real-time streaming quotes with 5-level market depth. Subscribe to any symbols available on your account.
wss://ws.xbtfx.com/v1/ws A few lines of code in your language of choice. Standard HTTP — any language that can make a POST request works.
# Send a buy order to your XBTFX account
curl -X POST https://interface.xbtfx.com/v1/trade \
-H "Authorization: Bearer $XBTFX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"symbol":"EURUSD","side":"buy","volume":0.10,"sl":1.082,"tp":1.09}'
# Retrieve open positions
curl https://interface.xbtfx.com/v1/positions \
-H "Authorization: Bearer $XBTFX_API_KEY"import requests
API_KEY = "xbtfx_live_your_key_here"
BASE = "https://interface.xbtfx.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Send a trade to your account
r = requests.post(f"{BASE}/v1/trade", json={
"symbol": "EURUSD",
"side": "buy",
"volume": 0.10,
}, headers=HEADERS)
print(r.json()["status"]) # "filled", or "placed" while it executesconst ws = new WebSocket("wss://ws.xbtfx.com/v1/ws");
ws.onopen = () => ws.send(JSON.stringify({
action: "auth", token: "xbtfx_live_..."
}));
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
if (msg.action === "auth_ok") ws.send(JSON.stringify({
action: "subscribe", channel: "quotes",
symbols: ["EURUSD", "BTCUSD"]
}));
if (msg.channel === "quote") console.log(msg.symbol, msg.bid, msg.ask);
};interface.xbtfx.comShell
AI-ready
The XBTFX Trading API is built to be consumed by AI agents and large language models — clean JSON, human-readable errors, predictable endpoints. Connect via the XBTFX Skills Hub or the MCP server and your AI client can send trades through conversational commands.
Less technical? See our AI Agent Trading overview.
Example conversation
Today · 13:25 GMT
If today's NFP prints above 200k, close all my open EURUSD and GBPUSD trades.
13:25 ✓✓Got it. Watching the BLS release at 13:30 GMT. I'll close 4 positions if NFP > 200k.
13:25tool · xbtfx_get_positions4 open · EURUSD ×2, GBPUSD ×2 · floating +$184.20
13:2613:30 · NFP released: 247k (forecast 195k)
tool · xbtfx_close_all (filter: EURUSD, GBPUSD)Closed 4 positions in 38 ms · realized +$212.80
13:30Illustrative example. Conditional flows depend on the configured agent and market-data feeds.
Use cases
Four common patterns we see across automated and AI-driven workflows on XBTFX accounts.
AI monitors news and economic data in real time, sending trades to your account when market-moving events are detected.
AI tracks your margin, floating PnL, and exposure, adjusting stops, reducing sizes, or closing trades to protect capital.
Define target allocations and let AI maintain them, sending adjustment trades when drift exceeds your threshold.
Ask your AI to analyze trade history, calculate win rates by symbol, and identify your best-performing setups.
Use your current Pro MetaTrader 5 account, your existing base currency, and your existing margin mode. The API plugs into the same account you already trade on.
Technical specs
Account compatibility
Example code, AI skill files, and full API documentation — everything you need to get building.
Full endpoint reference with request/response examples, authentication guide, and WebSocket integration.
Sample code in Python, JavaScript, curl, and more. Copy and run.
Skill files for trading, account, market data, and WebSocket workflows for compatible agent frameworks.
For Claude Code, Claude Desktop, OpenAI Codex, Cursor, Windsurf, and other MCP-compatible clients.
Same shell, two starting points — pick the one that matches your account state.
Log in to portal.xbtfx.com with your XBTFX account credentials, select your trading account, and generate a key.
Open consoleInstall a skill from the Skills Hub, or connect the MCP server to Claude Code, Cursor, Windsurf, or other compatible clients. Keys stay local.
MCP docsVerify with GET /v1/auth/status, then issue natural-language commands or call the REST/WebSocket endpoints directly.
Read docsRegister at portal.xbtfx.com and open a Pro account. Choose your preferred base currency — USD, USDT, BTC, ETH, or XRP.
Create accountLog in to portal.xbtfx.com with your XBTFX account credentials, select your trading account, and generate a key.
Open consoleInstall a skill from the Skills Hub, or connect the MCP server to Claude Code, Cursor, Windsurf, or other compatible clients. Then send your first trade.
MCP docsOpen your XBTFX account, generate an API key in the portal and send your first trade.