Skip to content

Releases

Balanced Portfolio v1.0.0

Choose a tag to compare

@hxlog hxlog released this 17 Jul 08:37
7279a63

Balanced Portfolio v1.0.0

First stable release of an open-source multi-asset risk-parity portfolio platform with CFFEX index-futures analytics and OTC autocallable pricing.


中文介绍

这是什么(产品)

Balanced Portfolio(均衡组合)是一套面向学习与研究的全栈投资组合管理系统。它以桥水风格的风险平价 / 全天候思想为核心,把宏观场景划分、组合优化、历史回测、机构级可视化,以及国内股指期货结构观察、场外自动敲入敲出(autocallable)结构化产品定价,整合进同一套可自托管的应用中。

本版本 v1.0.0 是项目的首个正式稳定版:公开能力边界、部署路径与主要功能模块相对稳定,适合克隆仓库本地搭建、阅读实现,或在自有环境中做教学与研究实验。在线演示见 xushilu.com;开发心路与产品说明见 博客长文。

主要功能

1. 多资产风险平价组合与回测

按 GDP 增长 / 宏观通胀二分法,将资产映射到四象限(不同宏观环境下占优品种的配置框架),并提供多种优化与风险分配方式,包括:

  • 象限内最大夏普或 Sortino + 象限间等风险贡献(quadrant_inner_sharpe_outer_rp)
  • 全资产等风险贡献(风险平价)(all_risk_parity)
  • 全资产最大夏普或 Sortino(all_max_sharpe)
  • 按优化指标(比率平方)分配风险预算(sharpe_sq_risk_budget)

回测结果覆盖:优化权重、净值曲线、调仓记录、风险指标、相关性,以及绩效归因。系统强调无未来函数约束:每个交易日仅使用当日及之前滚动窗口数据;测试会验证「篡改未来收益不得改变历史净值」。

2. 中金所股指期货数据看板

跟踪 IF / IH / IC / IM 及对应指数(沪深 300、上证 50、中证 500、中证 1000),提供同一交易日口径的:

  • 收盘快照
  • 期限结构
  • 历史年化升贴水与统计分位

用于观察基差与期限结构,不包含下单或实时成交保证。

3. 场外期权自动敲入敲出(Autocallables)定价

覆盖雪球、凤凰、气囊与障碍等结构;支持蒙特卡洛、BSM 求解、积分法等路径。输出包括公允价值、PV、PoL,以及 Delta / Gamma / Vega / Theta / Rho 等敏感度,并支持存续路径与状态可视化。定价可异步执行并持久化,便于交互式研究。

4. 机构向可视化与工程化

开箱可用的交互仪表盘,把组合回测、期货看板与 OTC 定价放在统一前端;后端提供 OpenAPI(/docs)、健康检查与可部署架构。

技术说明

  • 栈: Python 3.11–3.14(FastAPI)、Node.js 20+(Next.js)、PostgreSQL 18 + TimescaleDB;行情经 AKShare 接入。
  • 数据流: 原始行情写入后清洗到 bp_quote_clean(A 股交易日历对齐、内部缺口线性插值、前导缺口截断、无右端锚点的尾部缺口报错),回测只读清洗行情。
  • 异步: 生产可用 Redis + Celery;本地可用 BP_TASK_MODE=inline。
  • 文档: 架构见 docs/architecture.md,部署见 docs/deployment.md 与 deploy/OPS.md。

快速开始

请参阅仓库 README Quick Start:配置 .env → 安装依赖 → 执行 ddl/schema.sql → python -m bp_ingest run → 启动 uvicorn 与前端 npm run dev。

数据与投资免责声明

AKShare 聚合公开数据接口,数据源可能调整、延迟、限流、修订或停止服务。项目不保证行情、交易日历、复权、基差、波动率、定价结果和回测结果完整、准确或持续可用,使用者应自行核验数据授权、质量和适用性。

本项目仅用于软件开发、教学和研究,不构成投资建议、交易信号、估值意见、要约或任何收益承诺。回测和模型价格不代表未来表现或可成交价格,实盘决策及损失由使用者自行承担。


English

What it is (product)

Balanced Portfolio is an open-source, self-hostable full-stack platform for multi-asset risk-parity / all-weather style portfolio construction and backtesting, plus CFFEX equity-index futures analytics and OTC autocallable structured-product pricing. It is intended for developers, students, and researchers who want a transparent, end-to-end stack—from market ingest and cleaning through optimization, async jobs, and interactive dashboards.

v1.0.0 is the first stable tagged release under Semantic Versioning. Live demo: xushilu.com. Long-form product story: blog post.

Highlights

1. Risk-parity portfolios & backtests

Assets are organized via a growth/inflation four-quadrant macro lens. Supported optimizers / risk budgets include:

  • Quadrant-inner max Sharpe or Sortino, outer equal risk contribution
  • All-asset equal risk contribution (classic risk parity)
  • All-asset max Sharpe or Sortino
  • Risk budgets proportional to squared performance ratios

Outputs include weights, NAV, rebalances, risk metrics, correlations, and performance attribution. Backtests are designed to be point-in-time: each day uses only data available on or before that day; tests assert that mutating future returns does not change historical NAV.

2. CFFEX index-futures dashboard

Tracks IF, IH, IC, IM and their underlyings with same-trading-day snapshots, term structure, historical annualized basis, and statistical percentiles—for market structure observation, not execution.

3. OTC autocallables pricing

Snowball, phoenix, airbag, and barrier-style products with Monte Carlo and analytical / integral methods where applicable. Reports fair value, PV, PoL, Greeks (Delta, Gamma, Vega, Theta, Rho), and path/status views for interactive study.

4. Production-minded visualization

A unified web UI over FastAPI + Next.js, with OpenAPI docs, health checks, and documented deployment (PostgreSQL 18 + TimescaleDB; optional workers).

Technical notes

  • Quotes are cleaned onto a shared A-share calendar before entering the engine.
  • Heavy work can run via Redis + Celery, or inline FastAPI background tasks for local development.
  • See docs/architecture.md and docs/deployment.md for architecture and ops.

Getting started

Follow the repository README Quick Start, then open http://localhost:3000 (API health: /api/health, OpenAPI: /docs).

Data & investment disclaimer

AKShare aggregates public data interfaces that may change, delay, rate-limit, revise, or stop. This project does not guarantee completeness, accuracy, or ongoing availability of market data, calendars, corporate actions, basis, volatility, pricing, or backtest results. Users must verify data licensing, quality, and fitness for purpose.

This project is for software development, education, and research only. It does not constitute investment advice, trading signals, valuation opinions, offers, or any performance promise. Backtests and model prices do not represent future results or executable prices. Users are solely responsible for real-world decisions and losses.


Assets

Source code archives are provided automatically by GitHub for tag v1.0.0 (zip / tar.gz). No additional binaries are attached to this release.

Full changelog

Initial stable release v1.0.0 (first release for this repository). Tagged commit: 7279a636acbad81ffd1a3cf721c327b84f0c4b2a.

Links