# ChatGPT trading bot with the IG API, the safe way

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/guides/ai-trading-bot-ig-chatgpt, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

ChatGPT can write IG API code for you, but it should never see your key or password, and nothing should trade until you arm it. Build read-first on a demo account, with a human confirming every order.

- Checked: 2026-09-18
- For: Non coders building with AI help
- About: [IG](https://openbrokerapi.com/brokers/ig)

## Steps

### 1. Use a demo account and a demo key

IG demo API access needs a demo account opened with the same email as your live account, and demo has its own key. See our IG demo API key guide.

Status: verified. Source: [labs.ig.com](https://labs.ig.com/faq.html), checked 2026-09-18.

### 2. Keys in environment variables, never in the chat

Ask ChatGPT for code that reads the key, username and password from environment variables, then set them on your own machine. Do not paste them into the conversation.

Status: verified. Source: [raw.githubusercontent.com](https://raw.githubusercontent.com/ig-python/trading-ig/master/trading_ig/rest.py), checked 2026-09-18.

### 3. Read first

Start with calls that only read: accounts, positions, prices. The IG demo host is https://demo-api.ig.com/gateway/deal.

Status: verified. Source: [raw.githubusercontent.com](https://raw.githubusercontent.com/ig-python/trading-ig/master/trading_ig/rest.py), checked 2026-09-18.

### 4. Trading off until armed

Keep order code behind a switch that is off by default, and ask for typed confirmation before each order. The MCP specification says there should always be a human in the loop who can deny tool calls; the same rule suits a plain script.

Status: verified. Source: [modelcontextprotocol.io](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), checked 2026-09-18.

### 5. Respect IG's allowances

Ask ChatGPT to add a limiter: IG allows 60 non-trading requests per minute per app and 100 trading and 30 non-trading per account, and will not raise them.

Status: verified. Source: [labs.ig.com](https://labs.ig.com/faq.html), checked 2026-09-18.

### 6. Spread bet or CFD

Tell ChatGPT which account you use. Spread bets need expiry DFB and CFDs expiry "-", according to trading-ig.

Status: verified. Source: [trading-ig.readthedocs.io](https://trading-ig.readthedocs.io/en/latest/faq.html), checked 2026-09-18.

### 7. Official IG assistant: Australia only

IG Australia's assistant works in ChatGPT, is read only and cannot place, amend or close trades, and uses OAuth so your IG password is never shared with the AI. It needs an IG Australia CFD account; we found no UK version.

Status: verified. Source: [ig.com](https://www.ig.com/au/trading-platforms/ai-assistant), checked 2026-09-18.

### 8. Community IG MCP server trades by default

The community ig-trading-mcp server reads IG_API_KEY, IG_IDENTIFIER, IG_PASSWORD and IG_DEMO and exposes trading tools as soon as it starts. It is listed in our AI and MCP guide, not tested or endorsed.

Status: verified. Source: [github.com](https://github.com/kea0811/ig-trading-mcp), checked 2026-09-18.

## Sources

- Status: verified. Source: [IG Labs FAQ](https://labs.ig.com/faq.html), checked 2026-10-12.
- Status: verified. Source: [trading-ig rest.py (community source)](https://raw.githubusercontent.com/ig-python/trading-ig/master/trading_ig/rest.py), checked 2026-09-18.
- Status: verified. Source: [trading-ig FAQ (community source)](https://trading-ig.readthedocs.io/en/latest/faq.html), checked 2026-09-18.
- Status: verified. Source: [MCP specification 2025-06-18: Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), checked 2026-09-18.
- Status: verified. Source: [IG AU: AI assistant](https://www.ig.com/au/trading-platforms/ai-assistant), checked 2026-09-18.
- Status: verified. Source: [GitHub: kea0811/ig-trading-mcp (community)](https://github.com/kea0811/ig-trading-mcp), checked 2026-09-18.

## More on the IG API

- [IG API quickstart](https://openbrokerapi.com/brokers/ig/quickstart): From credentials to a first call on a demo account, step by step.
- [IG API error codes](https://openbrokerapi.com/errors/ig): 132 decoded, each with what it means, and the fix where the source gives one.
- [IG API endpoints](https://openbrokerapi.com/brokers/ig/endpoints): 49 documented, each with its method, path, parameters and source.
- [IG messages](https://openbrokerapi.com/brokers/ig/messages): 5 documented, each with its fields and source.
- [IG API page](https://openbrokerapi.com/brokers/ig): The full record: access, authentication, limits and the source for each.
- [Get your IG trade history into a spreadsheet](https://openbrokerapi.com/guides/ig-trade-history): Guide
- [IG deal confirms: turning a deal reference into a result](https://openbrokerapi.com/guides/ig-deal-confirms): Guide
- [IG demo API key: how to get one and what it allows](https://openbrokerapi.com/guides/ig-demo-api-key): Guide
- [IG streaming with Python](https://openbrokerapi.com/guides/ig-lightstreamer-python): Guide

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: ChatGPT trading bot with the IG API, the safe way. Broker API Hub, https://openbrokerapi.com/guides/ai-trading-bot-ig-chatgpt, newest check 2026-09-18.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
