@@ -292,6 +292,63 @@ def _calculate_opportunity_scores(self) -> Dict[str, int]:
292292
293293 return self .opportunity_scores
294294
295+ def _calculate_coin_score (self , symbol : str , prices : np .ndarray , volumes : np .ndarray ) -> int :
296+ """Calculate opportunity score for a single coin (more aggressive)."""
297+ # Base score starts at 50 (neutral)
298+ score = 50
299+
300+ try :
301+ # Check if we have enough data
302+ if len (prices ) < 10 :
303+ return 50
304+
305+ # Calculate price changes
306+ if len (prices ) >= 2 :
307+ recent_change = (prices [- 1 ] / prices [- 2 ] - 1 ) * 100
308+ # Reward recent price increases more aggressively
309+ if recent_change > 1 :
310+ score += recent_change * 2 # Double weight for upward movement
311+ elif recent_change < - 1 :
312+ score -= abs (recent_change )
313+
314+ # Calculate RSI
315+ rsi = self ._calculate_rsi (prices )
316+
317+ # RSI component - more aggressive weighting
318+ if rsi < 30 : # Oversold - buying opportunity
319+ score += (30 - rsi ) * 1.5
320+ elif rsi > 70 : # Overbought - selling opportunity
321+ score -= (rsi - 70 ) * 1.5
322+
323+ # Price trend component - shorter timeframes for faster response
324+ if len (prices ) >= 6 :
325+ short_ma = np .mean (prices [- 3 :]) # 3-period MA (was 5)
326+ long_ma = np .mean (prices [- 6 :]) # 6-period MA (was 10)
327+
328+ # More aggressive scoring for uptrends
329+ if short_ma > long_ma : # Uptrend
330+ trend_strength = (short_ma / long_ma - 1 ) * 100
331+ score += 10 + trend_strength
332+ else : # Downtrend
333+ trend_weakness = (1 - short_ma / long_ma ) * 100
334+ score -= 10 + trend_weakness
335+
336+ # Volume component - more aggressive
337+ if len (volumes ) >= 3 :
338+ avg_volume = np .mean (volumes [- 4 :- 1 ]) # Last 3 periods excluding current
339+ current_volume = volumes [- 1 ]
340+
341+ # Higher volume is more important
342+ if current_volume > avg_volume * 1.5 :
343+ volume_increase = (current_volume / avg_volume - 1 ) * 10
344+ score += 10 + volume_increase
345+
346+ except Exception as e :
347+ print (f"Error in score calculation: { e } " )
348+
349+ # Ensure score is within 0-100 range
350+ return max (0 , min (100 , int (score )))
351+
295352 def _calculate_rsi (self , prices : np .ndarray , period : int = 14 ) -> float :
296353 """Calculate Relative Strength Index."""
297354 if len (prices ) < period + 1 :
0 commit comments