7static_assert(
to_size(std::views::iota(0, 10)) == 10uz);
8static_assert(
to_size(std::vector{1.0, 2.0}) == 2uz);
9static_assert(
to_size(std::vector{1, 2, 3}) == 3uz);
13static_assert(
to_first(std::vector{1, 2, 3}) == 1);
14static_assert(
to_first(std::vector{1.0, 2.0, 3.0}) == 1.0);
15static_assert(
to_first(std::vector{
'a'}) ==
'a');
17static_assert(
to_last(std::vector{1, 2, 3}) == 3);
18static_assert(
to_last(std::vector{1.0, 2.0, 3.0}) == 3.0);
19static_assert(
to_last(std::vector{
'a'}) ==
'a');
21static_assert(
to_sum(std::vector{1, 2, 3}) == 6.0);
22static_assert(
to_sum(std::vector{1.0f, 2.0f}) == 3.0f);
23static_assert(
to_sum(std::vector<int>{}) == 0.0);
26static_assert(std::ranges::size(
identity(std::vector{2, 2})) == 2uz);
28static_assert(
to_profit(100.0, 100.0) == 0.0);
29static_assert(
to_profit(100.0f, 150.0f) == 50.0f);
30static_assert(
to_profit(200.0, 100.0) == -50.0);
31static_assert(
to_profit(200.0l, 100.0l) == -50.0l);
37static_assert(
to_time(std::vector{1.4, 2.0, 3.0}) == 1);
38static_assert(
to_time(std::vector{1.6, 2.0, 3.0}) == 2);
39static_assert(
to_open(std::vector{0.0, 1.0, 2.0, 3.0, 4.0}) == 1.0);
40static_assert(
to_high(std::vector{0.0, 1.0, 2.0, 3.0, 4.0}) == 2.0);
41static_assert(
to_low(std::vector{0.0, 1.0, 2.0, 3.0, 4.0}) == 3.0);
42static_assert(
to_close(std::vector{0.0, 1.0, 2.0, 3.0, 4.0}) == 4.0);
43static_assert(
to_volume(std::vector{0.0, 1.0, 2.0, 3.0, 4.0, 5.0}) == 5.0);
Core routines that don't depend on any other fx routines.
constexpr auto to_first(std::ranges::range auto &&xs)
Return the first entry in a series.
constexpr auto to_time(std::ranges::range auto &&xs)
Get time of a data point.
constexpr auto to_last
Return the last entry in a series.
constexpr auto to_low(std::ranges::range auto &&xs)
Get low price for a data point.
constexpr auto to_profit(auto &&entry, auto &&exit)
Calculate profit from a trade.
constexpr auto to_sum(std::ranges::range auto &&xs)
Calculate sum of series.
constexpr auto identity
Just passing through.
constexpr auto to_close(std::ranges::range auto &&xs)
Get close price for a data point.
constexpr auto to_open(std::ranges::range auto &&xs)
Get open price for a data point.
constexpr auto to_volume
Get total volume for a data point.
constexpr auto to_high(std::ranges::range auto &&xs)
Get high price for a data point.
constexpr T to_size(std::ranges::range auto &&xs)
Calculate size of a series, return type depends on input param.