File size: 4,777 Bytes
da0ce7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

import sys
import os
import time
from dataclasses import dataclass
from typing import Dict, Any

# Mock Dr. Auris / Sero Advice
@dataclass
class SeroAdvice:
    recommendation: str
    confidence: float
    reasoning: str

# Mock Client for Capital
class MockCapitalClient:
    def place_market_order(self, symbol, side, quantity):
        print(f"\n[MOCK CAPITAL] πŸ”« EXECUTING SNIPER KILL: {side} {quantity} {symbol}")
        print(f"[MOCK CAPITAL] βœ… ORDER ACCEPTED (ID: mock_12345)")
        time.sleep(1) # Sim latency
        return {
            "dealReference": "mock_12345", 
            "status": "ACCEPTED",
            "id": "mock_12345",
            "filled_qty": quantity,
            "filled_avg_price": 101.00 # Mock fill price
        }

# Mock Cost Basis Info
class MockCostBasisTracker:
    def can_sell_profitably(self, symbol, current_price, exchange=None, quantity=None):
        entry_price = 100.00
        print(f"   βœ… [MOCK] Cost basis found: {symbol} -> entry ${entry_price:.2f}")
        return True, {'entry_price': entry_price}

    def update_position(self, *args, **kwargs):
        pass

class MockTradeLogger:
    def log_trade(self, *args, **kwargs):
        print(f"[MOCK LOGGER] Trade logged successfully.")
    
    def log_execution(self, *args, **kwargs):
        print(f"[MOCK LOGGER] Execution logged successfully.")

# Import the specific module (assumes python path is correct)
sys.path.insert(0, os.getcwd())

try:
    from orca_complete_kill_cycle import OrcaKillCycle, QUEEN_MIN_PROFIT_PCT
except ImportError:
    print("❌ Could not import OrcaKillCycle. Run this from repo root.")
    sys.exit(1)

# Subclass to inject mocks
class ValidatedSniperOrca(OrcaKillCycle):
    def __init__(self):
        # Skip full init to avoid loading everything
        self.running = True
        self.positions = {}
        self.clients = {'capital': MockCapitalClient()}
        self.cost_basis_tracker = MockCostBasisTracker()
        self.fee_rates = {'capital': 0.001}
        self.truth_bridge = None # Default
        self.is_real_win = None # Disable external fee check for mock
        self.epsilon_profit_usd = 0.0001
        self.cop_min_action = None
        self.cop_max_action = None
        self.cop_last_action = None
        self.trade_logger = MockTradeLogger()
        self.tracked_positions = {}
        
    def _prediction_window_ready(self, symbol):
        # Force a "NOT READY" to prove the bypass works
        return False, {'reason': 'NO_VALIDATED_PREDICTIONS'}

    def _get_sero_advice_sync(self, symbol, side, context, queen_confidence):
        print(f"\nπŸ‘‘ [QUEEN] Speaking to Dr. Auris Throne about {symbol}...")
        print(f"πŸ€– [DR AURIS] Analyzing market structure for {symbol}...")
        print(f"πŸ€– [DR AURIS] VALIDATED: Market conditions support aggressive action.")
        print(f"πŸ‘‘ [QUEEN] APPROVED. Proceed with {side}.")
        return SeroAdvice(recommendation='PROCEED', confidence=0.95, reasoning="Market Structure Supports Sell")

def run_test():
    orca = ValidatedSniperOrca()
    
    symbol = "TSLA"
    exchange = "capital"
    quantity = 1.0
    
    # Scene Setup
    entry_price = 100.00
    # Current price is HIGHER than Target (0.40%)
    # Target = 100.40. Let's make it 101.00 (1% profit)
    current_price = 101.00 
    entry_cost = entry_price * quantity
    
    print("="*60)
    print(f"πŸ§ͺ TESTING IRA SNIPER LOGIC ON {exchange.upper()} ({symbol})")
    print(f"πŸ“‰ Entry: ${entry_price:.2f}")
    print(f"πŸ“ˆ Current: ${current_price:.2f}")
    print(f"🎯 Target Growth: {QUEEN_MIN_PROFIT_PCT}%")
    print("="*60)

    # 1. Validating the "Bird in Hand" Logic first (queen_approved_exit)
    print("\nπŸ” STEP 1: Queen Validation Check...")
    can_exit, info = orca.queen_approved_exit(
        symbol=symbol,
        exchange=exchange,
        current_price=current_price,
        entry_price=entry_price,
        entry_qty=quantity,
        entry_cost=entry_cost,
        reason="TARGET_HIT"
    )
    
    print("   ...Validation Complete.")
    
    # 2. Executing the Kill (execute_sell_with_logging)
    print("\nπŸ” STEP 2: Executing Kill Cycle (simulating real call)...")
    
    # We pass the result of step 1 as context basically
    orca.execute_sell_with_logging(
        client=orca.clients['capital'],
        symbol=symbol,
        quantity=quantity,
        exchange=exchange,
        current_price=current_price,
        entry_cost=entry_cost,
        reason="GROWTH_MODE_TARGET"
    )

    print("\nβœ… TEST COMPLETE: Logic verification finished.")

if __name__ == "__main__":
    run_test()