원클릭으로
database-sqlite
SQLite best practices, connection management, and migration system for PolyFlup.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
SQLite best practices, connection management, and migration system for PolyFlup.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Chronological log of system improvements and session summaries for PolyFlup.
Polymarket-specific terminology, trading strategies, and API reference.
Coding standards, modular architecture, and common execution patterns for the PolyFlup Python backend.
Specialized in maintaining project documentation, ensuring it reflects the current state of the codebase and operational procedures.
Specialized in syncing the production database and performing analysis on trades, balances, and market history.
Specialized in syncing logs from production and analyzing them to find trade history, errors, or performance metrics.
| name | database-sqlite |
| description | SQLite best practices, connection management, and migration system for PolyFlup. |
ALWAYS use the db_connection() context manager:
from src.data.db_connection import db_connection
with db_connection() as conn:
c = conn.cursor()
c.execute("SELECT * FROM trades")
# Commit happens automatically on success
conn.commit() manually.execute_trade) from within an existing transaction, MUST pass the active cursor.The migration system tracks versions in the schema_version table.
src/data/migrations.py.MIGRATIONS list.src/data/database.py.Main table: trades
id, timestamp, symbol, side, entry_price, size, bet_usd, edgeorder_id, order_status, limit_sell_order_id, scale_in_order_idscaled_in, is_reversal, target_price, reversal_triggered, reversal_triggered_atsettled, settled_at, exited_early, final_outcome, exit_price, pnl_usd, roi_pctwindow_start, window_end, last_scale_in_atslug, token_id, p_yes, best_bid, best_ask, imbalance, funding_biasadditive_confidence, additive_bias, bayesian_confidence, bayesian_bias, market_prior_p_up# Get open positions with all relevant data
c.execute("""
SELECT id, symbol, token_id, side, entry_price, size, bet_usd,
limit_sell_order_id, scale_in_order_id, scaled_in, edge,
last_scale_in_at, window_end
FROM trades
WHERE settled = 0 AND exited_early = 0
AND datetime(window_end) > datetime(?)
""", (now.isoformat(),))
# Update position size after scale-in
c.execute("""
UPDATE trades
SET size = ?, bet_usd = ? * entry_price,
scaled_in = 1, last_scale_in_at = ?
WHERE id = ?
""", (new_size, new_size, now.isoformat(), trade_id))
# Settle position with exit data
c.execute("""
UPDATE trades
SET settled = 1, exited_early = 1, exit_price = ?,
pnl_usd = ?, roi_pct = ?, settled_at = ?
WHERE id = ?
""", (exit_price, pnl_usd, roi_pct, now.isoformat(), trade_id))
PRAGMA journal_mode=WALadditive_confidence, additive_bias, bayesian_confidence, bayesian_bias, market_prior_p_up) for A/B testingup_total, down_total, momentum_score, momentum_dir, flow_score, flow_dir, divergence_score, divergence_dir, vwm_score, vwm_dir, pm_mom_score, pm_mom_dir, adx_score, adx_dir, lead_lag_bonus) for confidence formula calibrationlast_scale_in_at column for tracking scale-in timingreversal_triggered_at column for timing reversalsreversal_triggered column for reversal trackingscale_in_order_id column for tracking pending scale-in orders