Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cfe8d07
Add 5-minute prediction mode and refactor shared display
Jean1239 Apr 2, 2026
5753685
5m: show market interval, detect next market, fix title visibility
Jean1239 Apr 3, 2026
796b094
Add Polymarket trading integration + env file support
Jean1239 Apr 3, 2026
5d14f05
Add exit signal recommendation for open positions
Jean1239 Apr 3, 2026
f7ef82e
sync
Jean1239 Apr 6, 2026
9cd3766
Add live trading improvements: USDC balance, GnosisSafe auth, FAK ord…
Jean1239 Apr 6, 2026
4a1cb52
Simplify: code cleanup and quality improvements
Jean1239 Apr 6, 2026
14bd9e5
Modularize trading layer for multi-bot reuse
Jean1239 Apr 6, 2026
fbe4223
Fix sell: divide fetchPositionBalance by 1e6 to convert raw token uni…
Jean1239 Apr 6, 2026
a8e2101
Add dry-run study logger for signal performance analysis
Jean1239 Apr 6, 2026
efbb165
Refine signal strategy based on dry-run analysis
Jean1239 Apr 7, 2026
ae3d471
Fix: move marketSlugNow declaration before cooldown block
Jean1239 Apr 7, 2026
f61efe5
Add staleness watchdog to all WebSocket streams
Jean1239 Apr 7, 2026
07a4ae2
Restructure dry-run as paper-trading simulator with position tracking
Jean1239 Apr 7, 2026
3cfdf55
Replace signal stats with paper-trading trade summary in console display
Jean1239 Apr 13, 2026
45170e2
Add POLYMARKET_LIVE_TRADING flag: default sim mode, show virtual posi…
Jean1239 Apr 13, 2026
fe27514
Tighten exit thresholds based on 5-day dry-run analysis
Jean1239 Apr 14, 2026
2c0cbc7
Add Telegram notifications for trade events and daily summary
Jean1239 Apr 14, 2026
fa9fc9b
Disable 5m SIGNAL_FLIP, fix sign formatting, add trade stats to notif…
Jean1239 Apr 15, 2026
577d5f4
Skip entry on markets where bot started late (late-start guard)
Jean1239 Apr 15, 2026
83a4a7b
Use Polymarket outcomePrices for settlement; add PTB safety guard on …
Jean1239 Apr 15, 2026
f821b16
Add entry price filter and price_to_beat columns to dry-run CSV
Jean1239 Apr 15, 2026
bb04bf7
Disable stop-loss on 5m bot: hold-to-settlement is dominant strategy
Jean1239 Apr 16, 2026
78e60ec
Add STRATEGY_LOG.md: catalog all strategy versions and dry-run perfor…
Jean1239 Apr 16, 2026
d44c75c
Activate entry filter, disable 15m FLIP, add high-conviction sizing
Jean1239 Apr 18, 2026
367b60a
Consolidate dry-run results into STRATEGY_LOG (39 trades 15m, 188 tra…
Jean1239 Apr 23, 2026
d36b3f4
Document local run params and explain remote vs local performance gap
Jean1239 Apr 23, 2026
df66f55
Add Coolify deploy: log server, log rotation, named volumes
Jean1239 Apr 25, 2026
e716580
feat: adiciona dashboard com vite
Jean1239 Apr 26, 2026
c7c3043
fix(dashboard): improve mobile UI/UX across all pages
claude Apr 26, 2026
51f8faa
chore: update package-lock.json after npm install
claude Apr 26, 2026
6fd7cd7
feat(dashboard): localize trade timestamps to pt-BR with relative time
claude Apr 26, 2026
0cd0b41
feat: aprimoramentos visuais dashboard
Jean1239 Apr 26, 2026
8a1d3c6
fix: live signals real-time + deploy isolation
Jean1239 Apr 26, 2026
d6853c5
fix(dashboard): align SimStatus boxes to bottom of signal cards
Jean1239 Apr 26, 2026
5eb7b26
fix(dashboard): fixed-height indicator section aligns SimStatus boxes
Jean1239 Apr 26, 2026
3e74b99
feat(dashboard): show entry price, invested and P&L in live signals p…
Jean1239 Apr 26, 2026
ba4a411
feat: adiciona pagina de download dos arquivos
Jean1239 Apr 26, 2026
9e1b775
feat: mudanças na logica e adiciona botão de reset
Jean1239 Apr 27, 2026
b03ec16
feat: adiciona toast
Jean1239 Apr 27, 2026
6b71474
feat: fix live signals page
Jean1239 Apr 28, 2026
ff7e048
correçoes no zip de arquivos
Jean1239 Apr 29, 2026
3de35ee
v11
Jean1239 Apr 30, 2026
8e7461d
fix: current price
Jean1239 Apr 30, 2026
3a8b436
feat: selective file download — checkbox selection + ZIP of chosen files
claude May 4, 2026
7c66e83
fix: replace native checkbox with shadcn Checkbox; fix multi-select s…
claude May 4, 2026
cc4b24f
docs: document shadcn CLI unavailability and UI component conventions
claude May 4, 2026
952bb94
fix+feat: v12 — blockedHoursUtc bug fix + disableTimeDecay 15m + hour…
claude May 4, 2026
8ea449b
docs(v12): complete strategy change documentation per skill template
claude May 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"permissions": {
"allow": [
"Bash(npm install:*)",
"Bash(fish -c \"npm install @polymarket/clob-client\")",
"Bash(fish -c \"nvm use latest && npm install @polymarket/clob-client\")",
"Bash(fish -c \"nvm list\")",
"Bash(fish -c \"nvm current\")",
"Bash(fish -c \"nvm use lts && npm install @polymarket/clob-client\")",
"Bash(fish -c \"nvm use lts && node -e \\\\\"import\\('@polymarket/clob-client'\\).then\\(m => console.log\\(Object.keys\\(m\\).join\\(', '\\)\\)\\)\\\\\"\")",
"Bash(fish -c 'nvm use lts && node -e \":*)",
"Bash(fish -c 'nvm use lts && node --input-type=module -e \":*)"
]
},
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "STRATEGY_FILES='src/config.js src/config5m.js src/engines/edge.js src/engines/edge5m.js src/engines/probability.js src/engines/probability5m.js src/engines/regime.js src/dryRun.js src/trading/executor.js src/trading/position.js'; CHANGED=$(git -C \"$(jq -r '.session_id' 2>/dev/null | head -c0; git rev-parse --show-toplevel 2>/dev/null || pwd)\" diff --name-only HEAD 2>/dev/null); ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd); CHANGED=$(git -C \"$ROOT\" diff --name-only HEAD 2>/dev/null; git -C \"$ROOT\" diff --name-only 2>/dev/null); MATCH=$(echo \"$CHANGED\" | grep -E '^src/(config|engines/edge|engines/probability|engines/regime|dryRun|trading/executor|trading/position)' | head -1); if [ -n \"$MATCH\" ]; then echo '{\"systemMessage\": \"Strategy files were modified this session. Run the document-strategy-change skill to update STRATEGY_LOG.md and CLAUDE.md before finishing.\"}'; fi",
"timeout": 10
}
]
}
]
}
}
113 changes: 113 additions & 0 deletions .claude/skills/document-strategy-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
name: document-strategy-change
description: Run after any change to strategy logic, engine parameters, config defaults, or trading rules. Dumps live defaults, appends a new version entry to STRATEGY_LOG.md, and updates CLAUDE.md if new env vars or logic changed.
---

