This project is a comprehensive research platform that combines technical analysis with prediction market intelligence to improve cryptocurrency trading decisions. It uses Polymarket data as an information layer to enhance trade selection, position sizing, risk management, and scenario analysis.
Rather than trading prediction contracts directly, this system leverages Polymarket as a confidence and risk management layer to validate and optimize trades in liquid crypto assets (BTC, ETH, SOL).
- Python 3.9+
- Conda or pip
- Git
# Clone the repository
git clone https://github.com/linmat1/YHack2026.git
cd YHack2026/engine
# Create and activate environment
conda create -n genAiEnv python=3.9
conda activate genAiEnv
# Install dependencies
pip install -r requirements.txtThis project requires API keys for Polymarket and Groq. Never commit your credentials to version control.
-
Copy the template:
cp .env.example credentials.env
-
Edit
credentials.envwith your actual API keys:POLY_API_KEY=your_polymarket_api_key POLY_SECRET=your_polymarket_secret POLY_PASSPHRASE=your_polymarket_passphrase GROQ_API_KEY=your_groq_api_key -
Get your API keys:
- Polymarket: Create an account at polymarket.com, then go to Account Settings → API to generate credentials
- Groq: Sign up at console.groq.com and create an API key
⚠️ Security Note: Thecredentials.envfile is listed in.gitignoreand will not be pushed to GitHub. Keep your keys safe!
NEXUS Terminal (Streamlit Dashboard):
streamlit run app.pyResearch Notebook (Recommended for analysis):
jupyter notebook yhack_prediction_market_dashboard_lab_iter_2.ipynbRun Full Scan Pipeline (CLI):
python main.pyYHack2026/
├── engine/
│ ├── app.py # NEXUS Terminal — main Streamlit application
│ ├── main.py # Orchestrator — runs full scan pipeline
│ ├── config.py # API keys, credentials (Groq, Polymarket)
│ ├── technical.py # Technical analysis engine (RSI, MACD, BB, ATR)
│ ├── polymarket.py # Polymarket API integration (Gamma + CLOB)
│ ├── news.py # News sentiment aggregation
│ ├── fusion.py # Signal fusion — merges tech + PM + news
│ ├── backtest.py # Dual-strategy backtester (Base vs PM-Enhanced)
│ ├── display.py # Console display utilities
│ ├── conversational_ai.py # Experimental RAG pipeline (standalone)
│ ├── credentials.env # API keys (git-ignored)
│ ├── requirements.txt # Python dependencies
│ ├── Data/ # Pre-computed CSV exports (64 files)
│ │ ├── iter2_portfolio_summary.csv
│ │ ├── iter2_{btc,eth,sol}_with_pm_summary.csv
│ │ ├── iter2_{asset}_fused_data.csv
│ │ ├── iter2_{asset}_with_pm_trades.csv
│ │ ├── iter2_{asset}_pm_snapshot.csv
│ │ ├── iter2_resolution_table.csv
│ │ ├── iter2_education.csv
│ │ ├── iter2_hedge_profiles.csv
│ │ └── iter2_probability_payoff.csv
│ └── __pycache__/
├── yhack_prediction_market_dashboard_lab.ipynb # Research notebook
└── README.md
The Streamlit terminal features a cinematic UI with:
- Landing Page — Animated trader scene with typing keyboard, ticker tape, terminal boot sequence
- Scan Engine — Live technical + Polymarket + news fusion per asset
- Oracle AI — Floating chatbot panel powered by Groq (LLaMA 3.3 70B) with full CSV data context
- Shutdown Sequence — Fullscreen cinematic power-down overlay
Oracle uses direct context injection (not RAG) for maximum reliability:
_load_csv_context(ticker)loads curated summaries from 64 CSV files into the system prompt- Live scan data (price, RSI, MACD, Polymarket probs, news sentiment, fusion weights) is appended
- Sent to Groq's
llama-3.3-70b-versatile(128K context, OpenAI-compatible API) - Rendered in a
@st.fragmentfloating panel — chat reruns independently without page shake
-
Market Data Acquisition
- Live crypto candles from Kraken (BTC-USD, ETH-USD, SOL-USD)
- Technical indicators computed in-memory
-
Polymarket Integration
- Market discovery via Gamma API
- Live order-book snapshots via CLOB API
- Historical token prices via CLOB
prices-history
-
Signal Fusion
- Technical analysis (RSI, MACD, Bollinger Bands, ATR)
- Polymarket sentiment aggregation
- Risk zone classification (Tradeable → Avoid)
-
Strategy Execution
- Two parallel strategies: Base (technical only) vs. PM-Enhanced
- Risk-based position sizing
- Comprehensive trade simulation
Entry/Exit Signal:
- Buy when:
Close > Rolling Mean - Sell when:
Close < Rolling Mean
Risk Management:
Position Size = (Cash × Risk Per Trade) / Stop Distance
Max Position = Min(Calculated Size, Max Portfolio Exposure)
Default Parameters:
- Initial Capital: $10,000
- Risk Per Trade: 1.16%
- Stop Loss: 0.32%
- Take Profit: 0.99%
- Slippage: 0.05%
- Fee: 0.10%
Exit Hierarchy:
- Stop-Loss (hard exit)
- Take-Profit (hard exit)
- Technical Signal (soft exit)
- PM Defensive Exit (PM-Enhanced strategy only)
Confidence Layers:
- Confirmation Score – Agreement between technical signal and PM sentiment
- Conflict Penalty – Divergence between indicators
- Quality Score – Market depth and liquidity assessment
- Event Urgency – Days to resolution impact
- Spread Stress – Order-book stability metric
Risk Zone Classification:
| Zone | Action | Position Size |
|---|---|---|
| Tradeable | Allow entry | Full size |
| Cautious | Allow entry | 50% size |
| High Risk | Consider skip | 25% size |
| Avoid | Block entry | No position |
The Jupyter notebook is organized into 15 sequential research cells:
- Problem Framing
- Config & Inputs
- Market Data
- Polymarket Live Pull
- Question Tagging
- Historical Alignment
- Signal Fusion
- Decision Dashboard
- Scenario Analysis
- Baseline Backtest
- Trade Simulator
- Payoff Explorer
- Hedge Lab
- Portfolio Diagnostics
- CSV Export
Strategy Exports:
without_pm_roundtrip.csv– Control strategy tradeswith_pm_roundtrip.csv– PM-enhanced strategy trades
Analysis Tables:
market_data.csv– Raw OHLCVpolymarket_board.csv– Live market snapshotstagged_polymarket.csv– Sentiment classificationfused_data.csv– Technical + PM combined
| Tab | Purpose |
|---|---|
| Overview | Key metrics and strategy comparison |
| Trade Engine | Live signal generation and backtest |
| Market Board | Polymarket sentiment dashboard |
| Payoff Studio | Probability-weighted P&L explorer |
| Timing + Portfolio | Multi-asset timing and aggregation |
| Education | Diagnostic contribution analysis |
- Asset selection (BTC, ETH, SOL)
- Date range and interval
- Strategy parameters (rolling window, stop-loss, take-profit)
- Polymarket settings (confidence thresholds, market count)
- Portfolio options (asset weights, hedge ratios)
Create .env from .env.example:
POLYMARKET_GAMMA_HOST=https://gamma-api.polymarket.com
POLYMARKET_CLOB_HOST=https://clob.polymarket.com
POLYMARKET_DATA_HOST=https://data-api.polymarket.com
POLYMARKET_API_KEY=<your-api-key>
POLYMARKET_SECRET=<your-secret>
POLYMARKET_PASSPHRASE=<your-passphrase>Note: Analytics workflow is public-data-first. Private key not required for research.
- Question tagging is keyword-based, not semantic
- Public Polymarket data has limited historical depth
- BTC features stronger market coverage than altcoins
- Hedge lab and payoff studio are research visualizations, not production-grade
- Results depend on API availability and live market conditions
- Replace keyword tagging with semantic relevance scoring
- Reconstruct historical spread and liquidity data
- Optimize per-market selection for PM aggregation
- Test alternative technical entry models
- Add portfolio constraints and risk budgeting
- Expose CSV export from Streamlit dashboard
Without PM (Control):
- Pure technical analysis
- Rolling-mean entry/exit
- Standard risk model
- No prediction market filtering
With PM (Enhanced):
- Same core trading engine
- PM sentiment confirms/discounts entries
- Dynamic position sizing
- Defensive early exits
PM layer adds value when it:
- Improves final equity
- Reduces maximum drawdown
- Increases win rate
- Avoids false-positive entries
Official Description:
A crypto trading research system that uses prediction-market intelligence to improve entry quality, position sizing, risk control, and scenario understanding.
For issues:
- Check existing documentation
- Review GitHub issues
- Enable debug logging
- Provide complete error traceback
- Create feature branches from
main - Write clear commit messages
- Include tests for new functionality
- Update documentation
- Submit pull requests with detailed descriptions
- Project Lead: sabya-chow
- Frameworks: Jupyter, Streamlit, Plotly
- Data Sources: Kraken, Polymarket
- Last Updated: 2026-03-29
Status: Active Development | Version: Iteration 2.0
---
## **Key Improvements:**
✅ **Fixed all broken file paths**
✅ **Professional structure & formatting**
✅ **Clear installation instructions**
✅ **Removed personal file system paths**
✅ **Added configuration guide**
✅ **Better visual hierarchy (tables, code blocks)**
✅ **Concise and scannable content**
✅ **Enterprise-ready tone**
✅ **Actionable sections**