Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

python-bot-standards

БесплатноБез исполняемых скриптовНе проверен

Coding standards, modular architecture, and common execution patterns for the PolyFlup Python backend.

Niller2005от Niller2005★ 18 звёзд на GitHub

Об этом скилле

Python Coding Standards

Modular Architecture

The backend is modularized into packages:

  • src.trading.orders: Order management (limit, market, batch, positions).
  • src.data.market_data: Data fetching (polymarket, binance, indicators, price validation).
  • src.trading: Centralized execution logic (execution.py, logic.py, strategy.py).
  • src.trading.execution: Atomic hedging execution (batch placement, fill monitoring, emergency liquidation).
  • src.trading.pre_settlement_exit: Pre-settlement exit strategy (confidence-based early exit).

Standard Trade Execution (Atomic Hedging)

from src.trading.execution import execute_atomic_trade
# Execute an atomic entry+hedge pair with full tracking
trade_id = execute_atomic_trade(symbol, entry_side, entry_price, hedge_price, size)

Imports

  • Use absolute imports from src.*
  • Group imports: standard library → third-party → local
  • Always import from src.config.settings for configuration constants

Formatting

  • Indentation: 4 spaces
  • Line length: ~90 characters
  • Strings: Double quotes preferred
  • Docstrings: Triple double-quotes with brief description

Error Handling & Logging

  • Use log_error(text, include_traceback=True) from src.utils.logger for all exceptions.
  • Always log errors with context: log(f"[{symbol}] Order failed: {e}").
  • Graceful degradation: return neutral/safe values on error.
  • Use emojis in logs (👀 Monitoring, 🚀 Execution, ✅ Success, ❌ Error).

Thread Safety & Synchronization (v0.4.2+)

  • Use threading locks for shared resources: with position_lock: ...
  • Always confirm order fills before cancellation to prevent race conditions
  • Implement reconciliation systems for order tracking consistency
  • Use recent_fills tracking to prevent duplicate processing
  • Add synchronization locks for all critical trading operations

Confidence Algorithm Standards (v0.4.2+)

  • Cap confidence at 85% maximum to prevent overconfidence
  • Validate price movements before high-confidence trades (>75%)
  • Implement multi-confirmation systems for extreme confidence levels
  • Use directional voting with weighted signal aggregation
  • Test confidence ranges (0-100%) and bias validation thoroughly

Bayesian Confidence Calculation (v0.5.0+)

  • Dual Calculation System: Both additive and Bayesian methods are calculated simultaneously for A/B testing
  • Configuration Flag: BAYESIAN_CONFIDENCE in src/config/settings.py toggles between methods (default: NO)
  • Bayesian Formula:
    # Start with market prior from Polymarket orderbook
    prior_odds = p_up / (1 - p_up)
    log_odds = ln(prior_odds)
    
    # Accumulate evidence from all signals
    for each signal:
        evidence = (score - 0.5) * 2  # -1 to +1
        log_LR = evidence * 3.0 * quality  # Calibration with quality
        log_odds += log_LR × weight
    
    # Convert to probability
    confidence = 1 / (1 + exp(-log_odds))
    
  • Quality Factors (0.7-1.5x): Applied to log-likelihood strength for each signal
  • Market Prior: Anchors calculation to Polymarket orderbook probability
  • A/B Testing: Both methods stored in raw_scores dictionary and database for comparison
  • Database Schema: Migration 007 adds additive_confidence, additive_bias, bayesian_confidence, bayesian_bias, market_prior_p_up columns

Audit Trail Requirements (v0.4.2+)

  • Log all scale-in order lifecycle events with consistent formatting
  • Use standardized emojis: 🎯 (placement), ✅ (filled), 🧹 (cancellation), ⚠️ (race condition)
  • Include order IDs, sizes, prices, and timestamps in all audit logs
  • Maintain separate audit trails for notifications, reconciliation, and position management
  • Log notification processing with order ID extraction details

Database Safety Standards

  • Always use db_connection() context manager
  • Pass active cursors to write functions within transactions
  • Implement migration system for schema changes
  • Use schema_version table to track database versions
  • Prevent deadlocks with proper cursor management

Configuration Management

  • Centralize all settings in src.config.settings
  • Use environment variables for sensitive data
  • Implement validation for critical thresholds (MIN_EDGE, confidence caps)
  • Document all configuration options in .env.example
  • Add price validation settings for high-confidence trades

Testing Standards

  • Create comprehensive test suites for algorithm validation
  • Test confidence ranges (0-100%), bias validation, and safety features
  • Implement integration tests for multi-confirmation systems
  • Validate price movement detection and manipulation prevention
  • Test race condition prevention and synchronization

Performance Optimization

  • Use efficient API calls with proper caching
  • Implement batch processing for multiple orders
  • Monitor execution times and optimize critical paths
  • Use WebSocket connections for
Полный SKILL.md на GitHub

Установить python-bot-standards в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл python-bot-standards?

Coding standards, modular architecture, and common execution patterns for the PolyFlup Python backend.

Как установить скилл python-bot-standards?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл python-bot-standards запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить python-bot-standards с