PineForge HPO 1.11.0
Native hyperparameter optimization for PineForge strategies
Loading...
Searching...
No Matches
return_stats.hpp File Reference
#include <cstddef>
#include <cstdint>
#include <limits>
#include <optional>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

struct  pineforge::hpo::EquityPointsView
 Borrowed, strided view of an ordered array of records holding (time_ms, equity). More...
 
struct  pineforge::hpo::ReturnStatsRequest
 Selects the series to compute. A series that is not requested costs nothing. More...
 
struct  pineforge::hpo::ReturnSeriesStats
 All published fields of one series plus diagnostics. More...
 
struct  pineforge::hpo::ReturnStatsResult
 The series that were requested; an absent series was not requested. More...
 
struct  pineforge::hpo::ReturnStatsMetric
 One of the eighteen metric names, decomposed. More...
 
struct  pineforge::hpo::ReturnBlockLayout
 Block layout of one bar-return series: how many intervals each block holds and which curve point opens it. More...
 
struct  pineforge::hpo::ReturnBlockMoments
 Moments of every block of one bar-return series, ascending block. More...
 

Namespaces

namespace  pineforge
 
namespace  pineforge::hpo
 

Enumerations

enum class  pineforge::hpo::ReturnSeries : std::uint8_t { pineforge::hpo::Bar , pineforge::hpo::Monthly }
 Return frequency of one statistics series. More...
 
enum class  pineforge::hpo::ReturnStatistic : std::uint8_t {
  pineforge::hpo::Count , pineforge::hpo::Skipped , pineforge::hpo::PeriodsPerYear , pineforge::hpo::Mean ,
  pineforge::hpo::Std , pineforge::hpo::SharpePerPeriod , pineforge::hpo::Skew , pineforge::hpo::KurtRaw ,
  pineforge::hpo::Status
}
 One published field of a series. Declaration order is the wire order of the metric names. More...
 
enum class  pineforge::hpo::ReturnStatsStatus : std::uint8_t {
  pineforge::hpo::Ok = 0 , pineforge::hpo::InsufficientCount = 1 , pineforge::hpo::ZeroVariance = 2 , pineforge::hpo::NonfiniteInput = 4 ,
  pineforge::hpo::PeriodUnavailable = 6 , pineforge::hpo::UnsupportedTimezone = 7 , pineforge::hpo::DerivedNonfinite = 8
}
 Stable numeric status of one series. More...
 
enum class  pineforge::hpo::ReturnPeriodFailure : std::uint8_t {
  pineforge::hpo::None , pineforge::hpo::TooFewPoints , pineforge::hpo::NonPositiveSpan , pineforge::hpo::SpanOverflow ,
  pineforge::hpo::UtcRange
}
 Why the period or time basis of a series is unavailable. Diagnostic only; not on the wire. More...
 
enum class  pineforge::hpo::ReturnBlocksStatus : std::uint8_t {
  pineforge::hpo::NotRequested = 0 , pineforge::hpo::Ok = 1 , pineforge::hpo::NonPositiveEquity = 2 , pineforge::hpo::Nonfinite = 3 ,
  pineforge::hpo::UnusableCurve = 4 , pineforge::hpo::UnusableLayout = 5
}
 Status of one row's block moments. More...
 

Functions

template<typename Record >
EquityPointsView pineforge::hpo::make_equity_points_view (const Record *records, std::size_t count, std::int64_t Record::*time_ms, double Record::*equity) noexcept
 Builds an EquityPointsView over count records of type Record from pointers to its time_ms and equity members, for example &pf_equity_point_t::time_ms.
 
ReturnStatsResult pineforge::hpo::compute_return_stats (const EquityPointsView &points, const ReturnStatsRequest &request) noexcept
 Computes the requested return statistics from a borrowed equity curve.
 
bool pineforge::hpo::is_utc_chart_timezone (std::string_view chart_timezone) noexcept
 True for the chart timezone names that select UTC bucketing: empty, UTC and Etc/UTC.
 
std::string_view pineforge::hpo::return_stats_metric_name (ReturnSeries series, ReturnStatistic statistic) noexcept
 Returns the wire metric name, for example returns.bar.sharpe_per_period.
 
std::optional< ReturnStatsMetric > pineforge::hpo::parse_return_stats_metric (std::string_view name) noexcept
 Resolves a metric name; returns an empty value for every name outside the eighteen.
 
bool pineforge::hpo::return_stats_contraction_free () noexcept
 Sanity probe of this translation unit's build: true when a multiply followed by an add is evaluated as two rounded operations (no contraction) and explicit fma is fused.
 
std::string_view pineforge::hpo::return_blocks_status_text (ReturnBlocksStatus status) noexcept
 Returns the wire text of a status: ok, non_positive_equity, non_finite, and empty for the statuses that are never published as a payload status.
 
ReturnBlockLayout pineforge::hpo::compute_block_layout (const EquityPointsView &points, std::uint32_t blocks)
 Cuts the adjacent intervals of a curve into blocks (S) blocks, and reads the opening timestamp of every one of them from the borrowed curve.
 
ReturnBlockMoments pineforge::hpo::reduce_return_blocks (const EquityPointsView &points, const ReturnBlockLayout &layout)
 Reduces the bar returns of a curve into the blocks of its own layout.
 

Variables

constexpr std::string_view pineforge::hpo::kReturnStatsContract = "pineforge-hpo-return-stats/v1"
 Contract string of the result-level return_stats object (legacy mode, version 1).
 
constexpr std::string_view pineforge::hpo::kReturnBlocksContract = "pineforge-hpo-return-blocks/v1"
 Contract string of the per-row block_returns object and of the result-level return_blocks object that declares the layout its rows were reduced under (version 1, bar series).
 
constexpr double pineforge::hpo::kReturnStatsRiskFreeAnnual = 0.02
 Fixed annual risk-free rate.
 
constexpr std::int64_t pineforge::hpo::kReturnStatsUtcMinMs = -1099511627775000
 Earliest Unix millisecond timestamp whose UTC month can be derived (inclusive).
 
constexpr std::int64_t pineforge::hpo::kReturnStatsUtcMaxMs = 1099511627775999
 Latest Unix millisecond timestamp whose UTC month can be derived (inclusive).
 
constexpr std::size_t pineforge::hpo::kReturnStatisticCount = 9
 Number of published fields per series.
 
constexpr std::size_t pineforge::hpo::kReturnStatsMetricCount = 18
 Number of metric names of this contract (two series times nine fields).