Skip to main content

Online covariancecomparisonutil, precision, portfolios and ensembles

Project description

precise docs tests tests-scipy-173 tests-sans-ppo License: MIT

Goals:

  1. A slowly growing collection of one-line online covariance forecasting and portfolio construction methods. See docs and related literature.

  2. A home for my own stuff: "Schur Complementary" portfolio construction, a new approach that leans on connection between top-down (hierarchical) and bottom-up (optimization) portfolio construction revealed by block matrix inversion. This got quite a reaction when I posted it, and it is evidently ground-breaking, seminal work. Yes I'm joking but see Schur Complementary Portfolios to unify Modern Portfolio Theory and Machine Learning methodology if you are interested.

  3. Maybe ... ensembling per optimizing a portfolio of models although to be honest my main focus is financial portfolios.

The package was taken for a spin in the M6 Financial Forecasting contest too, and it has been quite successful.

Usage

Again, see the docs, but briefly:

Covariance estimation

Here y is a vector:

from precise.skaters.covariance.ewapm import ewa_pm_emp_scov_r005_n100 as f 
s = {}
for y in ys:
    x, x_cov, s = f(s=s, y=y)

This package contains lots of different "f"s. There is a LISTING_OF_COV_SKATERS with links to the code. See the covariance documentation.

Portfolio weights

Here y is a vector:

    from precise.skaters.managers.schurmanagers import schur_weak_pm_t0_d0_r025_n50_g100_long_manager as mgr
    s = {}
    for y in ys:
        w, s = mgr(s=s, y=y)

This package contains lots of "mgr"'s. There is a LISTING_OF_MANAGERS with links to respective code. See the manager documentation.

Model ensembling

This will depend on what automl convenient tooling you use. But see the article which uses LazyPredict, or the colab notebook on which is is based.

Install

pip install precise 

or for latest:

pip install git+https://github.com/microprediction/precise.git

Trouble? It probably isn't with precise per se.

pip install --upgrade pip
pip install --upgrade setuptools 
pip install --upgrade wheel
pip install --upgrade ecos   # <--- Try conda install ecos if this fails
pip install --upgrade osqp   # <-- Can be tricky on some systems see https://github.com/cvxpy/cvxpy/issues/1190#issuecomment-994613793
pip install --upgrade pyportfolioopt # <--- Skip if you don't plan to use it
pip install --upgrade riskparityportfolio
pip install --upgrade scipy
pip install --upgrade precise 

Miscellaneous

  • Here is some related, and potentially related, literature.
  • This is a piece of the microprediction project aimed at creating millions of autonomous critters to distribute AI at low cost, should you ever care to cite the same. The uses include mixtures of experts models for time-series analysis, buried in timemachines somewhere.
  • If you just want univariate calculations, and don't want numpy as a dependency, there is momentum. However if you want univariate forecasts of the variance of something, as distinct from mere online calculations of the same, you might be better served by the timemachines package. In particular I would suggest checking the time-series elo ratings and the "special" category in particular, as various kinds of empirical moment time-series (volatility etc) are used to determine those ratings.
  • The name of this package refers to precision matrices, not numerical precision. This isn't a source of high precision covariance calculations per se. The intent is more in forecasting future realized covariance, conscious of the noise in the empirical distribution. Perhaps I'll include some more numerically stable methods from this survey to make the name more fitting. Pull requests are welcome!
  • The intent is that methods are parameter free. However some not-quite autonomous methods admit a few parameters (the factories).

Disclaimer

Not investment advice. Not M6 entry advice. Just a bunch of code subject to the MIT License disclaimers.

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

precise-0.12.2.tar.gz (122.5 kB view details)

Uploaded Source

Built Distribution

precise-0.12.2-py3-none-any.whl (153.4 kB view details)

Uploaded Python 3

File details

Details for the file precise-0.12.2.tar.gz.

File metadata

  • Download URL: precise-0.12.2.tar.gz
  • Upload date:
  • Size: 122.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for precise-0.12.2.tar.gz
Algorithm Hash digest
SHA256 b33a1ef9c0e0081ad28b710fc938003d5773a2c50b88928deece5142dda24d62
MD5 0fd750807764c15832b76168d69fa18b
BLAKE2b-256 418b6ffffc838c36b4486942218afcec585a87765a83e041b4378622890c00a2

See more details on using hashes here.

File details

Details for the file precise-0.12.2-py3-none-any.whl.

File metadata

  • Download URL: precise-0.12.2-py3-none-any.whl
  • Upload date:
  • Size: 153.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for precise-0.12.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f22a0ad84ed8aa7f40dc44411d647b323c0a2c2f8187647579e5b6f14357b31
MD5 3f127336b422e486a5c8ef08b4931b28
BLAKE2b-256 369f0200c64ab41aba89d2d09fbd1d096b7e703a30cbc00c9a0c86457c87015d

See more details on using hashes here.

Supported by

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