algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
file.hpp
1#pragma once
2
3#include "./market.hpp"
4
5#include <boost/json.hpp>
6
7#include <chrono>
8#include <cstdint>
9#include <cstdio>
10#include <memory>
11#include <optional>
12#include <stdexcept>
13#include <string>
14#include <string_view>
15#include <utility>
16#include <vector>
17
18#if defined(_WIN32)
19#include <io.h>
20#else
21#include <cerrno>
22
23#include <fcntl.h>
24#include <sys/file.h>
25#include <unistd.h>
26#endif
27
28namespace algotradelib {
29namespace mock {
30
68public:
70 static constexpr std::int64_t FORMAT = 1;
75 static constexpr std::int64_t SEMANTICS = 1;
76
91 std::string path, std::vector<BarSeries> bars, MarketSettings settings, std::vector<Instrument> instruments = {}
92 )
93 : market_(std::move(bars), std::move(settings), std::move(instruments)), path_(std::move(path)) {
94 open_file();
95 if (!opened_) {
96 // A refused file is not held: its lock would refuse this program's own retry.
97 handle_.reset();
98 }
99 market_.recorder_.record_ = [this](const Market::Change& change) {
100 return record(change);
101 };
102 }
103
105 ~MarketFile() = default;
106
107 MarketFile(const MarketFile&) = delete;
108 MarketFile& operator=(const MarketFile&) = delete;
109
114 bool open() const noexcept {
115 return opened_;
116 }
117
122 bool failed() const noexcept {
123 return failed_;
124 }
125
130 const std::string& rejection() const noexcept {
131 return rejection_;
132 }
133
138 const std::string& path() const noexcept {
139 return path_;
140 }
141
147 Market& market() noexcept {
148 return market_;
149 }
150
155 const Market& market() const noexcept {
156 return market_;
157 }
158
159private:
160 using Clock = std::chrono::system_clock;
161
162 // A 64-bit FNV-1a digest, fed fixed-width integers and length-prefixed text, so two different inputs never feed it the
163 // same bytes.
164 class Digest {
165 public:
166 void add(std::int64_t value) {
167 for (int at = 0; at < 64; at += 8) {
168 state_ = (state_ ^ ((static_cast<std::uint64_t>(value) >> at) & 0xffU)) * 0x100000001b3ULL;
169 }
170 }
171
172 void add(std::string_view text) {
173 add(static_cast<std::int64_t>(text.size()));
174 for (const char ch : text) {
175 state_ = (state_ ^ static_cast<unsigned char>(ch)) * 0x100000001b3ULL;
176 }
177 }
178
179 void add(const Decimal64& value) {
180 add(value.coefficient());
181 add(static_cast<std::int64_t>(value.scale()));
182 }
183
184 void add(const Date& date) {
185 add(static_cast<std::int64_t>(date.year_));
186 add(static_cast<std::int64_t>(date.month_));
187 add(static_cast<std::int64_t>(date.day_));
188 }
189
190 void add(Clock::time_point at) {
191 add(ticks(at));
192 }
193
194 void add(const InstrumentId& id) {
195 add(static_cast<std::int64_t>(id.country_));
196 add(static_cast<std::int64_t>(id.venue_));
197 add(id.symbol_);
198 }
199
200 void add(const VenueKey& venue) {
201 add(static_cast<std::int64_t>(venue.kind()));
202 add(static_cast<std::int64_t>(venue.venue()));
203 add(venue.raw_code().str());
204 }
205
206 void add(const StatedDate& date) {
207 add(static_cast<std::int64_t>(date.state()));
208 if (date.state() == StatedDate::State::STATED) {
209 add(date.date());
210 }
211 }
212
213 template <typename T>
214 void add(const std::optional<T>& value) {
215 add(static_cast<std::int64_t>(value.has_value()));
216 if (value) {
217 add(*value);
218 }
219 }
220
221 std::string hex() const {
222 std::string text(16, '0');
223 for (std::size_t at = 0; at < 16; ++at) {
224 text[15 - at] = "0123456789abcdef"[(state_ >> (4 * at)) & 0xfU];
225 }
226 return text;
227 }
228
229 private:
230 std::uint64_t state_{0xcbf29ce484222325ULL};
231 };
232
233 static std::int64_t ticks(Clock::time_point at) {
234 return static_cast<std::int64_t>(at.time_since_epoch().count());
235 }
236
237 static Clock::time_point instant(std::int64_t count) {
238 return Clock::time_point(Clock::duration(count));
239 }
240
241 // The digest of everything a replay depends on; see the class.
242 std::string fingerprint() const {
243 Digest digest;
244 digest.add(SEMANTICS);
245 // The clock's unit, and the size of each enum a line names by number: a file is not read across them.
246 digest.add(static_cast<std::int64_t>(Clock::period::num));
247 digest.add(static_cast<std::int64_t>(Clock::period::den));
248 for (
249 const auto size :
250 {all_countries.size(), all_venues.size(), all_order_sides.size(), all_order_types.size(),
252 ) {
253 digest.add(static_cast<std::int64_t>(size));
254 }
255 const auto& settings = market_.settings_;
256 digest.add(settings.cash_.amount_);
257 digest.add(settings.cash_.currency_.str());
258 digest.add(settings.start_);
259 const auto& fills = settings.fills_;
260 digest.add(static_cast<std::int64_t>(*fills.library_market_price()));
261 digest.add(static_cast<std::int64_t>(fills.limit_price()));
262 digest.add(fills.slippage().basis_points_);
263 digest.add(static_cast<std::int64_t>(fills.slippage().ticks_));
264 digest.add(fills.sell_tax() ? std::optional<Decimal64>(fills.sell_tax()->rate_) : std::nullopt);
265 digest.add(static_cast<std::int64_t>(fills.sell_tax() ? fills.sell_tax()->country_ : Country::KR));
266 const auto& commission = fills.commission();
267 digest.add(commission.stated_model().rate_);
268 digest.add(commission.stated_model().minimum_);
269 digest.add(commission.asserted_venue());
270 digest.add(static_cast<std::int64_t>(commission.dating_market()));
271 const auto& schedule = commission.schedule();
272 // Zero for a stated policy, else one more than the schedule's rows.
273 digest.add(static_cast<std::int64_t>(schedule ? schedule->rates_.size() + 1 : 0));
274 for (std::size_t row = 0; schedule && row < schedule->rates_.size(); ++row) {
275 const auto& rate = schedule->rates_[row];
276 digest.add(static_cast<std::int64_t>(rate.country_));
277 digest.add(rate.other_.str());
278 digest.add(rate.venue_);
279 digest.add(rate.rate_);
280 digest.add(rate.institution_rate_);
281 digest.add(rate.from_);
282 digest.add(rate.until_);
283 digest.add(static_cast<std::int64_t>(rate.from_unreadable_));
284 digest.add(static_cast<std::int64_t>(rate.until_unreadable_));
285 }
286 digest.add(static_cast<std::int64_t>(settings.session_.open_.count()));
287 digest.add(static_cast<std::int64_t>(settings.session_.close_.count()));
288 digest.add(static_cast<std::int64_t>(settings.session_.utc_offset_.count()));
289 const auto& calendar = market_.calendar_;
290 digest.add(static_cast<std::int64_t>(calendar.country_));
291 digest.add(static_cast<std::int64_t>(calendar.unreadable_days_));
292 digest.add(static_cast<std::int64_t>(calendar.days_.size()));
293 for (const auto& day : calendar.days_) {
294 digest.add(day.date_);
295 digest.add(static_cast<std::int64_t>(day.open_));
296 }
297 digest.add(static_cast<std::int64_t>(market_.listings_.size()));
298 for (const auto& listing : market_.listings_) {
299 const auto& series = listing.series_;
300 digest.add(series.instrument_);
301 digest.add(static_cast<std::int64_t>(series.interval_));
302 digest.add(static_cast<std::int64_t>(series.stamp_));
303 digest.add(series.currency_.str());
304 digest.add(static_cast<std::int64_t>(series.adjusted_));
305 digest.add(static_cast<std::int64_t>(series.bars_.size()));
306 for (const auto& bar : series.bars_) {
307 digest.add(bar.timestamp_);
308 digest.add(bar.open_);
309 digest.add(bar.high_);
310 digest.add(bar.low_);
311 digest.add(bar.close_);
312 digest.add(bar.volume_);
313 digest.add(bar.traded_value_);
314 }
315 const auto& reference = listing.reference_;
316 digest.add(reference.id_);
317 digest.add(reference.name_);
318 digest.add(reference.english_name_);
319 digest.add(reference.isin_);
320 digest.add(static_cast<std::int64_t>(reference.segment_.known_));
321 digest.add(reference.segment_.other_.str());
322 digest.add(static_cast<std::int64_t>(reference.type_));
323 digest.add(static_cast<std::int64_t>(reference.status_));
324 digest.add(reference.currency_.str());
325 digest.add(static_cast<std::int64_t>(reference.common_share_));
326 digest.add(reference.listed_on_);
327 digest.add(reference.delisted_on_);
328 digest.add(reference.shares_outstanding_);
329 digest.add(reference.lot_size_);
330 digest.add(static_cast<std::int64_t>(reference.price_rule_.kind_));
331 digest.add(reference.price_rule_.source_);
332 digest.add(static_cast<std::int64_t>(reference.price_rule_.bands_.size()));
333 for (const auto& band : reference.price_rule_.bands_) {
334 digest.add(band.from_);
335 digest.add(band.tick_);
336 }
337 }
338 return digest.hex();
339 }
340
341 // The first line, newline included.
342 std::string header_line() const {
343 boost::json::object header;
344 header["mock_market"] = FORMAT;
345 header["semantics"] = SEMANTICS;
346 header["fingerprint"] = fingerprint();
347 return boost::json::serialize(header) + "\n";
348 }
349
350 // Closes a stream; never called for the null a failed open leaves behind.
351 static void closer(std::FILE* handle) noexcept {
352 std::fclose(handle);
353 }
354
355 // Opens, locks, checks and replays the file; on any refusal says why in `rejection_`. Only the repair of an
356 // incomplete last line or header changes the file before a refusal.
357 void open_file() {
358 if (!market_.settings_.fills_.library_market_price()) {
359 rejection_ = "a mock market whose market orders a caller's own function prices cannot be kept in a file";
360 return;
361 }
362#if defined(_WIN32)
363 handle_.reset(std::fopen(path_.c_str(), "a+b"));
364#else
365 const int descriptor = ::open(path_.c_str(), O_RDWR | O_APPEND | O_CREAT | O_CLOEXEC, 0666);
366 if (descriptor < 0) {
367 rejection_ = "the mock market's state file could not be opened";
368 return;
369 }
370 if (::flock(descriptor, LOCK_EX | LOCK_NB) != 0) {
371 // Closed before the reason is stored, which may allocate and throw.
372 const bool held_elsewhere = errno == EWOULDBLOCK;
373 ::close(descriptor);
374 rejection_ = held_elsewhere ?
375 "the mock market's state file is open in another market (one at a time)" :
376 "the mock market's state file could not be locked";
377 return;
378 }
379 handle_.reset(::fdopen(descriptor, "a+b"));
380 if (handle_ == nullptr) {
381 ::close(descriptor);
382 }
383#endif
384 if (handle_ == nullptr) {
385 rejection_ = "the mock market's state file could not be opened";
386 return;
387 }
388 // Unbuffered: a failed write leaves nothing behind for a later flush to complete.
389 std::setvbuf(handle_.get(), nullptr, _IONBF, 0);
390 std::string text;
391 char buffer[65536];
392 std::rewind(handle_.get());
393 while (const auto count = std::fread(buffer, 1, sizeof(buffer), handle_.get())) {
394 text.append(buffer, count);
395 }
396 if (std::ferror(handle_.get()) != 0 || std::fseek(handle_.get(), 0, SEEK_END) != 0) {
397 rejection_ = "the mock market's state file could not be read";
398 return;
399 }
400 const auto header = header_line();
401 const auto last = text.rfind('\n');
402 if (last == std::string::npos) {
403 // Empty, or a header cut short, before any change was made.
404 if (header.compare(0, text.size(), text) != 0) {
405 rejection_ = "the file is not a mock market's state file";
406 } else if (!cut(0) || !write_whole(header) || !sync() || !sync_folder()) {
407 rejection_ = "the mock market's state file could not be started";
408 } else {
409 opened_ = true;
410 }
411 return;
412 }
413 const auto first = text.find('\n');
414 if (!check_header(std::string_view(text).substr(0, first + 1), header)) {
415 return;
416 }
417 for (auto begin = first + 1; begin <= last;) {
418 const auto end = text.find('\n', begin);
419 if (!replay(std::string_view(text).substr(begin, end - begin))) {
420 rejection_ = "the mock market's state file does not replay: a line is damaged or out of order";
421 return;
422 }
423 begin = end + 1;
424 }
425 if (last + 1 < text.size() && !cut(last + 1)) {
426 rejection_ = "the mock market's state file ends in a line cut short, which could not be removed";
427 return;
428 }
429 // An earlier process may have stopped before either flush: what was replayed must be on the disk before it stands.
430 if (!sync() || !sync_folder()) {
431 rejection_ = "the mock market's state file could not be flushed to disk";
432 return;
433 }
434 opened_ = true;
435 }
436
437 // Tests the first line against this market's; says why in `rejection_` when it differs.
438 bool check_header(std::string_view line, const std::string& expected) {
439 if (line == expected) {
440 return true;
441 }
442 boost::system::error_code error;
443 const auto value = boost::json::parse(line, error);
444 const auto* fields = error ? nullptr : value.if_object();
445 const auto format = fields ? integer(*fields, "mock_market") : std::nullopt;
446 if (!format) {
447 rejection_ = "the file is not a mock market's state file";
448 } else if (*format != FORMAT) {
449 rejection_ = "the mock market's state file is of another format";
450 } else if (integer(*fields, "semantics") != SEMANTICS) {
451 rejection_ = "the mock market's state file was written under other market rules";
452 } else {
453 rejection_ =
454 "the mock market's state file belongs to another market: its bars, settings or reference data differ";
455 }
456 return false;
457 }
458
459 // Shortens the file to `size` bytes and flushes it.
460 bool cut(std::size_t size) {
461#if defined(_WIN32)
462 const bool shortened = ::_chsize_s(::_fileno(handle_.get()), static_cast<long long>(size)) == 0;
463#else
464 const bool shortened = ::ftruncate(::fileno(handle_.get()), static_cast<off_t>(size)) == 0;
465#endif
466 return shortened && std::fseek(handle_.get(), 0, SEEK_END) == 0 && sync();
467 }
468
469 // Writes `line` at the end of the file; `false` unless every byte was.
470 bool write_whole(const std::string& line) {
471 return std::fwrite(line.data(), 1, line.size(), handle_.get()) == line.size() && std::fflush(handle_.get()) == 0;
472 }
473
474 // Asks the system to put the file's bytes on the disk.
475 bool sync() {
476#if defined(_WIN32)
477 return ::_commit(::_fileno(handle_.get())) == 0;
478#else
479 return ::fsync(::fileno(handle_.get())) == 0;
480#endif
481 }
482
483 // Puts a new file's name on the disk, so a crash cannot lose the file; Windows has no such call.
484 bool sync_folder() const {
485#if defined(_WIN32)
486 return true;
487#else
488 const auto slash = path_.rfind('/');
489 const auto folder = slash == std::string::npos ? std::string(".") : path_.substr(0, slash == 0 ? 1 : slash);
490 const int descriptor = ::open(folder.c_str(), O_RDONLY | O_CLOEXEC);
491 const bool synced = descriptor >= 0 && ::fsync(descriptor) == 0;
492 if (descriptor >= 0) {
493 ::close(descriptor);
494 }
495 return synced;
496#endif
497 }
498
499 // Writes and flushes the line for a change before the market makes it; what became of a line that failed.
500 std::optional<MarketFileError::Kind> record(const Market::Change& change) {
501 if (!opened_ || failed_) {
503 }
504 boost::json::object entry;
505 entry["at"] = ticks(market_.now());
506 if (change.order_ != nullptr) {
507 const auto& order = *change.order_;
508 boost::json::object fields;
509 fields["symbol"] = order.instrument_.symbol_;
510 fields["country"] = static_cast<std::int64_t>(order.instrument_.country_);
511 fields["venue"] = static_cast<std::int64_t>(order.instrument_.venue_);
512 fields["side"] = static_cast<std::int64_t>(order.side_);
513 fields["type"] = static_cast<std::int64_t>(order.type_);
514 fields["time_in_force"] = static_cast<std::int64_t>(order.time_in_force_);
515 fields["session"] = static_cast<std::int64_t>(order.session_);
516 fields["route"] = static_cast<std::int64_t>(order.venue_);
517 fields["quantity"] = decimal(order.quantity_);
518 if (order.price_) {
519 fields["price"] = decimal(*order.price_);
520 }
521 entry["place"] = std::move(fields);
522 } else if (change.order_id_ != nullptr) {
523 entry["cancel"] = *change.order_id_;
524 } else {
525 entry["advance"] = ticks(*change.to_);
526 }
527 if (!write_whole(boost::json::serialize(entry) + "\n")) {
528 failed_ = true;
530 }
531 if (!sync()) {
532 failed_ = true;
534 }
535 return std::nullopt;
536 }
537
538 // Makes the change a line records; `false` if the line is damaged or the market does not take it as it did.
539 bool replay(std::string_view line) {
540 boost::system::error_code error;
541 const auto value = boost::json::parse(line, error);
542 const auto* entry = error ? nullptr : value.if_object();
543 if (entry == nullptr || integer(*entry, "at") != ticks(market_.now())) {
544 return false;
545 }
546 if (const auto* place = entry->if_contains("place")) {
547 const auto order = order_from(*place);
548 return order && market_.place(*order).has_value();
549 }
550 if (const auto* cancel = entry->if_contains("cancel")) {
551 return cancel->is_string() && market_.cancel(std::string(cancel->as_string())).has_value();
552 }
553 const auto to = integer(*entry, "advance");
554 if (!to || *to <= ticks(market_.now())) {
555 return false;
556 }
557 try {
558 market_.advance_to(instant(*to));
559 } catch (const std::runtime_error&) {
560 // The market halted on this move, as it did when the move was recorded.
561 return market_.halted().has_value();
562 }
563 return true;
564 }
565
566 // Reads a placement's fields; nothing if any is missing or out of range.
567 static std::optional<OrderRequest> order_from(const boost::json::value& value) {
568 const auto* fields = value.if_object();
569 const auto* symbol = fields ? fields->if_contains("symbol") : nullptr;
570 if (symbol == nullptr || !symbol->is_string()) {
571 return std::nullopt;
572 }
573 const auto country = enumerated<Country>(*fields, "country", all_countries.size());
574 const auto venue = enumerated<Venue>(*fields, "venue", all_venues.size());
575 const auto side = enumerated<OrderSide>(*fields, "side", all_order_sides.size());
576 const auto type = enumerated<OrderType>(*fields, "type", all_order_types.size());
577 const auto time_in_force = enumerated<TimeInForce>(*fields, "time_in_force", all_times_in_force.size());
578 const auto session = enumerated<OrderSession>(*fields, "session", all_order_sessions.size());
579 const auto route = enumerated<Venue>(*fields, "route", all_venues.size());
580 const auto quantity = decimal_from(fields->if_contains("quantity"));
581 const auto* price = fields->if_contains("price");
582 const auto limit = decimal_from(price);
583 if (
584 !country || !venue || !side || !type || !time_in_force || !session || !route || !quantity || (price && !limit)
585 ) {
586 return std::nullopt;
587 }
588 OrderRequest order;
589 order.instrument_ = InstrumentId{*country, *venue, std::string(symbol->as_string())};
590 order.side_ = *side;
591 order.type_ = *type;
592 order.time_in_force_ = *time_in_force;
593 order.session_ = *session;
594 order.venue_ = *route;
595 order.quantity_ = *quantity;
596 order.price_ = limit;
597 return order;
598 }
599
600 static std::optional<std::int64_t> integer(const boost::json::object& fields, std::string_view key) {
601 const auto* value = fields.if_contains(key);
602 return value != nullptr && value->is_int64() ? std::optional<std::int64_t>(value->as_int64()) : std::nullopt;
603 }
604
605 template <typename Enum>
606 static std::optional<Enum> enumerated(const boost::json::object& fields, std::string_view key, std::size_t size) {
607 const auto value = integer(fields, key);
608 if (!value || *value < 0 || static_cast<std::size_t>(*value) >= size) {
609 return std::nullopt;
610 }
611 return static_cast<Enum>(*value);
612 }
613
614 // A decimal as its coefficient and scale, which keep the scale as given.
615 static boost::json::array decimal(const Decimal64& value) {
616 return boost::json::array{value.coefficient(), static_cast<std::int64_t>(value.scale())};
617 }
618
619 // Reads a decimal `decimal` wrote; nothing if it is not one.
620 static std::optional<Decimal64> decimal_from(const boost::json::value* value) {
621 const auto* pair = value != nullptr ? value->if_array() : nullptr;
622 if (pair == nullptr || pair->size() != 2 || !(*pair)[0].is_int64() || !(*pair)[1].is_int64()) {
623 return std::nullopt;
624 }
625 const auto scale = (*pair)[1].as_int64();
626 if (scale < 0 || scale > 255) {
627 return std::nullopt;
628 }
629 return Decimal64((*pair)[0].as_int64(), static_cast<std::uint8_t>(scale));
630 }
631
632 Market market_;
633 std::string path_;
634 // The open file, closed with the market or when its opening throws: closing releases its lock.
635 std::unique_ptr<std::FILE, void (*)(std::FILE*)> handle_{nullptr, &closer};
636 std::string rejection_;
637 bool opened_{false};
638 bool failed_{false};
639};
640
641} // namespace mock
642} // namespace algotradelib
std::string str() const
Returns the code.
Definition types.hpp:418
Decimal64()=default
Constructs zero.
@ STATED
A date that was read.
@ UNCONFIRMED
It was written, and flushing it to disk failed: reopening the file may make the move.
Definition market.hpp:57
@ NOT_WRITTEN
It was not written whole, or not at all: reopening the file does not make the move.
Definition market.hpp:55
static constexpr std::int64_t FORMAT
The file format's number, on its first line.
Definition file.hpp:70
const std::string & path() const noexcept
Returns the file's path.
Definition file.hpp:138
const Market & market() const noexcept
Returns the kept market.
Definition file.hpp:155
bool open() const noexcept
Tests whether the file opened and replayed.
Definition file.hpp:114
~MarketFile()=default
Closes the file, which releases its lock.
Market & market() noexcept
Returns the kept market, for MockClient and MarketClock.
Definition file.hpp:147
MarketFile(std::string path, std::vector< BarSeries > bars, MarketSettings settings, std::vector< Instrument > instruments={})
Opens or creates the file, replays it into a market built as Market's constructor builds one,...
Definition file.hpp:90
bool failed() const noexcept
Tests whether a line could not be written or flushed since the file opened.
Definition file.hpp:122
static constexpr std::int64_t SEMANTICS
The number of the market's rules a file replays under, raised when a fill, cost, ledger,...
Definition file.hpp:75
const std::string & rejection() const noexcept
Returns why the file did not open.
Definition file.hpp:130
A market in memory: bars the caller gives, a clock the caller moves, one account's cash,...
Definition market.hpp:143
The mock broker: an in-memory market over bars the caller gives, bound like any broker.
Definition client.hpp:11
void bar(S &strategy, Ctx &context, const BarEvent &event)
Calls strategy.on_bar(context, event) if the strategy declares on_bar; otherwise does nothing.
Definition concept.hpp:282
The library: broker-neutral types (core), and the modules below.
constexpr std::array< Venue, 4 > all_venues
Every Venue, in declaration order.
Definition types.hpp:53
constexpr std::array< OrderType, 9 > all_order_types
Every OrderType, in declaration order.
Definition types.hpp:2019
constexpr std::array< OrderSide, 2 > all_order_sides
Every OrderSide, in declaration order.
Definition types.hpp:1980
constexpr std::array< OrderSession, 9 > all_order_sessions
Every OrderSession, in declaration order.
Definition types.hpp:2151
constexpr std::array< TimeInForce, 4 > all_times_in_force
Every TimeInForce, in declaration order.
Definition types.hpp:2099
constexpr std::array< Country, 2 > all_countries
Every Country, in declaration order.
Definition types.hpp:38
Currency currency_
The currency; the library never adds amounts in different currencies.
Definition types.hpp:1172
Decimal64 amount_
The amount.
Definition types.hpp:1170
How a Market starts and what it charges.
Definition market.hpp:85
Money cash_
The starting cash, in the one currency the market keeps cash in.
Definition market.hpp:87
backtest::NextBarFillModel fills_
The fill rule and its costs, as a backtest's; no commission, slippage or tax by default.
Definition market.hpp:91
std::chrono::system_clock::time_point start_
The market's first instant; bars that ended by then are history.
Definition market.hpp:89
strategy::SessionWindow session_
The session window local dates and the close are read in, as a backtest's (backtest::ReplayConfig::se...
Definition market.hpp:96
std::chrono::minutes open_
The session open, in minutes from local midnight.
Definition event.hpp:124
std::chrono::minutes utc_offset_
The market's offset from UTC.
Definition event.hpp:128
std::chrono::minutes close_
The session close, in minutes from local midnight.
Definition event.hpp:126