algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::BrokerTraits< mock::MockClient > Struct Reference

The mock broker's adaptation: what it implements, and the thunks to mock::MockClient. More...

#include <algotradelib/src/brokers/mock/traits.hpp>

Inheritance diagram for algotradelib::BrokerTraits< mock::MockClient >:
Collaboration diagram for algotradelib::BrokerTraits< mock::MockClient >:

Public Types

using Client = mock::MockClient
 The client.
using Config = mock::MarketSettings
 The configuration: the market's settings.
using Account = mock::MockAccount
 The account; the mock has one.
using BrokerTag = mock::Broker
 The broker tag.
using PlaceAck = PlacedOrder<mock::Broker>
 The acknowledgement, already normalized.
using Amendment = mock::MockAmendment
 A cancellation.
using HistoryQuery = OrderHistoryQuery
 The history query, the library's own.
using WorkingOrdersResult = WorkingOrders<mock::Broker>
 The working-order listing, already normalized.

Static Public Member Functions

static constexpr bool supports_interval (BarInterval interval)
 Tests whether the mock can hold bars of an interval: minute to daily.
static std::optional< BrokerError > validate_bars (const BarQuery &query)
 Refuses a bar request for an interval no market can hold, before the client.
static std::optional< BrokerError > validate_calendar (Country, std::optional< Date >)
 Admits every calendar request; the market refuses another country itself.
static std::optional< BrokerError > validate_place (const OrderRequest &order)
 Refuses an idempotency key, before the client.
static Result< PlacedOrder< mock::Broker > > normalize_place (Result< PlaceAck > raw)
 Returns the acknowledgement as it is: the market answers in the library's own shape.
static Result< WorkingOrders< mock::Broker > > normalize_working_orders (Result< WorkingOrdersResult > raw)
 Returns the listing as it is.
static Result< Amendment > to_replacement (const OrderRef< mock::Broker > &, const AmendInstruction &)
 Refuses every modification: the mock broker cancels but does not modify orders.
static Result< Amendment > to_cancellation (const OrderRef< mock::Broker > &ref, const AmendInstruction &instruction)
 Converts a cancellation of the whole remainder; refuses a stated quantity.
static Result< HistoryQuery > to_history_query (const Account &, const OrderHistoryQuery &query)
 Passes a history query through; refuses a symbol filter or a row limit.
static const network::RateLimitStats * rate_limit_stats (const Client &)
 The mock broker is never paced.
static Result< QuoteSnapshot > quote (Client &client, InstrumentId instrument)
 Forwards a quote request.
static Result< Instrument > instrument (Client &client, InstrumentId instrument)
 Forwards a reference-data request.
static Result< TradingCalendar > calendar (Client &client, Country country, std::optional< Date >)
 Forwards a calendar request; the answer covers every date the market has, whatever from.
static Result< BarSeries > bars (Client &client, BarQuery query)
 Forwards a bar request.
static Result< HoldingsSnapshot > holdings (Client &client, const Account &)
 Forwards a holdings request.
static Result< BuyingPower > buying_power (Client &client, const Account &, Currency currency)
 Forwards a buying-power request.
static Result< PlaceAck > place_order (Client &client, const Account &, OrderRequest order)
 Forwards a placement.
static Result< PlaceAck > replace_order (Client &, const Account &, Amendment)
 Never called: to_replacement refuses every modification.
static Result< PlaceAck > cancel_order (Client &client, const Account &, Amendment amendment)
 Forwards a cancellation.
static Result< WorkingOrdersResult > working_orders (Client &client, const Account &)
 Forwards a working-order request.
static Result< OrderPage > order_history (Client &client, const Account &, HistoryQuery query)
 Forwards an order-history request.

Static Public Attributes

static constexpr std::string_view name = mock::Broker::name
 The broker's name, "mock".
static constexpr bool blocking = true
 The client returns each result.
static constexpr bool data_only = false
 It takes orders.
static constexpr bool has_account_discovery = false
 No account listing: there is one account.
static constexpr bool has_client_order_id = false
 No idempotency key.
