Skip to main content

fastest python trading bot

Project description

walrasquant

walrasquant is a high-performance Python framework for quantitative trading. It is designed for low-latency execution, multi-exchange connectivity, and strategy development at scale.

Highlights

  • Async-first architecture for real-time trading workflows
  • Multi-exchange support (OKX, Binance, Bybit, Hyperliquid, Bitget)
  • Built-in order and position lifecycle management
  • Strategy framework with execution algorithms (including TWAP)
  • Optional web API integration with FastAPI
  • CLI and PM2 tooling for monitoring and operations

Installation

Requirements

  • Python >=3.11,<3.14
  • Redis (recommended for monitoring and shared runtime state)

From PyPI

pip install walrasquant

From source

git clone https://github.com/walras-group/WalrasQuant.git
cd WalrasQuant
uv pip install -e .

Quick start

from decimal import Decimal

from walrasquant.constants import settings, ExchangeType, OrderSide, OrderType
from walrasquant.config import Config, BasicConfig, PublicConnectorConfig, PrivateConnectorConfig
from walrasquant.engine import Engine
from walrasquant.exchange.okx import OkxAccountType
from walrasquant.schema import BookL1, Order
from walrasquant.strategy import Strategy


OKX_API_KEY = settings.OKX.DEMO_1.api_key
OKX_SECRET = settings.OKX.DEMO_1.secret
OKX_PASSPHRASE = settings.OKX.DEMO_1.passphrase


class DemoStrategy(Strategy):
    def __init__(self):
        super().__init__()
        self.subscribe_bookl1(symbols=["BTCUSDT-PERP.OKX"])
        self.signal = True

    def on_filled_order(self, order: Order):
        print(order)

    def on_bookl1(self, bookl1: BookL1):
        if not self.signal:
            return

        self.create_order(
            symbol="BTCUSDT-PERP.OKX",
            side=OrderSide.BUY,
            type=OrderType.MARKET,
            amount=Decimal("0.1"),
        )
        self.create_order(
            symbol="BTCUSDT-PERP.OKX",
            side=OrderSide.SELL,
            type=OrderType.MARKET,
            amount=Decimal("0.1"),
        )
        self.signal = False


config = Config(
    strategy_id="okx_demo_buy_sell",
    user_id="user_test",
    strategy=DemoStrategy(),
    basic_config={
        ExchangeType.OKX: BasicConfig(
            api_key=OKX_API_KEY,
            secret=OKX_SECRET,
            passphrase=OKX_PASSPHRASE,
            testnet=True,
        )
    },
    public_conn_config={
        ExchangeType.OKX: [PublicConnectorConfig(account_type=OkxAccountType.DEMO)]
    },
    private_conn_config={
        ExchangeType.OKX: [PrivateConnectorConfig(account_type=OkxAccountType.DEMO)]
    },
)

engine = Engine(config)

if __name__ == "__main__":
    try:
        engine.start()
    finally:
        engine.dispose()

CLI tools

After installation, the following commands are available:

  • wq for PM2-based strategy process operations

Documentation

  • Local docs source: docs/

Contributing

Contributions are welcome. Please open an issue or submit a PR.

License

MIT License

Project details


Download files

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

Source Distribution

walrasquant-0.3.14.tar.gz (220.3 kB view details)

Uploaded Source

Built Distribution

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

walrasquant-0.3.14-py3-none-any.whl (264.7 kB view details)

Uploaded Python 3

File details

Details for the file walrasquant-0.3.14.tar.gz.

File metadata

  • Download URL: walrasquant-0.3.14.tar.gz
  • Upload date:
  • Size: 220.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for walrasquant-0.3.14.tar.gz
Algorithm Hash digest
SHA256 aee2b028dc2a4fa5b262a1ee5361f65a178400fde7d535f562b542dea4c5edd4
MD5 d0442a9665e9df8bd561559503192dfe
BLAKE2b-256 96c0f30eccad5312b37c36f8609c92b1f1b53470b3174a031213375b6f095b7d

See more details on using hashes here.

File details

Details for the file walrasquant-0.3.14-py3-none-any.whl.

File metadata

  • Download URL: walrasquant-0.3.14-py3-none-any.whl
  • Upload date:
  • Size: 264.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for walrasquant-0.3.14-py3-none-any.whl
Algorithm Hash digest
SHA256 88dcde2b89ba0e63db6fc7bd1fa351117050d092c184b7cf2dd2fe33c3a28ed7
MD5 a0d192dd931f67c3aba6c0518dfdaadc
BLAKE2b-256 fad805ed2c6c49029ca3f43a5c88fdb25f0c4220b53afd406cd9b4ed9126ce5a

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