feat(algo): Made algo 100% market_regime compliant. Added epsilon. Tested. Increased regime calcs per tick
This commit is contained in:
@@ -334,7 +334,7 @@ class SILOQYMainActorConfig(ActorConfig):
|
|||||||
|
|
||||||
class DOLPHINRegimeActorConfig(ActorConfig):
|
class DOLPHINRegimeActorConfig(ActorConfig):
|
||||||
max_symbols: int = 5000
|
max_symbols: int = 5000
|
||||||
ticks_per_analysis: int = 250
|
ticks_per_analysis: int = 10
|
||||||
|
|
||||||
class SILOQYNormalizerConfig(ActorConfig):
|
class SILOQYNormalizerConfig(ActorConfig):
|
||||||
pass
|
pass
|
||||||
@@ -989,6 +989,9 @@ class DOLPHINRegimeActor(Actor):
|
|||||||
bullish = 0
|
bullish = 0
|
||||||
bearish = 0
|
bearish = 0
|
||||||
|
|
||||||
|
# NEW: Track pattern of bullish/bearish symbols for this calculation
|
||||||
|
symbol_pattern = []
|
||||||
|
|
||||||
# PRESERVED: Original analysis with exact thresholds
|
# PRESERVED: Original analysis with exact thresholds
|
||||||
for idx in range(self.active_symbols):
|
for idx in range(self.active_symbols):
|
||||||
open_price = self.open_prices[idx]
|
open_price = self.open_prices[idx]
|
||||||
@@ -999,13 +1002,23 @@ class DOLPHINRegimeActor(Actor):
|
|||||||
|
|
||||||
analyzed += 1
|
analyzed += 1
|
||||||
|
|
||||||
# PRESERVED: EXACT DOLPHIN thresholds
|
# NEW: Direct price comparison with epsilon for precision
|
||||||
change = (close_price - open_price) / open_price
|
EPSILON = 1e-10 # Very small tolerance to capture any meaningful price change
|
||||||
|
|
||||||
if change >= 0.0015: # 0.15% threshold for bullish
|
# Check if prices are effectively equal
|
||||||
|
if abs(close_price - open_price) <= EPSILON:
|
||||||
|
# Prices are effectively equal
|
||||||
|
symbol_pattern.append(f"S{close_price:.2f}={open_price:.2f}")
|
||||||
|
elif close_price > open_price:
|
||||||
|
# Bullish: close > open
|
||||||
bullish += 1
|
bullish += 1
|
||||||
elif change <= -0.0015: # -0.15% threshold for bearish
|
# Arrow points to close (larger price)
|
||||||
|
symbol_pattern.append(f"B{open_price:.2f}->{close_price:.2f}")
|
||||||
|
else:
|
||||||
|
# Bearish: close < open
|
||||||
bearish += 1
|
bearish += 1
|
||||||
|
# Arrow points to open (larger price)
|
||||||
|
symbol_pattern.append(f"X{close_price:.2f}<-{open_price:.2f}")
|
||||||
|
|
||||||
if analyzed == 0:
|
if analyzed == 0:
|
||||||
return
|
return
|
||||||
@@ -1056,9 +1069,16 @@ class DOLPHINRegimeActor(Actor):
|
|||||||
self.regime_history.append(regime)
|
self.regime_history.append(regime)
|
||||||
|
|
||||||
# Periodic regime status (even without changes)
|
# Periodic regime status (even without changes)
|
||||||
if self.regime_calculations % 10 == 0: # Every 10 calculations
|
if self.regime_calculations % 1 == 0: # Every calculation
|
||||||
self.log.info(f"REGIME STATUS: {regime.value} | Bull: {bull_ratio:.1%} "
|
self.log.info(f"REGIME STATUS: {regime.value} | Bull: {bull_ratio:.1%} "
|
||||||
f"Bear: {bear_ratio:.1%} | Processed: {self.processed_ticks} ticks")
|
f"Bear: {bear_ratio:.1%} | Processed: {self.processed_ticks} ticks")
|
||||||
|
|
||||||
|
# NEW: Log symbol pattern and counts
|
||||||
|
if symbol_pattern: # Only if we have symbols to show
|
||||||
|
pattern_str = " ".join(symbol_pattern) + " " # Create pattern with spaces
|
||||||
|
bull_count = sum(1 for s in symbol_pattern if s.startswith("B"))
|
||||||
|
bear_count = sum(1 for s in symbol_pattern if s.startswith("X"))
|
||||||
|
self.log.info(f"{pattern_str} and totals: BULLS:{bull_count}/BEARS:{bear_count}")
|
||||||
|
|
||||||
def _calculate_confidence(self, bull_ratio: float, bear_ratio: float,
|
def _calculate_confidence(self, bull_ratio: float, bear_ratio: float,
|
||||||
analyzed: int, total: int) -> float:
|
analyzed: int, total: int) -> float:
|
||||||
@@ -1194,7 +1214,7 @@ def test_siloqy_actors_with_nautilus_process_management():
|
|||||||
config={
|
config={
|
||||||
"component_id": "DOLPHIN-REGIME-ACTOR",
|
"component_id": "DOLPHIN-REGIME-ACTOR",
|
||||||
"max_symbols": 5000,
|
"max_symbols": 5000,
|
||||||
"ticks_per_analysis": 250 # Reduced for throttle mode testing
|
"ticks_per_analysis": 2 # Reduced for throttle mode testing
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user