static constexpr bool has_working_orders = true
 Lists open orders.
static constexpr bool has_amendable_quantity = true
 Reports each open order's quantity as amendable.
static constexpr bool working_orders_state_terminal = false
 The listing shows open orders only, as every shipped broker's does.
static constexpr bool has_trigger_price = false
 No stop-limit orders.
static constexpr bool has_order_by_id = false
 No single-order inquiry.
static constexpr bool has_partial_cancel = false
 Cancels the whole remainder only.
static constexpr bool history_requires_range = false
 The history needs no date range.
static constexpr bool has_history_cursor = false
 The whole history comes in one answer.
static constexpr bool has_history_limit = false
 No row limit.
static constexpr bool has_history_symbol_filter = false
 No symbol filter.
static constexpr bool has_depth = false
 No order book.
static constexpr bool has_price_limits = false
 No price band.
static constexpr bool has_trade_prints = false
 No trade prints.
static constexpr bool has_batch_prices = false
 One quote per request.
static constexpr bool has_buying_power = true
 Reports buying power.
static constexpr bool has_buying_power_quantity = false
 No affordable quantity.
static constexpr SellableSource sellable_source = SellableSource::HOLDINGS
 The holdings rows carry the sellable quantity.
static constexpr bool has_commission_schedule = false
 No commission schedule; costs come from the market's fill model.
static constexpr bool has_reference_data = true
 Answers reference data: what the market was given, or its default.
static constexpr bool has_batch_reference_data = false
 No reference data.
static constexpr bool has_calendar = true
 Publishes a calendar: what the market was given, or the dates of its bars.
static constexpr bool has_calendar_range = true
 One answer covers every date the market has.
static constexpr bool has_calendar_sessions = false
 No session hours.

Detailed Description

The mock broker's adaptation: what it implements, and the thunks to mock::MockClient.

It lists working orders (open orders only), reports buying power, carries the sellable quantity on its holdings rows, and answers reference data and a calendar (what the market was given, or its defaults). It refuses before calling the client: a trigger price, an idempotency key, a modification (replace_unsupported), a partial cancellation (partial_cancel_unsupported), and a history filtered by symbol or limited to a row count.

Definition at line 30 of file traits.hpp.

Member Typedef Documentation

◆ Account

The account; the mock has one.

Definition at line 36 of file traits.hpp.

◆ Amendment

A cancellation.

Definition at line 42 of file traits.hpp.

◆ BrokerTag

The broker tag.

Definition at line 38 of file traits.hpp.

◆ Client

The client.

Definition at line 32 of file traits.hpp.

◆ Config

The configuration: the market's settings.

Definition at line 34 of file traits.hpp.

◆ HistoryQuery

The history query, the library's own.

Definition at line 44 of file traits.hpp.

◆ PlaceAck

The acknowledgement, already normalized.

Definition at line 40 of file traits.hpp.

◆ WorkingOrdersResult

The working-order listing, already normalized.

Definition at line 46 of file traits.hpp.

Member Function Documentation

◆ bars()

Result< BarSeries > algotradelib::BrokerTraits< mock::MockClient >::bars ( Client & client,
BarQuery query )
inlinestatic

Forwards a bar request.

Parameters
clientThe client.
queryThe query.
Returns
The client's answer.

Definition at line 251 of file traits.hpp.

◆ buying_power()

Result< BuyingPower > algotradelib::BrokerTraits< mock::MockClient >::buying_power ( Client & client,
const Account & ,
Currency currency )
inlinestatic

Forwards a buying-power request.

Parameters
clientThe client.
currencyThe currency.
Returns
The client's answer.

Definition at line 270 of file traits.hpp.

◆ calendar()

Result< TradingCalendar > algotradelib::BrokerTraits< mock::MockClient >::calendar ( Client & client,
Country country,
std::optional< Date >  )
inlinestatic

Forwards a calendar request; the answer covers every date the market has, whatever from.

Parameters
clientThe client.
countryThe market.
Returns
The client's answer.

Definition at line 241 of file traits.hpp.

◆ cancel_order()

