algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::DataOnlyTraits< Tag > Struct Template Reference

A base for the BrokerTraits of a market-data client that cannot trade. More...

#include <algotradelib/src/core/data_only_traits.hpp>

Public Types

using BrokerTag = Tag
 The vendor's tag type.
using Account = data_only::NoAccount
 No account; the session binds an empty one.
using PlaceAck = data_only::NoAck
 Never produced: placement refuses.
using Amendment = data_only::NoAmendment
 Never produced: amendment refuses.
using HistoryQuery = data_only::NoHistoryQuery
 Never produced: history refuses.
using WorkingOrdersResult = data_only::NoWorkingOrders
 Never produced: working orders are not claimed.

Static Public Member Functions

static Account no_account ()
 Returns an empty account, which every account-side member refuses.
template<typename Client>
static const network::RateLimitStats * rate_limit_stats (const Client &)
 Reports that the client runs no rate limiter; declare your own if it does.
static std::optional< BrokerError > validate_place (const OrderRequest &)
 Refuses every order before it is built.
static Result< PlacedOrder< Tag > > normalize_place (Result< PlaceAck > raw)
 Passes the refusal through (an acknowledgement is refused too).
static Result< Amendment > to_replacement (const OrderRef< Tag > &, const AmendInstruction &)
 Refuses an amendment.
static Result< Amendment > to_cancellation (const OrderRef< Tag > &, const AmendInstruction &)
 Refuses a cancellation.
static Result< HistoryQuery > to_history_query (const Account &, const OrderHistoryQuery &)
 Refuses a history query.
template<typename Client>
static Result< HoldingsSnapshot > holdings (Client &, Account &)
 Refuses holdings.
template<typename Client, typename Handler>
static void holdings (Client &, Account &, Handler &&handler)
 Refuses holdings, asynchronously.
template<typename Client>
static Result< PlaceAck > place_order (Client &, Account &, OrderRequest)
 Refuses a placement.
template<typename Client, typename Handler>
static void place_order (Client &, Account &, OrderRequest, Handler &&handler)
 Refuses a placement, asynchronously.
template<typename Client>
static Result< PlaceAck > replace_order (Client &, Account &, Amendment)
 Refuses a replacement.
template<typename Client, typename Handler>
static void replace_order (Client &, Account &, Amendment, Handler &&handler)
 Refuses a replacement, asynchronously.
template<typename Client>
static Result< PlaceAck > cancel_order (Client &, Account &, Amendment)
 Refuses a cancellation.
template<typename Client, typename Handler>
static void cancel_order (Client &, Account &, Amendment, Handler &&handler)
 Refuses a cancellation, asynchronously.
template<typename Client>
static Result< OrderPage > order_history (Client &, Account &, HistoryQuery)
 Refuses order history.
template<typename Client, typename Handler>
static void order_history (Client &, Account &, HistoryQuery, Handler &&handler)
 Refuses order history, asynchronously.

Static Public Attributes

static constexpr bool data_only = true
 true: the client is a market-data source; see BrokerCaps::data_only.

Detailed Description

template<typename Tag>
struct algotradelib::DataOnlyTraits< Tag >

A base for the BrokerTraits of a market-data client that cannot trade.

Inherit it and declare only what the vendor serves:

template <>
using Client = my::Client;
using Config = my::Config;
static constexpr std::string_view name = my::Tag::name;
static constexpr bool blocking = true;
static constexpr bool supports_interval(BarInterval interval);
static std::optional<BrokerError> validate_bars(const BarQuery& query);
static Result<QuoteSnapshot> quote(Client& client, InstrumentId instrument);
static Result<BarSeries> bars(Client& client, BarQuery query);
};
ATL_ASSERT_BROKER(my::Client); // in one source file
Either a value or a BrokerError.
Definition types.hpp:1058
BarInterval
The period one bar covers.
What bars to fetch.
Describes one broker client to the library: its types, capabilities, call thunks and normalizers.
A base for the BrokerTraits of a market-data client that cannot trade.
Identifies an instrument: its country, venue and symbol.
Definition types.hpp:85

An asynchronous client takes the completion token as the last argument. To serve more (a calendar, reference data, price limits), declare that capability true and add its thunk.

