Pacifica Trading Bot in Python

This guide shows how to build a Pacifica trading bot in Python with LumiBot, for both AI agent trading and algorithmic trading. LumiBot connects to Pacifica through CCXT, the open source library that talks to more than 100 crypto exchanges. You will create a Pacifica account and API wallet, connect it, and run two examples: a simple algorithmic trading bot and an agentic trading bot where an AI agent makes the calls.

What BotSpot MCP adds

Use Claude, ChatGPT, Codex, Cursor, VS Code or another MCP-compatible assistant? Connect the free BotSpot MCP for:

  • Skills: build LumiBot strategies.

  • Free data: news, economics and SEC filings.

  • Backtests: run tests and read charts.

  • Cloud hosting: low-cost scheduled bots.

  • Community: share bots and discuss trades.

  • Marketplace: discover and publish strategies.

  • Broker linking: connect accounts through BotSpot.

Connect your AI assistant

Pacifica at a glance

CCXT exchange id

pacifica

Markets

Spot, Perpetual swaps

Testnet (sandbox)

Yes

Credentials

private key, wallet address

Live data streams

prices, order book, trades, candles, your orders

CCXT request spacing

about 600 ms between requests

Official site

https://www.pacifica.fi

API docs

https://docs.pacifica.fi/api-documentation/api/rest-api

Fees

https://docs.pacifica.fi/trading-on-pacifica/trading-fees

What is Pacifica?

Pacifica is a decentralized, self-custody trading platform on Solana that launched in June 2025. It offers perpetual futures on crypto and other markets, plus spot markets quoted in USDC. CCXT 4.5.91 lists both spot and perpetual markets.

Sign up for Pacifica

  1. There is no account form. Open app.pacifica.fi and connect a Solana wallet such as Phantom, Solflare or Backpack.

  2. Deposit USDC into your Pacifica account. Pacifica lists a 10 dollar minimum deposit.

  3. Keep your main wallet’s secret key or seed phrase private. The bot uses a separate agent key instead (see below).

Open a Pacifica account

Set up a Pacifica API wallet

  1. Pacifica has no API key and secret. A bot signs with an API Agent Key (Pacifica also calls it an agent wallet).

  2. With your main wallet connected, open the API key page at https://app.pacifica.fi/apikey.

  3. Generate an agent key and bind it to your account. You sign the binding in your browser, so your main secret never leaves your wallet.

  4. Save the agent wallet’s private key and its public key in a safe place.

  5. Give LumiBot the agent private key as privateKey and your main account address as walletAddress. CCXT reads the agent’s public key from the agentAddress option.

Which permissions to turn on: There are no permission boxes to set. Pacifica says an agent key can trade, but cannot move funds the way your main wallet can, and you can revoke it at any time. Keep your main wallet’s private key out of LumiBot.

Warning

A Pacifica private key is as powerful as the money it controls. Use a separate wallet or API wallet that holds only what you want the bot to trade, keep the key out of your code and out of Git, and move your funds if the key ever leaks.

Connect Pacifica to LumiBot

The simplest way: put these lines in a .env file next to your strategy. LumiBot loads the file, sees TRADING_BROKER=pacifica and connects to Pacifica for you, so your strategy needs no broker code.

TRADING_BROKER=pacifica
PACIFICA_PRIVATE_KEY=your_privateKey
PACIFICA_WALLET_ADDRESS=your_walletAddress
PACIFICA_SANDBOX=true   # testnet; remove this line for your live account

LumiBot reads exactly the fields CCXT needs for Pacifica (privateKey, walletAddress). 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 Pacifica:

import os

PACIFICA_CONFIG = {
    "exchange_id": "pacifica",
    "privateKey": os.environ.get("PACIFICA_PRIVATE_KEY"),
    "walletAddress": os.environ.get("PACIFICA_WALLET_ADDRESS"),
    "sandbox": True,  # testnet first; set False for your live account
}

from lumibot.brokers import Ccxt

broker = Ccxt(PACIFICA_CONFIG)
# then: MyStrategy(broker=broker, ...)

Either way, LumiBot turns on CCXT’s built-in rate limiting for you.

Practice on the Pacifica testnet

Pacifica runs a testnet with its API at https://test-api.pacifica.fi, and it uses test USDC called USDP. Bind a separate agent key for the testnet. Set PACIFICA_SANDBOX=true (or "sandbox": True in a code config) to use it.

CCXT sends sandbox requests to: https://test-api.pacifica.fi. Testnet and live accounts use different keys.

Algorithmic trading example: a simple Pacifica bot

This bot buys about 50 USDC of BTC on Pacifica 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. Pacifica accepts only limit orders through CCXT, so the example places a limit order just above the last price.

from lumibot.entities import Asset
from lumibot.strategies import Strategy


class PacificaBuyOnce(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
            # This exchange takes only limit orders through CCXT.
            order = self.create_order(coin, quantity, "buy", limit_price=price * 1.002, quote=self.quote_asset)
            self.submit_order(order)


if __name__ == "__main__":
    # LumiBot reads TRADING_BROKER and the keys from your .env file.
    strategy = PacificaBuyOnce(quote_asset=Asset("USDC", asset_type=Asset.AssetType.CRYPTO))
    strategy.run_live()

Agentic trading example: an AI agent that trades on Pacifica

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 Pacifica 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 PacificaAITrader(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 Pacifica. "
                "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": "Pacifica", "quote": "USDC", "date": self.get_datetime().isoformat()},
        )


if __name__ == "__main__":
    # LumiBot reads TRADING_BROKER and the keys from your .env file.
    strategy = PacificaAITrader(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 Pacifica

Market

Listed by CCXT

Spot

Yes

Margin

No

Perpetual swaps

Yes

Dated futures

No

Options

No

CCXT lists these order features for Pacifica: stop orders, reduce-only 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.

Perpetual futures example on Pacifica

Pacifica also lists perpetual swaps. This bot opens one small long position in BTC/USDC:USDC worth about 50 USDC and then holds it. LumiBot treats a perpetual as asset_type="crypto_future" and sizes it in contracts, the same model as LumiBot’s Bitunix futures broker. Contract symbols can differ by exchange, so check the symbol in self.broker.api.markets before going live. In hedge mode, add position_side="long" to create_order. Pacifica accepts only limit orders through CCXT, so the example places a limit order just above the last price.

from lumibot.entities import Asset
from lumibot.strategies import Strategy


class PacificaOpenOneLong(Strategy):
    """Open one small long BTC perpetual position, 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):
        # The full CCXT symbol keeps the settlement currency clear.
        contract = self.broker.get_asset("BTC/USDC:USDC")
        if self.get_position(contract) is not None:
            return  # already holding the position
        price = self.get_last_price(contract)
        if price:
            # Each contract covers contract.multiplier BTC; size the order to about 50 USDC.
            quantity = round(50 / (price * contract.multiplier), 6)
            # This exchange takes only limit orders through CCXT.
            order = self.create_order(contract, quantity, "buy", limit_price=price * 1.002)
            self.submit_order(order)


if __name__ == "__main__":
    # LumiBot reads TRADING_BROKER and the keys from your .env file.
    strategy = PacificaOpenOneLong(quote_asset=Asset("USDC", asset_type=Asset.AssetType.CRYPTO))
    strategy.run_live()

Fees and partner IDs on Pacifica

You pay Pacifica’s normal trading fees. LumiBot may attach its own exchange partner ID. That costs you nothing extra. CCXT also adds its own extra builder fee on Pacifica, paid by you. LumiBot turns it off. LumiBot never adds a builder fee unless one is turned on in its settings, and it logs a warning when one is, because it costs you extra on every order.

Pacifica tips

  • CCXT needs your main account address as walletAddress (set PACIFICA_WALLET_ADDRESS) and the agent key as privateKey. If the agent key is not your main key, also set the CCXT option agentAddress to the agent wallet address in a code config, for example "options": {"agentAddress": "..."}.

  • Requests always use your main account’s public address as the account. The agent key only signs, so walletAddress must be your main (or sub-account) address, not the agent address.

  • Perpetuals use cross margin by default, with isolated margin available. Leverage ranges from 3x to 50x depending on the market.

  • Pacifica market symbols are case sensitive, for example BTC and kBONK. In CCXT the BTC perpetual is BTC/USDC:USDC.

  • Pacifica uses a credit-based rate limit with a 60-second rolling window, so keep the bot’s polling modest.

Frequently asked questions

Can I build a Pacifica trading bot in Python?

Yes. Install LumiBot (pip install lumibot), set your Pacifica keys and use the pacifica CCXT exchange id as shown above.

Does Pacifica have a testnet?

Yes. Set PACIFICA_SANDBOX=true and use keys from the Pacifica testnet.

Which keys does a Pacifica bot need?

There are no permission boxes to set. Pacifica says an agent key can trade, but cannot move funds the way your main wallet can, and you can revoke it at any time. Keep your main wallet’s private key out of LumiBot.

Can an AI agent trade on Pacifica 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 Pacifica 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 Pacifica 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.

Try BotSpot

Sources