Skip to main content

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.

The GBM Plus API Python library (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.
This is an unofficial, reverse-engineered library and is not affiliated with or endorsed by GBM. The GBM Plus / Homebroker API is not publicly documented. Development of this library relied on reverse engineering the platform’s private API. GBM’s Terms of Service state: “Se encuentra prohibido colocar o utilizar los Servicios y Contenidos del Portal en sitios o páginas propias o de terceros, sin autorización previa y por escrito de GBM.” While directly consuming the API is not explicitly prohibited, GBM may interpret this library as falling under that clause. It is solely your responsibility to review the Terms of Service and determine whether your use is permitted before proceeding.

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. The gbmplus 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 main GBMPlusAPI 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 pattern client.scope.operation(...), where:
  • client is the GBMPlusAPI instance you create at startup.
  • scope is one of the four modules: accounts, orders, transfers, or tradingUSA.
  • operation is the specific API method you want to call.
For example, to retrieve all of your strategies (accounts):
import gbmplus

gbm = gbmplus.GBMPlusAPI(output_log=False)

accounts = gbm.accounts.getAccounts()
print(accounts)
When you call GBMPlusAPI(...), the SDK automatically:
  1. Reads your credentials from environment variables (or constructor arguments).
  2. Calls session.authenticate() against the GBM auth endpoint to obtain a Bearer access token.
  3. Calls session.getMainContract() to resolve your primary contract ID, which is required by most subsequent requests.
After instantiation, the session object silently attaches the 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 the gbmplus package:
ExportTypeDescription
GBMPlusAPIClassMain client object. Authenticates and exposes the four API modules.
OrderTypesEnumOrder direction: OrderTypes.Buy (1) or OrderTypes.Sell (8).
TradingTypesEnumOrder execution style: TradingTypes.Limited (0) or TradingTypes.Market (5).
InstrumentTypesEnumMarket segment: InstrumentTypes.SIC (0) or InstrumentTypes.IPC (2).
UserErrorExceptionRaised when one or more credentials are missing at instantiation.
AuthenticationErrorExceptionRaised when the GBM+ auth endpoint rejects the supplied credentials.
import gbmplus
from gbmplus.exceptions import UserError, AuthenticationError

# Enums are used when submitting orders
order_type = gbmplus.OrderTypes.Buy
trading_type = gbmplus.TradingTypes.Market
instrument = gbmplus.InstrumentTypes.IPC

Requirements

Before using gbmplus, make sure you have the following:
Python 3
required
The library requires Python 3. Install it from python.org if you do not already have it.
pip
required
The standard Python package manager. Used to install gbmplus from the Python Package Index.
USER_EMAIL
required
The email address associated with your GBM+ account.
USER_PASSWORD
required
The password for your GBM+ account.
CLIENT_ID
required
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.

Build docs developers (and LLMs) love