# Broker API Hub > An independent reference for retail broker trading APIs: how to get access, authentication, rate limits, endpoints and error codes. Every fact carries the page it was read on and the date it was checked, and a fact that could not be verified says so. Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Nothing on the site is investment advice, and no page asks for an API key, a username or a password. The site holds 21 broker records, 8 platform API records, 359 recorded endpoints, 215 functions and messages of interfaces that are not HTTP, 1,776 error codes, 37 guides and 31 lessons. The newest check of a broker record, a platform record or a rate limit is dated 12 Oct 2026 (2026-10-12). What a person has checked: of the 2,479 records that carry a review state, 2,256 were read on the vendor's own page by a person and carry the date it was read. The rest were carried over from an earlier version of the site with their original dates or written from this site's own reading, and each record says which in its review field. When you cite a figure from this site, cite the source and the checked date printed beside it. A broker's own documentation always wins where the two differ. Reading this site as a program or an assistant: - Markdown: 2,499 reference pages have a markdown version at the page address plus .md. That covers every broker, platform, endpoint, function, message, error, rate limit, quickstart, guide and answer page. A link below ends in .md wherever the page has such a version. Cite the page address without .md. - Status: every fact is verified, conflicting or unverified. Pass an unverified fact on as unverified. Not recorded means this site holds no record, never that the thing does not exist. - Nothing here is ranked or recommended. Lists are in name, path, code or date order. ## Start here - [Getting started with API trading](https://openbrokerapi.com/guides/getting-started-with-api-trading.md): what an API is, what you need before you start, and how to make a first call safely - [Brokers](https://openbrokerapi.com/brokers): the directory of 21 retail brokers: 14 recorded as having an API of their own on a verified statement, 1 on an unverified one and 6 reached through platform APIs only - [Platforms](https://openbrokerapi.com/platforms): the 8 platform APIs and the brokers that offer each - [Errors](https://openbrokerapi.com/errors): 1,776 error codes by broker, each with its cause and its source - [What changed](https://openbrokerapi.com/changes): 121 dated changes to broker APIs, each with the page it was read on - [Answers](https://openbrokerapi.com/answers): the questions people ask about each broker API, each answered from a record with its source and checked date - [Guides](https://openbrokerapi.com/guides): step by step guides, each step with its source - [Learn](https://openbrokerapi.com/learn): lessons that teach coding by building trading tools - [Practice API](https://openbrokerapi.com/mock): fixed JSON files of invented data that answer a real GET request with no account and no key. Not any broker's API ## For programs and assistants - [The full reference in one file](https://openbrokerapi.com/llms-full.txt): every broker and platform record with its claims and limits, 359 endpoints by method and path, 215 functions and messages by name, and 1,776 error codes by code and HTTP status, as markdown - [Use this site with an AI assistant](https://openbrokerapi.com/ai): what exists for machines, how to point an assistant at it, and what to be careful of - [OpenAPI files](https://openbrokerapi.com/specs): 12 OpenAPI 3.1 files generated from the endpoint records. Independent and unofficial, not any broker's own specification - [The practice API as an OpenAPI file](https://openbrokerapi.com/mock/v1/openapi.json): an OpenAPI 3.1 file for the practice API, to load into an API tool. Invented practice data, not any broker's API - [Brokers with an MCP server](https://openbrokerapi.com/ai/mcp-directory): 25 MCP servers for brokers and platforms, each marked official or community, with whether it can place orders - [Tools](https://openbrokerapi.com/tools): small tools that run in the browser, listed below - [Error lookup](https://openbrokerapi.com/tools/error-lookup): Paste an error message or code and get the decoded error pages that match it. - [Position size calculator](https://openbrokerapi.com/tools/position-size-calculator): The arithmetic from the position size lesson, worked for the figures you type. Not advice on how much to risk. - [Rate limit calculator](https://openbrokerapi.com/tools/rate-limit-calculator): Check a polling plan against a published limit: whether it fits, the headroom, and the shortest interval that would. - [Request builder](https://openbrokerapi.com/tools/request-builder): Pick a documented endpoint and get a curl, a Python and a JavaScript snippet that read credentials from environment variables. ## Brokers - [Axi](https://openbrokerapi.com/brokers/axi.md): Spread bets and CFDs on MT4, MT5 and the Axi Trading Platform. - [Bitget](https://openbrokerapi.com/brokers/bitget.md): A crypto exchange with a REST and WebSocket API of its own. - [Capital.com](https://openbrokerapi.com/brokers/capital-com.md): Public REST API and WebSocket feed for Capital.com CFD accounts, live and demo. - [CMC Markets](https://openbrokerapi.com/brokers/cmc-markets.md): Large UK spread betting and CFD broker whose automation route is MT4. - [Deriv](https://openbrokerapi.com/brokers/deriv.md): Websocket first trading API with published per call budgets. - [Dukascopy](https://openbrokerapi.com/brokers/dukascopy.md): A Swiss bank with a Java API for its JForex platform and a FIX 4.4 API. - [eToro](https://openbrokerapi.com/brokers/etoro.md): Public REST API and WebSocket for verified eToro users, with demo trading endpoints. - [Exness](https://openbrokerapi.com/brokers/exness.md): A public retail API exists, gated behind verification and a minimum deposit, with no published rate limits. - [FOREX.com / StoneX Trading (City Index)](https://openbrokerapi.com/brokers/forex-com-city-index.md): StoneX (formerly GAIN Capital) REST trading API shared by FOREX.com and StoneX Trading, the new UK name for City Index since 9 Sep 2026. - [FXCM](https://openbrokerapi.com/brokers/fxcm.md): ForexConnect and Java SDKs for Trading Station accounts; FXCM's REST API is no longer listed and we found no formal retirement notice. - [FxPro](https://openbrokerapi.com/brokers/fxpro.md): CFD broker offering MT4, MT5 and cTrader at group level. - [IG](https://openbrokerapi.com/brokers/ig.md): REST plus streaming for IG spread bet and CFD accounts. - [Interactive Brokers](https://openbrokerapi.com/brokers/ibkr.md): TWS API (socket via TWS or IB Gateway), and a single IBKR Web API that IBKR is folding Client Portal Web API, Digital Account Management and the Flex Web Service into. - [OANDA](https://openbrokerapi.com/brokers/oanda.md): v20 REST API with HTTP streaming for prices and transactions. - [Pepperstone](https://openbrokerapi.com/brokers/pepperstone.md): Spread bets and CFDs with MT4, MT5, cTrader and TradingView, plus an API offered by application. - [Saxo OpenAPI](https://openbrokerapi.com/brokers/saxo.md): OAuth 2.0 REST and WebSocket API, with a free simulation environment. - [Swissquote](https://openbrokerapi.com/brokers/swissquote.md): A Swiss bank whose FIX and REST APIs are published on its institutional pages. - [ThinkMarkets](https://openbrokerapi.com/brokers/thinkmarkets.md): Spread betting and CFDs on ThinkTrader, MT4 and MT5. - [Tickmill](https://openbrokerapi.com/brokers/tickmill.md): CFD broker offering MT4 and MT5 plus futures platforms. - [Trading 212](https://openbrokerapi.com/brokers/trading-212.md): REST API for the General Invest Account and the Stocks and Shares ISA, described as beta; it does not reach the CFD account. - [XTB](https://openbrokerapi.com/brokers/xtb.md): xAPI (xStation5) was switched off on 14 Mar 2025. ## Platforms - [cTrader Open API](https://openbrokerapi.com/platforms/ctrader.md): Spotware's open API for cTrader accounts, JSON or Protobuf over TCP or WebSocket. - [DXtrade APIs](https://openbrokerapi.com/platforms/dxtrade.md): Devexperts' platform with REST and WebSocket push APIs; trader access depends on the broker. - [Match-Trader Platform API](https://openbrokerapi.com/platforms/match-trader.md): Match-Trade's trader-facing REST and WebSocket API for Match-Trader accounts. - [MetaApi](https://openbrokerapi.com/platforms/metaapi.md): Cloud REST and WebSocket API over MT4 and MT5 accounts at any MetaTrader broker. - [MetaCopier](https://openbrokerapi.com/platforms/metacopier.md): Cloud copy trading and risk management bridge across MT4, MT5, cTrader, TradeLocker, DXtrade, Match-Trader and others. - [MetaTrader 4 (MQL4)](https://openbrokerapi.com/platforms/metatrader-4.md): MetaQuotes' FX terminal; automation is MQL4 code running inside the terminal. - [MetaTrader 5 (Python package and MQL5)](https://openbrokerapi.com/platforms/metatrader-5.md): MetaQuotes' multi-asset trading terminal. - [TradeLocker API](https://openbrokerapi.com/platforms/tradelocker.md): REST trading API for TradeLocker accounts, with an official Python client. ## Functions, messages and streaming Interfaces that are not HTTP: 106 functions of language bindings and 109 messages and subscriptions of wire protocols and streaming connections, owned by brokers as well as platform APIs. Each has no method and no path, so no OpenAPI file describes it. Each index lists the calls, and each call has a page with a markdown version. - [Bitget: messages](https://openbrokerapi.com/brokers/bitget/messages): Bitget WebSocket API, 10 messages (2 requests, 8 subscriptions), each is sent as JSON over an open WebSocket connection; the records name WebSocket as the transport - [Capital.com: messages](https://openbrokerapi.com/brokers/capital-com/messages): Capital.com WebSocket API, 7 messages (2 events, 5 requests), each is sent as JSON over an open WebSocket connection; the records name WebSocket as the transport - [Deriv: messages](https://openbrokerapi.com/brokers/deriv/messages): Deriv WebSocket API, 19 messages (19 requests), each is sent as JSON over an open WebSocket connection; the records name WebSocket as the transport - [eToro: messages](https://openbrokerapi.com/brokers/etoro/messages): eToro WebSocket API, 6 messages (3 requests, 3 subscriptions), each is sent as JSON over an open WebSocket connection; the records name WebSocket as the transport - [IG: messages](https://openbrokerapi.com/brokers/ig/messages): IG Streaming API, 5 messages (5 subscriptions), each travels over a Lightstreamer connection that stays open, which a Lightstreamer client library manages; the records name Lightstreamer as the transport - [Saxo OpenAPI: messages](https://openbrokerapi.com/brokers/saxo/messages): Saxo OpenAPI streaming connection, 5 messages (4 events, 1 request), each travels over an open WebSocket connection; the records name WebSocket as the transport - [cTrader Open API: messages](https://openbrokerapi.com/platforms/ctrader/messages): cTrader Open API, 49 messages (7 events, 23 requests, 19 responses), each is sent over an open TCP or WebSocket connection, as Protocol Buffers or as JSON - [DXtrade APIs: messages](https://openbrokerapi.com/platforms/dxtrade/messages): DXtrade Push API, 8 messages (2 events, 6 requests), each is sent as JSON or XML over an open WebSocket connection; the records name WebSocket as the transport - [MetaTrader 4 (MQL4): functions](https://openbrokerapi.com/platforms/metatrader-4/functions): MQL4, 28 functions, called from an MQL4 program, not sent over HTTP - [MetaTrader 5 (Python package and MQL5): functions](https://openbrokerapi.com/platforms/metatrader-5/functions): MetaTrader5 Python package, 32 functions, called from a Python program, not sent over HTTP; MQL5, 46 functions, called from an MQL5 program, not sent over HTTP ## Reference across brokers - [Rate limits](https://openbrokerapi.com/rate-limits): 35 limit records, each with its scope, source and checked date - [Endpoints by task](https://openbrokerapi.com/endpoints): the same job across the APIs that document it - [Capability tables](https://openbrokerapi.com/capabilities): one feature at a time across every broker and platform record - [Across brokers](https://openbrokerapi.com/across-brokers): one field of the records read across every broker and platform - [Quickstarts](https://openbrokerapi.com/quickstart): 10 quickstarts, from a key to a first call on a demo account - [Weekly digest](https://openbrokerapi.com/changes/weekly): the change log grouped by week, then by broker or platform - [Market data sources](https://openbrokerapi.com/data-sources): 20 sources of market data, with what each source's own pages say you may do with it - [Glossary](https://openbrokerapi.com/glossary): the terms these pages use ## OpenAPI files - [Capital.com API](https://openbrokerapi.com/specs/capital-com.json): 36 operations, each with its source and checked date - [Deriv API](https://openbrokerapi.com/specs/deriv.json): 5 operations, each with its source and checked date - [eToro API](https://openbrokerapi.com/specs/etoro.json): 51 operations, each with its source and checked date - [IG API](https://openbrokerapi.com/specs/ig.json): 49 operations, each with its source and checked date - [Interactive Brokers API](https://openbrokerapi.com/specs/ibkr.json): 23 operations, each with its source and checked date - [OANDA API](https://openbrokerapi.com/specs/oanda.json): 33 operations, each with its source and checked date - [Saxo OpenAPI](https://openbrokerapi.com/specs/saxo.json): 68 operations, each with its source and checked date - [Trading 212 API](https://openbrokerapi.com/specs/trading-212.json): 16 operations, each with its source and checked date - [DXtrade APIs](https://openbrokerapi.com/specs/dxtrade.json): 21 operations, each with its source and checked date - [Match-Trader Platform API](https://openbrokerapi.com/specs/match-trader.json): 17 operations, each with its source and checked date - [MetaApi](https://openbrokerapi.com/specs/metaapi.json): 17 operations, each with its source and checked date - [TradeLocker API](https://openbrokerapi.com/specs/tradelocker.json): 23 operations, each with its source and checked date ## Guides - [Before you go live: a checklist](https://openbrokerapi.com/guides/before-you-go-live.md): A checklist to work through before a script leaves a demo account, with the facts each recorded broker API gives for it. - [ChatGPT trading bot with the IG API, the safe way](https://openbrokerapi.com/guides/ai-trading-bot-ig-chatgpt.md): 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. - [Choosing a broker API for Python](https://openbrokerapi.com/guides/choosing-python-broker-api.md): The honest state of the Python wrapper ecosystem for retail broker APIs. - [Claude with MetaTrader 5: a safe, read-first setup](https://openbrokerapi.com/guides/claude-mt5.md): There are two routes: MetaTrader 5's own AI and MCP support, where Anthropic is a selectable provider, or Claude writing Python for the MetaTrader5 package. - [Demo vs live: the mix-up that breaks most first logins](https://openbrokerapi.com/guides/demo-vs-live.md): Demo and live usually mean different hosts, and often different keys or usernames. - [Export your MetaTrader trade history, no code](https://openbrokerapi.com/guides/metatrader-trade-history.md): If your broker gives you MetaTrader 4 or 5, the desktop terminal can save your account history as a report file. - [Get your Capital.com trade history into a spreadsheet](https://openbrokerapi.com/guides/capital-com-trade-history.md): Capital.com generates statements on the web and in the app. - [Get your eToro trade history into a spreadsheet](https://openbrokerapi.com/guides/etoro-trade-history.md): Download eToro's account statement from Portfolio, My Portfolio, History, and save it as Excel or PDF. - [Get your IG trade history into a spreadsheet](https://openbrokerapi.com/guides/ig-trade-history.md): Use the IG website, not the app: in My IG, open Live accounts, then History, pick your dates and all transaction types, and download the account ledger summary. - [Get your Interactive Brokers trade history into a spreadsheet](https://openbrokerapi.com/guides/ibkr-trade-history.md): Two routes in Client Portal: an Activity Statement for a quick CSV, or a Flex Query when you want only the trade columns you choose. - [Get your OANDA trade history into a spreadsheet](https://openbrokerapi.com/guides/oanda-trade-history.md): OANDA's HUB exports transaction history straight to CSV. - [IBKR API without TWS: headless IB Gateway options](https://openbrokerapi.com/guides/ibkr-headless-gateway.md): You cannot skip IBKR's gateway software as a retail user, but you can skip the full TWS window. - [IG deal confirms: turning a deal reference into a result](https://openbrokerapi.com/guides/ig-deal-confirms.md): A create call on IG hands back a deal reference, not a fill, and the client then reads the confirm for that reference. - [IG demo API key: how to get one and what it allows](https://openbrokerapi.com/guides/ig-demo-api-key.md): IG does not hand out API keys from a standalone demo account. - [Place your first order on a demo account: what every API asks for](https://openbrokerapi.com/guides/first-demo-order-fields.md): What each recorded broker API asks for when you place an order on a demo account, field by field, from this site's endpoint records. - [Sessions and tokens: how each API keeps you signed in](https://openbrokerapi.com/guides/sessions-and-tokens.md): How each recorded broker API keeps you signed in: a login call that returns session tokens, a long lived key sent on every request, or an OAuth token that has to be refreshed. - [Spread betting API in the UK: which brokers offer one](https://openbrokerapi.com/guides/spread-betting-api.md): Of the brokers we cover, IG is the one that documents spread betting through its own API. - [Staying logged in: session lifetimes compared](https://openbrokerapi.com/guides/staying-logged-in.md): Every broker logs you out differently. - [AI assistants and broker APIs: connect one safely](https://openbrokerapi.com/guides/ai-mcp.md): MCP servers let an AI assistant call a broker API as a set of tools, and 2026 is the year brokers started shipping their own. - [Broker API rate limits compared](https://openbrokerapi.com/guides/rate-limits-survival.md): Every published broker and platform API rate limit we track, with its scope, the page it came from and the date we checked it. - [Broker streaming APIs compared](https://openbrokerapi.com/guides/streaming-compared.md): How each broker and platform API pushes prices and account updates: the transport, the cap on streams or subscriptions, and the heartbeat, each with its source and checked date. - [Capital.com API with Python](https://openbrokerapi.com/guides/capital-com-api-python.md): Capital.com publishes a REST API and a Postman collection, but no Python SDK of its own. - [cTrader Open API with Python](https://openbrokerapi.com/guides/ctrader-open-api-python.md): cTrader's API is not REST. - [Does FXCM still offer a REST API?](https://openbrokerapi.com/guides/fxcm-rest-api.md): We could not find a REST API listed by FXCM, and a third party guide dated June 2026 still sells one. - [Export Trading 212 trade history to Excel or a spreadsheet](https://openbrokerapi.com/guides/trading-212-trade-history.md): Export your Trading 212 history as a CSV file from the app: menu, History, Export, then pick the dates and the data. - [ib_async vs ib_insync: which one is maintained, and which is archived](https://openbrokerapi.com/guides/ib-async-vs-ib-insync.md): The most starred Interactive Brokers Python library, ib_insync, is archived and has not been pushed since 14 Mar 2024, and it is still the one most people install: 617,422 (read 2 October 2026) installs of the archived package on the pypistats.org /recent last_month counter, against 556,555 of the maintained continuation, ib_async, on its own reading of 23 Sep 2026. - [IG streaming with Python](https://openbrokerapi.com/guides/ig-lightstreamer-python.md): IG's prices do not stream over its REST API. - [Interactive Brokers MCP servers, compared](https://openbrokerapi.com/guides/interactive-brokers-mcp-servers.md): Search for an Interactive Brokers MCP server and you will find one official route from IBKR itself and a scatter of community repositories nobody has reviewed in one place. - [MetaTrader 5 for Python: which platforms does it run on?](https://openbrokerapi.com/guides/metatrader-5-python-platforms.md): The commonest question about the MetaTrader 5 Python package is which operating systems it runs on. - [MT5 trade history to a spreadsheet with Python](https://openbrokerapi.com/guides/mt5-trade-history-to-a-spreadsheet.md): Asked over and over on the MQL5 forum and answered in no single place. - [The three Interactive Brokers REST front doors compared](https://openbrokerapi.com/guides/ibkr-rest-front-doors.md): Interactive Brokers publishes more than one REST front door and they do not point at each other. - [What AI assistants get wrong about broker APIs](https://openbrokerapi.com/guides/ai-coding-traps.md): You asked an assistant to build it and it does not work. - [What the FCA Handbook PERG says about a UK publisher carrying paid broker links](https://openbrokerapi.com/guides/section-21-and-affiliate-links.md): Only the PERG paragraphs opened on 25 Sep 2026 are used here, and each one is named. - [Is API trading for you?](https://openbrokerapi.com/guides/is-api-trading-for-you.md): One screen for someone who has never coded: who should not bother, the realistic first win, what the first request costs, and what it is not. - [How to use a GitHub repository: the basics](https://openbrokerapi.com/guides/use-a-github-repository.md): How to get a published folder of code onto your computer and running, without knowing Git. - [Instrument names across broker APIs](https://openbrokerapi.com/guides/instrument-names-across-apis.md): What each API calls its identifier for a market, in the words of the records, and why one symbol map across them is hard to build. ## Registers - [Fact register](https://openbrokerapi.com/facts): the figures that appear on more than one page, with the readings each replaced - [Partner programme register](https://openbrokerapi.com/partners/broker-programmes): 29 firms, with what each publishes about its partner programme - [Trading repositories on GitHub](https://openbrokerapi.com/github): 70 listed repositories out of 155 read, ordered by stars with no editorial ranking - [Corrections](https://openbrokerapi.com/corrections): how to report an error and what has been corrected ## Data downloads The registers as JSON at stable addresses, licensed CC BY 4.0 unless the line says otherwise. Each has a CSV at the same address ending .csv, except the index of broker and platform files. - [Limits register](https://openbrokerapi.com/data/limits.json): 35 records, one record per rate limit or allowance, with its scope, source and checked date - [Error records](https://openbrokerapi.com/data/errors.json): 1,776 records, every error code across every broker, platform, standard, language and tool, with a short title made by a stated rule, its HTTP status, category, source, checked date and the address of the page that explains it. All rights reserved and given for reference, not CC BY 4.0 - [Endpoint records](https://openbrokerapi.com/data/endpoints.json): 359 records, every documented HTTP endpoint across every broker and platform API, with its owner, method, path, a title made by a stated rule, task, status, source, checked date and the address of its page. All rights reserved and given for reference, not CC BY 4.0 - [Function and message records](https://openbrokerapi.com/data/calls.json): 215 records, every function and message of an interface that is not HTTP (language bindings, wire protocols and streaming connections), with its owner, kind, interface, name, role, transport, channel, tasks, status, source, checked date and the address of its page. All rights reserved and given for reference, not CC BY 4.0 - [What changed](https://openbrokerapi.com/data/changes.json): 121 records, the whole log of dated changes to broker and platform APIs, each with the page it was read on - [MCP server directory](https://openbrokerapi.com/data/mcp-servers.json): 25 records, one record per MCP server that connects to a broker or platform, marked official or community, with the firms that were looked for and had none found listed beside them - [Partner programme register](https://openbrokerapi.com/data/programmes.json): 29 records, one record per firm, with the published figure as worded and the page opened - [Fact register](https://openbrokerapi.com/data/facts.json): 14 records, the figures that appear on more than one page, each with its source and the readings it replaced - [Trading repositories on GitHub](https://openbrokerapi.com/data/repositories.json): 155 records, repository records read from GitHub, with the date each was read - [Capability grid](https://openbrokerapi.com/data/capabilities.json): 448 records, one record per cell of the capability tables, with its state, source and checked date - [Market data source directory](https://openbrokerapi.com/data/data-sources.json): 20 records, one record per market data source, with its free tier, redistribution terms and position on training AI models as its own pages word them - [Broker and platform files](https://openbrokerapi.com/data/brokers.json): 29 records, the index of one file per broker and per platform, each holding everything this site records for it, with the licence of each section stated in the file - [About the downloads](https://openbrokerapi.com/data): licence and how to cite ## Optional - [Your first Python script: profit and loss on one trade](https://openbrokerapi.com/learn/first-python-script): Write and run a script that works out the profit or loss on one trade. - [Variables and types: what a value can be](https://openbrokerapi.com/learn/variables-and-types): Meet the four kinds of value every script is made of, see why text does not do arithmetic, and convert between them. - [If statements and comparisons: let the program decide](https://openbrokerapi.com/learn/if-statements-and-comparisons): Ask a question in code and do different things depending on the answer. - [Lists and loops: work through many prices](https://openbrokerapi.com/learn/lists-and-loops): Keep a run of prices in a list, pick values out of it, and repeat work over it. - [Write a function: size a position from the risk you choose](https://openbrokerapi.com/learn/functions-and-position-size): Wrap a calculation in a function you can reuse and test, using position sizing as the example. - [Test your own functions with plain asserts](https://openbrokerapi.com/learn/test-your-own-functions): Write down what a function must do as small checks that run in a second, so a later change cannot break it unnoticed. - [Read prices from a file and work out a moving average](https://openbrokerapi.com/learn/read-prices-from-a-file): Load a CSV file of daily prices, keep the closing prices in a list and work out a moving average. - [Dates, times and time zones in Python](https://openbrokerapi.com/learn/dates-times-and-time-zones): Turn timestamps from text into values you can subtract, compare and show in another time zone. - [Read and write JSON, the format broker APIs speak](https://openbrokerapi.com/learn/read-and-write-json): Load a JSON file into Python, pick out what you need, write your own JSON file and read it back. - [Handle money with Decimal, not float](https://openbrokerapi.com/learn/money-with-decimal): See where ordinary decimal numbers go slightly wrong, and use Decimal to add up and round money exactly. - [Build a trade journal from a list of closed trades](https://openbrokerapi.com/learn/build-a-trade-journal): Read closed trades from a file, work out the win rate, average win and loss and the total per market, and write the result to a new file. - [Measure drawdown and losing runs](https://openbrokerapi.com/learn/measure-drawdown): Track a running balance through a list of trades and find the worst fall from a high and the longest losing run. - [What a broker API sends back, and how to read it](https://openbrokerapi.com/learn/read-an-api-response): Open a mock response in the shape a positions call returns and work out the running profit or loss on each position. - [Your first HTTP request: ask the practice API](https://openbrokerapi.com/learn/first-http-request): Make a real HTTP request from Python to this site's practice API and read the account summary it sends back. - [Read your positions and work out exposure by instrument](https://openbrokerapi.com/learn/positions-and-exposure): Fetch the open positions from the practice API, work out how much of each market they hold, and check your own sums against what the API reports. - [API keys, demo accounts and how not to leak either](https://openbrokerapi.com/learn/keys-and-demo-accounts): What an API key is, why you start on a demo account, and the one habit that keeps a key out of your code: environment variables. - [Your first API call: read your positions on a demo account](https://openbrokerapi.com/learn/first-api-call): Log in to a demo account from Python and read your open positions. - [Collect a long history one page at a time](https://openbrokerapi.com/learn/collect-paged-results): Broker APIs hand back long histories in pages. - [Pagination over HTTP: follow the pointer to the next page](https://openbrokerapi.com/learn/follow-the-next-page): Collect a trade history from the practice API one page at a time, by following the pointer each page gives to the next, with a pause between requests and a proof that nothing is missing. - [Turn a price history into moving averages and a CSV file](https://openbrokerapi.com/learn/price-history-to-csv): Fetch ten daily candles from the practice API, work out a three day and a five day simple moving average, write them to a CSV file a spreadsheet can open, and read the file back to prove it is right. - [Handle a failed call: retry, back off, give up](https://openbrokerapi.com/learn/retry-and-backoff): Decide which failures are worth retrying, wait longer after each one, and stop after a fixed number of attempts. - [Stay under a rate limit on purpose](https://openbrokerapi.com/learn/stay-under-a-rate-limit): Build a small pacer that knows how many calls you have made in the last window and tells you how long to wait. - [Handle an error reply: read it, then retry, sign in or stop](https://openbrokerapi.com/learn/handle-an-error-reply): Fetch an expired session and a rate limit refusal from the practice API, read what each body says and act on it: retry only what can succeed on a second try, a fixed number of times. - [Idempotency: do not send an order twice](https://openbrokerapi.com/learn/idempotent-orders): See a retry open the same position twice on a mock broker, then prevent it by sending one reference with every attempt. - [Log what your program did, so you can find out later](https://openbrokerapi.com/learn/log-what-your-program-did): Replace print with logging: messages with a level and a time, sent to the screen and to a file at once. - [Log every API call, and keep secrets out of the log](https://openbrokerapi.com/learn/log-your-api-calls): Put logging inside the one function that makes requests, so that every call to the practice API leaves a line saying what was asked and what came back, and nothing secret is ever written down. - [Backtest a trading rule in plain Python](https://openbrokerapi.com/learn/backtest-an-idea): Turn a rule into code and run it over past prices, with costs, before it goes anywhere near an account. - [The look ahead mistake in a backtest signal](https://openbrokerapi.com/learn/moving-average-look-ahead): Write a signal as a function, write it again with a small slip that lets it see the future, and catch the slip with a test. - [Keep settings and secrets out of your code](https://openbrokerapi.com/learn/settings-from-the-environment): Read every setting in one function, from environment variables with safe defaults, refuse a wrong value before any request is made, and never print a secret. - [Write tests with unittest, on saved replies, with no network](https://openbrokerapi.com/learn/test-with-saved-replies): Save two order confirmations from the practice API to disk once, then test the function that reads them with unittest, with the network switched off for every test. - [Build a command line tool that summarises one instrument](https://openbrokerapi.com/learn/command-line-summary): Turn a script into a small tool: name an instrument when you run it and it prints a summary from the practice API, says plainly when it cannot, and tells the terminal whether it worked.