Skip to main content

A multi-factor quantitative trading framework for cryptocurrency markets.

Project description

Phandas

en zh-TW

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 Fetching: Multi-source OHLCV data
  • Factor Engine: 50+ time-series and cross-sectional operators
  • Neutralization: Vector projection & regression-based orthogonalization
  • Backtesting: Dollar-neutral strategies with dynamic rebalancing
  • Performance Metrics: Sharpe, Sortino, Calmar, Max Drawdown, VaR
  • MCP Integration: AI agents (Claude) can directly access Phandas via JSON config

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
factor = vector_neut(rank(momentum_20), rank(-volume))

# Backtest strategy
result = backtest(
    entry_price_factor=open, 
    strategy_factor=factor,
    transaction_cost=(0.0003, 0.0003)
)

result.plot_equity()

AI Integration via MCP

Use Phandas with AI IDEs (Cursor, Claude Desktop) directly—no coding required.

Setup for Cursor (Recommended)

  1. pip install phandas
  2. Open Cursor → Settings → Tools & MCP → New MCP Server
  3. Paste the JSON config below, save and restart
{
  "mcpServers": {
    "phandas": {
      "command": "python",
      "args": ["-m", "phandas.mcp_server"]
    }
  }
}

Available Tools (4 Functions)

  • fetch_market_data: Get OHLCV data for symbols
  • list_operators: Browse all 50+ factor operators
  • read_source: View source code of any function
  • execute_factor_backtest: Backtest custom factor expressions

Developed by Phantom Management.


繁體中文

一個專為加密貨幣市場設計的多因子量化交易框架。

概述

Phandas 是一個為系統化投資組合構建與風險管理而設計的量化分析框架。它為因子投資與統計套利策略提供高效能的資料結構與金融分析工具。

核心功能

  • 資料獲取:多源 OHLCV 資料
  • 因子引擎:50+ 時間序列與橫截面運算子
  • 因子中性化:向量投影與迴歸正交化
  • 回測引擎:美元中性策略、動態調倉
  • 績效指標:夏普比、Sortino、Calmar、最大回撤、VaR
  • MCP 集成:AI 代理(Claude)可直接調用 Phandas

安裝

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

# 對成交量進行中性化
factor = vector_neut(rank(momentum_20), rank(-volume))

# 回測策略
result = backtest(
    entry_price_factor=open, 
    strategy_factor=factor,
    transaction_cost=(0.0003, 0.0003)
)

result.plot_equity()

AI 集成(MCP 支援)

在 AI IDE(Cursor、Claude Desktop)中直接使用 Phandas—無需編碼。

Cursor 設定(推薦)

  1. pip install phandas
  2. 開啟 Cursor → Settings → Tools & MCP → New MCP Server
  3. 貼上下方 JSON 配置,儲存並重啟
{
  "mcpServers": {
    "phandas": {
      "command": "python",
      "args": ["-m", "phandas.mcp_server"]
    }
  }
}

可用工具(4 個函數)

  • fetch_market_data: 獲取代幣 OHLCV 資料
  • list_operators: 瀏覽 50+ 因子運算子
  • read_source: 查看任何函數的源代碼
  • execute_factor_backtest: 回測自訂因子表達式

由 Phantom Management 開發。

Community & Support | 社群與支持

License

This project is licensed under the BSD 3-Clause License - see LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phandas-0.15.0.tar.gz (46.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phandas-0.15.0-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file phandas-0.15.0.tar.gz.

File metadata

  • Download URL: phandas-0.15.0.tar.gz
  • Upload date:
  • Size: 46.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for phandas-0.15.0.tar.gz
Algorithm Hash digest
SHA256 807b8d81ba907374b0e361e55eba60a215186cbe927383f6dc4c56ae4e0e22e4
MD5 a713e71a8cb68a0cd4d3e0a46be172ea
BLAKE2b-256 c669fb98f27cee07818eb995d5d2885436eca5a1a7da3d499c568861992e20e4

See more details on using hashes here.

File details

Details for the file phandas-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: phandas-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for phandas-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cbcd134079eb54eeef7018a4bd0690a3f93393258af568262311a076bdfb4da
MD5 4655ee0d6edeee41ca2a2a1b4b1396a3
BLAKE2b-256 a1b1a36147c7020d567e5dc633e5892b0c37d4154dfc5e6831a8c1deee839ecf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page