algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
concept.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "./event.hpp"
4#include "./intent.hpp"
5#include "./portfolio.hpp"
6
7#include <chrono>
8#include <optional>
9#include <string>
10#include <string_view>
11#include <type_traits>
12#include <utility>
13#include <vector>
14
15namespace algotradelib {
16namespace strategy {
17
60
61namespace strategy_detail {
62
76#define ATL_DETECT_DECLARED(NAME) \
77 struct NAME##_fallback { \
78 int NAME; \
79 }; \
80 template <typename S> \
81 struct NAME##_probe : S, NAME##_fallback {}; \
82 template <typename S, typename = void> \
83 struct NAME##_is_ambiguous : std::true_type {}; \
84 template <typename S> \
85 struct NAME##_is_ambiguous<S, std::void_t<decltype(&NAME##_probe<S>::NAME)>> : std::false_type {}; \
86 template <typename S> \
87 constexpr bool declares_##NAME = \
88 std::conjunction_v<std::is_class<S>, std::negation<std::is_final<S>>, NAME##_is_ambiguous<S>>
89
90ATL_DETECT_DECLARED(on_start);
91ATL_DETECT_DECLARED(on_stop);
93ATL_DETECT_DECLARED(on_bars);
94ATL_DETECT_DECLARED(on_quote);
95ATL_DETECT_DECLARED(on_fill);
96ATL_DETECT_DECLARED(on_order_update);
97ATL_DETECT_DECLARED(on_phase);
98ATL_DETECT_DECLARED(on_data);
99ATL_DETECT_DECLARED(reads_bar_history);
100
101#undef ATL_DETECT_DECLARED
102
103// Whether `S::reads_bar_history` names an accessible static data member declared `const bool`. The declared type
104// is checked as well as the address's, since a class type can overload `operator&`.
105template <typename S, typename = void>
106struct names_static_bool_reads_bar_history : std::false_type {};
107template <typename S>
108struct names_static_bool_reads_bar_history<
109 S, std::void_t<decltype(S::reads_bar_history), decltype(&S::reads_bar_history)>
110>
111: std::bool_constant<
112 std::is_same_v<decltype(S::reads_bar_history), const bool> &&
113 std::is_same_v<decltype(&S::reads_bar_history), const bool*>
114 > {};
115
116template <typename S, bool Declared = declares_reads_bar_history<S>>
117struct bar_history_policy {
118 static constexpr bool value = true;
119};
120
121template <typename S>
122struct bar_history_policy<S, true> {
123 static_assert(
124 names_static_bool_reads_bar_history<S>::value,
125 "reads_bar_history must be a public `static constexpr bool`; a declaration of any other kind is "
126 "refused rather than read as absent, which would keep the history it asked to drop, or the reverse"
127 );
128 static constexpr bool value = S::reads_bar_history;
129};
130
135template <typename S>
136constexpr bool reads_bar_history = bar_history_policy<S>::value;
137
138// Whether `S` names a member type `data_type`.
139template <typename S, typename = void>
140struct names_data_type : std::false_type {};
141template <typename S>
142struct names_data_type<S, std::void_t<typename S::data_type>> : std::true_type {};
143
145struct NoDataRecord {
146 NoDataRecord() = delete;
147};
148
149template <typename S, bool Names = names_data_type<S>::value>
150struct named_data_type {
151 using type = NoDataRecord;
152};
153
154template <typename S>
155struct named_data_type<S, true> {
156 using type = typename S::data_type;
157};
158
159template <typename S, bool Declared = declares_on_data<S>>
160struct data_policy {
161 static_assert(
162 !names_data_type<S>::value,
163 "`data_type` names the record type on_data takes, but this strategy declares no on_data, so no record "
164 "would reach it: declare on_data, or remove data_type"
165 );
166 using type = NoDataRecord;
167};
168
169template <typename S>
170struct data_policy<S, true> {
171 static_assert(
172 names_data_type<S>::value,
173 "a strategy declaring on_data names the record type it takes: `using data_type = ...;` (a std::variant "
174 "for several kinds of record)"
175 );
176 using type = typename named_data_type<S>::type;
177};
178
183template <typename S>
184using data_record_t = typename data_policy<S>::type;
185
187template <typename S>
188constexpr bool declares_any_handler =
189 declares_on_start<S> || declares_on_stop<S> || declares_on_bar<S> || declares_on_bars<S> || declares_on_quote<S> ||
190 declares_on_fill<S> || declares_on_order_update<S> || declares_on_phase<S> || declares_on_data<S>;
191
193template <typename S>
194constexpr bool names_can_be_read = std::is_class_v<S> && !std::is_final_v<S>;
195
197template <typename S>
198void require_readable_names() {
199 static_assert(
200 names_can_be_read<S>,
201 "a final strategy cannot be checked for a handler the runner would skip, because its member names "
202 "cannot be looked up; remove `final` from the strategy class"
203 );
204}
205
210template <typename S>
211void require_one_bar_handler() {
212 static_assert(
213 !(declares_on_bar<S> && declares_on_bars<S>),
214 "a strategy declares on_bar or on_bars, not both: on_bar receives each bar, on_bars every "
215 "instrument's bar of a period at once; keep the one this strategy decides with"
216 );
217}
218
219} // namespace strategy_detail
220
229namespace dispatch {
230
239template <typename S, typename Ctx>
240void start(S& strategy, Ctx& context) {
241 strategy_detail::require_readable_names<S>();
242 if constexpr (strategy_detail::declares_on_start<S>) {
243 strategy.on_start(context);
244 } else {
245 static_cast<void>(strategy);
246 static_cast<void>(context);
247 }
248}
249
258template <typename S, typename Ctx>
259void stop(S& strategy, Ctx& context) {
260 strategy_detail::require_readable_names<S>();
261 if constexpr (strategy_detail::declares_on_stop<S>) {
262 strategy.on_stop(context);
263 } else {
264 static_cast<void>(strategy);
265 static_cast<void>(context);
266 }
267}
268
281template <typename S, typename Ctx>
282void bar(S& strategy, Ctx& context, const BarEvent& event) {
283 strategy_detail::require_readable_names<S>();
284 strategy_detail::require_one_bar_handler<S>();
285 static_assert(
286 strategy_detail::declares_on_bar<S> || !strategy_detail::declares_on_bars<S>,
287 "this strategy declares on_bars, so its bars are delivered in slices: feed it through "
288 "Runner::record and Runner::feed(const BarSlice&), not one BarEvent at a time"
289 );
290 if constexpr (strategy_detail::declares_on_bar<S>) {
291 strategy.on_bar(context, event);
292 } else {
293 static_cast<void>(strategy);
294 static_cast<void>(context);
295 static_cast<void>(event);
296 }
297}
298
308template <typename S, typename Ctx>
309void bars(S& strategy, Ctx& context, const BarSlice& slice) {
310 strategy_detail::require_readable_names<S>();
311 strategy_detail::require_one_bar_handler<S>();
312 if constexpr (strategy_detail::declares_on_bars<S>) {
313 strategy.on_bars(context, slice);
314 } else {
315 static_cast<void>(strategy);
316 static_cast<void>(context);
317 static_cast<void>(slice);
318 }
319}
320
330template <typename S, typename Ctx>
331void quote(S& strategy, Ctx& context, const QuoteEvent& event) {
332 strategy_detail::require_readable_names<S>();
333 if constexpr (strategy_detail::declares_on_quote<S>) {
334 strategy.on_quote(context, event);
335 } else {
336 static_cast<void>(strategy);
337 static_cast<void>(context);
338 static_cast<void>(event);
339 }
340}
341
351template <typename S, typename Ctx>
352void fill(S& strategy, Ctx& context, const Fill& event) {
353 strategy_detail::require_readable_names<S>();
354 if constexpr (strategy_detail::declares_on_fill<S>) {
355 strategy.on_fill(context, event);
356 } else {
357 static_cast<void>(strategy);
358 static_cast<void>(context);
359 static_cast<void>(event);
360 }
361}
362
372template <typename S, typename Ctx>
373void order_update(S& strategy, Ctx& context, const OrderSnapshot& event) {
374 strategy_detail::require_readable_names<S>();
375 if constexpr (strategy_detail::declares_on_order_update<S>) {
376 strategy.on_order_update(context, event);
377 } else {
378 static_cast<void>(strategy);
379 static_cast<void>(context);
380 static_cast<void>(event);
381 }
382}
383
394template <typename S, typename Ctx>
395void phase(S& strategy, Ctx& context, const MarketPhase& event) {
396 strategy_detail::require_readable_names<S>();
397 if constexpr (strategy_detail::declares_on_phase<S>) {
398 strategy.on_phase(context, event);
399 } else {
400 static_cast<void>(strategy);
401 static_cast<void>(context);
402 static_cast<void>(event);
403 }
404}
405
415template <typename S, typename Ctx>
416void data(S& strategy, Ctx& context, const DataEvent<strategy_detail::data_record_t<S>>& event) {
417 strategy_detail::require_readable_names<S>();
418 if constexpr (strategy_detail::declares_on_data<S>) {
419 strategy.on_data(context, event);
420 } else {
421 static_cast<void>(strategy);
422 static_cast<void>(context);
423 static_cast<void>(event);
424 }
425}
426
427} // namespace dispatch
428
429namespace strategy_detail {
430
432template <typename S, typename Ctx>
433void call_every_handler(
434 S& strategy, Ctx& context, const BarEvent& bar, const BarSlice& slice, const QuoteEvent& quote, const Fill& fill,
435 const OrderSnapshot& order, const MarketPhase& phase, const DataEvent<data_record_t<S>>& data
436) {
437 dispatch::start(strategy, context);
438 dispatch::stop(strategy, context);
439 // The bar route the runner takes: slices for a strategy declaring `on_bars`, single bars otherwise.
440 if constexpr (declares_on_bars<S>) {
441 static_cast<void>(bar);
442 dispatch::bars(strategy, context, slice);
443 } else {
444 static_cast<void>(slice);
445 dispatch::bar(strategy, context, bar);
446 }
447 dispatch::quote(strategy, context, quote);
448 dispatch::fill(strategy, context, fill);
449 dispatch::order_update(strategy, context, order);
450 dispatch::phase(strategy, context, phase);
451 dispatch::data(strategy, context, data);
452}
453
458template <typename S, typename Ctx>
459constexpr bool compiles_every_handler_call() {
460 if constexpr (names_can_be_read<S>) {
461 static_cast<void>(&call_every_handler<S, Ctx>);
462 }
463 return true;
464}
465
466} // namespace strategy_detail
467
473struct NoCaps {
475 static constexpr bool has_account_discovery = false;
477 static constexpr bool has_client_order_id = false;
479 static constexpr bool has_trigger_price = false;
481 static constexpr bool data_only = false;
483 static constexpr bool has_working_orders = false;
485 static constexpr bool working_orders_state_terminal = false;
487 static constexpr bool has_amendable_quantity = false;
489 static constexpr bool has_order_by_id = false;
491 static constexpr bool has_partial_cancel = false;
493 static constexpr bool history_requires_range = false;
495 static constexpr bool has_history_cursor = false;
497 static constexpr bool has_history_limit = false;
499 static constexpr bool has_history_symbol_filter = false;
501 static constexpr bool has_depth = false;
503 static constexpr bool has_price_limits = false;
505 static constexpr bool has_trade_prints = false;
507 static constexpr bool has_batch_prices = false;
509 static constexpr bool has_reference_data = false;
511 static constexpr bool has_batch_reference_data = false;
513 static constexpr bool has_calendar = false;
515 static constexpr bool has_calendar_range = false;
517 static constexpr bool has_calendar_sessions = false;
519 static constexpr bool has_buying_power = false;
521 static constexpr bool has_buying_power_quantity = false;
523 static constexpr bool has_commission_schedule = false;
532 static constexpr bool supports_interval(BarInterval) {
533 return false;
534 }
535};
536
538struct AllCaps {
540 static constexpr bool has_account_discovery = true;
542 static constexpr bool has_client_order_id = true;
544 static constexpr bool has_trigger_price = true;
546 static constexpr bool data_only = false;
548 static constexpr bool has_working_orders = true;
550 static constexpr bool working_orders_state_terminal = true;
552 static constexpr bool has_amendable_quantity = true;
554 static constexpr bool has_order_by_id = true;
556 static constexpr bool has_partial_cancel = true;
558 static constexpr bool history_requires_range = true;
560 static constexpr bool has_history_cursor = true;
562 static constexpr bool has_history_limit = true;
564 static constexpr bool has_history_symbol_filter = true;
566 static constexpr bool has_depth = true;
568 static constexpr bool has_price_limits = true;
570 static constexpr bool has_trade_prints = true;
572 static constexpr bool has_batch_prices = true;
574 static constexpr bool has_reference_data = true;
576 static constexpr bool has_batch_reference_data = true;
578 static constexpr bool has_calendar = true;
580 static constexpr bool has_calendar_range = true;
582 static constexpr bool has_calendar_sessions = true;
584 static constexpr bool has_buying_power = true;
586 static constexpr bool has_buying_power_quantity = true;
588 static constexpr bool has_commission_schedule = true;
597
601 static constexpr bool supports_interval(BarInterval) {
602 return true;
603 }
604};
605
609 static constexpr std::string_view name = "probe";
610};
611
625template <typename CapsType>
627public:
631 using caps = CapsType;
632
634 ProbeContextT() = default;
636 ProbeContextT(const ProbeContextT&) = delete;
649
651 class Log {
652 public:
657 void note(std::string_view message) {
658 lines_.emplace_back(message);
659 }
660
664 const std::vector<std::string>& lines() const noexcept {
665 return lines_;
666 }
667
668 private:
669 std::vector<std::string> lines_;
670 };
671
676 std::chrono::system_clock::time_point now() const noexcept {
677 return now_;
678 }
679
684 MarketPhase phase() const noexcept {
685 return phase_;
686 }
687
692 const SessionWindow& session() const noexcept {
693 return session_;
694 }
695
700 const TradingCalendar& calendar() const noexcept {
701 return calendar_;
702 }
703
708 const Portfolio<ProbeBroker>& portfolio() const noexcept {
709 return portfolio_;
710 }
711
718 std::optional<Instrument> instrument(const InstrumentId& id) const {
719 for (const auto& known : instruments_) {
720 if (known.id_ == id) {
721 return known;
722 }
723 }
724 return std::nullopt;
725 }
726
731 void submit(OrderIntent intent) {
732 submitted_.push_back(std::move(intent));
733 }
734
739 void submit(TargetPosition target) {
740 targets_.push_back(std::move(target));
741 }
742
747 void cancel(const OrderRef<ProbeBroker>& ref) {
748 canceled_.push_back(CancelIntent<ProbeBroker>{ref, {}});
749 }
750
755 Log& log() noexcept {
756 return log_;
757 }
758
763 const std::vector<OrderIntent>& submitted() const noexcept {
764 return submitted_;
765 }
766
770 const std::vector<TargetPosition>& targets() const noexcept {
771 return targets_;
772 }
773
777 const std::vector<CancelIntent<ProbeBroker>>& canceled() const noexcept {
778 return canceled_;
779 }
780
782 std::chrono::system_clock::time_point now_{};
792 std::vector<Instrument> instruments_;
793
794private:
795 std::vector<OrderIntent> submitted_;
796 std::vector<TargetPosition> targets_;
797 std::vector<CancelIntent<ProbeBroker>> canceled_;
798 Log log_;
799};
800
803
806
813template <typename S, typename Ctx>
815 // A strategy's handler names are looked up through a class derived from it, which a `final` class does
816 // not allow; read any other way, a handler the runner cannot call could be skipped in silence.
817 static_assert(
818 strategy_detail::names_can_be_read<S>,
819 "a final strategy cannot be checked for a handler the runner would skip, because its member names "
820 "cannot be looked up; remove `final` from the strategy class"
821 );
822 // A handler taking its context by value would submit to a copy, and what it submitted would be lost.
823 // Every context this library hands a strategy is move-only; a caller's own must be too -- from the
824 // mutable lvalue `dispatch` passes as well as from a `const` one, since a copy constructor may take either.
825 static_assert(
826 !std::is_copy_constructible_v<Ctx> && !std::is_constructible_v<Ctx, Ctx&>,
827 "a strategy context must not be copyable, so that a handler taking it by value does not compile "
828 "(what it submitted would go to the copy and be lost); delete the context's copy constructor"
829 );
830 static_assert(
831 strategy_detail::declares_any_handler<S>,
832 "This type declares no strategy handler. Expected at least one of on_start, on_bar, on_bars, "
833 "on_quote, on_fill, on_order_update, on_phase, on_data, or on_stop"
834 );
835 static_assert(
836 !(strategy_detail::declares_on_bar<S> && strategy_detail::declares_on_bars<S>),
837 "a strategy declares on_bar or on_bars, not both: on_bar receives each bar, on_bars every "
838 "instrument's bar of a period at once; keep the one this strategy decides with"
839 );
840
841 // Instantiated so a malformed `reads_bar_history` is refused here too.
842 static_assert(strategy_detail::reads_bar_history<S> || !strategy_detail::reads_bar_history<S>);
843
845 static constexpr bool value = strategy_detail::compiles_every_handler_call<S, Ctx>();
846};
847
866#define ATL_ASSERT_STRATEGY(S, Ctx) \
867 static_assert( \
868 ::algotradelib::strategy::StrategyConformance<S, Ctx>::value, \
869 "Strategy does not satisfy the algotradelib strategy surface; see the messages above" \
870 )
871
872} // namespace strategy
873} // namespace algotradelib
One order a strategy asks the runner to place.
Definition intent.hpp:253
A log that keeps each line in memory for a test to read.
Definition concept.hpp:651
void note(std::string_view message)
Records one line.
Definition concept.hpp:657
const std::vector< std::string > & lines() const noexcept
Returns the recorded lines.
Definition concept.hpp:664
A context for testing a strategy without a runner: it records what the strategy asks for.
Definition concept.hpp:626
ProbeContextT & operator=(const ProbeContextT &)=delete
Deleted: a probe cannot be copied.
std::chrono::system_clock::time_point now() const noexcept
Returns the current instant.
Definition concept.hpp:676
const std::vector< CancelIntent< ProbeBroker > > & canceled() const noexcept
Returns the cancellations requested.
Definition concept.hpp:777
void cancel(const OrderRef< ProbeBroker > &ref)
Records a cancellation.
Definition concept.hpp:747
const std::vector< TargetPosition > & targets() const noexcept
Returns the target positions submitted.
Definition concept.hpp:770
const Portfolio< ProbeBroker > & portfolio() const noexcept
Returns the portfolio.
Definition concept.hpp:708
CapsType caps
The broker capabilities the strategy sees.
Definition concept.hpp:631
ProbeContextT & operator=(ProbeContextT &&)=default
Move assignment: takes the other probe's state.
ProbeBroker Broker
The broker tag; see ProbeBroker.
Definition concept.hpp:629
Log & log() noexcept
Returns the log.
Definition concept.hpp:755
ProbeContextT(ProbeContextT &&)=default
Move constructor: takes the other probe's state.
const TradingCalendar & calendar() const noexcept
Returns the trading calendar.
Definition concept.hpp:700
void submit(TargetPosition target)
Records a target position.
Definition concept.hpp:739
std::chrono::system_clock::time_point now_
Definition concept.hpp:782
const SessionWindow & session() const noexcept
Returns the session window.
Definition concept.hpp:692
void submit(OrderIntent intent)
Records an order intent.
Definition concept.hpp:731
MarketPhase phase() const noexcept
Returns the market phase.
Definition concept.hpp:684
const std::vector< OrderIntent > & submitted() const noexcept
Returns the order intents submitted.
Definition concept.hpp:763
ProbeContextT()=default
Constructs an empty probe.
std::optional< Instrument > instrument(const InstrumentId &id) const
Looks up an instrument's reference data in instruments_.
Definition concept.hpp:718
ProbeContextT(const ProbeContextT &)=delete
Deleted: like a runner's context, a probe cannot be copied.
#define ATL_DETECT_DECLARED(NAME)
Definition concept.hpp:76
The events a runner delivers to a strategy's handlers, and the market phase.
What a strategy asks the runner for: orders (OrderIntent), target positions (TargetPosition) and canc...
Calls a strategy's handlers, skipping the ones it does not declare.
Definition concept.hpp:229
void phase(S &strategy, Ctx &context, const MarketPhase &event)
Calls strategy.on_phase(context, event) if the strategy declares on_phase; otherwise does nothing.
Definition concept.hpp:395
void quote(S &strategy, Ctx &context, const QuoteEvent &event)
Calls strategy.on_quote(context, event) if the strategy declares on_quote; otherwise does nothing.
Definition concept.hpp:331
void start(S &strategy, Ctx &context)
Calls strategy.on_start(context) if the strategy declares on_start; otherwise does nothing.
Definition concept.hpp:240
void stop(S &strategy, Ctx &context)
Calls strategy.on_stop(context) if the strategy declares on_stop; otherwise does nothing.
Definition concept.hpp:259
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
void fill(S &strategy, Ctx &context, const Fill &event)
Calls strategy.on_fill(context, event) if the strategy declares on_fill; otherwise does nothing.
Definition concept.hpp:352
void order_update(S &strategy, Ctx &context, const OrderSnapshot &event)
Calls strategy.on_order_update(context, event) if the strategy declares on_order_update; otherwise do...
Definition concept.hpp:373
void data(S &strategy, Ctx &context, const DataEvent< strategy_detail::data_record_t< S > > &event)
Calls strategy.on_data(context, event) if the strategy declares on_data; otherwise does nothing.
Definition concept.hpp:416
void bars(S &strategy, Ctx &context, const BarSlice &slice)
Calls strategy.on_bars(context, slice) if the strategy declares on_bars; otherwise does nothing.
Definition concept.hpp:309
What a strategy sees and emits: events, intents, the portfolio, reconciliation and risk limits.
Definition concept.hpp:16
MarketPhase
Where the clock stands relative to the trading session.
Definition event.hpp:33
@ OPEN
Inside the session.
Definition event.hpp:46
ProbeContextT< NoCaps > MinimalContext
A probe context whose broker implements nothing optional.
Definition concept.hpp:802
ProbeContextT< AllCaps > FullContext
A probe context whose broker implements everything optional.
Definition concept.hpp:805
The library: broker-neutral types (core), and the modules below.
SellableSource
Where the library gets a broker's sellable quantity.
Definition types.hpp:1362
@ INQUIRY
From a per-instrument inquiry, made only where the snapshot has no figure.
Definition types.hpp:1366
@ NONE
No per-instrument inquiry: any figure comes on the holdings rows (Kiwoom), or there is none.
Definition types.hpp:1368
BarInterval
The period one bar covers.
Identifies an instrument: its country, venue and symbol.
Definition types.hpp:85
A broker's reference to one order, used to amend or cancel it.
Definition types.hpp:2402
The state of one order, as a broker listing reported it.
Definition types.hpp:2299
What a sellable quantity covers, and how RiskGuard must treat resting sells against it.
Definition types.hpp:1191
@ WHOLE_HOLDING
Every share held of the instrument, whatever venue or lot.
Definition types.hpp:1197
@ DEDUCT
Subtract every resting sell from the figure.
Definition types.hpp:1215
The trading days a broker reported for one market, ascending by date.
Definition calendar.hpp:72
A capability set in which the broker implements everything optional.
Definition concept.hpp:538
static constexpr bool has_batch_reference_data
Whether one reference-data request can cover several instruments.
Definition concept.hpp:576
static constexpr bool has_calendar_sessions
Whether the adapter fills each open day's session hours (TradingDay::regular_, extended_); a live loo...
Definition concept.hpp:582
static constexpr bool has_client_order_id
Whether the broker accepts an idempotency key (OrderRequest::client_order_id_).
Definition concept.hpp:542
static constexpr bool has_trigger_price
Whether the adapter sends trigger prices (stop-limit orders).
Definition concept.hpp:544
static constexpr bool supports_interval(BarInterval)
Tests whether the broker serves bars of an interval (the unnamed argument).
Definition concept.hpp:601
static constexpr bool has_trade_prints
Whether the broker publishes recent trades.
Definition concept.hpp:570
static constexpr bool has_history_limit
Whether an order-history inquiry accepts a row limit (OrderHistoryQuery::limit_).
Definition concept.hpp:562
static constexpr bool working_orders_state_terminal
Whether the working-order listing can show a terminal status (filled, cancelled, ....
Definition concept.hpp:550
static constexpr SellableBasis sellable_inquiry_basis
The whole holding, with resting sells deducted (the basis the library assumes for Toss,...
Definition concept.hpp:592
static constexpr bool has_batch_prices
Whether the broker quotes several instruments in one request.
Definition concept.hpp:572
static constexpr bool has_working_orders
Whether the broker lists the orders still open to amendment. A listing shows only what the broker's A...
Definition concept.hpp:548
static constexpr bool has_price_limits
Whether the broker publishes the day's price limits.
Definition concept.hpp:568
static constexpr bool has_amendable_quantity
Whether the broker reports the quantity still amendable on an open order.
Definition concept.hpp:552
static constexpr bool has_partial_cancel
Whether the broker can cancel part of an order.
Definition concept.hpp:556
static constexpr bool has_calendar_range
Whether one calendar request covers a span of dates.
Definition concept.hpp:580
static constexpr bool has_depth
Whether the broker publishes the order book (depth).
Definition concept.hpp:566
static constexpr bool history_requires_range
Whether an order-history inquiry needs a date range (OrderHistoryQuery::from_).
Definition concept.hpp:558
static constexpr bool has_buying_power
Whether the broker reports buying power.
Definition concept.hpp:584
static constexpr bool has_account_discovery
Whether the broker lists the selectable accounts.
Definition concept.hpp:540
static constexpr bool has_calendar
Whether the broker publishes the trading calendar.
Definition concept.hpp:578
static constexpr SellableSource sellable_source
The sellable quantity comes from an inquiry.
Definition concept.hpp:590
static constexpr bool has_order_by_id
Whether the broker can look up one order by its id.
Definition concept.hpp:554
static constexpr bool has_commission_schedule
Whether the broker publishes the account's commission rates.
Definition concept.hpp:588
static constexpr bool has_reference_data
Whether the broker publishes instrument reference data.
Definition concept.hpp:574
static constexpr bool data_only
false: this broker takes orders.
Definition concept.hpp:546
static constexpr bool has_buying_power_quantity
Whether the broker can also say how many shares are affordable.
Definition concept.hpp:586
static constexpr bool has_history_symbol_filter
Whether an order-history inquiry can filter by symbol.
Definition concept.hpp:564
static constexpr bool has_history_cursor
Whether an order-history answer can carry a cursor to the next page.
Definition concept.hpp:560
One bar, delivered to on_bar.
Definition event.hpp:313
Every instrument's bar of one interval for one period end, delivered to on_bars.
Definition event.hpp:569
A request to cancel one working order.
Definition intent.hpp:480
A record of data from outside the broker, delivered to on_data.
Definition event.hpp:856
One execution of an order the strategy placed, delivered to on_fill.
Definition event.hpp:886
A capability set in which the broker implements nothing optional.
Definition concept.hpp:473
static constexpr bool history_requires_range
Whether an order-history inquiry needs a date range (OrderHistoryQuery::from_).
Definition concept.hpp:493
static constexpr bool has_reference_data
Whether the broker publishes instrument reference data.
Definition concept.hpp:509
static constexpr bool has_buying_power
Whether the broker reports buying power.
Definition concept.hpp:519
static constexpr bool has_client_order_id
Whether the broker accepts an idempotency key (OrderRequest::client_order_id_).
Definition concept.hpp:477
static constexpr bool has_calendar_sessions
Whether the adapter fills each open day's session hours (TradingDay::regular_, extended_); a live loo...
Definition concept.hpp:517
static constexpr bool has_order_by_id
Whether the broker can look up one order by its id.
Definition concept.hpp:489
static constexpr bool data_only
Whether the client is a market-data source that takes no orders (built on DataOnlyTraits).
Definition concept.hpp:481
static constexpr bool has_batch_reference_data
Whether one reference-data request can cover several instruments.
Definition concept.hpp:511
static constexpr bool has_account_discovery
Whether the broker lists the selectable accounts.
Definition concept.hpp:475
static constexpr bool has_batch_prices
Whether the broker quotes several instruments in one request.
Definition concept.hpp:507
static constexpr bool has_history_limit
Whether an order-history inquiry accepts a row limit (OrderHistoryQuery::limit_).
Definition concept.hpp:497
static constexpr bool has_buying_power_quantity
Whether the broker can also say how many shares are affordable.
Definition concept.hpp:521
static constexpr bool has_commission_schedule
Whether the broker publishes the account's commission rates.
Definition concept.hpp:523
static constexpr bool supports_interval(BarInterval)
Tests whether the broker serves bars of an interval (the unnamed argument).
Definition concept.hpp:532
static constexpr bool working_orders_state_terminal
Whether the working-order listing can show a terminal status (filled, cancelled, ....
Definition concept.hpp:485
static constexpr SellableBasis sellable_inquiry_basis
Unestablished, since there is no inquiry.
Definition concept.hpp:527
static constexpr bool has_trigger_price
Whether the adapter sends trigger prices (stop-limit orders).
Definition concept.hpp:479
static constexpr bool has_calendar_range
Whether one calendar request covers a span of dates.
Definition concept.hpp:515
static constexpr bool has_history_cursor
Whether an order-history answer can carry a cursor to the next page.
Definition concept.hpp:495
static constexpr bool has_trade_prints
Whether the broker publishes recent trades.
Definition concept.hpp:505
static constexpr bool has_amendable_quantity
Whether the broker reports the quantity still amendable on an open order.
Definition concept.hpp:487
static constexpr bool has_working_orders
Whether the broker lists the orders still open to amendment. A listing shows only what the broker's A...
Definition concept.hpp:483
static constexpr bool has_price_limits
Whether the broker publishes the day's price limits.
Definition concept.hpp:503
static constexpr bool has_calendar
Whether the broker publishes the trading calendar.
Definition concept.hpp:513
static constexpr bool has_partial_cancel
Whether the broker can cancel part of an order.
Definition concept.hpp:491
static constexpr bool has_depth
Whether the broker publishes the order book (depth).
Definition concept.hpp:501
static constexpr bool has_history_symbol_filter
Whether an order-history inquiry can filter by symbol.
Definition concept.hpp:499
static constexpr SellableSource sellable_source
No sellable-quantity figure is available.
Definition concept.hpp:525
What the account holds and which orders are still working, as a strategy sees it.
Definition portfolio.hpp:82
The broker tag of a probe context; nothing it issues reaches a market.
Definition concept.hpp:607
static constexpr std::string_view name
The broker name an order reference prints.
Definition concept.hpp:609
A quote the runner has just read, delivered to on_quote.
Definition event.hpp:841
The intraday session of a market, as the operator states it.
Definition event.hpp:122
static SessionWindow krx()
Returns the KRX regular session, 09:00-15:30 KST.
Definition event.hpp:136
The checks behind ATL_ASSERT_STRATEGY; instantiating it reports what is wrong with S.
Definition concept.hpp:814
static constexpr bool value
Always true; reading it compiles every handler call the runner makes with Ctx.
Definition concept.hpp:845
The position a strategy wants to hold in one instrument.
Definition intent.hpp:451