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

One instrument's bars as numeric columns: one row per bar, one column per BarField. More...

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

Public Member Functions

 SeriesFrame ()=default
 Constructs an empty frame.
 SeriesFrame (TimeIndex index, InstrumentId instrument={})
 Constructs a frame with one row per instant, every value missing().
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 InstrumentId & instrument () const noexcept
 Returns the instrument the frame describes.
math::SeriesView column (BarField field) const
 Returns one field's column.
math::SeriesView close () const
 Returns the close column.
math::SeriesView open () const
 Returns the open column.
math::SeriesView high () const
 Returns the high column.
math::SeriesView low () const
 Returns the low column.
math::SeriesView volume () const
 Returns the volume column.
Scalar at (std::size_t row, BarField field) const
 Reads one value.
void set (std::size_t row, BarField field, Scalar value)
 Writes one value.
math::MatrixView values () const
 Returns all values.

Detailed Description

One instrument's bars as numeric columns: one row per bar, one column per BarField.

Build one with from_bars(). column() and the named accessors return views into the frame's own storage, without copying.

A field the broker did not report (an open on a day with no trade, an omitted traded value) is missing() in that row, not zero.

Definition at line 89 of file frame.hpp.

Constructor & Destructor Documentation

◆ SeriesFrame()

algotradelib::analytics::SeriesFrame::SeriesFrame ( TimeIndex index,
InstrumentId instrument = {} )
inlineexplicit

Constructs a frame with one row per instant, every value missing().

Parameters
indexThe instants of the rows.
instrumentThe instrument the frame describes.

Definition at line 100 of file frame.hpp.

Member Function Documentation

◆ at()

Scalar algotradelib::analytics::SeriesFrame::at ( std::size_t row,
BarField field ) const
inline

Reads one value.

Parameters
rowThe row position.
fieldThe field.
Returns
The value, or missing() if it was not reported.
Exceptions
std::out_of_rangeif row is past the end.

Definition at line 180 of file frame.hpp.

◆ close()

math::SeriesView algotradelib::analytics::SeriesFrame::close ( ) const
inline

Returns the close column.

Returns
A view of BarField::CLOSE.

Definition at line 146 of file frame.hpp.

◆ column()

math::SeriesView algotradelib::analytics::SeriesFrame::column ( BarField field) const
inline

Returns one field's column.

Parameters
fieldThe field.
Returns
A view into the frame's storage; valid while the frame is alive and unmoved.

Definition at line 138 of file frame.hpp.

Referenced by close(), high(), low(), open(), and volume().

◆ columns()

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

Returns the number of columns.

Returns
bar_field_count.

Definition at line 119 of file frame.hpp.

◆ high()

math::SeriesView algotradelib::analytics::SeriesFrame::high ( ) const
inline

Returns the high column.

Returns
A view of BarField::HIGH.

Definition at line 158 of file frame.hpp.

◆ instrument()

const InstrumentId & algotradelib::analytics::SeriesFrame::instrument ( ) const
inlinenoexcept

Returns the instrument the frame describes.

Returns
The instrument.

Definition at line 131 of file frame.hpp.

Referenced by SeriesFrame().

◆ low()

math::SeriesView algotradelib::analytics::SeriesFrame::low ( ) const
inline

Returns the low column.

Returns
A view of BarField::LOW.

Definition at line 164 of file frame.hpp.

◆ open()

math::SeriesView algotradelib::analytics::SeriesFrame::open ( ) const
inline

Returns the open column.

Returns
A view of BarField::OPEN.

Definition at line 152 of file frame.hpp.

◆ rows()

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

Returns the number of rows.

Returns
The number of instants (bars) in the frame.

Definition at line 113 of file frame.hpp.

Referenced by at(), and set().

◆ set()

void algotradelib::analytics::SeriesFrame::set ( std::size_t row,
BarField field,
Scalar value )
inline

Writes one value.

Parameters
rowThe row position.
fieldThe field.
valueThe value to store.
Exceptions
std::out_of_rangeif row is past the end.

Definition at line 197 of file frame.hpp.

Referenced by algotradelib::analytics::from_bars().

◆ time()

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

Returns the instants of the rows.

Returns
The frame's time index.

Definition at line 125 of file frame.hpp.

◆ values()

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

Returns all values.

Returns
A view of the rows-by-bar_field_count storage, columns in BarField order.

Definition at line 210 of file frame.hpp.

◆ volume()

math::SeriesView algotradelib::analytics::SeriesFrame::volume ( ) const
inline

Returns the volume column.

Returns
A view of BarField::VOLUME.

Definition at line 170 of file frame.hpp.


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