Implementation:51bitquant Ai hedge fund crypto weighted signal combination
| Knowledge Sources | |
|---|---|
| Domains | Signal_Generation, Decision_Fusion |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
Concrete tool for fusing multiple categorical trading signals into a single weighted bullish/neutral/bearish decision provided by the `weighted_signal_combination` function.
Description
weighted_signal_combination maps each signal's `signal` string to a numeric value (`bullish:1, neutral:0, bearish:-1`) and computes a confidence-weighted sum: `Σ(value × weight × confidence) / Σ(weight × confidence)`. The normalized score is thresholded at ±0.2 to produce the final `bullish` (>0.2), `bearish` (<-0.2), or `neutral` signal. Confidence of the result is `abs(final_score)`.
Usage
Call this function to combine the outputs of the five signal calculators in general_indicators, or to combine any set of `{name: {signal, confidence}}` dicts with a matching weights dict. Used by MacdStrategy.
Code Reference
Source Location
- Repository: ai-hedge-fund-crypto
- File: src/indicators/general_indicators.py
Signature
def weighted_signal_combination(signals: Dict[str, Dict], weights: Dict[str, float]) -> Dict[str, Any]:
signal_values = {"bullish": 1, "neutral": 0, "bearish": -1}
weighted_sum = 0
total_confidence = 0
for strategy, signal in signals.items():
numeric_signal = signal_values[signal["signal"]]
weight = weights[strategy]
confidence = signal["confidence"]
weighted_sum += numeric_signal * weight * confidence
total_confidence += weight * confidence
final_score = weighted_sum / total_confidence if total_confidence > 0 else 0
if final_score > 0.2:
signal = "bullish"
elif final_score < -0.2:
signal = "bearish"
else:
signal = "neutral"
return {"signal": signal, "confidence": abs(final_score)}
Import
from src.indicators.general_indicators import weighted_signal_combination
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| signals | Dict[str, Dict] | Yes | `{strategy_name: {"signal": str, "confidence": float, ...}}` |
| weights | Dict[str, float] | Yes | `{strategy_name: weight}`; keys must match `signals` |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Dict[str, Any] | "neutral"|"bearish", "confidence": float}` |
Usage Examples
Combine Five Signals
from src.indicators.general_indicators import (
calculate_trend_signals, calculate_momentum_signals, weighted_signal_combination,
)
signals = {
"trend": calculate_trend_signals(df),
"momentum": calculate_momentum_signals(df),
}
weights = {"trend": 0.25, "momentum": 0.25}
combined = weighted_signal_combination(signals, weights)
print(combined["signal"], combined["confidence"])