arbitrage history tracking#15
Open
arnavdhole wants to merge 1 commit into
Open
Conversation
… history endpoint Database (supabase/migrations/20260425000000_arbitrage_history.sql): - arbitrage_opportunities: one row per unique (polymarket_id, kalshi_id) pair, upserted on every scan. Tracks first/last seen, max spread ever observed, observation count, and lifecycle status (active/closed). - arbitrage_snapshots: append-only time-series, one row per scan per pair. Records exact prices, spread, direction, and volumes at that moment. - Indexes on status+last_seen, category, max_spread, and observed_at. Recorder (src/api/arbitrage-recorder.ts): - recordArbitrageOpportunities() upserts pairs and inserts snapshots in one call. - Closes stale opportunities that haven't been seen in 10+ minutes. - buildSupabaseClient() creates a service-role client for server-side writes. Cron job (api/cron/record-arbitrage.ts): - Runs every 5 minutes via Vercel Cron. - Uses a 1% threshold (vs 3% API default) to capture near-arbitrage in history. - Same CRON_SECRET auth pattern as refresh-markets. History endpoint (api/markets/arbitrage/history.ts): - GET /api/markets/arbitrage/history - Filterable by date range, status (active/closed/all), minSpread, category. - Paginated with limit/offset. - Joins latest snapshot onto each opportunity row so callers see current prices. vercel.json: - Registered /api/markets/arbitrage/history route. - Registered /api/cron/record-arbitrage route and cron schedule (*/5 * * * *).
|
@arnavdhole is attempting to deploy a commit to the Victor's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Adds a system to persist every arbitrage opportunity the detector finds.
DB (supabase/migrations/):
upserted each scan. Tracks first/last seen, max spread, observation count, status.
Records exact prices, spread, direction, and volumes at that moment.
Recorder (src/api/arbitrage-recorder.ts):
Cron job (api/cron/record-arbitrage.ts):
near-arbitrage in history.
History endpoint: