Skip to main content

A portfolio management tool with built-in state-of-the-art portfolio optimization algorithms, with extensibility for different use cases for both institutes and retail traders.

Project description

TiPortfolio

A portfolio management tool with built-in state-of-the-art portfolio optimization algorithms, with extensibility for different use cases for both institutes and retail traders.

Installation

pip install tiportfolio

# For interactive Plotly charts:
pip install tiportfolio[interactive]

# For Equal Risk Contribution (ERC) weighting:
pip install tiportfolio[erc]

Quick Start

import tiportfolio as ti

# 1. Fetch data (Yahoo Finance by default, or Alpaca if API keys are set)
data = ti.fetch_data(["QQQ", "BIL", "GLD"], start="2019-01-01", end="2024-12-31")

# 2. Define strategy using the algo stack: Signal → Select → Weigh → Action
portfolio = ti.Portfolio(
    "monthly_equal_weight",
    [
        ti.Signal.Monthly(),    # WHEN to rebalance
        ti.Select.All(),        # WHAT to include
        ti.Weigh.Equally(),     # HOW MUCH to allocate
        ti.Action.Rebalance(),  # EXECUTE trades
    ],
    ["QQQ", "BIL", "GLD"],
)

# 3. Run backtest
result = ti.run(ti.Backtest(portfolio, data))

# 4. View results
result.summary()       # key metrics: Sharpe, CAGR, max drawdown, etc.
result.plot()          # equity curve + drawdown chart

Requirements

  • Python 3.10+
  • pandas, numpy, matplotlib

Data fetching uses Yahoo Finance by default. For Alpaca, set ALPACA_API_KEY and ALPACA_API_SECRET in your environment (see .env.example).

Development

uv sync
uv run python -m pytest

License

Apache 2.0

Project details


Download files

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

Source Distribution

tiportfolio-1.1.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

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

tiportfolio-1.1.0-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

Details for the file tiportfolio-1.1.0.tar.gz.

File metadata

  • Download URL: tiportfolio-1.1.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tiportfolio-1.1.0.tar.gz
Algorithm Hash digest
SHA256 294a77ab91e7977bfc4c23e195ce34f4d1bbcd9470bfdf55df144ae4f2fbc80e
MD5 0e1d3e259e3adee1a562a9f742b98ad2
BLAKE2b-256 5c40693d667f7a019aa6d8da97b75245da3d7ba0fa60b130caae5af6d6f02e87

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiportfolio-1.1.0.tar.gz:

Publisher: publish.yml on TradeInsight-Info/TiPortfolio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiportfolio-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tiportfolio-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 49.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tiportfolio-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e8cc1c3322dab0c4dab80a3cc9d53e0bc7e639b4bd3e3164ad24b36ed09cda6
MD5 c4502a5b9bde31a084f7259ff20721c7
BLAKE2b-256 18ca3977c938d1fb1115448f5b91c73a3f067ecd418c29da118e12ac353d7062

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiportfolio-1.1.0-py3-none-any.whl:

Publisher: publish.yml on TradeInsight-Info/TiPortfolio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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