|
Crypto backtesting
|
Core routines that don't depend on any other fx routines. More...
Functions | |
| template<typename T = size_t> | |
| constexpr T | to_size (std::ranges::range auto &&xs) |
| Calculate size of a series, return type depends on input param. | |
| constexpr auto | to_first (std::ranges::range auto &&xs) |
| Return the first entry in a series. | |
| constexpr auto | to_sum (std::ranges::range auto &&xs) |
| Calculate sum of series. | |
| constexpr auto | to_sum2 (std::ranges::range auto &&xs) |
| Calculate sum of series. | |
| constexpr auto | to_profit (auto &&entry, auto &&exit) |
| Calculate profit from a trade. | |
| void | BM_is_entry (benchmark::State &state) |
| void | BM_is_entry2 (benchmark::State &state) |
| void | BM_to_exit (benchmark::State &state) |
| void | BM_to_exit2 (benchmark::State &state) |
| void | BM_to_vwap (benchmark::State &state) |
| void | BM_to_vwap2 (benchmark::State &state) |
| void | BM_to_atr (benchmark::State &state) |
| void | BM_to_atr2 (benchmark::State &state) |
| void | BM_to_atr3 (benchmark::State &state) |
| void | BM_is_recent_dip2 (benchmark::State &state) |
| void | BM_to_average_func (benchmark::State &state) |
| void | BM_to_average_func2 (benchmark::State &state) |
| void | BM_to_average_volume (benchmark::State &state) |
| void | BM_to_average_volume2 (benchmark::State &state) |
| BENCHMARK (BM_is_entry) | |
| BENCHMARK (BM_is_entry2) | |
| BENCHMARK (BM_to_exit) | |
| BENCHMARK (BM_to_exit2) | |
| BENCHMARK (BM_to_vwap) | |
| BENCHMARK (BM_to_vwap2) | |
| BENCHMARK (BM_is_recent_dip2) | |
| BENCHMARK (BM_to_atr) | |
| BENCHMARK (BM_to_atr2) | |
| BENCHMARK (BM_to_atr3) | |
| BENCHMARK (BM_to_average_func) | |
| BENCHMARK (BM_to_average_func2) | |
| BENCHMARK (BM_to_average_volume) | |
| BENCHMARK (BM_to_average_volume2) | |
| void | BM_to_size (benchmark::State &state) |
| void | BM_to_first (benchmark::State &state) |
| void | BM_to_last (benchmark::State &state) |
| void | BM_to_sum (benchmark::State &state) |
| void | BM_to_sum2 (benchmark::State &state) |
| void | BM_to_spot (benchmark::State &state) |
| void | BM_identity (benchmark::State &state) |
| void | BM_identity2 (benchmark::State &state) |
| void | BM_to_profit (benchmark::State &state) |
| BENCHMARK (BM_to_size) | |
| BENCHMARK (BM_to_first) | |
| BENCHMARK (BM_to_last) | |
| BENCHMARK (BM_to_sum) | |
| BENCHMARK (BM_to_sum2) | |
| BENCHMARK (BM_to_spot) | |
| BENCHMARK (BM_identity) | |
| BENCHMARK (BM_identity2) | |
| BENCHMARK (BM_to_profit) | |
| void | BM_to_time (benchmark::State &state) |
| void | BM_to_open (benchmark::State &state) |
| void | BM_to_high (benchmark::State &state) |
| void | BM_to_low (benchmark::State &state) |
| void | BM_to_close (benchmark::State &state) |
| void | BM_to_volume (benchmark::State &state) |
| BENCHMARK (BM_to_time) | |
| BENCHMARK (BM_to_open) | |
| BENCHMARK (BM_to_high) | |
| BENCHMARK (BM_to_low) | |
| BENCHMARK (BM_to_close) | |
| BENCHMARK (BM_to_volume) | |
| constexpr auto | to_time (std::ranges::range auto &&xs) |
| Get time of a data point. | |
| constexpr auto | to_open (std::ranges::range auto &&xs) |
| Get open price for a data point. | |
| constexpr auto | to_high (std::ranges::range auto &&xs) |
| Get high price for a data point. | |
| constexpr auto | to_low (std::ranges::range auto &&xs) |
| Get low price for a data point. | |
| constexpr auto | to_close (std::ranges::range auto &&xs) |
| Get close price for a data point. | |
| constexpr auto | to_atr (auto &&series) |
| Calculate ATR of a series. | |
| constexpr auto | to_atr2 (auto &&series) |
| Calculate ATR of a series. | |
| constexpr double | to_atr3 (auto &&series) |
| Calculate ATR of a series. | |
| constexpr double | to_vwap (std::ranges::range auto &&xs) |
| Calculate VWAP rolling average. | |
| constexpr double | to_vwap2 (std::ranges::range auto &&xs) |
| Calculate VWAP rolling average. | |
| auto | is_recent_dip2 (auto &&series) |
| Test if there has been a recent minimum. | |
Variables | |
| constexpr auto | win {68uz} |
| The number of prices in a trading window. | |
| constexpr auto | win2 {34uz} |
| constexpr auto | win4 {17uz} |
| constexpr auto | take_profit {3.0} |
| Close position if price has increased by this percentage. | |
| constexpr auto | stop_loss {take_profit * 2.0} |
| Close position if price has decreased by this percentage. | |
| constexpr auto | minimum_entry {4.3} |
| Minimum price to consider a trade. | |
| constexpr auto | minimum_atr {take_profit / 6.0} |
| Minimum (normalised) ATR to consider a trade. | |
| constexpr auto | cells {6uz} |
| Number of cells in a row of price data. | |
| constexpr auto | earliest_entry_epoch {1689798790} |
| Furthest back in time to consider a trade. | |
| constexpr auto | to_last |
| Return the last entry in a series. | |
| constexpr auto | identity = [](auto &&xs) { return xs; } |
| Just passing through. | |
| constexpr auto | identity2 |
| Just passing through. | |
| constexpr auto | to_volume |
| Get total volume for a data point. | |
| constexpr auto | to_average_func |
| constexpr auto | to_average_func2 |
| constexpr auto | to_spot |
| Calculate spot value, note we don't average all of the OHLC prices. | |
| constexpr auto | to_average_volume |
| Calculate average volume over a series. | |
| constexpr auto | to_average_volume2 |
| Calculate average volume over a series. | |
| auto | to_exit |
| Find an exit in a series. | |
| auto | to_exit2 |
| Find an exit in a series. | |
| auto | is_entry |
| Calculate if the final price is an entry. | |
| auto | is_entry2 |
| Calculate if the final price is an entry. | |
Core routines that don't depend on any other fx routines.
| fx::BENCHMARK | ( | BM_identity | ) |
| fx::BENCHMARK | ( | BM_identity2 | ) |
| fx::BENCHMARK | ( | BM_is_entry | ) |
| fx::BENCHMARK | ( | BM_is_entry2 | ) |
| fx::BENCHMARK | ( | BM_is_recent_dip2 | ) |
| fx::BENCHMARK | ( | BM_to_atr | ) |
| fx::BENCHMARK | ( | BM_to_atr2 | ) |
| fx::BENCHMARK | ( | BM_to_atr3 | ) |
| fx::BENCHMARK | ( | BM_to_average_func | ) |
| fx::BENCHMARK | ( | BM_to_average_func2 | ) |
| fx::BENCHMARK | ( | BM_to_average_volume | ) |
| fx::BENCHMARK | ( | BM_to_average_volume2 | ) |
| fx::BENCHMARK | ( | BM_to_close | ) |
| fx::BENCHMARK | ( | BM_to_exit | ) |
| fx::BENCHMARK | ( | BM_to_exit2 | ) |
| fx::BENCHMARK | ( | BM_to_first | ) |
| fx::BENCHMARK | ( | BM_to_high | ) |
| fx::BENCHMARK | ( | BM_to_last | ) |
| fx::BENCHMARK | ( | BM_to_low | ) |
| fx::BENCHMARK | ( | BM_to_open | ) |
| fx::BENCHMARK | ( | BM_to_profit | ) |
| fx::BENCHMARK | ( | BM_to_size | ) |
| fx::BENCHMARK | ( | BM_to_spot | ) |
| fx::BENCHMARK | ( | BM_to_sum | ) |
| fx::BENCHMARK | ( | BM_to_sum2 | ) |
| fx::BENCHMARK | ( | BM_to_time | ) |
| fx::BENCHMARK | ( | BM_to_volume | ) |
| fx::BENCHMARK | ( | BM_to_vwap | ) |
| fx::BENCHMARK | ( | BM_to_vwap2 | ) |
| void fx::BM_identity | ( | benchmark::State & | state | ) |
| void fx::BM_identity2 | ( | benchmark::State & | state | ) |
| void fx::BM_is_entry | ( | benchmark::State & | state | ) |
| void fx::BM_is_entry2 | ( | benchmark::State & | state | ) |
| void fx::BM_is_recent_dip2 | ( | benchmark::State & | state | ) |
Definition at line 88 of file main.cxx.
| void fx::BM_to_atr | ( | benchmark::State & | state | ) |
| void fx::BM_to_atr2 | ( | benchmark::State & | state | ) |
| void fx::BM_to_atr3 | ( | benchmark::State & | state | ) |
| void fx::BM_to_average_func | ( | benchmark::State & | state | ) |
| void fx::BM_to_average_func2 | ( | benchmark::State & | state | ) |
| void fx::BM_to_average_volume | ( | benchmark::State & | state | ) |
Definition at line 103 of file main.cxx.
| void fx::BM_to_average_volume2 | ( | benchmark::State & | state | ) |
Definition at line 108 of file main.cxx.
| void fx::BM_to_close | ( | benchmark::State & | state | ) |
Definition at line 211 of file main.cxx.
| void fx::BM_to_exit | ( | benchmark::State & | state | ) |
| void fx::BM_to_exit2 | ( | benchmark::State & | state | ) |
| void fx::BM_to_first | ( | benchmark::State & | state | ) |
Definition at line 137 of file main.cxx.
| void fx::BM_to_high | ( | benchmark::State & | state | ) |
Definition at line 201 of file main.cxx.
| void fx::BM_to_last | ( | benchmark::State & | state | ) |
| void fx::BM_to_low | ( | benchmark::State & | state | ) |
Definition at line 206 of file main.cxx.
| void fx::BM_to_open | ( | benchmark::State & | state | ) |
Definition at line 196 of file main.cxx.
| void fx::BM_to_profit | ( | benchmark::State & | state | ) |
Definition at line 172 of file main.cxx.
| void fx::BM_to_size | ( | benchmark::State & | state | ) |
Definition at line 132 of file main.cxx.
| void fx::BM_to_spot | ( | benchmark::State & | state | ) |
Definition at line 157 of file main.cxx.
| void fx::BM_to_sum | ( | benchmark::State & | state | ) |
Definition at line 147 of file main.cxx.
| void fx::BM_to_sum2 | ( | benchmark::State & | state | ) |
Definition at line 152 of file main.cxx.
| void fx::BM_to_time | ( | benchmark::State & | state | ) |
Definition at line 191 of file main.cxx.
| void fx::BM_to_volume | ( | benchmark::State & | state | ) |
| void fx::BM_to_vwap | ( | benchmark::State & | state | ) |
Definition at line 63 of file main.cxx.
| void fx::BM_to_vwap2 | ( | benchmark::State & | state | ) |
Definition at line 68 of file main.cxx.
| auto fx::is_recent_dip2 | ( | auto && | series | ) |
Test if there has been a recent minimum.
Definition at line 141 of file trade.h.
|
constexpr |
Calculate ATR of a series.
Definition at line 43 of file trade.h.
|
constexpr |
Calculate ATR of a series.
Definition at line 62 of file trade.h.
|
constexpr |
Calculate ATR of a series.
Definition at line 81 of file trade.h.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Calculate profit from a trade.
Definition at line 59 of file core.h.
|
constexpr |
|
constexpr |
|
constexpr |
Calculate sum of series.
Definition at line 37 of file core.h.
|
constexpr |
|
constexpr |
Calculate VWAP rolling average.
Definition at line 110 of file trade.h.
|
constexpr |
Calculate VWAP rolling average.
Definition at line 125 of file trade.h.
|
constexpr |
|
constexpr |
Furthest back in time to consider a trade.
Definition at line 26 of file constants.h.
|
constexpr |
|
constexpr |
| auto fx::is_entry |
Calculate if the final price is an entry.
Definition at line 199 of file trade.h.
| auto fx::is_entry2 |
Calculate if the final price is an entry.
Definition at line 232 of file trade.h.
|
constexpr |
Minimum (normalised) ATR to consider a trade.
Definition at line 20 of file constants.h.
|
constexpr |
|
constexpr |
Close position if price has decreased by this percentage.
Definition at line 14 of file constants.h.
|
constexpr |
Close position if price has increased by this percentage.
Definition at line 11 of file constants.h.
|
constexpr |
Calculate average of series, applying a function to each element (which could be a no-op)
|
constexpr |
Definition at line 21 of file trade.h.
|
constexpr |
Calculate average volume over a series.
|
constexpr |
Calculate average volume over a series.
| auto fx::to_exit |
Find an exit in a series.
Definition at line 152 of file trade.h.
| auto fx::to_exit2 |
Find an exit in a series.
Definition at line 177 of file trade.h.
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Definition at line 7 of file constants.h.
|
constexpr |
Definition at line 8 of file constants.h.