# Document Strategy Change

Run this skill whenever you edit any of these files:
- `src/config.js` or `src/config5m.js`
- `src/engines/edge.js` or `src/engines/edge5m.js`
- `src/engines/probability.js` or `src/engines/probability5m.js`
- `src/engines/regime.js`
- `src/dryRun.js`
- `src/trading/executor.js`
- `src/trading/position.js`

## Steps

### 1. Dump live config defaults

Run both config files through Node to get the actual default values in effect:

```bash
node --input-type=module -e "
import cfg from './src/config.js';
console.log(JSON.stringify(cfg.trading, null, 2));
"
```

```bash
node --input-type=module -e "
import cfg from './src/config5m.js';
console.log(JSON.stringify(cfg.trading, null, 2));
"
```

Capture the output — these are the canonical values to document. Note: the cloud deployment runs **code defaults only** (no env var overrides), so what Node prints IS what runs in production.

### 2. Identify the new version number

Read the current `STRATEGY_LOG.md` and find the highest `## vN` heading. The new entry is `## v(N+1)`.

### 3. Write the STRATEGY_LOG.md entry

Append a new section at the top of the log (after the header) following this exact template:

```markdown
## v{N+1} — {YYYY-MM-DD}

### Changes
- {Bullet per logical change. Include: what changed, old value → new value, and rationale}

### Parameters — 15m bot (code defaults, no env overrides)
| Parameter | Value |
|---|---|
| tradeAmount | ... |
| entryMinMarketPrice | ... |
| entryMaxMarketPrice | ... |
| takeProfitPct | ... |
| stopLossPct | ... |
| signalFlipMinProb | ... |
| stopLossMinProb | ... |
| stopLossMinDurationS | ... |
| flipCooldownS | ... |
| blockedHoursUtc | ... |
| blockedRegimes | ... |

### Parameters — 5m bot (code defaults, no env overrides)
| Parameter | Value |
|---|---|
| tradeAmount | ... |
| entryMinMarketPrice | ... |
| entryMaxMarketPrice | ... |
| takeProfitPct | ... |
| stopLossPct | ... |
| disableStopLoss | ... |
| signalFlipMinProb | ... |
| disableSignalFlip | ... |
| flipCooldownS | ... |
| blockedHoursUtc | ... |

### Baseline results (before this change)
> Copy from the most recent dry-run analysis or the previous version's results section.
> If no fresh data is available, write: "No new data — see previous version."

### Estimated impact
- {What improvement or behavior change is expected and why}

---
```

