Skip to content

dimes-fi/multiply-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

dimes-multiply

PyPI version Python 3.9+ License: MIT

Python SDK for the Dimes Multiply leverage protocol. Multiply is an embedded leverage layer for prediction markets — it lets traders take leveraged positions on market outcomes across platforms like Polymarket and Kalshi.

Installation

pip install dimes-multiply

Quick Start

from multiply import MultiplyClient

client = MultiplyClient(api_key="your-api-key")

# Browse prediction markets with leverage
markets = client.get_markets(
    platform="polymarket",
    status="active",
    min_leverage=3,
)

# Open a 5x leveraged long position
result = client.create_position(
    market_id=markets.data[0]["id"],
    outcome_id=markets.data[0]["outcomes"][0]["id"],
    side="long",
    collateral_usdc=100,
    leverage=5,
)

pos = result.position
print(f"Opened {pos.leverage}x position — notional: ${pos.notional_usdc}")

API Reference

MultiplyClient(api_key, base_url=None, chain_id=137, timeout=30)

Parameter Type Default Description
api_key str required API key from app.dimes.fi/developers
base_url str https://api.dimes.fi/v1 API base URL
chain_id int 137 Chain ID (Polygon)
timeout float 30 Request timeout in seconds

The client can be used as a context manager:

with MultiplyClient(api_key="your-key") as client:
    markets = client.get_markets()

Markets

client.get_markets(**kwargs)

List available prediction markets with optional filters.

markets = client.get_markets(
    platform="polymarket",    # Filter by platform
    status="active",          # "active", "paused", "resolved", "expired"
    min_liquidity=10_000,     # Minimum USDC liquidity
    min_leverage=2,           # Minimum leverage available
    query="election",         # Search query
    limit=50,                 # Results per page (max 200)
    offset=0,                 # Pagination offset
)

client.get_market(market_id)

Get a single market by ID.

client.get_leverage(market_id)

Get leverage tiers, margin requirements, and funding rates.

info = client.get_leverage("market_abc123")
print(f"Max leverage: {info.max_leverage}x")
print(f"Funding rate: {info.funding_rate_annualized}%")
for tier in info.tiers:
    print(f"  {tier.leverage}x — margin: {tier.initial_margin:.0%}")

Positions

client.create_position(**kwargs)

Open a leveraged position.

result = client.create_position(
    market_id="market_abc123",
    outcome_id="outcome_yes",
    side="long",              # "long" or "short"
    collateral_usdc=100,      # Collateral in USDC
    leverage=5,               # Leverage multiplier
    max_slippage=0.01,        # 1% slippage tolerance
)

client.get_position(position_id)

Get position details including current PnL.

client.get_positions(status=None)

List all positions. Optionally filter by "open", "closed", or "liquidated".

client.close_position(position_id, fraction=1.0, max_slippage=None)

Close a position fully or partially.

# Close 50% of a position
result = client.close_position("pos_xyz789", fraction=0.5)

Account

client.get_account()

Get account summary with balance, locked collateral, unrealized PnL, and health factor.

Types

All Pydantic models are importable:

from multiply import (
    Market,
    Position,
    LeverageInfo,
    LeverageTier,
    CreatePositionParams,
    Account,
)

Examples

See the examples/ directory:

Error Handling

The SDK raises httpx.HTTPStatusError for non-2xx responses:

import httpx

try:
    result = client.create_position(...)
except httpx.HTTPStatusError as e:
    print(f"API error {e.response.status_code}: {e.response.text}")

Links

License

MIT

About

Python SDK for Dimes Multiply — embedded leverage infrastructure for prediction markets. Build trading bots and analytics with Polymarket leverage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages