openseries package

The openseries package provides two main classes for financial time series analysis:

  • OpenTimeSeries: For single financial time series analysis

  • OpenFrame: For multi-asset portfolio analysis and comparison

Both classes inherit from the private _CommonModel class, which in turn inherits from Pydantic’s BaseModel. This inheritance structure provides:

  • Data validation through Pydantic’s validation system

  • Common functionality shared between both classes (risk metrics, plotting, data handling)

  • Type safety and consistent API design

The _CommonModel class contains all the shared methods and properties that both OpenTimeSeries and OpenFrame use, including risk calculations, plotting capabilities, and data manipulation functions.

Main Classes

openseries.OpenTimeSeries

OpenTimeSeries objects are at the core of the openseries package.

openseries.OpenFrame

OpenFrame objects hold OpenTimeSeries in the list constituents.

Utility Functions

openseries.timeseries_chain

Chain two timeseries together.

openseries.report_html

Generate a responsive HTML report page with line and bar plots and a table.

Portfolio Tools

openseries.efficient_frontier

Identify an efficient frontier.

openseries.simulate_portfolios

Generate random weights for simulated portfolios.

openseries.constrain_optimized_portfolios

Constrain optimized portfolios to those that improve on the current one.

openseries.prepare_plot_data

Prepare data to be used as point_frame in the sharpeplot function.

openseries.sharpeplot

Create scatter plot coloured by Sharpe Ratio.

Date Utilities

openseries.date_fix

Parse different date formats into datetime.date.

openseries.date_offset_foll

Offset dates according to a given calendar.

openseries.generate_calendar_date_range

Generate a list of business day calendar dates.

openseries.get_previous_business_day_before_today

Bump date backwards to find the previous business day.

openseries.holiday_calendar

Generate a business calendar.

openseries.offset_business_days

Bump date by business days.

Simulation

openseries.ReturnSimulation

The class ReturnSimulation allows for simulating financial timeseries.

Types and Enums

openseries.ValueType

Enum types of OpenTimeSeries to identify the output.

Other Utilities

openseries.load_plotly_dict

Load Plotly defaults.

openseries.export_plotly_figure

Export a Plotly figure to a mobile-responsive HTML file or inline div.