:seo_title: Pacifica Trading Bot in Python: AI Agent and Algorithmic Trading with LumiBot .. Generated by scripts/generate_ccxt_exchange_pages.py from docsrc/_data/. Edit the data, not this page. Pacifica Trading Bot in Python ============================== .. meta:: :description: Build a Pacifica trading bot in Python with LumiBot and CCXT. Set up Pacifica API wallet keys, connect them, and run a regular or AI agent strategy. :keywords: Pacifica trading bot, Pacifica API, Pacifica Python, agentic trading Pacifica, AI trading bot Pacifica, algorithmic trading Pacifica, ccxt pacifica 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. Pacifica at a glance -------------------- .. list-table:: :widths: 35 65 * - CCXT exchange id - ``pacifica`` * - Markets - Perpetual swaps * - Testnet (sandbox) - Yes * - Credentials - private key, wallet address * - Live data streams - prices, order book, trades, candles, your orders * - CCXT request spacing - about 50 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. In CCXT, Pacifica is set up for its perpetual markets. Sign up for Pacifica -------------------- #. There is no account form. Open app.pacifica.fi and connect a Solana wallet such as Phantom, Solflare or Backpack. #. Deposit USDC into your Pacifica account. Pacifica lists a 10 dollar minimum deposit. #. 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 ---------------------------- #. Pacifica has no API key and secret. A bot signs with an API Agent Key (Pacifica also calls it an agent wallet). #. With your main wallet connected, open the API key page at https://app.pacifica.fi/apikey. #. 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. #. Save the agent wallet's private key and its public key in a safe place. #. 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. .. code-block:: bash 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: .. code-block:: python 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 -------------------------------------------------- CCXT lists no spot market for Pacifica, so this example trades a perpetual contract. It opens one small long BTC position worth about 50 USDC 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. If your account uses hedge mode, add ``position_side="long"`` to ``create_order``. .. code-block:: python 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) order = self.create_order(contract, quantity, "buy") 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() 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. .. code-block:: python 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 the BTC/USDC:USDC perpetual contract (asset_type 'crypto_future'), long or short, or stay flat. " "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:USDC prices and your current position, 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 :doc:`AI agents quickstart ` for models, tools and memory. What you can trade on Pacifica through CCXT ------------------------------------------- .. list-table:: :header-rows: 1 :widths: 40 60 * - Market - Listed by CCXT * - Spot - No * - Margin - No * - Perpetual swaps - Yes * - Dated futures - No * - Options - No CCXT lists these order features for Pacifica: market orders, limit orders, 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/USDC:USDC``. See :doc:`the CCXT guide ` for contract quantities, position modes and leverage. 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/USDC:USDC``. **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 `_ Related guides -------------- * :doc:`CCXT crypto trading with LumiBot ` * :doc:`AI agents quickstart ` * :doc:`AftermathFinance trading bot ` * :doc:`Apex trading bot ` * :doc:`BloFin trading bot ` * :doc:`dYdX trading bot ` Sources ------- * `Pacifica Docs: API Agent Keys `_ (read 2026-10-23) * `Pacifica Docs: MCP Configuration (agent key and testnet host) `_ (read 2026-10-23) * `Pacifica Docs: About Us `_ (read 2026-10-23) * `Pacifica Docs: Trading overview `_ (read 2026-10-23) * `Pacifica Docs: Deposits and Withdrawals `_ (read 2026-10-23) * `Pacifica Docs: Market Symbols `_ (read 2026-10-23) * `Pacifica Docs: Rate Limits `_ (read 2026-10-23) * `CCXT Pacifica adapter source (credential and agentAddress options) `_ (read 2026-10-23) * Exchange id, URLs, markets, credentials and stream support: CCXT 4.5.64 metadata, generated 2026-10-23