Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This project is an **experimental, research-focused trading tool**.

## Table of Contents

- [Strategy Playbook (Start Here)](#strategy-playbook-start-here)
- [Minimum Requirements](#minimum-requirements)
- [Priority Keys (Live Trading)](#priority-keys-live-trading)
- [Quickstart](#quickstart)
Expand All @@ -34,6 +35,22 @@ This project is an **experimental, research-focused trading tool**.
- [Ops API](#ops-api)
- [Documentation Map](#documentation-map)

## Strategy Playbook (Start Here)

The runtime surfaces four strategy labels. Each has different risk shape, execution behavior, and controls.

| Strategy label | Core idea | Unique characteristics | Primary controls |
| --- | --- | --- | --- |
| `near_zero` | Paired YES+NO arbitrage on one market | Symmetric two-leg execution, strict gate checks on spread/depth/staleness, strongest fill-discipline posture | `strategyMode=near_zero_risk`, `signalMode=near_zero|both`, `edgeRequired`, `minPairedFillRate`, `maxLegSkewMs` |
| `ev` | Single-sided directional execution from calibrated probability/insight | One-leg intent (`side=yes|no`), confidence/edge thresholding, cooldown + per-market/portfolio EV notional caps | `signalMode=ev|both`, `evEdgeRequired`, `evConfidenceMin`, `evCooldownSeconds`, `evMaxPerMarketNotional`, `evMaxPortfolioNotional` |
| `fw_projection` | Frank-Wolfe optimized projection for dependency-aware opportunity selection | Solver-driven lower-bound checks, only converged/feasible opportunities proceed, dependency graph quality affects candidate set | `fwDependency*`, `fwGapAbsTolerance`, `fwGapRelTolerance`, `fwMaxLoopRuntimeMs`, `fwMinEdgeThreshold` |
| `fw_basket` | Multi-market FW basket execution | Basket-level selection/ranking, market count bounds, configurable basket execution mode (`sequential_failfast` or `batch_best_effort`) | `fwBasketMinMarkets`, `fwBasketMaxMarkets`, `fwBasketExecutionMode`, `fwMaxPerMarketNotional`, `fwMaxPortfolioNotional` |

Operator notes:
- Dashboard intent labels are normalized to `near_zero`, `ev`, `fw_projection`, and `fw_basket`.
- `ev_single_side` is displayed as `ev`.
- If explicit strategy metadata is missing, IDs can infer strategy (`:fw:`, `:fwb:`, `:yes:`, `:no:`).

## Minimum Requirements

### Local Monitoring Only (No Live Trading)
Expand Down
16 changes: 16 additions & 0 deletions agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## 📋 Navigation

- [Overview](#overview)
- [Strategy Snapshot](#strategy-snapshot)
- [Project Structure](#project-structure)
- [Where to Look](#where-to-look)
- [Complexity Hotspots](#complexity-hotspots)
Expand Down Expand Up @@ -38,6 +39,21 @@ Near-zero-risk Polymarket CLOB arbitrage bot. TypeScript + Fastify backend, Reac

---

## Strategy Snapshot

Core runtime strategies and their unique characteristics:

| Strategy | Unique behavior | Main control surfaces |
|------|----------|-------|
| `near_zero` | Paired YES/NO arbitrage with the strictest two-leg safety posture. | `strategyMode`, `signalMode`, `edgeRequired`, `minPairedFillRate`, `maxLegSkewMs` |
| `ev` | Single-sided directional execution with confidence thresholds, cooldown, and EV notional caps. | `signalMode`, `evEdgeRequired`, `evConfidenceMin`, `evCooldownSeconds`, `evMaxPerMarketNotional`, `evMaxPortfolioNotional` |
| `fw_projection` | Dependency-aware Frank-Wolfe projection; non-converged or non-feasible outputs are rejected. | `fwDependency*`, `fwGapAbsTolerance`, `fwGapRelTolerance`, `fwMaxLoopRuntimeMs`, `fwMinEdgeThreshold` |
| `fw_basket` | Multi-market FW basket intents with bounded basket size and configurable execution mode. | `fwBasketExecutionMode`, `fwBasketMinMarkets`, `fwBasketMaxMarkets`, `fwMaxPerMarketNotional`, `fwMaxPortfolioNotional` |

Ops labels normalize strategy output to: `near_zero`, `ev`, `fw_projection`, `fw_basket`.

---

## Project Structure

```
Expand Down
1 change: 1 addition & 0 deletions docs/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Applies to `docs/` and all nested documentation files.
## Responsibilities
- Keep architecture, operations, setup, and testing docs in sync with runtime behavior.
- Maintain one canonical command reference for start/help/stop workflows.
- Surface strategy characteristics early in docs (`near_zero`, `ev`, `fw_projection`, `fw_basket`) before procedural details.

## Rules
- Source technical claims from code and scripts in this repository.
Expand Down
16 changes: 16 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ This document reflects the current runtime architecture in `src/` and the active
- Dashboard: React + Vite (`dashboard/src/`)
- Persistence: SQLite event store (`src/core/EventStore.ts`)

## Strategy Matrix (Read First)

Runtime strategy labels and their distinguishing execution traits:

| Strategy label | Pipeline shape | Distinguishing traits | Main policy surfaces |
| --- | --- | --- | --- |
| `near_zero` | `Scanner -> Risk -> Execution` | Paired YES/NO arbitrage with strict two-leg safety gates and near-zero-risk defaults | `strategyMode`, `signalMode`, `edgeRequired`, `minPairedFillRate`, `maxLegSkewMs` |
| `ev` | `SignalAggregator/Scanner -> Risk -> Execution` | Single-sided directional execution (`side=yes|no`) with confidence, cooldown, and EV notional limits | `signalMode`, `evEdgeRequired`, `evConfidenceMin`, `evCooldownSeconds`, `evMaxPerMarketNotional`, `evMaxPortfolioNotional` |
| `fw_projection` | `Scanner -> FwProjectionAgent -> Risk -> Execution` | Dependency-aware FW solver output; non-converged or non-feasible projection results are rejected | `fwDependency*`, `fwGapAbsTolerance`, `fwGapRelTolerance`, `fwMaxLoopRuntimeMs`, `fwMinEdgeThreshold` |
| `fw_basket` | `Scanner -> FwProjectionAgent -> Risk -> Execution` | Multi-market FW basket intents with configurable execution mode and basket size bounds | `fwBasketExecutionMode`, `fwBasketMinMarkets`, `fwBasketMaxMarkets`, `fwMaxPerMarketNotional`, `fwMaxPortfolioNotional` |

Operator-facing normalization:
- Dashboard labels normalize to `near_zero`, `ev`, `fw_projection`, `fw_basket`.
- `ev_single_side` is displayed as `ev`.
- Opportunity IDs can infer strategy when metadata is missing (`:fw:`, `:fwb:`, `:yes:`, `:no:`).

## System Topology

```mermaid
Expand Down
11 changes: 11 additions & 0 deletions docs/Operations/runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

Operate OpenPolyTrader safely across `off`, `shadow`, `paper`, and `live` modes.

## Strategy Quick Reference

Know the active strategy class before making operational decisions:

| Strategy label | Primary intent shape | Distinguishing characteristics | Main runtime controls |
| --- | --- | --- | --- |
| `near_zero` | Paired YES/NO arbitrage | Strongest two-leg safety posture; strict spread/depth/staleness/fill discipline | `strategyMode`, `signalMode`, `edgeRequired`, `minPairedFillRate`, `maxLegSkewMs` |
| `ev` | Single-sided directional | Confidence-thresholded intent, cooldown throttling, EV-specific notional caps | `signalMode`, `evEdgeRequired`, `evConfidenceMin`, `evCooldownSeconds`, `evMaxPerMarketNotional`, `evMaxPortfolioNotional` |
| `fw_projection` | Dependency-aware projected intent | Frank-Wolfe solver constraints; non-converged/non-feasible outputs are rejected | `fwDependency*`, `fwGapAbsTolerance`, `fwGapRelTolerance`, `fwMaxLoopRuntimeMs`, `fwMinEdgeThreshold` |
| `fw_basket` | Multi-market projected basket | Basket-level sizing and execution mode constraints | `fwBasketExecutionMode`, `fwBasketMinMarkets`, `fwBasketMaxMarkets`, `fwMaxPerMarketNotional`, `fwMaxPortfolioNotional` |

## Minimum Requirements

### Local safe operations
Expand Down
11 changes: 11 additions & 0 deletions src/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

TypeScript backend implementing agent-based arbitrage trading system with event-sourced state.

## Strategy Snapshot

Runtime strategy types (`src/domain/opportunity.ts`) and their distinguishing behavior:

| Strategy type | Distinguishing behavior | Primary policy controls |
| --- | --- | --- |
| `near_zero` | Paired YES/NO arbitrage flow with strict two-leg gate constraints. | `strategyMode`, `signalMode`, `edgeRequired`, `minPairedFillRate`, `maxLegSkewMs` |
| `ev` | Single-sided directional opportunity (`side=yes|no`) driven by calibrated confidence/edge checks. | `signalMode`, `evEdgeRequired`, `evConfidenceMin`, `evCooldownSeconds`, `evMaxPerMarketNotional`, `evMaxPortfolioNotional` |
| `fw_projection` | Dependency-aware Frank-Wolfe projection candidate; only solver-valid outputs are actionable. | `fwDependency*`, `fwGapAbsTolerance`, `fwGapRelTolerance`, `fwMaxLoopRuntimeMs`, `fwMinEdgeThreshold` |
| `fw_basket` | Multi-market FW basket opportunity with explicit basket sizing and execution mode. | `fwBasketExecutionMode`, `fwBasketMinMarkets`, `fwBasketMaxMarkets`, `fwMaxPerMarketNotional`, `fwMaxPortfolioNotional` |

## Structure

```
Expand Down
7 changes: 7 additions & 0 deletions src/agents/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Applies to `src/agents/` and all agent subdirectories.
- Emit and consume MessageBus events to move opportunities through the trading pipeline.
- Keep agent decisions deterministic unless explicitly in LLM advisory/active modes.

## Strategy Characteristics

- `near_zero`: paired YES/NO arbitrage with strict two-leg safety and gate discipline.
- `ev`: single-sided directional execution path with confidence thresholds, cooldown, and EV notional caps.
- `fw_projection`: dependency-aware Frank-Wolfe projection path; non-converged/non-feasible candidates are rejected.
- `fw_basket`: multi-market FW basket execution with bounded basket size and mode (`sequential_failfast` or `batch_best_effort`).

## Rules
- Read the root `AGENTS.md` and the nearest local `AGENTS.md` before changes.
- Do not bypass risk gates or execution safety checks.
Expand Down
Loading