This example shows how to buy US stocks through the Trading USA account usingDocumentation 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.
gbm.tradingUSA.generateOrderUSA(). Unlike Mexican market orders, Trading USA orders require an instrument_id — an internal GBM identifier that is not the same as the stock ticker. You retrieve the correct instrument_id by calling getMarketsUSA() and looking up the ticker in the results before placing your order.
Prerequisites
Before running this example, make sure you have:- An authenticated GBM+ session (valid email, password, and
client_id) - The Trading USA strategy activated in your GBM+ account
- The ticker symbol of the US stock you want to buy (e.g.
'AMZN')
Full example
Step-by-step walkthrough
Instantiate the client
Create a
GBMPlusAPI instance. The SDK authenticates your GBM+ session immediately on construction.Get the Trading USA account
Fetch the Trading USA strategy account object by its exact name using the
getAccount() convenience helper.Extract the account_id
The
account_id is used to scope all Trading USA API calls (order submission, order retrieval) to your specific Trading USA contract.Fetch the full list of US market instruments
getMarketsUSA() returns a list of all instruments available on the Trading USA platform, each with a security_id (the ticker) and an instrument_id (the internal GBM identifier required for order placement).getMarketsUSA() retrieves a large list of instruments and may take several seconds to complete. Consider caching the result if you need to look up multiple tickers in the same session.Build a ticker-keyed dictionary and look up your stock
Index the markets list by
security_id (the ticker symbol) so you can retrieve any instrument by its familiar ticker.Extract the instrument_id
Pull the
instrument_id from the matched market entry. This is the value you will pass to generateOrderUSA().Place the buy order
Call
generateOrderUSA() with the account ID, ticker, amount in MXN, and instrument ID. The SDK submits the order to the Trading USA API and returns the response payload.Understanding instrument IDs
US orders on GBM+ cannot be placed using only the ticker symbol. Every instrument has aninstrument_id — an internal GBM identifier — that must be included in the order payload. The mapping between tickers and instrument IDs is surfaced by getMarketsUSA(), which returns a list of objects shaped like:
security_id — is the recommended way to resolve a human-readable ticker to its corresponding instrument_id before placing an order:
Order amount
Theamount parameter in generateOrderUSA() is denominated in Mexican Pesos (MXN), not US dollars and not shares. GBM+ Trading USA supports fractional investing, so you can buy as little as 20 MXN worth of a stock regardless of its per-share price. The platform converts the peso amount to the equivalent fractional share position at execution time.