Summary
PEP 8 and clean-code principles discourage magic numbers (unexplained numeric literals) in function bodies. pulseengine/core/signals.py and pulseengine/core/price.py contain several such constants that are not defined in config.py.
Affected locations
pulseengine/core/signals.py — compute_signal_score
raw["trend"] = {"uptrend": 2.0, "downtrend": -2.0, "sideways": 0.0}.get(trend, 0.0)
raw["momentum"] = round(max(-2.0, min(2.0, roc / 5.0)), 2) # 5.0 is undocumented
sentiment_raw = max(-2.0, min(2.0, avg_sent * 4.0)) # 4.0 is undocumented
raw["trend_strength"] = round(max(-1.0, min(1.0, ts / 3.0)), 2) # 3.0 is undocumented
pulseengine/core/price.py — classify_trend
if ma7 > ma30 * 1.01: # 1% band threshold
return "uptrend"
if ma7 < ma30 * 0.99: # same
return "downtrend"
Proposed fix
Add named constants to pulseengine/core/config.py:
# Signal scoring normalisation denominators
SIGNAL_TREND_MAX = 2.0
SIGNAL_MOMENTUM_NORMALISER = 5.0
SIGNAL_SENTIMENT_SCALE = 4.0
SIGNAL_TREND_STRENGTH_NORMALISER = 3.0
# Trend classification band (1 % MA divergence triggers uptrend/downtrend)
TREND_BAND_PCT = 0.01
Then reference these constants in the relevant functions instead of the bare literals.
Summary
PEP 8 and clean-code principles discourage magic numbers (unexplained numeric literals) in function bodies.
pulseengine/core/signals.pyandpulseengine/core/price.pycontain several such constants that are not defined inconfig.py.Affected locations
pulseengine/core/signals.py—compute_signal_scorepulseengine/core/price.py—classify_trendProposed fix
Add named constants to
pulseengine/core/config.py:Then reference these constants in the relevant functions instead of the bare literals.