Implement Broker API
Overview
This step-by-step tutorial walks you through implementing the required methods to enable basic trading functionality using the Broker API. By the end of this guide, you'll know how to:
- Set up the widget and connect it to your broker implementation.
- Make symbols tradable and provide detailed instrument data.
- Enable trading buttons, Account Manager, and Order Ticket.
- Load and manage orders.
This tutorial is split into two parts:
- Enable trading UI — focuses on setting up the UI and activating key trading components like the Order Ticket and Account Manager.
- Manage orders — covers how to store, return, and update orders to make the trading flow functional.
This guide focuses on the bare minimum needed to get trading components working. Once complete, you’ll have a functional mocked Broker API implementation — ideal for testing UI and workflows before connecting to a real backend.
Before you start
Consider taking the following steps before proceeding with the tutorial:
- Set up the Widget Constructor and run the library. Refer to the First run tutorial for more information.
- Connect data to the library. Refer to the Connecting data tutorial for more information.
- (Optional) Enable debug logs for troubleshooting.
Class scaffold
The class used in broker.ts
provides a skeleton implementation of the Broker API.
Initially, all methods simply throw error messages — this helps highlight which methods are missing when the library tries to use them.
As you follow the tutorial, we’ll gradually replace these errors with basic mock implementations. This allows you to:
- Get a functional mock setup.
- See which UI components depend on which methods.
- Understand how the Broker API interacts with the library step by step.
Click to reveal broker.ts
broker.ts