Your own trading agent
Write the prompt, the rules and the limits. Your agent trades through the same API as everything else in Mega1: quotes, orders, positions and the account’s live state.
The First Forex Broker Built for AI Agents
Build trading agents, dashboards and tools on Mega1’s open API, or connect Claude, Cursor and other MCP clients to your XBTFX account. Trade, manage positions and stream market data from your own code or in plain language.
Illustrative example, not real trading data.
For traders who want AI in the loop, with an API that states exactly what it does.
Write the prompt, the rules and the limits. Your agent trades through the same API as everything else in Mega1: quotes, orders, positions and the account’s live state.
Mega1 publishes its API as an OpenAPI 3.1 document. Hand it to Claude, Cursor or any coding assistant and it knows every endpoint, field and error before it writes a line.
Trade operations carry an ID you choose. If the connection drops, your agent checks whether the operation went through instead of sending it twice.
Preview an order’s margin, commission and whether the account can afford it before it goes to the market.
Ask your AI to build a dashboard, a risk monitor or a specialist interface against your key, in the browser, on the command line or on the desktop.
A single WebSocket carries quotes, market depth, orders, positions, deals and account state, so your tools react the moment something changes.
The trader side of Mega1’s API, in six groups. Your key works only on your own accounts.
Current quotes, historical candles, the symbols on your account and their trading terms.
Market and pending orders: place, modify, cancel one or all, with a preview of margin and commission first.
Set stop loss and take profit, close in full or in part, reverse, or close two hedged positions against each other.
Live balance, equity and margin, your accounts, and the leverage that applies to each symbol.
Order, deal and position history, account statements, and equity and margin snapshots over time.
One JSON WebSocket for quotes, depth, orders, positions, deals and account state.
Add the XBTFX MCP server to Claude Desktop, Cursor, Windsurf or another MCP client, and your assistant can trade your account in plain language.
The setup guide covers your key, each client and every tool the server offers.
Read the setup guide{
"mcpServers": {
"xbtfx": {
"command": "npx",
"args": ["@xbtfx/mcp-trading"],
"env": { "XBTFX_API_KEY": "your_key_here" }
}
}
} Register at XBTFX and open a Mega1 trading account in the portal.
Create accountIn the Mega1 terminal, create the key your agent will use. Treat it like a password: keep it out of your code and your chats.
Give your coding assistant the OpenAPI contract and describe what to build. Review its work before it trades.
OpenAPI contractOpen an XBTFX account, create your API key in the Mega1 terminal and connect your AI.