The GBM Plus API Python library (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/markzuckerbergas/gbmplus-api-python/llms.txt
Use this file to discover all available pages before exploring further.
gbmplus) is a community-built Python SDK that lets you interact with the GBM Plus and Homebroker trading platform programmatically. With it you can retrieve account and strategy data, place buy and sell orders on Mexican and US markets, execute cash transfers between strategies, and integrate your GBM+ portfolio into any Python script or application — all through a clean, object-oriented interface.
What is GBM Plus?
GBM Plus (formerly Homebroker) is a retail brokerage platform operated by GBM (Grupo Bursátil Mexicano) that allows individual investors in Mexico to buy and sell securities on the Mexican Stock Exchange (IPC/BMV) as well as US-listed stocks through its Trading USA product. Users manage multiple investment strategies (accounts) within a single contract, and can move cash freely between them. Thegbmplus library exposes these capabilities via a Python API so you can automate trading workflows, backtest ideas, and monitor your portfolio without using the web interface.
Library overview
The SDK is organized into four functional modules, each accessible as a property on the mainGBMPlusAPI client object.
Accounts
Retrieve your GBM+ contract, list all strategies (accounts), look up a strategy by name, and fetch cash transaction history.
Orders
Submit, track, and cancel buy or sell orders for Mexican-market instruments using market or limit order types.
Transfers
Move cash between your GBM+ strategies, for example from Smart Cash to an investment strategy.
Trading USA
Place orders for US-listed equities (e.g. AMZN, AAPL) through the GBM+ Trading USA product.
How it works
Every operation in the library follows the patternclient.scope.operation(...), where:
clientis theGBMPlusAPIinstance you create at startup.scopeis one of the four modules:accounts,orders,transfers, ortradingUSA.operationis the specific API method you want to call.
GBMPlusAPI(...), the SDK automatically:
- Reads your credentials from environment variables (or constructor arguments).
- Calls
session.authenticate()against the GBM auth endpoint to obtain a Bearer access token. - Calls
session.getMainContract()to resolve your primary contract ID, which is required by most subsequent requests.
Authorization: Bearer <token> header to every outgoing request — you never have to manage tokens manually.
Public API exports
The following names are importable directly from thegbmplus package:
| Export | Type | Description |
|---|---|---|
GBMPlusAPI | Class | Main client object. Authenticates and exposes the four API modules. |
OrderTypes | Enum | Order direction: OrderTypes.Buy (1) or OrderTypes.Sell (8). |
TradingTypes | Enum | Order execution style: TradingTypes.Limited (0) or TradingTypes.Market (5). |
InstrumentTypes | Enum | Market segment: InstrumentTypes.SIC (0) or InstrumentTypes.IPC (2). |
UserError | Exception | Raised when one or more credentials are missing at instantiation. |
AuthenticationError | Exception | Raised when the GBM+ auth endpoint rejects the supplied credentials. |
Requirements
Before usinggbmplus, make sure you have the following:
The library requires Python 3. Install it from python.org if you do not already have it.
The standard Python package manager. Used to install
gbmplus from the Python Package Index.The email address associated with your GBM+ account.
The password for your GBM+ account.
A client identifier tied to your GBM+ session. This value is not the same as your account number.
Finding your CLIENT_ID: The
CLIENT_ID is visible in the GBM+ login dashboard. Open the login page in your browser, open the browser’s developer tools (F12), navigate to the Network tab, and inspect the authentication request to auth.gbm.com. The clientid field in the request payload is your CLIENT_ID. You can also find guidance in the project README which includes a screenshot of where to locate it.