Fill every `...` using the Node output from step 1. Do NOT leave any field blank or say "same as before" — always write the actual value.

### 4. Update CLAUDE.md if needed

- If you added a new env variable: add a row to the "Key environment variables" table.
- If you changed engine logic (new filter, new condition, disabled a feature): update the relevant engine description in the "Engines" section.
- If you changed executor/dryRun behavior: update those sections.

Do not rewrite CLAUDE.md wholesale — make targeted edits only.

### 5. Confirm

After writing, tell the user:
- Which version was added to STRATEGY_LOG.md
- Which CLAUDE.md sections were updated (if any)
- The key parameter values that changed

## Notes

- The log is append-only; never edit past versions.
- If the change is purely cosmetic (UI, display, logging format) and affects no strategy logic or parameters, skip this skill.
- If multiple related changes were made in one session, document them as a single version entry covering all changes.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
logs
.env
.env.*
*.md
IDEAS.md
136 changes: 136 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# ─────────────────────────────────────────────
# Polymarket – seleção de mercado
# ─────────────────────────────────────────────

# Fixar um mercado específico pelo slug (sobrescreve a seleção automática)
# POLYMARKET_SLUG=btc-updown-15m-1234567890

# Desativar a seleção automática do mercado mais recente (padrão: true)
# POLYMARKET_AUTO_SELECT_LATEST=true

# Labels dos outcomes (padrão: Up / Down)
# POLYMARKET_UP_LABEL=Up
# POLYMARKET_DOWN_LABEL=Down

# URL do WebSocket de dados ao vivo da Polymarket
# POLYMARKET_LIVE_WS_URL=wss://ws-live-data.polymarket.com

# ─────────────────────────────────────────────
# Trading real (opcional – deixar vazio = modo leitura)
# ─────────────────────────────────────────────

# Chave privada da carteira Polygon (habilita ordens reais)
# POLYMARKET_PRIVATE_KEY=0x...

# Endereço do perfil Polymarket (necessário se a conta foi criada pelo site/email)
# POLYMARKET_FUNDER=0x...

# Tipo de assinatura:
# 0 = EOA (carteira direta, sem proxy)
# 1 = POLY_PROXY (proxy Polymarket — auto-detectado se POLYMARKET_FUNDER for GnosisSafe)
# 2 = GNOSIS_SAFE (conta criada pelo site Polymarket via Metamask — mais comum)
# POLYMARKET_SIGNATURE_TYPE=2

# Valor em USDC por trade (padrão: 5)
# POLYMARKET_TRADE_AMOUNT=5

# ─────────────────────────────────────────────
# Thresholds de saída de posição (exit strategy)
# ─────────────────────────────────────────────

# Take profit: % de ROI para recomendar venda com lucro (padrão: 20)
# Só dispara se o modelo também confirmar reversão.
# TRADE_TAKE_PROFIT_PCT=20

# Stop loss: % de ROI negativo para recomendar saída (padrão: 25)
# Só dispara se o modelo também confirmar reversão.
# TRADE_STOP_LOSS_PCT=25

# Probabilidade mínima do lado oposto para considerar que o modelo inverteu (padrão: 0.58 / 5m: 0.62)
# Usado como gatilho para TP, SL e SIGNAL_FLIPPED.
# TRADE_SIGNAL_FLIP_PROB=0.58

# Prob mínima específica para stop-loss (padrão: 0.65) — pode ser mais rígida que signalFlipMinProb
# TRADE_SL_MIN_PROB=0.65

# Duração mínima da posição antes de SL poder disparar, em segundos (padrão: 120)
# TRADE_SL_MIN_DURATION_S=120

# Cooldown pós-SIGNAL_FLIP antes de re-entrar no mesmo mercado, em segundos (padrão: 60 / 5m: 90)
# TRADE_FLIP_COOLDOWN_S=60