Result< PlaceAck > algotradelib::BrokerTraits< mock::MockClient >::cancel_order ( Client & client,
const Account & ,
Amendment amendment )
inlinestatic

Forwards a cancellation.

Parameters
clientThe client.
amendmentThe order id.
Returns
The client's answer.

Definition at line 298 of file traits.hpp.

◆ holdings()

Result< HoldingsSnapshot > algotradelib::BrokerTraits< mock::MockClient >::holdings ( Client & client,
const Account &  )
inlinestatic

Forwards a holdings request.

Parameters
clientThe client.
Returns
The client's answer.

Definition at line 260 of file traits.hpp.

◆ instrument()

Result< Instrument > algotradelib::BrokerTraits< mock::MockClient >::instrument ( Client & client,
InstrumentId instrument )
inlinestatic

Forwards a reference-data request.

Parameters
clientThe client.
instrumentThe instrument.
Returns
The client's answer.

Definition at line 231 of file traits.hpp.

Referenced by instrument(), and quote().

◆ normalize_place()

Result< PlacedOrder< mock::Broker > > algotradelib::BrokerTraits< mock::MockClient >::normalize_place ( Result< PlaceAck > raw)
inlinestatic

Returns the acknowledgement as it is: the market answers in the library's own shape.

Parameters
rawThe client's answer.
Returns
The same.

Definition at line 155 of file traits.hpp.

◆ normalize_working_orders()

Result< WorkingOrders< mock::Broker > > algotradelib::BrokerTraits< mock::MockClient >::normalize_working_orders ( Result< WorkingOrdersResult > raw)
inlinestatic

Returns the listing as it is.

Parameters
rawThe client's answer.
Returns
The same.

Definition at line 164 of file traits.hpp.

◆ order_history()

Result< OrderPage > algotradelib::BrokerTraits< mock::MockClient >::order_history ( Client & client,
const Account & ,
HistoryQuery query )
inlinestatic

Forwards an order-history request.

Parameters
clientThe client.
queryThe query.
Returns
The client's answer.

Definition at line 317 of file traits.hpp.

◆ place_order()

Result< PlaceAck > algotradelib::BrokerTraits< mock::MockClient >::place_order ( Client & client,
const Account & ,
OrderRequest order )
inlinestatic

Forwards a placement.

Parameters
clientThe client.
orderThe order.
Returns
The client's answer.

Definition at line 280 of file traits.hpp.

◆ quote()

Result< QuoteSnapshot > algotradelib::BrokerTraits< mock::MockClient >::quote ( Client & client,
InstrumentId instrument )
inlinestatic

Forwards a quote request.

Parameters
clientThe client.
instrumentThe instrument.
Returns
The client's answer.

Definition at line 221 of file traits.hpp.

◆ rate_limit_stats()

const network::RateLimitStats * algotradelib::BrokerTraits< mock::MockClient >::rate_limit_stats ( const Client & )
inlinestatic

The mock broker is never paced.

Returns
nullptr.

Definition at line 211 of file traits.hpp.

◆ replace_order()

Result< PlaceAck > algotradelib::BrokerTraits< mock::MockClient >::replace_order ( Client & ,
const Account & ,
Amendment  )
inlinestatic

Never called: to_replacement refuses every modification.

Returns
A refusal.

Definition at line 288 of file traits.hpp.

◆ supports_interval()

constexpr bool algotradelib::BrokerTraits< mock::MockClient >::supports_interval ( BarInterval interval)
inlinestaticconstexpr

Tests whether the mock can hold bars of an interval: minute to daily.

A market answers only the interval of each instrument's own series (unsupported_interval).

Parameters
intervalThe interval.
Returns
true for every interval from a minute to a day.

Definition at line 114 of file traits.hpp.

Referenced by validate_bars().

◆ to_cancellation()

Result< Amendment > algotradelib::BrokerTraits< mock::MockClient >::to_cancellation ( const OrderRef< mock::Broker > & ref,
const AmendInstruction & instruction )
inlinestatic

Converts a cancellation of the whole remainder; refuses a stated quantity.

