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.1.1.tar.gz (18.0 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.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for algoglide-0.1.1.tar.gz
Algorithm Hash digest
SHA256 20e27c71622cbbe5cd2dfcac596fe2de1a86139e3987fcea6c3f8b44bf4663a3
MD5 fd477dd1099dc7eae56d55a92551bd59
BLAKE2b-256 b8760a1b7e7c336b11d4ff92ace0ab154aa082e6c20967a2b84aa67c3d554f4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: algoglide-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cdee3d1c151147f48b0c56a2ada4fd48bf76445527b7c5283501a3c7bb25327
MD5 b86c3d125200860cf3e7cded5bfb2441
BLAKE2b-256 04a17738a7b40e860764c9f8537989f3f877f7c334be03fc3881da575e413a3c

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