"""Пример: трейдинг-сигнал buy/sell/wait с confidence-гейтом. НЕ финансовый совет — демонстрация паттерна (см. jarrodwatts/jev-trader).""" import sys, os sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from jev_client import decide MIN_CONFIDENCE = 0.6 # ниже порога -> всегда wait def signal(snapshot: dict) -> dict: """snapshot: {'pair':'BTC/USDT','price':...,'change_24h':...,'rsi':...,'news':'...'}""" r = decide(state=f"Market snapshot: {snapshot}", questions={ 'action': {'type': 'choice', 'instructions': 'Decide the next trade action for a short-term position', 'criteria': {'buy': 'momentum and sentiment favour entry now', 'sell': 'take profit / cut risk now', 'wait': 'not enough edge, stay flat'}}, 'risk': {'type': 'score', 'instructions': 'How risky is entering right now?', 'criteria': ['low', 'medium', 'high', 'extreme']}, 'volatile': {'type': 'noul', 'instructions': 'Is the market unusually volatile per this snapshot?'}, }) a = r['answers'] act = a['action']['choice'] if a['action'].get('confidence', 0) >= MIN_CONFIDENCE else 'wait' return {'action': act, 'confidence': a['action'].get('confidence'), 'risk': a['risk']['score'], 'volatile': a['volatile']['noul']} if __name__ == '__main__': snap = {'pair': 'BTC/USDT', 'price': 118420, 'change_24h': '-3.8%', 'rsi': 31, 'news': 'ETF outflows 2nd day, macro risk-off, no major liquidation cascade yet'} print(signal(snap))