Every account-side member (holdings, place, replace, cancel, history) refuses before any I/O with data_only::refusal(); none returns success, since an empty holdings or history would be read as facts about an account. So:

The account-side members ignore their client, account, request, reference and instruction arguments, which are unnamed.

Note
A member you declare hides every inherited member of that name, overloads included (declaring a blocking holdings hides the asynchronous one); re-expose with using DataOnlyTraits<Tag>::holdings;.
Warning
Not a base for a trading adapter that is still incomplete.
Template Parameters
TagThe vendor's tag type.

Definition at line 147 of file data_only_traits.hpp.

Member Typedef Documentation

◆ Account

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::Account = data_only::NoAccount

No account; the session binds an empty one.

Definition at line 151 of file data_only_traits.hpp.

◆ Amendment

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::Amendment = data_only::NoAmendment

Never produced: amendment refuses.

Definition at line 155 of file data_only_traits.hpp.

◆ BrokerTag

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::BrokerTag = Tag

The vendor's tag type.

Definition at line 149 of file data_only_traits.hpp.

◆ HistoryQuery

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::HistoryQuery = data_only::NoHistoryQuery

Never produced: history refuses.

Definition at line 157 of file data_only_traits.hpp.

◆ PlaceAck

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::PlaceAck = data_only::NoAck

Never produced: placement refuses.

Definition at line 153 of file data_only_traits.hpp.

◆ WorkingOrdersResult

template<typename Tag>
using algotradelib::DataOnlyTraits< Tag >::WorkingOrdersResult = data_only::NoWorkingOrders

Never produced: working orders are not claimed.

Definition at line 159 of file data_only_traits.hpp.

Member Function Documentation

◆ cancel_order() [1/2]

template<typename Tag>
template<typename Client>
Result< PlaceAck > algotradelib::DataOnlyTraits< Tag >::cancel_order ( Client & ,
Account & ,
Amendment  )
inlinestatic

Refuses a cancellation.

Template Parameters
ClientThe client type.
Returns
The refusal.

Definition at line 317 of file data_only_traits.hpp.

◆ cancel_order() [2/2]

template<typename Tag>
template<typename Client, typename Handler>
void algotradelib::DataOnlyTraits< Tag >::cancel_order ( Client & ,
Account & ,
Amendment ,
Handler && handler )
inlinestatic

Refuses a cancellation, asynchronously.

Template Parameters
ClientThe client type.
HandlerThe completion handler type.
Parameters
handlerCalled once, through its associated executor, with the refusal.

Definition at line 328 of file data_only_traits.hpp.

◆ holdings() [1/2]

template<typename Tag>
template<typename Client>
Result< HoldingsSnapshot > algotradelib::DataOnlyTraits< Tag >::holdings ( Client & ,
Account &  )
inlinestatic

Refuses holdings.

Template Parameters
ClientThe client type.
Returns
The refusal.

Definition at line 254 of file data_only_traits.hpp.

◆ holdings() [2/2]

template<typename Tag>
template<typename Client, typename Handler>
void algotradelib::DataOnlyTraits< Tag >::holdings ( Client & ,
Account & ,
Handler && handler )
inlinestatic

Refuses holdings, asynchronously.

Template Parameters
ClientThe client type.
HandlerThe completion handler type.
Parameters
handlerCalled once, through its associated executor, with the refusal.

Definition at line 265 of file data_only_traits.hpp.

◆ no_account()

template<typename Tag>
Account algotradelib::DataOnlyTraits< Tag >::no_account ( )
inlinestatic

Returns an empty account, which every account-side member refuses.

Returns
The account.

Definition at line 165 of file data_only_traits.hpp.

◆ normalize_place()

template<typename Tag>
Result< PlacedOrder< Tag > > algotradelib::DataOnlyTraits< Tag >::normalize_place ( Result< PlaceAck > raw)
inlinestatic

Passes the refusal through (an acknowledgement is refused too).

Parameters
rawThe placement result.
Returns
A refusal.

Definition at line 220 of file data_only_traits.hpp.

◆ order_history() [1/2]

template<typename Tag>
template<typename Client>
Result< OrderPage > algotradelib::DataOnlyTraits< Tag >::order_history ( Client & ,
Account & ,
HistoryQuery  )
inlinestatic

Refuses order history.

Template Parameters
ClientThe client type.
Returns
The refusal.

Definition at line 338 of file data_only_traits.hpp.

◆ order_history() [2/2]

template<typename Tag>
template<typename Client, typename Handler>
void algotradelib::DataOnlyTraits< Tag >::order_history ( Client & ,
Account & ,
HistoryQuery ,
Handler && handler )
inlinestatic

Refuses order history, asynchronously.

Template Parameters
ClientThe client type.
HandlerThe completion handler type.
Parameters
handlerCalled once, through its associated executor, with the refusal.

Definition at line 349 of file data_only_traits.hpp.

◆ place_order() [1/2]

template<typename Tag>
template<typename Client>
Result< PlaceAck > algotradelib::DataOnlyTraits< Tag >::place_order ( Client & ,
Account & ,
OrderRequest  )
inlinestatic

Refuses a placement.

Template Parameters
ClientThe client type.
Returns
The refusal.

Definition at line 275 of file data_only_traits.hpp.

◆ place_order() [2/2]

template<typename Tag>
template<typename Client, typename Handler>
void algotradelib::DataOnlyTraits< Tag >::place_order ( Client & ,
Account & ,
OrderRequest ,
Handler && handler )
inlinestatic

Refuses a placement, asynchronously.

Template Parameters
ClientThe client type.
HandlerThe completion handler type.
Parameters
handlerCalled once, through its associated executor, with the refusal.

Definition at line 286 of file data_only_traits.hpp.

◆ rate_limit_stats()

template<typename Tag>
template<typename Client>
const network::RateLimitStats * algotradelib::DataOnlyTraits< Tag >::rate_limit_stats ( const Client & )
inlinestatic

Reports that the client runs no rate limiter; declare your own if it does.

Template Parameters
ClientThe client type.
Returns
nullptr.

Definition at line 203 of file data_only_traits.hpp.

◆ replace_order() [1/2]

template<typename Tag>
template<typename Client>
Result< PlaceAck > algotradelib::DataOnlyTraits< Tag >::replace_order ( Client & ,
Account & ,
Amendment  )
inlinestatic

Refuses a replacement.

Template Parameters
ClientThe client type.
Returns
The refusal.

Definition at line 296 of file data_only_traits.hpp.

◆ replace_order() [2/2]

template<typename Tag>
template<typename Client, typename Handler>
void algotradelib::DataOnlyTraits< Tag >::replace_order ( Client & ,
Account & ,
Amendment ,
Handler && handler )
inlinestatic

Refuses a replacement, asynchronously.

Template Parameters
ClientThe client type.
HandlerThe completion handler type.
Parameters
handlerCalled once, through its associated executor, with the refusal.

Definition at line 307 of file data_only_traits.hpp.

◆ to_cancellation()

template<typename Tag>
Result< Amendment > algotradelib::DataOnlyTraits< Tag >::to_cancellation ( const OrderRef< Tag > & ,
const AmendInstruction &  )
inlinestatic

Refuses a cancellation.

Returns
data_only::refusal().

Definition at line 236 of file data_only_traits.hpp.

◆ to_history_query()

template<typename Tag>
Result< HistoryQuery > algotradelib::DataOnlyTraits< Tag >::to_history_query ( const Account & ,
const OrderHistoryQuery &  )
inlinestatic

Refuses a history query.

Returns
data_only::refusal().

Definition at line 244 of file data_only_traits.hpp.

◆ to_replacement()

template<typename Tag>
Result< Amendment > algotradelib::DataOnlyTraits< Tag >::to_replacement ( const OrderRef< Tag > & ,
const AmendInstruction &  )
inlinestatic

Refuses an amendment.

Returns
data_only::refusal().

Definition at line 228 of file data_only_traits.hpp.

◆ validate_place()

template<typename Tag>
std::optional< BrokerError > algotradelib::DataOnlyTraits< Tag >::validate_place ( const OrderRequest & )
inlinestatic

Refuses every order before it is built.

Returns
data_only::refusal().

Definition at line 211 of file data_only_traits.hpp.

Member Data Documentation

◆ data_only

template<typename Tag>
bool algotradelib::DataOnlyTraits< Tag >::data_only = true
staticconstexpr

true: the client is a market-data source; see BrokerCaps::data_only.

Definition at line 162 of file data_only_traits.hpp.


The documentation for this struct was generated from the following file: