A multi-factor quantitative trading framework for cryptocurrency markets.
Project description
English
A multi-factor quantitative trading framework for cryptocurrency markets.
Overview
Phandas is a quantitative analysis framework designed for systematic portfolio construction and risk management. It provides high-performance data structures and financial analysis tools for factor investing and statistical arbitrage strategies.
Key Features
- Data management: Automated OHLCV data fetching with validation and quality checks
- Factor operations: Extensive library of time-series and cross-sectional operators
- Neutralization: Vector projection and regression-based factor neutralization
- Backtesting: Dollar-neutral portfolio construction with dynamic rebalancing
- Performance Analytics: Total Return, Annual Return, Sharpe Ratio, Max Drawdown, Turnover
Installation
pip install phandas
Quick Start
from phandas import *
# Fetch market data
panel = fetch_data(
symbols=['ETH', 'SOL', 'ARB', 'OP', 'POL', 'SUI'],
timeframe='1d',
start_date='2023-01-01',
sources=['binance', 'benchmark', 'calendar'],
)
# Extract factors
close = panel['close']
volume = panel['volume']
open = panel['open']
# Construct momentum factor
momentum_20 = (close / close.ts_delay(20)) - 1
# Neutralize against volume
neutralized_factor = vector_neut(rank(momentum_20), rank(-volume))
# Backtest strategy
result = backtest(
price_factor=open,
strategy_factor=neutralized_factor,
transaction_cost=(0.0003, 0.0003)
)
result.plot_equity()
MCP Support (Model Context Protocol)
Phandas provides a built-in MCP server, allowing AI agents (like Claude) to directly use Phandas tools to fetch data and analyze markets.
Configuration for Claude Desktop
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"phandas": {
"command": "uvx",
"args": ["phandas", "phandas-mcp"]
}
}
}
Or if you have installed it in your local environment (requires pip install phandas):
{
"mcpServers": {
"phandas": {
"command": "python",
"args": ["-m", "phandas.mcp_server"]
}
}
}
Developed by Phantom Management.
繁體中文
一個專為加密貨幣市場設計的多因子量化交易框架。
概述
Phandas 是一個為系統化投資組合構建與風險管理而設計的量化分析框架。它為因子投資與統計套利策略提供高效能的資料結構與金融分析工具。
核心功能
- 資料管理:自動化 OHLCV 資料獲取,包含驗證與品質檢查
- 因子運算:豐富的時間序列與橫截面運算子庫
- 中性化:基於向量投影與迴歸的因子中性化
- 回測:美元中性投組構建、動態調倉
- 績效分析:年化收益、夏普比率、最大回撤、換手率
安裝
pip install phandas
快速開始
from phandas import *
# 獲取市場資料
panel = fetch_data(
symbols=['ETH', 'SOL', 'ARB', 'OP', 'POL', 'SUI'],
timeframe='1d',
start_date='2023-01-01',
sources=['binance', 'benchmark', 'calendar'],
)
# 提取因子
close = panel['close']
volume = panel['volume']
open = panel['open']
# 構建動量因子
momentum_20 = (close / close.ts_delay(20)) - 1
# 對成交量進行中性化
neutralized_factor = vector_neut(rank(momentum_20), rank(-volume))
# 回測策略
result = backtest(
price_factor=open,
strategy_factor=neutralized_factor,
transaction_cost=(0.0003, 0.0003)
)
result.plot_equity()
MCP 支援 (Model Context Protocol)
Phandas 內建 MCP 伺服器,允許 AI 代理(如 Claude)直接使用 Phandas 工具來獲取資料與分析市場。
Claude Desktop 設定
請將以下內容加入您的 claude_desktop_config.json:
{
"mcpServers": {
"phandas": {
"command": "uvx",
"args": ["phandas", "phandas-mcp"]
}
}
}
或者,如果您已在本地環境安裝(需先執行 pip install phandas):
{
"mcpServers": {
"phandas": {
"command": "python",
"args": ["-m", "phandas.mcp_server"]
}
}
}
由 Phantom Management 開發。
Community & Support | 社群與支持
- Discord: Join our community
- GitHub Issues: Report bugs or request features
License
This project is licensed under the BSD 3-Clause License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file phandas-0.14.0.tar.gz.
File metadata
- Download URL: phandas-0.14.0.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7b560200ac33b8b819d110a28cafd7d46fffa1c86c021396d6176dbb0958fe6
|
|
| MD5 |
6ef2ac40de58cad45cc4568466d9167e
|
|
| BLAKE2b-256 |
ae2770cb1d9a6479e24bb97a800b7d1efacc24a7f42451b7b894836bc2dfc72f
|
File details
Details for the file phandas-0.14.0-py3-none-any.whl.
File metadata
- Download URL: phandas-0.14.0-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a51a28ecc3cc27afef950af4e34bfa93ae5038fdabf27ebf6ff146cf74ed81
|
|
| MD5 |
8e313a5c7ec00321bc60dc5b0db95c89
|
|
| BLAKE2b-256 |
86a17b22161b9629cba8740c4affaf9ceb4913596676360ffca14eca2b4c9219
|