Skip to content

Portfolio Rebalancer

Signal-driven portfolio rebalancer using composite scores and regime filters. Framework: Python + numpy.

Live Output Preview

If you ran this bot right now, the API would return:

# Live API output — June 17, 2026
Market Regime: Trending
Safety Score: 96.1 (HIGH)

Composite Signals:
  BTC: sell (score: -0.269)\n  ETH: neutral (score: -0.094)\n  SOL: sell (score: -0.135)\n  HYPE: strong_sell (score: -0.357)\n
# The bot would use this data to make trading decisions

Complete Source Code

Copy this code and run — no API key required:

import requests

BASE = "https://algotick.dev"

def get_target_allocation():
    """Signal-driven portfolio rebalancer using composite and regime."""
    composite = requests.get(f"{{BASE}}/v1/signals/composite",
                            params={{}}).json()
    safety = requests.get(f"{{BASE}}/v3/signals/safety",
                         params={{}}).json()

    coherence = safety.get("coherence_score", 50)
    cash_weight = max(0.1, 1 - coherence / 100)  # More cash when signals disagree

    allocations = {{}}
    for sig in composite.get("signals", []):
        coin = sig.get("coin")
        score = sig.get("composite_score", 0)
        regime = sig.get("regime", "neutral")

        # Score-weighted allocation
        weight = max(0, (score + 1) / 2)  # Normalize -1..1 to 0..1
        if "mean" in regime.lower():
            weight *= 0.5  # Reduce size in mean-reverting regimes
        allocations[coin] = weight

    # Normalize
    total = sum(allocations.values()) or 1
    risk_budget = 1 - cash_weight
    for coin in allocations:
        allocations[coin] = (allocations[coin] / total) * risk_budget

    allocations["CASH"] = cash_weight

    print("\nTarget Allocation:")
    for coin, weight in sorted(allocations.items(), key=lambda x: -x[1]):
        print(f"  {{coin}}: {{weight*100:.1f}}%")

get_target_allocation()

Setup Instructions

  1. Install dependencies: pip install requests (Python) or npm install node-fetch (TypeScript)
  2. Run the script and monitor the output
  3. Connect your exchange API for live trading

API Endpoints Used

Framework
Python + numpy
Data Source
Algo Tick API
# No API key required. All endpoints used by this template:
curl https://algotick.dev/v3/signals/regime
curl https://algotick.dev/v1/signals/composite
curl https://algotick.dev/v3/signals/safety
curl https://algotick.dev/v1/signals/volatility?coin=BTC

Don't just stare at the dashboard. Automate it.

Every metric on this page is available via our sub-millisecond API.
Build trading bots, backtest strategies, and power AI agents with institutional-grade data.

Explore API →

More Python Templates

Other Frameworks

Continue the Research

⚡ API Docs📁 Data Library📖 Playbooks🎯 Alpha Strategies