Python bot standards

From Niller2005/PolyFlup · View interactive version

Python bot standards is an AI agent skill from the GitHub repository Niller2005/PolyFlup. Coding standards, modular architecture, and common execution patterns for the PolyFlup Python backend.

How to use this skill

Skill file

Python Coding Standards

Modular Architecture

The backend is modularized into packages:

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

Formatting

Error Handling & Logging

Thread Safety & Synchronization (v0.4.2+)

Confidence Algorithm Standards (v0.4.2+)

Bayesian Confidence Calculation (v0.5.0+)

```python

# 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))

```

Audit Trail Requirements (v0.4.2+)

Database Safety Standards

Configuration Management

Testing Standards

Performance Optimization

Documentation Standards

Code Quality Standards

Security Standards

Deployment Standards

Monitoring & Alerting

Version Control Standards

Atomic Hedging Execution (v0.6.0+)

Position Monitoring & Reporting (v0.6.0+)

MIN_ORDER_SIZE Smart Hold Logic (v0.6.0+)

```python

if size < MIN_ORDER_SIZE:

current_price = get_current_price()

if current_price > entry_price: # WINNING

log("๐ŸŽฏ HOLDING through resolution - too small to sell but profitable")

return True # Let it resolve for profit

else: # LOSING

log("๐Ÿ”’ Position ORPHANED - too small to sell, will lose on resolution")

return False # Accept small loss

```

Version History

v0.6.x (Oct 2026) - Polymarket V2

v0.6.0 (Jan 2026)

v0.5.0 (Jan 2026)

v0.4.4 (Jan 2026)

v0.4.3 (Jan 2026)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.