← back to Ken
kalshi-dash/set-confidence.sh
29 lines
#!/usr/bin/env bash
# Adjust ONLY Ken's auto-trader min_confidence threshold (real-money entry filter).
# Deliberately narrow: it cannot touch safe_mode, enabled, budget, or position caps —
# so a permission grant for this script pre-approves *only* the confidence knob.
# Usage: set-confidence.sh <50-99>
set -euo pipefail
cd "$(dirname "$0")"
VAL="${1:-}"
if ! [[ "$VAL" =~ ^[0-9]+$ ]] || (( VAL < 50 || VAL > 99 )); then
echo "usage: set-confidence.sh <integer 50-99> (got: '${VAL}')" >&2
exit 2
fi
set -a; source .env; set +a
: "${ADMIN_USER:?ADMIN_USER not set in .env}" "${ADMIN_PASSWORD:?ADMIN_PASSWORD not set in .env}"
curl -s -u "$ADMIN_USER:$ADMIN_PASSWORD" -X POST http://127.0.0.1:7810/api/trading/mode \
-H 'Content-Type: application/json' \
-d "{\"action\":\"update_trade_config\",\"min_confidence\":${VAL}}" \
| python3 -c "
import sys,json
try: d=json.load(sys.stdin)
except Exception as e: print('FAILED: non-JSON response:',e,file=sys.stderr); sys.exit(1)
tc=d.get('trade_config')
if d.get('error') or not tc or tc.get('min_confidence') is None:
print('FAILED: min_confidence NOT changed —',d.get('error') or d,file=sys.stderr); sys.exit(1)
print('OK min_confidence ->',tc.get('min_confidence'),'| unchanged: sources',tc.get('min_sources'),'budget',tc.get('budget_cents'),'maxpos',tc.get('max_position_cents'),'stoploss',tc.get('daily_loss_limit_cents'),'enabled',tc.get('enabled'))"