This is a Python library for quantitative finance, specifically portfolio optimization and risk management. It implements Conditional Value-at-Risk (CVaR) optimization using Benders decomposition, mean-variance optimization via quadratic programming, and entropy pooling for adjusting scenario probabilities under user-defined views and stress tests. The library also includes fully flexible resampling (FFR) for simulation, Black's model for option pricing, and a set of helper functions for financial statistics. It is designed as a monolithic Python package with a clean API, extensive tests (100% coverage), and 14 Jupyter notebooks that serve as reproducible examples. While the primary character is an application library, it has a strong research and educational orientation, referencing academic papers and providing walkthroughs. The code is well-structured, but domain-specific and depends on cvxopt with GLPK for linear programming, which may limit portability.
This repository implements an automated trading bot for Kalshi prediction markets, leveraging AI models (primarily via OpenRouter) to make directional trading decisions. The system is built as an async Python application with a CLI entry point (`cli.py`), a Streamlit dashboard, and a paper trading mode. It supports multiple strategies: an AI-driven directional strategy using a multi-agent debate pipeline (bull/bear researchers, risk manager, trader), a conservative NO-side safe compounder, market making, and a unified trading system that dynamically allocates capital. The core data flow involves ingesting market data from the Kalshi REST and WebSocket APIs, persisting to SQLite, running AI inference through OpenRouter with fallback chains and cost tracking, executing trades via Kalshi's signed REST API, and monitoring positions with stop-loss/take-profit logic. Risk management is enforced through Kelly criterion position sizing, edge filtering, category scoring, portfolio enforcer, and cash reserves. The codebase also includes performance analysis jobs, a paper trading signal tracker with static HTML dashboard, and a comprehensive test suite. External dependencies include Kalshi API, OpenRouter (with optional xAI and Grok models), SQLite, Streamlit, and various async libraries (httpx, aiohttp, websockets).