emrpy.visualization.timeseries

Time Series Visualization Utilities

Functions for plotting financial and time series data with proper handling of trading gaps and discontinuous timestamps.

Functions

plot_multiple_log_returns(df[, ...])

Plot multiple time series as cumulative log returns for comparison.

plot_timeseries(df[, timestamp_col, ...])

Plot time series data with continuous bar numbering to avoid trading gaps.

emrpy.visualization.timeseries.plot_multiple_log_returns(df, timestamp_col='timestamp', price_col='close', segment_col='Symbol', segment_values=None, figsize=(12, 8))

Plot multiple time series as cumulative log returns for comparison.

Converts price data to log returns and plots them on the same graph, making it easy to compare performance across different assets.

Return type:

None

Parameters:

dfpd.DataFrame

DataFrame containing the time series data

timestamp_colstr, default ‘timestamp’

Name of the timestamp column

price_colstr, default ‘close’

Name of the price column

segment_colstr, default ‘Symbol’

Column name that identifies different assets

segment_valueslist, optional

List of assets to plot. If None, plots all unique values

figsizetuple, default (12, 8)

Figure size as (width, height)

Examples:

>>> # Plot specific stocks
>>> plot_multiple_log_returns(
...     df=stock_data,
...     segment_values=['AAPL', 'GOOGL', 'MSFT']
... )
>>> # Plot all assets in the dataset
>>> plot_multiple_log_returns(df=stock_data)
emrpy.visualization.timeseries.plot_timeseries(df, timestamp_col='timestamp', value_col='close', segment_col=None, segment_value=None, tick_every=100, figsize=(12, 6))

Plot time series data with continuous bar numbering to avoid trading gaps.

This function creates a continuous plot by using bar numbers instead of timestamps, which eliminates gaps from weekends and holidays in financial data.

Return type:

None

Parameters:

dfpd.DataFrame

DataFrame containing the time series data

timestamp_colstr, default ‘timestamp’

Name of the timestamp column

value_colstr, default ‘close’

Name of the column containing values to plot

segment_colstr, optional

Column name to filter by (e.g., ‘Symbol’ for stock tickers)

segment_valuestr, optional

Value to filter on in segment_col (e.g., ‘AAPL’)

tick_everyint, default 100

Show timestamp labels every N bars

figsizetuple, default (12, 6)

Figure size as (width, height)

Examples:

>>> # Plot AAPL data
>>> plot_timeseries(
...     df=stock_data,
...     segment_col='Symbol',
...     segment_value='AAPL'
... )
>>> # Plot all data without filtering
>>> plot_timeseries(df=price_data)