Fractrade ExecutionClient

The ExecutionClient is a Python client that executes trading actions received via WebSocket from the Fractrade platform.

Overview

The Fractrade platform (fractrade.xyz) allows you to create trading agents that generate trading actions. Each agent has a dedicated WebSocket connection that broadcasts these actions. The ExecutionClient connects to this WebSocket and executes the trading actions locally on your machine.

Action Types

The client handles the following action types:

  1. EXECUTE_HYPERLIQUID_PERP_TRADE: Execute perpetual trades (open/close positions)

  2. SET_HYPERLIQUID_PERP_STOP_LOSS: Set stop loss orders

  3. SET_HYPERLIQUID_PERP_TAKE_PROFIT: Set take profit orders

Installation

pip install fractrade-executor

Configuration

The executor requires the following environment variables:

# Required
FRAC_WS_URL=wss://your-websocket-url
FRAC_USER_TOKEN=your-user-token
HYPERLIQUID_PRIVATE_KEY=your-private-key
HYPERLIQUID_PUBLIC_ADDRESS=your-wallet-address

# Optional
LOGLEVEL=INFO  # Set to DEBUG for more detailed logs

Basic Usage

Advanced Usage

You can customize the executor by subclassing FractradeExecutor and overriding its methods:

WebSocket Messages

The executor receives WebSocket messages in the following format:

Error Handling

The executor includes comprehensive error handling and logging:

  • Connection errors are automatically retried

  • Trade execution errors are logged with details

  • Invalid messages are logged and skipped

  • Graceful shutdown on interruption

Logging

The executor uses Python's standard logging module. Set the LOGLEVEL environment variable to control log output:

Last updated