Skip to main content

Algoglide agent runtime SDK

Project description

algoglide

Algoglide agent runtime SDK for Python

Build, backtest, and deploy prediction-market trading agents.

Docs  ·  algoglide.com  ·  MCP Plugin


Install

pip install algoglide

Quick start

from algoglide import BaseStrategy, TickContext

class MomentumAgent(BaseStrategy):
    markets = ["will-bitcoin-hit-100k-by-2026"]

    def on_market_update(self, ctx: TickContext) -> None:
        yes = ctx.market.outcome("Yes")
        if not yes:
            return

        # Buy YES when price is below 40 cents
        if yes.price < 0.40 and ctx.market.elapsed_pct > 0.3:
            ctx.buy("Yes", size_usd=10.0, limit_price=yes.price + 0.01)
            ctx.log(f"Buying YES at {yes.price:.3f}")

        # Take profit above 65 cents
        if yes.price > 0.65:
            ctx.sell("Yes", size_usd=10.0)
            ctx.log(f"Taking profit at {yes.price:.3f}")

Concepts

Strategies are event-driven. You define a class that extends BaseStrategy, list the markets you want to trade, and implement on_market_update. The runtime calls your method on every price tick.

No polling loops. Never use while True or time.sleep. The runtime handles scheduling.

Context object. Every hook receives a TickContext (or FillContext) with market state, position info, and order methods.

Market state

def on_market_update(self, ctx: TickContext) -> None:
    # Current market snapshot
    yes = ctx.market.outcome("Yes")   # OutcomeSnapshot or None
    no  = ctx.market.outcome("No")

    # Price, spread, volume
    price = yes.price        # 0.0 - 1.0
    spread = ctx.market.spread
    volume = ctx.market.volume_24h

    # How far through the market's lifetime (0.0 = start, 1.0 = end)
    elapsed = ctx.market.elapsed_pct

Orders

# Market buy
ctx.buy("Yes", size_usd=10.0)

# Limit buy
ctx.buy("Yes", size_usd=10.0, limit_price=0.55)

# Sell
ctx.sell("Yes", size_usd=10.0)

# Cancel
ctx.cancel(order_id)

Fill handling

from algoglide import BaseStrategy, FillContext

class MyAgent(BaseStrategy):
    markets = ["some-market-slug"]

    def on_market_update(self, ctx):
        pass

    def on_fill(self, ctx: FillContext) -> None:
        ctx.log(f"Filled: {ctx.outcome} @ {ctx.price:.3f}, size={ctx.size:.2f}")
        ctx.log(f"Position: {ctx.position.size} @ avg {ctx.position.avg_price:.3f}")

Event decorators

from algoglide import BaseStrategy, on_news, on_signal_change

class NewsAgent(BaseStrategy):
    markets = ["fed-rate-decision-june"]

    def on_market_update(self, ctx):
        pass

    @on_news("federal reserve rate decision")
    def handle_fed_news(self, item):
        self.log(f"News: {item.headline}")

    @on_signal_change("fed-rate-decision-june", threshold=0.1)
    def handle_signal_shift(self, before, after):
        self.log(f"Signal shifted: {before.confidence:.2f} -> {after.confidence:.2f}")

Deploy

# Validate locally
algoglide validate agent.py

# Deploy to algoglide cloud
algoglide deploy agent.py --name "my-momentum-bot"

Or deploy via the MCP plugin in Claude Code / Cursor / Cline.

Links

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

algoglide-0.2.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

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

algoglide-0.2.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file algoglide-0.2.0.tar.gz.

File metadata

  • Download URL: algoglide-0.2.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for algoglide-0.2.0.tar.gz
Algorithm Hash digest
SHA256 79b6c8932c361fded2e2eb21cc7b86db6335a18cc1e12cdcab5e787fa3d8ca45
MD5 7e6b8ea41e5fc9376525a970105924ca
BLAKE2b-256 e31e93db8cee7b290fd52d95009c64b62c5e62cecbe133b47f519e450acd00f5

See more details on using hashes here.

File details

Details for the file algoglide-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: algoglide-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for algoglide-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bee7ffe4c183fc3f46a9ab9b7871dbffe79dfefbac42f498adfb55e43070bf6d
MD5 520b83a2c5c48e0bb8c38312c6d4839b
BLAKE2b-256 e1b9b3a54809c8e7739b3d666f670a0d32f03be603c704763b7a18d040242061

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