Skip to main content

Tool to help find an optimal portfolio allocation

Project description

Porfolio Finder

PyPI version fury.io PyPI pyversions Build Status Documentation Status

A Python library, based primarily around pandas, to identify an optimal portfolio allocation through back-testing.

API Documentation is available on Read the Docs.

Example Usage

Each of these examples make use of data.csv which provides returns for a handful of funds over 1970-2019.

Find best portfolio allocation to minimize the required timeframe to achieve a target value

from portfoliofinder import Allocations

Allocations(0.05, ['USA_TSM', 'WLDx_TSM', 'USA_INT', 'EM'])\
    .filter('USA_TSM>=0.6 & WLDx_TSM<=0.2 & USA_INT>=0.3')\
    .with_returns("data.csv")\
    .with_regular_contributions(100000, 10000)\
    .get_backtested_timeframes(target_value=1000000)\
    .get_statistics(['min', 'max', 'mean', 'std'])\
    .filter_by_min_of('max')\
    .filter_by_max_of('min')\
    .get_allocation_which_min_statistic('std')

Output

Statistic
min     14.000000
max     22.000000
mean    16.965517
std      2.809204
Name: Allocation(USA_TSM=0.65, WLDx_TSM=0.0, USA_INT=0.3, EM=0.05), dtype: float64

Find best portfolio allocation to maximize value with minimal risk over a fixed timeframe

from portfoliofinder import Allocations

Allocations(0.05, ['USA_TSM', 'WLDx_TSM', 'USA_INT', 'EM'])\
    .filter('USA_TSM>=0.6 & WLDx_TSM<=0.2 & USA_INT>=0.3')\
    .with_returns("data.csv")\
    .with_regular_contributions(100000, 10000)\
    .get_backtested_values(timeframe=10)\
    .get_statistics(['mean', 'std'])\
    .filter_by_gte_percentile_of(90, 'mean')\
    .get_allocation_which_min_statistic('std')

Output

Statistic
mean    446560.590088
std     117448.007302
Name: Allocation(USA_TSM=0.6, WLDx_TSM=0.0, USA_INT=0.3, EM=0.1), dtype: float64

Graph statistics from multiple portfolio allocations to visualize their efficient frontier

from portfoliofinder import Allocations

Allocations(0.05, ['USA_TSM', 'WLDx_TSM', 'USA_INT', 'EM'])\
    .filter('USA_TSM>=0.2 & USA_INT>=0.2')\
    .with_returns("data.csv")\
    .with_regular_contributions(100000, 10000)\
    .get_backtested_values(timeframe=10)\
    .get_statistics()\
    .graph('std', 'mean')

Output

efficient_frontier

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

portfoliofinder-0.2.4.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

portfoliofinder-0.2.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file portfoliofinder-0.2.4.tar.gz.

File metadata

  • Download URL: portfoliofinder-0.2.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1

File hashes

Hashes for portfoliofinder-0.2.4.tar.gz
Algorithm Hash digest
SHA256 a2bc10be9a73d4a318a7d90f6dcfd61b407e3cb86a5ffa3ffc403ce31c4e5829
MD5 8b634803e0494e5864f8e71ba6ccacb9
BLAKE2b-256 b354868d2580a957bcbc8b67c69481c7575d1ccd3a538bceaf67d3385fb30af8

See more details on using hashes here.

File details

Details for the file portfoliofinder-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: portfoliofinder-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1

File hashes

Hashes for portfoliofinder-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 058237b9a8e9a4974fb071385c9778d1563a5f90d664451c24990b206f6096ce
MD5 3c9dd5a9bdbf9c04537109d22964930f
BLAKE2b-256 ae136a2fe037b07f96118cb8624b1b6259cb9f9f567e4f2b0985eb1b2b911f33

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