Parameters
refThe order.
instructionThe cancellation.
Returns
The amendment, or INVALID_ARGUMENT partial_cancel_unsupported, not sent.

Definition at line 184 of file traits.hpp.

◆ to_history_query()

Result< HistoryQuery > algotradelib::BrokerTraits< mock::MockClient >::to_history_query ( const Account & ,
const OrderHistoryQuery & query )
inlinestatic

Passes a history query through; refuses a symbol filter or a row limit.

Parameters
queryThe query.
Returns
The query, or INVALID_ARGUMENT history_filter_unsupported, not sent.

Definition at line 198 of file traits.hpp.

◆ to_replacement()

Result< Amendment > algotradelib::BrokerTraits< mock::MockClient >::to_replacement ( const OrderRef< mock::Broker > & ,
const AmendInstruction &  )
inlinestatic

Refuses every modification: the mock broker cancels but does not modify orders.

Returns
INVALID_ARGUMENT replace_unsupported, not sent.

Definition at line 172 of file traits.hpp.

◆ validate_bars()

std::optional< BrokerError > algotradelib::BrokerTraits< mock::MockClient >::validate_bars ( const BarQuery & query)
inlinestatic

Refuses a bar request for an interval no market can hold, before the client.

Parameters
queryThe query.
Returns
INVALID_ARGUMENT unsupported_interval, or nothing.

Definition at line 123 of file traits.hpp.

◆ validate_calendar()

std::optional< BrokerError > algotradelib::BrokerTraits< mock::MockClient >::validate_calendar ( Country ,
std::optional< Date >  )
inlinestatic

Admits every calendar request; the market refuses another country itself.

Returns
Nothing.

Definition at line 134 of file traits.hpp.

◆ validate_place()

std::optional< BrokerError > algotradelib::BrokerTraits< mock::MockClient >::validate_place ( const OrderRequest & order)
inlinestatic

Refuses an idempotency key, before the client.

Parameters
orderThe order.
Returns
INVALID_ARGUMENT idempotency_key_unsupported, or nothing.

Definition at line 143 of file traits.hpp.

◆ working_orders()

Result< WorkingOrdersResult > algotradelib::BrokerTraits< mock::MockClient >::working_orders ( Client & client,
const Account &  )
inlinestatic

Forwards a working-order request.

Parameters
clientThe client.
Returns
The client's answer.

Definition at line 307 of file traits.hpp.

Member Data Documentation

◆ blocking

bool algotradelib::BrokerTraits< mock::MockClient >::blocking = true
staticconstexpr

The client returns each result.

Definition at line 51 of file traits.hpp.

◆ data_only

bool algotradelib::BrokerTraits< mock::MockClient >::data_only = false
staticconstexpr

It takes orders.

Definition at line 53 of file traits.hpp.

◆ has_account_discovery

bool algotradelib::BrokerTraits< mock::MockClient >::has_account_discovery = false
staticconstexpr

No account listing: there is one account.

Definition at line 56 of file traits.hpp.

◆ has_amendable_quantity

bool algotradelib::BrokerTraits< mock::MockClient >::has_amendable_quantity = true
staticconstexpr

Reports each open order's quantity as amendable.

Definition at line 62 of file traits.hpp.

◆ has_batch_prices

bool algotradelib::BrokerTraits< mock::MockClient >::has_batch_prices = false
staticconstexpr

One quote per request.

Definition at line 86 of file traits.hpp.

◆ has_batch_reference_data

bool algotradelib::BrokerTraits< mock::MockClient >::has_batch_reference_data = false
staticconstexpr

No reference data.

Definition at line 98 of file traits.hpp.

◆ has_buying_power

bool algotradelib::BrokerTraits< mock::MockClient >::has_buying_power = true
staticconstexpr

Reports buying power.

Definition at line 88 of file traits.hpp.

◆ has_buying_power_quantity

bool algotradelib::BrokerTraits< mock::MockClient >::has_buying_power_quantity = false
staticconstexpr

No affordable quantity.

Definition at line 90 of file traits.hpp.

◆ has_calendar

bool algotradelib::BrokerTraits< mock::MockClient >::has_calendar = true
staticconstexpr

Publishes a calendar: what the market was given, or the dates of its bars.

Definition at line 100 of file traits.hpp.

◆ has_calendar_range

bool algotradelib::BrokerTraits< mock::MockClient >::has_calendar_range = true
staticconstexpr

One answer covers every date the market has.

Definition at line 102 of file traits.hpp.

◆ has_calendar_sessions

bool algotradelib::BrokerTraits< mock::MockClient >::has_calendar_sessions = false
staticconstexpr

No session hours.

Definition at line 104 of file traits.hpp.

◆ has_client_order_id

bool algotradelib::BrokerTraits< mock::MockClient >::has_client_order_id = false
staticconstexpr

No idempotency key.

Definition at line 58 of file traits.hpp.

◆ has_commission_schedule

bool algotradelib::BrokerTraits< mock::MockClient >::has_commission_schedule = false
staticconstexpr

No commission schedule; costs come from the market's fill model.

Definition at line 94 of file traits.hpp.

◆ has_depth

bool algotradelib::BrokerTraits< mock::MockClient >::has_depth = false
staticconstexpr

No order book.

Definition at line 80 of file traits.hpp.

◆ has_history_cursor

bool algotradelib::BrokerTraits< mock::MockClient >::has_history_cursor = false
staticconstexpr

The whole history comes in one answer.

Definition at line 74 of file traits.hpp.

◆ has_history_limit

bool algotradelib::BrokerTraits< mock::MockClient >::has_history_limit = false
staticconstexpr

No row limit.

Definition at line 76 of file traits.hpp.

◆ has_history_symbol_filter

bool algotradelib::BrokerTraits< mock::MockClient >::has_history_symbol_filter = false
staticconstexpr

No symbol filter.

Definition at line 78 of file traits.hpp.

◆ has_order_by_id

bool algotradelib::BrokerTraits< mock::MockClient >::has_order_by_id = false
staticconstexpr

No single-order inquiry.

Definition at line 68 of file traits.hpp.

◆ has_partial_cancel

bool algotradelib::BrokerTraits< mock::MockClient >::has_partial_cancel = false
staticconstexpr

Cancels the whole remainder only.

Definition at line 70 of file traits.hpp.

◆ has_price_limits

bool algotradelib::BrokerTraits< mock::MockClient >::has_price_limits = false
staticconstexpr

No price band.

Definition at line 82 of file traits.hpp.

◆ has_reference_data

bool algotradelib::BrokerTraits< mock::MockClient >::has_reference_data = true
staticconstexpr

Answers reference data: what the market was given, or its default.

Definition at line 96 of file traits.hpp.

◆ has_trade_prints

bool algotradelib::BrokerTraits< mock::MockClient >::has_trade_prints = false
staticconstexpr

No trade prints.

Definition at line 84 of file traits.hpp.

◆ has_trigger_price

bool algotradelib::BrokerTraits< mock::MockClient >::has_trigger_price = false
staticconstexpr

No stop-limit orders.

Definition at line 66 of file traits.hpp.

◆ has_working_orders

bool algotradelib::BrokerTraits< mock::MockClient >::has_working_orders = true
staticconstexpr

Lists open orders.

Definition at line 60 of file traits.hpp.

◆ history_requires_range

bool algotradelib::BrokerTraits< mock::MockClient >::history_requires_range = false
staticconstexpr

The history needs no date range.

Definition at line 72 of file traits.hpp.

◆ name

std::string_view algotradelib::BrokerTraits< mock::MockClient >::name = mock::Broker::name
staticconstexpr

The broker's name, "mock".

Definition at line 49 of file traits.hpp.

◆ sellable_source

The holdings rows carry the sellable quantity.

Definition at line 92 of file traits.hpp.

◆ working_orders_state_terminal

bool algotradelib::BrokerTraits< mock::MockClient >::working_orders_state_terminal = false
staticconstexpr

The listing shows open orders only, as every shipped broker's does.

Definition at line 64 of file traits.hpp.


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