Crypto Calcs
Tutorial11 min read

Automate Position Sizing Based on Multi-Factor Trade Confirmation

Automate position sizing using a confirmation score API. Fetch composite scores, map confidence to risk percentage, and execute trades via webhook. Step-by-step

The Problem: Fixed Position Sizes Miss Confluence

Most retail crypto traders allocate the same percentage of capital to every trade—whether the setup has a single moving-average crossover or a rare alignment of five independent signals. A fixed 2% risk per trade ignores the reality that not all trade ideas are created equal. When derivatives open interest spikes, spot exchange netflows turn bullish, whale wallets accumulate aggressively, and macro sentiment flips risk‑on simultaneously, the probability of a profitable move is dramatically higher than when only one of those conditions is present. Ignoring this confluence means leaving money on the table during high‑probability windows—and often over‑exposing the account during weak setups that barely satisfy a single indicator.

Confluence in crypto is the art (and science) of layering independent data signals. A position sizing strategy that stays rigid regardless of confirmation quality suffers from two critical flaws: under‑sizing when the stars align, and over‑sizing when the case is thin. Traders who recognize this problem turn to dynamic sizing models that scale risk proportionally to the strength of evidence. But building a multi‑source scoring engine from scratch is non‑trivial; you need real‑time derivatives data, on‑chain analytics, whale‑wallet monitoring, and a way to fuse it all into a single numeric score. The solution is to consume a purpose‑built confirmation score API that does the heavy lifting, allowing you to automate position sizing decisions with institutional‑grade intelligence.

Solution: Fetch Confirmation Scores via API

Instead of manually scanning funding rates, Google Trends, and Etherscan, you can delegate the data aggregation to an API that returns a composite confirmation score. This score condenses multiple streams into a single number between 0 and 1, along with a recommended size multiplier and a confidence label. An API of this kind typically fuses four categories:

  • Derivatives metrics – open interest changes, funding rate extremes, long/short ratio, liquidation volumes.
  • On‑chain data – exchange netflows, active addresses, MVRV Z‑score, supply in profit.
  • Whale activity – tracking 1,500+ high‑net‑worth wallets for accumulation or distribution patterns.
  • Macro overlay – cross‑asset sentiment indices, DXY, equity correlation, fear‑and‑greed readings.

The Smart Money API is one such tool that delivers exactly this fusion. It exposes a simple REST endpoint that, given a trading pair and direction, returns a composite score, a confidence level (LOW, MEDIUM, HIGH, VERY HIGH), a practical size_mult field that you can plug directly into your risk formulas, and the individual sub‑scores for full transparency. With a documented 62% win rate on HIGH signals, it provides an edge that mechanical fixed‑sizing simply cannot match. The free tier offers enough requests to build and test a robust position‑scaling bot before you commit a single satoshi.

How to Size Positions Using a Confirmation Score API — Smart Money API
Smart Money API's dashboard dashboard.

Once you have access to a real‑time score, the entire sizing workflow shifts from guesswork to a repeatable algorithm. In the sections below, you will learn how to call the endpoint, interpret the response, map confidence to a risk percentage, and finally automate the process with a webhook‑driven Python bot.

Building a Confidence Scoring Function

Your first engineering step is to encapsulate the API call into a reusable Python function. This keeps your trading logic clean and makes it easy to swap data providers later. Below is a step‑by‑step procedure to build a robust get_confirmation() function.

  1. Obtain an API key. Sign up at the Smart Money API and copy your key from the dashboard. Treat it like a password; never hard‑code it into a public repository.
  2. Store the key securely. Use environment variables (e.g., export SMARTMONEY_API_KEY="your‑key") or a .env file that you load with python‑dotenv. In your script, read it via os.getenv("SMARTMONEY_API_KEY").
  3. Define the function signature. It should accept a symbol (e.g., "ETH") and a direction ("long" or "short"). The function will return the full JSON response dictionary.
  4. Add error handling and retries. Wrap the request in a try/except block that catches requests.exceptions.RequestException. If the API returns a non‑200 status code, log the error and return a safe fallback (e.g., None or a default low‑confidence score).
  5. Implement request timeout. Trading bots cannot hang on a slow API. Set a socket timeout of 5 seconds and a read timeout of 10 seconds. If the request exceeds the limit, abort and move on.
  6. Validate the response. Ensure the JSON contains the keys you expect ("composite", "confidence", "size_mult"). If not, treat it as an error to avoid mis‑sized positions.

While a simple mean‑reversion of scores would work, you can later blend this confirmation score with a dynamic fraction derived from the Kelly Criterion calculator on CryptoCalcs, which gives the optimal stake for a given edge and win probability. Stock the function away inside a module named signals.py so every part of your bot can import it.

API Integration: Calling /v1/confirm for Your Trade Pair

The Smart Money API operates a dedicated endpoint for trade confirmation. A single GET request with the pair and direction returns everything you need. Below is the exact request and a real response example.

GET /v1/confirm?symbol=BTC&direction=long
{
  "composite": 0.74,
  "confidence": "HIGH",
  "action": "CONFIRM",
  "size_mult": 1.5,
  "deriv_score": 0.81,
  "onchain_score": 0.68,
  "whale_score": 0.73
}

The response fields break down as follows:

  • composite (0.00 – 1.00): the overall weighted score; higher values represent stronger confluence.
  • confidence: a human‑readable label (LOW, MEDIUM, HIGH, VERY HIGH) mapped from the composite score thresholds.
  • action: either CONFIRM or WAIT, giving a binary go/no‑go recommendation.
  • size_mult: the recommended multiplier on your base risk (e.g., 1.5 means increase risk by 50%).
  • deriv_score, onchain_score, whale_score: granular sub‑scores so you can monitor which component is driving the composite.

To integrate this into a Python application, follow these steps:

  1. Import the requests library.
  2. Define the base URL (e.g., BASE_URL = "https://api.smartmoneyapi.com/v1").
  3. Construct the parameters dictionary: {"symbol": symbol, "direction": direction}.
  4. Set the headers dictionary with your API key: {"X‑API‑Key": api_key}.
  5. Issue the request: response = requests.get(f"{BASE_URL}/confirm", params=params, headers=headers, timeout=10).
  6. Check response.status_code. If 200, parse response.json(); otherwise, raise an exception or log an alert.
  7. Extract the composite, confidence, and size_mult from the parsed JSON and return them to the caller.

Always respect the API rate limits; cache the result for a few seconds if your bot polls more frequently than the API updates (usually every 30–60 seconds).

Mapping Score to Position Size (Risk Percentage)

With the size_mult in hand, you can dynamically scale your position. The idea is to start with a base risk percentage – the amount you are willing to lose on a “normal” trade – and multiply it by the API‑supplied multiplier. A conservative framework is shown in the table below.

Composite Score RangeConfidence Levelsize_multSuggested Account Risk
>= 0.80VERY HIGH2.0x2.5% – 3.0%
0.65 – 0.79HIGH1.5x1.5% – 2.0%
0.50 – 0.64MEDIUM1.0x1.0%
< 0.50LOW0.5x or skip0.5% or no trade

The multiplier approach is simple and prevents emotional override. For instance, if your base risk per trade is 1% of a $10,000 account, a HIGH signal with size_mult 1.5 gives you a $150 risk budget. To translate that into contract quantity, you can use the position size calculator on CryptoCalcs, which factors in your entry price and stop‑loss distance. Follow these steps:

  1. Retrieve size_mult from the API response.
  2. Define your base risk percentage (e.g., base_risk_pct = 1.0).
  3. Calculate adjusted risk: risk_pct = base_risk_pct * size_mult.
  4. Cap the maximum risk to prevent over‑allocation (e.g., risk_pct = min(risk_pct, 3.0)).
  5. Determine your stop‑loss distance in price terms (e.g., 2% below entry for a long).
  6. Plug account balance, entry price, stop‑loss, and risk_pct into the position size calculator to get the exact number of contracts.
  7. If using the Kelly Criterion as an overlay, compute the optimal fraction for the estimated win rate and blend it with the size_mult to avoid over‑betting.

This mapping turns a raw score into an actionable contract size, all without manual intervention.

Webhook Automation: Auto‑Size When Conditions Met

Polling the API every few seconds works, but a true automation leverages a webhook: your bot receives a notification the moment a high‑confidence signal fires, then immediately fetches the score, sizes the position, and places the order. Here’s how to build that flow using a lightweight web framework like Flask.

  1. Set up a webhook listener. Create a Flask or FastAPI endpoint that accepts POST requests from your signal provider. It should parse a JSON payload containing {"symbol": "BTC", "direction": "long"}.
  2. Validate the incoming payload. Check that the required fields exist and the direction is either long or short. Return a 400 Bad Request if not.
  3. Call the confirmation score function. Use the get_confirmation() from your module. If the returned confidence is "LOW" or the action is "WAIT", abort the trade and return a 200 with a message that the signal was ignored.
  4. Compute the position size. With the size_mult and your risk parameters, calculate the contract quantity using the strategy above.
  5. Execute the order via your exchange API. Use a library like ccxt to place a market or limit order on Binance, Bybit, or your preferred venue. Set the stop‑loss immediately after execution.
  6. Log everything. Record the signal, the API response, the computed size, and the exchange order ID into a database or a simple CSV file for later review.
  7. Return a response to the webhook provider. Send a 200 status with a JSON summary so you can monitor bot activity from your phone.

This webhook architecture ensures you never miss a high‑confluence setup while keeping a human in the loop only for oversight. The Smart Money API’s role is central: without its multi‑factor score, the webhook would be flying blind, sizing every alert identically.

Code Example: Python Bot with Smart Money API

Below is a minimal yet complete Python script that demonstrates the entire flow. It polls a configuration file (or you could trigger it externally), obtains a confirmation score, calculates the position size, and prints the summary that would be sent to an exchange. Replace the exchange‑specific order function with your own.

