Skip to main content

ocean-agent

English · 한국어

Tell your AI to trade. An MCP server for Pacifica that turns natural language into correct, risk-sized perpetual futures orders — plus a 24/7 autonomous trading entity governed by a policy file you control.

uvx ocean-agent        # no install needed

⚠️ This places real orders with real money. Read the disclaimer before connecting an account.

Built entirely on Pacifica. Calls the Pacifica REST API directly with the same Ed25519 agent-key signing the official tooling uses — no npm dependency.


Why this instead of raw API access

The official Pacifica MCP exposes the API as-is: your AI must compute exact prices and sizes itself, and a price that isn't a multiple of the market's tick size is rejected by the exchange. ocean-agent adds the layer above that:

Raw API / official MCP ocean-agent
Order prices AI computes exact values Say "3% stop" — tick/lot/min-order corrected automatically
Position sizing Manual Risk-based (fixed % of capital at risk per trade)
Safety None Two-step confirm gate on every money-moving tool
Statistics None Measured win rates and expected value, not textbook theory

MCP tools

Market & analysis

  • analyze_chart — multi-timeframe indicator snapshot with measured hit rates per signal on that specific coin and timeframe. Says "no edge detected" when there isn't one.
  • top_setups — live ranking of statistically-proven setups (EV × win rate × sample confidence), with entry, stop, target and leverage
  • market_context — Fear & Greed regime read
  • scan_funding — every market ranked by funding APR
  • learned_winrates / learned_combos — win-rate database built from live observation, including multi-signal combinations
  • review_predictions — past calls graded against what actually happened

Trading

  • open_with_bracket — entry plus exchange-native TP/SL in one call. The stops live on the exchange, so they fire even with your machine off.
  • protect_position — retrofit native TP/SL onto any open position
  • open_funding_position / close_funding_position — delta-neutral funding carry (spot buy + perp short) executed atomically as a batch
  • plan_oi_hedge — sizes an OI-farming position with its cross-exchange hedge, fee and funding math included
  • open_pacifica_leg, check_position, account_status

Print (experimental — uses an endpoint Pacifica has not documented; may change without notice)

  • print_quote — live premium, implied volatility and liquidation price
  • print_order / print_status / print_close
  • evaluate_print — statistical verdict on whether a Print offer is worth it: fill probability, average overshoot, and the breakeven APY that would compensate for it

Autonomous trading entity

A self-directed trader governed by policy.yaml — a delegation contract. It cannot act outside those bounds.

This is a separate always-on process, not an MCP tool. An MCP server only runs when your AI client calls it; a trader that must hold positions and manage stops around the clock needs its own process. Start it deliberately, and it keeps running whether or not any AI is connected.

python -m ocean_agent.autonomous --init    # create policy.yaml to edit
python -m ocean_agent.autonomous --dry     # decide, but place no orders
python -m ocean_agent.autonomous           # run continuously
python -m ocean_agent.autonomous --once    # single cycle
python -m ocean_agent.autonomous --report  # performance summary

Read policy.yaml before the first real run — capital, leverage cap, risk per trade and the hard-stop threshold all live there. Start with --dry on testnet.

Each cycle it reads the market, grades what it learned, manages open positions, and enters only setups that clear every gate.

Portfolio buckets — capital split across directional trading, funding carry and a cash reserve, rebalanced every cycle.

Position aftercare — moves the stop to breakeven once a trade is ahead, trails it as profit grows, and takes partial profit at target. Stops only ever move in your favour.

Liquidity gate — skips markets where your own order would be a large share of daily volume. Thin books are the real hazard: an order that only partly fills, and a stop that cannot be executed at its price.

Net-exposure limit — caps how one-directional the book can get, so a single market reversal cannot hit every position at once.

Self-remeasurement — this is the actual learning engine. On a schedule the bot re-measures the full matrix of coins × timeframes × signals and updates which timeframes it trades and which signals it trusts. Regimes change: in one measurement the 8h timeframe showed no edge at all; weeks later it was the best-performing band. Fixed parameters go stale, so they are not fixed.

python -m ocean_agent.rematrix          # remeasure now
python -m ocean_agent.rematrix --show   # what it currently believes

Adaptation — signals that lose in live grading are suspended, size is cut during drawdown and restored on recovery. Parameters adapt within policy bounds; the bot never rewrites its own code.

Final stop — a single hard halt at catastrophic loss. Otherwise it does not stop, it adapts.


Setup

Requires Python 3.10+.

  1. Create an agent wallet key at app.pacifica.fi/apikey. API keys can trade but cannot withdraw funds, and you can revoke them at any time.

  2. Put it in .env:

ADDRESS=your_main_wallet_address
PACIFICA_API_KEY=your_agent_wallet_key

# optional — testnet uses separate keys
ADDRESS_TESTNET=...
PACIFICA_API_KEY_TESTNET=...
  1. Point your MCP client at it:
{
  "mcpServers": {
    "ocean-agent": {
      "command": "uvx",
      "args": ["ocean-agent"],
      "env": { "PACIFICA_ENV_FILE": "/absolute/path/to/.env" }
    }
  }
}

Defaults to testnet. Set PACIFICA_BASE_URL=https://api.pacifica.fi for live trading.

Check your setup with python -m ocean_agent.doctor.


Safety

  • API keys are trading-only — this software cannot move your funds out
  • Every order tool previews first and executes only on explicit confirmation
  • Testnet and mainnet keys are kept separate
  • The autonomous entity acts only within policy.yaml

Risk

This is trading software. Leveraged perpetual futures can lose more than the margin you post. Measured win rates come from historical data and are regime-dependent — an edge that held for months can vanish when the market changes character. Nothing here is financial advice. Run it on testnet until you understand exactly what it does, and only risk what you can afford to lose.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocean_agent-0.3.0.tar.gz (387.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocean_agent-0.3.0-py3-none-any.whl (401.3 kB view details)

Uploaded Python 3

File details

Details for the file ocean_agent-0.3.0.tar.gz.

File metadata

  • Download URL: ocean_agent-0.3.0.tar.gz
  • Upload date:
  • Size: 387.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for ocean_agent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7e1397e7a735a25aa03eda5d882bf0dbd6a552376856e5477a7fef66eea36306
MD5 4128150a3d2a0efbde462c42b72589a5
BLAKE2b-256 ce624d2fd08ed8691de8ba25fa2f44df6a1bdedd39dc7d7c360cd85c7a9fd20f

See more details on using hashes here.

File details

Details for the file ocean_agent-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ocean_agent-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 401.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for ocean_agent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6e6725262c41a3003a532fde951d5ec436649294c1f9e0b5f947125f6f105d1
MD5 b265f4f83c1c8b0654ac915a8a5bdf78
BLAKE2b-256 506462d04affbc2eec0962bbd146447f9cc047de1de04b6166ed003c987e2e0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page