algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::analytics::Panel Class Reference

One bar field across many instruments: one row per instant, one column per instrument. More...

#include <algotradelib/src/analytics/panel.hpp>

Public Member Functions

 Panel ()=default
 Constructs an empty panel.
std::size_t rows () const noexcept
 Returns the number of rows.
std::size_t columns () const noexcept
 Returns the number of columns.
const TimeIndex & time () const noexcept
 Returns the instants of the rows.
const std::vector< InstrumentId > & instruments () const noexcept
 Returns the instruments of the columns.
BarField field () const noexcept
 Returns the bar field the panel holds.
Alignment alignment () const noexcept
 Returns how the panel lined up its instruments.
std::optional< std::size_t > find (const InstrumentId &instrument) const
 Finds an instrument's column.
math::SeriesView column (std::size_t position) const
 Returns one instrument's column.
Scalar at (std::size_t row, std::size_t column) const
 Reads one value.
math::MatrixView values () const
 Returns all values.

Static Public Member Functions

static Panel from_bars (const std::vector< BarSeries > &series, BarField field, Alignment alignment)
 Builds a panel of one bar field from several bar series.

Detailed Description

One bar field across many instruments: one row per instant, one column per instrument.

Build one with from_bars(). A row is a cross-section (all instruments at one instant), which is what ranking, covariance and portfolio weights read. The panel records the field and the Alignment it was built with.

Definition at line 74 of file panel.hpp.

Constructor & Destructor Documentation

◆ Panel()

algotradelib::analytics::Panel::Panel ( )
default

Constructs an empty panel.

Referenced by from_bars().

Member Function Documentation

◆ alignment()

Alignment algotradelib::analytics::Panel::alignment ( ) const
inlinenoexcept

Returns how the panel lined up its instruments.

Returns
The alignment passed to from_bars.

Definition at line 113 of file panel.hpp.

Referenced by from_bars().

◆ at()

Scalar algotradelib::analytics::Panel::at ( std::size_t row,
std::size_t column ) const
inline

Reads one value.

Parameters
rowThe row position.
columnThe column position.
Returns
The value, or missing().
Exceptions
std::out_of_rangeif row or column is past the end.

Definition at line 149 of file panel.hpp.

◆ column()

math::SeriesView algotradelib::analytics::Panel::column ( std::size_t position) const
inline

Returns one instrument's column.

Parameters
positionThe column position.
Returns
A view into the panel's storage; valid while the panel is alive and unmoved.
Exceptions
std::out_of_rangeif position is past the end.

Definition at line 135 of file panel.hpp.

Referenced by at(), find(), and from_bars().

◆ columns()

std::size_t algotradelib::analytics::Panel::columns ( ) const
inlinenoexcept

Returns the number of columns.

Returns
The number of instruments.

Definition at line 89 of file panel.hpp.

Referenced by at().

◆ field()

BarField algotradelib::analytics::Panel::field ( ) const
inlinenoexcept

Returns the bar field the panel holds.

Returns
The field passed to from_bars.

Definition at line 107 of file panel.hpp.

Referenced by from_bars().

◆ find()

std::optional< std::size_t > algotradelib::analytics::Panel::find ( const InstrumentId & instrument) const
inline

Finds an instrument's column.

Parameters
instrumentThe instrument, compared with InstrumentId::operator==.
Returns
Its column position, or std::nullopt if it is not in the panel.

Definition at line 120 of file panel.hpp.

◆ from_bars()

Panel algotradelib::analytics::Panel::from_bars ( const std::vector< BarSeries > & series,
BarField field,
Alignment alignment )
inlinestatic

Builds a panel of one bar field from several bar series.

Parameters
seriesThe series, one per column, each strictly ascending in time.
fieldThe bar field to take from each series.
alignmentHow to line up instants the series do not share.
Returns
The panel; empty (with field and alignment recorded) if series is empty.
Exceptions
std::invalid_argumentif any series is not strictly ascending in time.

Definition at line 171 of file panel.hpp.

◆ instruments()

const std::vector< InstrumentId > & algotradelib::analytics::Panel::instruments ( ) const
inlinenoexcept

Returns the instruments of the columns.

Returns
The instruments, in column order.

Definition at line 101 of file panel.hpp.

◆ rows()

std::size_t algotradelib::analytics::Panel::rows ( ) const
inlinenoexcept

Returns the number of rows.

Returns
The number of instants.

Definition at line 83 of file panel.hpp.

Referenced by at().

◆ time()

const TimeIndex & algotradelib::analytics::Panel::time ( ) const
inlinenoexcept

Returns the instants of the rows.

Returns
The panel's time index.

Definition at line 95 of file panel.hpp.

◆ values()

math::MatrixView algotradelib::analytics::Panel::values ( ) const
inline

Returns all values.

Returns
A view of the rows-by-instruments storage.

Definition at line 160 of file panel.hpp.


The documentation for this class was generated from the following file: