garpar package

Generation and analysis of artificial and real portfolio returns.

A comprehensive toolset for analyzing and managing financial portfolios/markets through the StocksSet class. Provides functionality for portfolio/market optimization, risk assessment, and performance analysis.

Key Features:
  • Portfolio/market construction and rebalancing

  • Risk metrics calculation (variance, VaR, etc.)

  • Expected returns estimation

  • Correlation and covariance analysis

  • Diversification metrics

  • Portfolio/market visualization tools

  • Market data handling and validation

  • Entropy-based analysis

Subpackages

Submodules

garpar.constants module

Constants used in Garpar project.

garpar.constants.EPSILON = 1e-09

Tolerance value for numerical operations

garpar.constants.GARPAR_METADATA_KEY = '__garpar_metadata__'

Key used to store metadata in a garpar.StocksSet

garpar.constants.VERSION = '1.6.0'

Version of the package

garpar.garpar_io module

Utilities to dump and load stocks sets into hdf5.

This module provides functions to dump and load stocks sets into HDF5 files.

Example

>>> from garpar import mkss
>>> from garpar.garpar_io import to_hdf5, read_hdf5
>>> ss = mkss(prices=[...])
>>> to_hdf5("path/to/file.hdf5", ss)
>>> ss2 = read_hdf5("path/to/file.hdf5")
garpar.garpar_io.read_hdf5(path_or_stream, group='stocks set')

HDF5 file reader.

Parameters:
  • path_to_stream (String) – Path to hdf5 stream

  • group (String) – The value to look inside hdf5 file

Returns:

A StocksSet instance

Return type:

garpar.core.stocks_set.StocksSet

garpar.garpar_io.to_hdf5(path_or_stream, ss, group='stocks set', **kwargs)

HDF5 file writer.

It is responsible for storing a stocks set in HDF5 format.

Parameters:
  • path_or_stream (str or file-like.) – Path or file like objet to the h5 to store the stocks set.

  • ss (garpar.stocks_set.StocksSet) – The stocks set to store.

  • group (str (default="stocks set")) – The name of the group where the stocks set will be stored.

  • kwargs – Extra arguments to the function h5py.File.create_dataset.