Bullish Trading Bot in Python¶
This guide shows how to build a Bullish trading bot in Python with LumiBot, for both AI agent trading and algorithmic trading. LumiBot connects to Bullish through CCXT, the open source library that talks to more than 100 crypto exchanges. You will create a Bullish account and API key, connect it, and run two examples: a simple algorithmic trading bot and an agentic trading bot where an AI agent makes the calls.
Bullish at a glance¶
CCXT exchange id |
|
Markets |
Spot, Perpetual swaps |
Testnet (sandbox) |
Yes |
Credentials |
API key, API secret |
Live data streams |
prices, order book, trades, your orders, your balance, your positions |
CCXT request spacing |
about 20 ms between requests |
Official site |
|
API docs |
What is Bullish?¶
Bullish is a regulated crypto exchange where you can buy, sell and trade digital assets such as Bitcoin and Ethereum. It offers spot and derivatives trading.
Sign up for Bullish¶
Create a Bullish account.
From the User Menu, choose Complete Account Verification and finish identity verification. Bullish says you cannot trade or deposit until this is done.
Register a two-factor authenticator, either a passkey (such as a hardware key) or a TOTP app.
Create a Bullish API key¶
Log in to Bullish, click your account initials in the upper right corner, then click Settings.
Click API Keys, then Add API Key.
Choose HMAC as the API Key type. LumiBot (through CCXT) signs in with an HMAC key and secret.
Enter a name in the Key Name field and, if you want, add an IP whitelist with your bot’s IP address.
Click Generate API Key and copy the key and secret somewhere safe.
Which permissions to turn on: Use an HMAC key for your bot. Bullish says HMAC keys only work on trading endpoints, while custody actions (deposits and withdrawals) need an ECDSA key. So an HMAC key can trade but cannot move money out. Do not give your bot an ECDSA key.
Warning
Never turn on withdrawals for a Bullish trading bot key. Bind the key to your server’s IP address when Bullish lets you, keep the secret out of your code and out of Git, and delete the key if it ever leaks.
Connect Bullish to LumiBot¶
The simplest way: put these lines in a .env file next to your strategy. LumiBot loads the file, sees TRADING_BROKER=bullish and connects to Bullish for you, so your strategy needs no broker code.
TRADING_BROKER=bullish
BULLISH_API_KEY=your_apiKey
BULLISH_API_SECRET=your_secret
BULLISH_SANDBOX=true # testnet; remove this line for your live account
LumiBot reads exactly the fields CCXT needs for Bullish (apiKey, secret). If one is missing, LumiBot stops at start-up and names the variable you still need.
You can also build the broker in code. This is handy when one script talks to more than one exchange, or when you need extra CCXT options. The keys in the config are CCXT’s own credential names for Bullish:
import os
BULLISH_CONFIG = {
"exchange_id": "bullish",
"apiKey": os.environ.get("BULLISH_API_KEY"),
"secret": os.environ.get("BULLISH_API_SECRET"),
"sandbox": True, # testnet first; set False for your live account
}
from lumibot.brokers import Ccxt
broker = Ccxt(BULLISH_CONFIG)
# then: MyStrategy(broker=broker, ...)
Either way, LumiBot turns on CCXT’s built-in rate limiting for you.
Practice on the Bullish testnet¶
Bullish’s docs mention sandbox and non-production environments, and CCXT’s sandbox mode points at Bullish’s SimNext test host (https://api.simnext.bullish-test.com). Bullish does not publish a public sign-up page for it, so contact Bullish support to get test access first. Then set BULLISH_SANDBOX=true (or "sandbox": True in a code config) to use it.
CCXT sends sandbox requests to: https://api.simnext.bullish-test.com/trading-api. Testnet and live accounts use different keys.
Algorithmic trading example: a simple Bullish bot¶
This bot buys about 50 USDC of BTC on Bullish once and then holds it. It is a starting point to check that your keys, balances and orders work. If the exchange’s minimum order is larger, raise the amount.
from lumibot.entities import Asset
from lumibot.strategies import Strategy
class BullishBuyOnce(Strategy):
"""Buy a small amount of BTC once, then hold it."""
def initialize(self):
self.sleeptime = "1H"
self.set_market("24/7") # crypto trades all day, every day
def on_trading_iteration(self):
coin = Asset("BTC", asset_type=Asset.AssetType.CRYPTO)
if self.get_position(coin) is not None:
return # already holding BTC
price = self.get_last_price(coin, quote=self.quote_asset)
if price:
quantity = round(50 / price, 6) # about 50 USDC worth
order = self.create_order(coin, quantity, "buy", quote=self.quote_asset)
self.submit_order(order)
if __name__ == "__main__":
# LumiBot reads TRADING_BROKER and the keys from your .env file.
strategy = BullishBuyOnce(quote_asset=Asset("USDC", asset_type=Asset.AssetType.CRYPTO))
strategy.run_live()
Agentic trading example: an AI agent that trades on Bullish¶
Agentic trading means an AI agent reads the market and decides what to do. In this example one LumiBot agent looks at prices and your Bullish account, then places the orders itself. There is no Python logic in between: you set the rules in plain English in the prompt, such as what it may trade and how big each order can be. This follows the same pattern as LumiBot’s AI trading team examples.
from lumibot.entities import Asset
from lumibot.strategies import Strategy
class BullishAITrader(Strategy):
"""One AI agent researches the market and places the trades itself."""
def initialize(self):
self.sleeptime = "4H"
self.set_market("24/7")
self.agents.create(
name="trader",
model="openai/gpt-6-luna",
reasoning_effort="high",
allow_trading=True,
system_prompt=(
"You manage a small crypto account on Bullish. "
"You may trade BTC and ETH against USDC (asset_type 'crypto', quote_symbol 'USDC'), or hold cash. "
"Before every order, call account_portfolio, account_positions and "
"market_last_price for that exact symbol in the same run. "
"Keep each order under 10% of the account value. "
"Explain each decision in one short paragraph."
),
)
def on_trading_iteration(self):
self.agents["trader"].run(
task_prompt="Review recent BTC/USDC and ETH/USDC prices and your current holdings, then decide whether to buy, sell or hold.",
context={"exchange": "Bullish", "quote": "USDC", "date": self.get_datetime().isoformat()},
)
if __name__ == "__main__":
# LumiBot reads TRADING_BROKER and the keys from your .env file.
strategy = BullishAITrader(quote_asset=Asset("USDC", asset_type=Asset.AssetType.CRYPTO))
strategy.run_live()
The agent needs a model key such as OPENAI_API_KEY in your environment. See the AI agents quickstart for models, tools and memory.
What you can trade on Bullish through CCXT¶
Market |
Listed by CCXT |
|---|---|
Spot |
Yes |
Margin |
No |
Perpetual swaps |
Yes |
Dated futures |
No |
Options |
No |
CCXT lists these order features for Bullish: market orders, limit orders, editing open orders, canceling orders.
For perpetual contracts, use the full CCXT symbol so the settlement currency is clear, for example BTC/USDT:USDT. See the CCXT guide for contract quantities, position modes and leverage.
Bullish tips¶
If you add an IP whitelist to your key, Bullish only accepts login requests from inside that IP range. Add the address of every machine that runs your bot.
Bullish orders are placed in a trading account. By default CCXT uses your Primary trading account. To use another one, set the CCXT option
tradingAccountId.Bullish spot markets are quoted in USDC (Bullish’s own market name is
BTCUSDC, which isBTC/USDCin CCXT). Run CCXTload_markets()to see the exact symbols for perpetuals.Bullish’s sign-in tokens last 24 hours. CCXT logs in again for you, so you do not need to refresh anything by hand.
Frequently asked questions¶
Can I build a Bullish trading bot in Python?
Yes. Install LumiBot (pip install lumibot), set your Bullish keys and use the bullish CCXT exchange id as shown above.
Does Bullish have a testnet?
Yes. Set BULLISH_SANDBOX=true and use keys from the Bullish testnet.
Which API permissions does a Bullish bot need?
Use an HMAC key for your bot. Bullish says HMAC keys only work on trading endpoints, while custody actions (deposits and withdrawals) need an ECDSA key. So an HMAC key can trade but cannot move money out. Do not give your bot an ECDSA key.
Can an AI agent trade on Bullish by itself?
Yes. The agentic example above gives one agent permission to trade. You control what it may trade and how much through its prompt.
Can I trade Bullish perpetual futures with LumiBot?
CCXT lists perpetual swaps for this exchange. Use the full contract symbol, such as BTC/USDT:USDT.
Is LumiBot free?
Yes. LumiBot is open source on GitHub at https://github.com/Lumiwealth/lumibot. You pay only your exchange’s trading fees and, for AI agents, your model provider.
Run it in the cloud with BotSpot¶
Do not want to keep a computer running for your Bullish bot? BotSpot is the hosted home for LumiBot strategies and AI trading agents: build with AI, backtest, connect a broker, and watch every trade with logs and alerts.
Sources¶
Bullish Developer Docs: Authentication (read 2026-10-23)
Bullish Developer Docs: REST API Overview (read 2026-10-23)
Bullish Developer Docs: Connectivity Options (read 2026-10-23)
Bullish Help Center: Steps to Complete Your KYC at Bullish (read 2026-10-23)
Bullish Help Center: Improving the safety and security of your Bullish account (read 2026-10-23)
Bullish home page (read 2026-10-23)
Exchange id, URLs, markets, credentials and stream support: CCXT 4.5.64 metadata, generated 2026-10-23