Fix/checkbox shadcn and docs#9
Open
Jean1239 wants to merge 49 commits into
Open
Conversation
- Add complete 5m assistant (index5m.js, config5m.js) with shorter timeframe indicators: EMA(3/8) crossover, momentum (ROC + acceleration), and Order Flow Imbalance (OFI) from Binance trade stream - Extract shared terminal rendering into display.js (ANSI colors, kv(), renderScreen(), colorPriceLine()) used by both 15m and 5m modes - Add 5m-tuned engines: probability5m (OFI + momentum + EMA cross primary signals, quadratic time decay) and edge5m (lower thresholds, shorter phases) - Add binanceWsOfi.js for real-time order flow data collection - Refactor index.js to use shared display module - Add npm run start:5m script - Add CLAUDE.md with full architecture documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- display.js: enter alternate screen buffer on first render so title always appears at row 1; truncate output to terminal height to prevent scroll overflow; add fmtEtHHMM() helper (HH:MM without seconds) - index5m.js: show "Interval: HH:MM → HH:MM ET" below the market slug; detect when the active market hasn't started yet and label it [PRÓXIMO MERCADO] in yellow, replace "Time left" with "Inicia em:" showing time until start Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Trading (src/trading/): - client.js: ClobClient init with L1+L2 auth via @polymarket/clob-client - orders.js: buyMarketOrder / sellMarketOrder wrappers - position.js: in-memory position state, ROI, chain balance sync - Keypress [B]/[S]/[Q] in both 15m and 5m loops when POLYMARKET_PRIVATE_KEY is set - Position + ROI section in TUI display Config / env: - Hardcode series IDs: 15m=10192, 5m=10684 (not overridable) - node --env-file=.env in npm start / start:5m - .env.example with all configurable variables - .gitignore: allow .env.example, keep .env ignored Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Evaluates 4 exit conditions each tick when a position is open: - TAKE_PROFIT: ROI >= takeProfitPct (default +20%) - STOP_LOSS: ROI <= -stopLossPct (default -25%) - SIGNAL_FLIPPED: opposite side model prob >= signalFlipMinProb (default 0.58) - TIME_DECAY: < 1.5min left and ROI < -5% Shows "► VENDER — <reason>" in the position section (yellow=MEDIUM, red=HIGH). Thresholds configurable via TRADE_TAKE_PROFIT_PCT, TRADE_STOP_LOSS_PCT, TRADE_SIGNAL_FLIP_PROB env vars. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ers, model-gated exits - Display USDC.e balance on-chain (Polygon) in header, refreshed every 30s - Auto-detect POLY_GNOSIS_SAFE when funder is a GnosisSafe contract (fixes invalid signature) - Switch orders from FOK to FAK to allow partial fills - Buy price uses bestAsk+0.02, sell uses bestBid-0.02 for reliable matching - Fetch actual on-chain share balance before selling (fixes balance mismatch error) - TP and SL exit signals now require model to also confirm reversal - TIME_DECAY exit skipped when entry price < 0.50 (cheap positions held to resolution) - Document new env vars: TRADE_TAKE_PROFIT_PCT, TRADE_STOP_LOSS_PCT, TRADE_SIGNAL_FLIP_PROB Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- client.js: reuse single provider for GnosisSafe detection (was creating two) - position.js: add promise lock to getPolygonProvider to prevent concurrent init race - index.js/index5m.js: replace Math.min/max with existing clamp() utility - display.js: simplify null/undefined check to != null - orders.js: remove narrating comment Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract shared concerns from index.js/index5m.js into reusable modules: - data/polymarket.js: add createMarketResolver() + fetchPolymarketSnapshot() so any future bot can resolve and snapshot a Polymarket market in one call - trading/keyboard.js: stdin setup, action queue, confirm-hint builder - trading/executor.js: buy/sell execution (price slippage, balance fetch, logging) - trading/priceLatch.js: Chainlink reference-price latch at market open - trading/tracker.js: per-market win/loss tracking; returns settled outcome for the caller to write in its own CSV format index.js and index5m.js are now thin orchestrators: they own only the mode-specific indicator pipeline, signal scoring, and display rendering. All trading state and Polymarket data access are delegated to the modules above. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ts to shares getBalanceAllowance returns balance in 6-decimal raw token units (like USDC), not in human-readable shares. The sell order was sending the raw value directly, causing the CLOB API to multiply it by 1e6 internally and reject with: balance: 2134231, order amount: 2134231000000 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each app now writes ./logs/dryrun_15m.csv and ./logs/dryrun_5m.csv. Ticks accumulate in memory per market; on slug change (settlement) the entire buffer is flushed with outcome, btc_at_settlement, direction_correct, and signal_roi filled in retroactively — enabling end-of-day analysis of which signals were correct and what ROI they would have produced if followed immediately. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
15m: reduce VWAP weight from +2 to +1 (too laggy over 240 candles), remove one-sided failedVwapReclaim bias, add indicator conflict detection — when HA + MACD + RSI majority disagrees with VWAP direction, suppress signal instead of entering against momentum. 5m: add HA + OFI alignment filter (both must disagree to suppress), raise MID/LATE thresholds to avoid low-conviction late entries, add 30s signal cooldown to prevent flip-flop (stable signals showed 62.5% win rate vs 40% for unstable). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Force reconnect when no message arrives within threshold: - Binance trade / OFI: 30s (trades arrive every ~100ms) - Polymarket live WS: 60s (Chainlink updates every few seconds) - Chainlink on-chain WS: 120s (on-chain events less frequent) Fixes zombie connections that stay "open" but stop delivering data, common on WSL2 and through proxies during long-running sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the passive tick logger with an active trading simulator that opens/closes virtual positions using the same exit logic as real trading (TP, SL, signal flip, time decay). Adds a per-trade journal CSV for easy performance analysis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- dryRun.getStats() now tracks wins, losses, totalTrades and recentTrades - Both index.js and index5m.js use dryRun stats for the HISTORICO panel - Display renamed to TRADES (paper): shows trade count, W/L, WR%, PNL - Each recent trade row shows time, side, P&L, ROI%, and exit reason code - Removed onSold/closedTrades signal-based tracking from index.js Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion - New env var POLYMARKET_LIVE_TRADING (default: false = simulated mode) - When not set or != "true", real orders are blocked even with private key - dryRun.getStats() now exposes full virtual position (entryPrice, shares, etc.) - POSICAO section shows simulated open position when in sim mode - Status badge: yellow SIM vs green LIVE with balance only in live mode - Both index.js and index5m.js branch on liveTrading for position display Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
15m: port stop-loss guards from 5m (minProb 0.58→0.65, minDuration 0→120s). The 5-day run showed 21 stops with 0 wins (−$10.22) — the permissive guards were cutting positions that would have recovered. 5m: reduce SIGNAL_FLIP sensitivity (signalFlipMinProb 0.58→0.62, flipConfirmTicks 3→5). The run showed 158 flip exits with only 3.8% win rate, despite a 92.8% settled-win rate — the lower threshold was catching transient blips across 0.58 that then reverted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New src/notify.js: notifyTrade, notifyStart, notifyDailySummary - dryRun.js: notifies BUY and SELL (including settlements) for both sims - executor.js: notifies real buy/sell orders - index.js / index5m.js: notifyStart on boot, daily summary at midnight ET - docker-compose.yml: --max-old-space-size=384 + mem_limit=512m on both bots Set TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID in .env to enable. All calls are fire-and-forget — silently no-ops if vars are unset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ications - dryRun.js: add disableSignalFlip config (default true on 5m) after counterfactual showed 5m signal flips were cutting winners (+$9.70 if held) - notify.js: always show explicit +/- sign on PNL, ROI, and cumulative PNL via new fmtSignedUsd/fmtSignedPct helpers; include total trades / W / L / WR on SELL notifications - display.js, index.js, index5m.js: show explicit '-' sign (not just red color) on BTC vs price-to-beat delta, position ROI/PNL, trade history Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bot used to enter positions even when it joined a market mid-way, where the price-to-beat reference is unreliable. Now any market where the bot started >90s after open is fully skipped for entry (both sim and live). The display shows 'AGUARD. PRÓX. MERCADO [late start]' in yellow until the next market begins. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…exits Settlement (win/loss determination): - polymarket.js: add fetchMarketOutcome(slug) — reads outcomePrices from Gamma API after market closes; returns UP/DOWN/null - dryRun.js + tracker.js: on slug change, query API for definitive outcome instead of estimating from btcFinal > ptb. Falls back to ptb only if API returns null (market not yet resolved or network error). - index.js + index5m.js: await tracker.update() and dryRun.tick() since settlement path is now async PTB safety guard on exits: - position.js: add btcPrice/priceToBeat/ptbSafeMarginUsd to evaluateExit — suppresses STOP_LOSS, SIGNAL_FLIP, TIME_DECAY when BTC is >= $30 on the winning side of the price-to-beat (absorbs ~$9 ptb drift + buffer) - dryRun.js: same guard in evaluateSimExit - config.js: TRADE_PTB_SAFE_MARGIN_USD env var, default 30 - index.js + index5m.js: pass btcPrice/priceToBeat/ptbSafeMarginUsd to all evaluateExit calls Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New TRADE_ENTRY_MIN_PRICE / TRADE_ENTRY_MAX_PRICE env vars (default 0–1, disabled) block entries when the market price of the chosen side is outside the range. Applied in both the paper-trading simulator and live executor. - Add price_to_beat and btc_vs_ptb columns to every tick row in dryrun_15m.csv and dryrun_5m.csv so future analysis can filter by ptb gap without needing a separate data source. - Extend trades CSV with ptb_at_entry, btc_at_entry, btc_vs_ptb_at_entry, market_up_at_entry, market_down_at_entry for per-trade ptb analysis. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Analysis of 161 SL trades showed 78% of SLs correctly exited before a total loss, but the 22% that cut eventual winners cost far more than the savings: real SL PnL was −$75.65 vs hypothetical hold-to-settlement PnL of −$25.64 (+$50 left on the table). With an 85% settled win rate, holding to settlement is the dominant strategy on 5m markets. - config5m.js: add disableStopLoss: true - trading/position.js: add disableStopLoss param to evaluateExit() - dryRun.js: honor disableStopLoss in sim exit logic + 5m factory - index5m.js: pass disableStopLoss to both evaluateExit call sites - CLAUDE.md: document SL disabled rationale alongside existing SIGNAL_FLIP note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mance Documents 9 archive snapshots with parameters, win rates, PnL, and the key decisions (disabling 5m SIGNAL_FLIP and STOP_LOSS) with their evidence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Entry price filter now gated by defaults (15m 0.45-0.58, 5m 0.50-0.60), skipping low-confidence zones identified from dry-run analysis. - 15m SIGNAL_FLIP exits disabled (was bleeding -$9.21 across 26 trades). - 5m TIME_DECAY tightened to 2.5min/15% (was cutting near -80% ROI with little recovery opportunity). - New asymmetric position sizing: 15m multiplies tradeAmount by 2x when entry is 0.45-0.50 AND model confidence >= 0.70 (disabled on 5m). - Fix: client.js now spreads config.trading so executor/simulator see entryMinMarketPrice, highConvictionMultiplier, and related params. - Add scripts/report.js + npm run report for post-change PnL review. - STRATEGY_LOG.md documents all params + routine to run after changes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…des 5m) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Local had TRADE_ENTRY_MIN_PRICE=0.40/MAX=0.85 in .env while remote ran with code defaults (0-1, no filter). The ~$18 gap likely explained by the local filter avoiding extreme-price trades that triggered bad SIGNAL_FLIPs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add src/logServer.js: HTTP server on port 3456 with /report, /logs listing and CSV download - Add entrypoint.sh: rotates tick logs on container start (gzip + 14-day retention), preserves trades CSV - Update Dockerfile: include scripts/ and entrypoint.sh - Update docker-compose.yml: named volume, tty, optional env_file, reports service Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- __root: hide sidebar on mobile; add top bar with hamburger + Sheet drawer that closes on navigation; keep desktop sidebar unchanged - trades: replace ScrollArea with overflow-x/y-auto + min-w-[700px] table so all 9 columns scroll horizontally on narrow viewports - signals: add flex-wrap + shrink-0 to rec/badge/time rows; add min-w-0 + gap to Kv rows; use items-start on card headers so timestamps don't overflow; reduce gap-x-6 → gap-x-4 in indicator grids - index: p-6 → p-4 md:p-6; truncate stat card value/sub text; flex-wrap on page header; YAxis width 80→72 for tighter chart on mobile https://claude.ai/code/session_01VkxSGCs14ai9xCwT3HDne1
Replace raw UTC string with two-line display: relative time ("há 5 min")
on top using Intl.RelativeTimeFormat pt-BR, and full local date in
Brazilian format (dd/mm/aaaa hh:mm) below in muted text. No extra deps.
https://claude.ai/code/session_01VkxSGCs14ai9xCwT3HDne1
dryRun.js: flush buffer every 5 ticks so the live dashboard shows current market data instead of the last market's closing frame. Partial flushes leave outcome/btc_at_settlement blank; final flush (market change or exit) fills them retroactively as before. Dockerfile.dashboard: dedicated lightweight image for logServer — only copies src/logServer.js and the built dashboard/dist, no bot dependencies and no entrypoint.sh rotation script. Dockerfile: remove dashboard builder stage (moved to Dockerfile.dashboard). docker-compose.yml: dashboard service now uses Dockerfile.dashboard, eliminating the entrypoint override that was needed as a workaround. entrypoint.sh: each bot rotates only its own CSV files (15m rotates signals.csv + dryrun_15m.csv; 5m rotates signals_5m.csv + dryrun_5m.csv) to prevent one container from deleting the other bot's freshly written data on deploy. signals.tsx: countdown uses s.timestamp instead of dataUpdatedAt to avoid the 1s/0s oscillation on each refetch; stale badge (yellow clock) appears when last tick is >15s old; timestamps shown in pt-BR local time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cards use flex-col + h-full so both fill the grid row height. A flex-1 spacer before the separator pushes WAIT/HOLD to the bottom regardless of how many indicator rows each card has. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both cards use min-h-[140px] on the indicator grid (sized for the 5m card's 5 rows). The 15m card's 4 rows leave whitespace below; the separator and WAIT/HOLD box are now at the same vertical position in both cards regardless of indicator count. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…osition box dryRun.js: adds sim_invested column to SIM_COLS; sets value on HOLD and BUY ticks from pos.invested / computed invested amount. logServer.js: parses sim_invested in both coerceSignals15m and coerceSignals5m. api.ts: adds sim_invested field to Signal15m and Signal5m interfaces. signals.tsx: SimStatus receives entryPrice, invested and pnl props; when holding, shows "Entry: 0.47 | Inv: $1.00 | P&L: +$0.23" below the action/ROI row. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds POST /api/files/zip-selected endpoint that accepts { names: string[] }
and streams a ZIP with only the requested files (same 50 MB-per-file guard
as the existing /api/files/zip endpoint).
On the dashboard, each file row now has a checkbox; clicking the row also
toggles selection. A header checkbox handles select-all / deselect-all
(with indeterminate state). When files are selected a "Baixar selecionados"
button appears showing the count and total size; it POSTs the selection to
the new endpoint and triggers a browser download. Individual-file and
download-all buttons are unchanged.
https://claude.ai/code/session_01MkQrQyGvaguq3i1UcM6e9w
…tate bug - Created dashboard/src/components/ui/checkbox.tsx using Radix UI Checkbox primitive (from radix-ui package), styled with shadcn new-york design tokens — visible checked/focus/disabled states - Replaced plain <input type="checkbox"> in files.tsx with the new Checkbox component so styling is consistent with the rest of the UI - Switched selected state from Set<string> to string[] — Set mutations were causing stale renders where only the last toggled row appeared checked; array-based state produces a new reference on every update - Header "select all" uses IndeterminateCheckbox wrapper that sets the Radix-compatible "indeterminate" checked value when some (not all) files are selected - Row click and checkbox click are properly decoupled to avoid double-toggle https://claude.ai/code/session_01MkQrQyGvaguq3i1UcM6e9w
Adds a "Dashboard UI components" section to CLAUDE.md explaining: - npx shadcn@latest add <component> fails (no outbound internet, 403) - How to write a missing component manually following the project pattern (import from "radix-ui", cn(), design tokens, data-slot, named export) - Rule against using bare HTML form elements in routes/feature components, with a quick reference table of native → shadcn equivalents https://claude.ai/code/session_01MkQrQyGvaguq3i1UcM6e9w
… tuning Bug fix (#1): - dryRun.js: createDryRunSimulator15m/5m built config object line-by-line but omitted blockedHoursUtc, causing config.blockedHoursUtc ?? [] = [] on every run. 34% of 15m trades and 33% of 5m trades entered during hours that should have been blocked. All v11 data is tainted by this bug. - Defaults in factory functions now match config.js / config5m.js exactly so the simulator and live-trading paths are symmetric. disableTimeDecay 15m (#2): - config.js: add disableTimeDecay=true (TRADE_DISABLE_TIME_DECAY). Raising entryMinMarketPrice to 0.50 made every trade qualify for the TIME_DECAY trigger (entry >= 0.50). 143 trades / 49% exited via TD = -$139.86. Same pattern as 5m in v10 (433 TD = -$159). Non-TD trades: 148, +$100.22, 73.6% WR. - index.js: add disableTimeDecay to baseExitEvalArgs (was missing, causing live display to show TD exits even when disabled). - index5m.js: fix ?? false → ?? true defensive fallback. Blocked hours (#3-#6): - 15m: [0,2,4,8,11,17,18,21] → [0,8,9,11,17,18,19,21,22] Released H02 (+$1.81) H04 (+$2.32); added H09 (-$6.75) H19 (-$7.36) H22 (-$4.27) - 5m: [2,3,6,10,16,19,20,21] → [2,3,4,6,10,16,19,20] Released H21 (+$10.49 — best hour, was erroneously blocked) Added H04 (-$8.43 — worst unblocked hour) STRATEGY_LOG.md updated: v12 snapshot with full parameter tables and analysis notes. https://claude.ai/code/session_01MkQrQyGvaguq3i1UcM6e9w
- Add TRADE_DISABLE_TIME_DECAY to env var table in CLAUDE.md - Update TRADE_BLOCKED_HOURS_UTC default to 0,8,9,11,17,18,19,21,22 (v12) - Update TRADE_BLOCKED_HOURS_UTC_5M default to 2,3,4,6,10,16,19,20 (v12) - Rewrite v12 STRATEGY_LOG.md entry using document-strategy-change skill template (Changes / Parameters tables / Baseline results / Estimated impact) https://claude.ai/code/session_01MkQrQyGvaguq3i1UcM6e9w
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.