import os
import requests
import json
import time
from dotenv import load_dotenv

load_dotenv()
API_KEY = os.getenv("SMARTMONEY_API_KEY")
BASE_URL = "https://api.smartmoneyapi.com/v1"

# ---------- Confirmation Fetch ----------
def get_confirmation(symbol, direction):
    """Call Smart Money API and return full response."""
    params = {"symbol": symbol, "direction": direction}
    headers = {"X-API-Key": API_KEY}
    try:
        resp = requests.get(f"{BASE_URL}/confirm",
                           params=params,
                           headers=headers,
                           timeout=10)
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        print(f"API error: {e}")
        return None

# ---------- Position Size Calculator ----------
def calculate_position(account_balance, entry_price, stop_loss,
                       base_risk_pct, size_mult, max_risk_pct=3.0):
    """Return contract quantity based on risk parameters."""
    risk_pct = min(base_risk_pct * size_mult, max_risk_pct)
    risk_amount = account_balance * (risk_pct / 100.0)
    stop_distance = abs(entry_price - stop_loss)
    if stop_distance == 0:
        return 0
    position_size = risk_amount / stop_distance
    return round(position_size, 6)

# ---------- Main Bot Loop ----------
def main():
    account = 10000.0          # $10,000 account
    base_risk = 1.0            # 1% base risk
    symbol = "BTC"
    direction = "long"
    entry = 65000.0
    stop = 63700.0             # -2% stop

    print(f"Fetching confirmation for {symbol} {direction}...")
    data = get_confirmation(symbol, direction)
    if data is None:
        print("Could not retrieve confirmation score. Exiting.")
        return

    composite = data.get("composite", 0)
    confidence = data.get("confidence", "LOW")
    size_mult = data.get("size_mult", 1.0)

    print(f"Score: {composite:.2f} | {confidence} | multiplier: {size_mult}")

    if confidence in ("LOW", "MEDIUM"):
        print("Confidence too low — skipping trade.")
        return

    qty = calculate_position(account, entry, stop, base_risk, size_mult)
    print(f"Calculated quantity: {qty} (risk ${account*(base_risk*size_mult/100):.2f})")
    # Here you would call your exchange's order function, e.g.:
    # place_order(symbol, direction, qty, entry, stop)

if __name__ == "__main__":
    main()

The script is deliberately modular: get_confirmation() handles all API communication, calculate_position() translates risk into size, and main() orchestrates the decision. You can swap the static execution with a webhook handler by wrapping the core logic inside a Flask route. The critical takeaway is that the entire sizing decision now hinges on a multi‑factor, data‑driven score — no more gut‑feel or uniform 2% betting.

Conclusion and Next Steps

Automated position sizing powered by a confirmation score API transforms your trading from uniform risk to intelligent, evidence‑based allocation. By fetching a composite score that merges derivatives, on‑chain, whale, and macro data, you ensure that your capital is deployed hardest when the odds are clearly in your favor and dialled back when the picture is murky. The Smart Money API provides that score with a single call, complete with a ready‑to‑use size multiplier and a track record of 62% win rate on HIGH signals. Get your free API key at Smart Money API signup and start building your own auto‑sizing bot today. Pair it with the CryptoCalcs position size and Kelly Criterion calculators to fine‑tune every parameter, and within a few hours you can have a system that sizes with the precision of a quantitative fund — operating around the clock on your favourite exchange.

Frequently Asked Questions

What is a confirmation score API?

A confirmation score API aggregates multiple data sources — such as derivatives, on-chain metrics, whale activity, and macro sentiment — into a single composite score that indicates the probability of a successful trade. It helps traders make data-driven sizing decisions rather than using a fixed risk percentage for every setup.

How does Smart Money API calculate its composite score?

Smart Money API combines weighted sub-scores from derivatives (funding rates, open interest, liquidations), on-chain data (exchange netflows, MVRV Z-score), whale wallet tracking (1,500+ addresses), and a macro overlay. All sub-scores are normalized to a 0–1 scale and blended into a final composite, along with a size_mult recommendation.

Can I use the free tier of Smart Money API for position sizing?

Yes. The free tier provides full access to the confirmation endpoint and includes enough monthly requests to build, test, and even run a personal trading bot. You only need to upgrade when your request volume exceeds the free limits.

Is a webhook necessary for automated position sizing?

A webhook isn’t strictly required, but it’s the most efficient way to trigger sizing logic instantly when a high-confidence signal appears. Without a webhook, your bot would need to poll the API frequently, missing opportunities if the timing lags or wasting resources.

How do I map a confirmation score to my risk percentage?

Start with a base risk per trade (e.g., 1% of your account). Multiply that base by the API’s size_mult field, which reflects the composite confidence level. For example, a size_mult of 1.5 turns a 1% base risk into a 1.5% risk. You can also cap the risk at a maximum, like 3%, to preserve capital during extreme-but-rare events.

position sizing confirmation APIauto position sizing apiconfidence score positionmulti-factor sizingwebhook position sizingapi-driven tradingcrypto position sizing automation