# Ticks consecutivos confirmando reversão antes de SIGNAL_FLIP disparar (padrão: 2 / 5m: 5)
# TRADE_FLIP_CONFIRM_TICKS=2

# Margem de segurança PTB: suprime SL/FLIP/TIME_DECAY se BTC está pelo menos X USD
# do lado vencedor do preço de referência (padrão: 30)
# TRADE_PTB_SAFE_MARGIN_USD=30

# Desabilitar saídas (padrão 15m: flip=true, sl=false | padrão 5m: flip=true, sl=true)
# TRADE_DISABLE_SIGNAL_FLIP=true
# TRADE_DISABLE_STOP_LOSS=false
# TRADE_DISABLE_SIGNAL_FLIP_5M=true
# TRADE_DISABLE_STOP_LOSS_5M=true

# ─────────────────────────────────────────────
# Filtro de preço de entrada (entry price gating)
# ─────────────────────────────────────────────
# Só entra quando o preço de mercado do lado escolhido está em [MIN, MAX].
# Defaults baseados em análise de dry-run:
# 15m: faixa 0.45–0.58 (exclui entradas <0.45 que perdem $3.77)
# 5m : faixa 0.50–0.60 (exclui zonas neutras 0.45–0.49 que perdem $2.40)
# Variáveis distintas por bot: o 5m tem seu próprio par *_5M.
# TRADE_ENTRY_MIN_PRICE=0.45
# TRADE_ENTRY_MAX_PRICE=0.58
# TRADE_ENTRY_MIN_PRICE_5M=0.50
# TRADE_ENTRY_MAX_PRICE_5M=0.60

# ─────────────────────────────────────────────
# TIME_DECAY (saída por tempo restante + loss)
# ─────────────────────────────────────────────
# Dispara quando: tempo restante (min) < MIN_LEFT_MIN AND ROI < -MIN_LOSS_PCT
# Só se aplica a entradas ≥ $0.50 (as baratas seguram até settlement).
# 15m: 1.5 min / 5% (configuração clássica)
# 5m : 2.5 min / 15% (mais conservador: recorta só quem já perdeu muito)
# TRADE_TIME_DECAY_MIN_LEFT_MIN=1.5
# TRADE_TIME_DECAY_MIN_LOSS_PCT=5
# TRADE_TIME_DECAY_MIN_LEFT_MIN_5M=2.5
# TRADE_TIME_DECAY_MIN_LOSS_PCT_5M=15

# ─────────────────────────────────────────────
# Sizing de alta convicção (high-conviction position sizing)
# ─────────────────────────────────────────────
# Multiplica o tradeAmount quando entryPrice ∈ [ENTRY_MIN, ENTRY_MAX]
# AND prob do lado escolhido ≥ MIN_PROB. MULT=1 desativa a feature.
# 15m: MULT=2 (ativo) — aproveita entradas baratas com alta convicção
# 5m : MULT=1 (desativado) — ruído mais alto, sem evidência para upsizing
# TRADE_HIGH_CONVICTION_MULT=2
# TRADE_HIGH_CONVICTION_MIN_PROB=0.70
# TRADE_HIGH_CONVICTION_ENTRY_MIN=0.45
# TRADE_HIGH_CONVICTION_ENTRY_MAX=0.50
# TRADE_HIGH_CONVICTION_MULT_5M=1

# ─────────────────────────────────────────────
# Chainlink / Polygon RPC
# ─────────────────────────────────────────────

# RPC HTTP principal do Polygon (fallback de preço Chainlink)
# POLYGON_RPC_URL=https://polygon-rpc.com

# Lista de RPCs HTTP alternativos separados por vírgula
# POLYGON_RPC_URLS=https://polygon-rpc.com,https://rpc.ankr.com/polygon

# RPCs WebSocket para preço Chainlink em tempo real
# POLYGON_WSS_URLS=wss://polygon-bor-rpc.publicnode.com

# Endereço do agregador BTC/USD da Chainlink no Polygon
# CHAINLINK_BTC_USD_AGGREGATOR=0xc907E116054Ad103354f2D350FD2514433D57F6f

# ─────────────────────────────────────────────
# Proxy (opcional)
# ─────────────────────────────────────────────

# Proxy HTTP/HTTPS para todas as conexões de saída
# HTTPS_PROXY=http://user:pass@host:port
# HTTP_PROXY=http://user:pass@host:port
# ALL_PROXY=socks5://user:pass@host:port
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/
logs/
.env
.env.*
!.env.example
.DS_Store
npm-debug.log*
yarn-debug.log*
Expand Down
11 changes: 11 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mcpServers": {
"shadcn": {
"command": "npx",
"args": [
"shadcn@latest",
"mcp"
]
}
}
}
Loading