openseries Documentation

PyPI version Conda Version Platform Python version GitHub Action Test Suite codecov GitHub License

openseries is a Python library for analyzing financial time series data. It provides tools to work with single assets or groups of assets, designed specifically for daily or less frequent data.

The library is built around two main classes:

  • OpenTimeSeries: For managing and analyzing individual time series

  • OpenFrame: For managing groups of time series and portfolio analysis

Key Features

  • Financial Analysis: Comprehensive set of financial metrics and ratios

  • Risk Management: VaR, CVaR, drawdown analysis, and risk-adjusted returns

  • Portfolio Tools: Portfolio optimization, rebalancing, and performance attribution

  • Visualization: Interactive plots using Plotly

  • Data Handling: Robust date handling and business day calendars

  • Type Safety: Built with Pydantic for data validation and type safety

Quick Start

Install openseries using pip:

pip install openseries

Or using conda:

conda install -c conda-forge openseries

Here’s a simple example to get you started:

from openseries import OpenTimeSeries
import yfinance as yf

# Download data
ticker = yf.Ticker("^GSPC")
history = ticker.history(period="5y")

# Create OpenTimeSeries
series = OpenTimeSeries.from_df(dframe=history.loc[:, "Close"])
series.set_new_label(lvl_zero="S&P 500")

# Calculate key metrics
print(f"Annual Return: {series.geo_ret:.2%}")
print(f"Volatility: {series.vol:.2%}")
print(f"Sharpe Ratio: {series.ret_vol_ratio:.2f}")
print(f"Max Drawdown: {series.max_drawdown:.2%}")

# Create interactive plot
series.plot_series()

Documentation Contents

Important Notes

Python Version Support

Indices and tables