![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
The library: broker-neutral types (core), and the modules below. More...
Namespaces | |
| namespace | analytics |
| Returns, rolling statistics, indicators and performance metrics over numeric series. | |
| namespace | backtest |
| Replays a strategy over stored bars: fill and cost models, the replay ledger, and the report. | |
| namespace | conformance |
| The compile-time check behind ATL_ASSERT_BROKER(Client). | |
| namespace | data_only |
| Placeholder types and the refusal used by DataOnlyTraits. | |
| namespace | kis |
| The Korea Investment & Securities (KIS) Open API client. | |
| namespace | kiwoom |
| The Kiwoom Securities REST API client. | |
| namespace | live |
| Connects a runner to a broker session for live trading. | |
| namespace | math |
| The numeric vocabulary: Scalar, missing(), and the matrix and vector types. | |
| namespace | network |
| HTTP and WebSocket transport, OAuth tokens, and request pacing. | |
| namespace | runner |
| Runs a strategy: the runner, the polling loop, the order journal, and stopping. | |
| namespace | strategy |
| What a strategy sees and emits: events, intents, the portfolio, reconciliation and risk limits. | |
| namespace | tossinvest |
| The Toss Securities Open API client. | |
Classes | |
| struct | AccountInfo |
| One account from a broker's account list. More... | |
| struct | AmendInstruction |
| A modification or cancellation of a working order. More... | |
| struct | Bar |
| One bar: the prices and volume of one period, as exact decimals. More... | |
| struct | BarQuery |
| What bars to fetch. More... | |
| struct | BarSeries |
| The bars of one instrument and interval, oldest first. More... | |
| class | BlockingSession |
| A blocking broker client bound to one account, with the same broker operations as BrokerSession, plus accounts(). More... | |
| struct | BrokerCaps |
| What one broker client implements, as compile-time constants. More... | |
| struct | BrokerError |
| The error a broker or transport operation returns. More... | |
| class | BrokerSession |
| An asynchronous broker client bound to one account, with broker-neutral operations. More... | |
| struct | BrokerTraits |
| Describes one broker client to the library: its types, capabilities, call thunks and normalizers. More... | |
| struct | BrokerTraits< kis::KisBlockingClient > |
| The BlockingSession adapter for kis::KisBlockingClient. More... | |
| struct | BrokerTraits< kis::KisClient > |
| The BrokerSession adapter for kis::KisClient. More... | |
| struct | BrokerTraits< kiwoom::KiwoomBlockingClient > |
| The BlockingSession adapter for kiwoom::KiwoomBlockingClient. More... | |
| struct | BrokerTraits< kiwoom::KiwoomClient > |
| The BrokerSession adapter for kiwoom::KiwoomClient. More... | |
| struct | BrokerTraits< tossinvest::TossBlockingClient > |
| The BlockingSession adapter for tossinvest::TossBlockingClient. More... | |
| struct | BrokerTraits< tossinvest::TossClient > |
| The BrokerSession adapter for tossinvest::TossClient. More... | |
| struct | BuyingPower |
| What the broker says may be spent, in one currency. More... | |
| class | Code |
| A short uppercase code (letters, digits, _), stored inline without allocation. More... | |
| struct | CommissionRate |
| One commission rate, the market and venue it applies to, and the dates it applies on. More... | |
| struct | CommissionSchedule |
| The commission rates a broker published for an account, or a caller stated. More... | |
| class | Currency |
| A three-letter currency code, such as KRW or USD (ISO 4217 style). More... | |
| struct | DataOnlyTraits |
| A base for the BrokerTraits of a market-data client that cannot trade. More... | |
| struct | Date |
| A calendar date with no time of day or time zone. More... | |
| class | Decimal64 |
| An exact signed decimal: an int64 coefficient times 10^-scale. More... | |
| struct | DepthLevel |
| One price level of an order book. More... | |
| struct | DepthSnapshot |
| An instrument's order book: resting bids and offers. More... | |
| struct | HoldingPosition |
| One position row in a holdings snapshot. More... | |
| struct | HoldingsSnapshot |
| An account's positions and per-currency totals at one point in time. More... | |
| struct | HoldingsTotals |
| The broker's holdings totals for one currency. More... | |
| struct | Instrument |
| Reference data for one instrument. More... | |
| struct | InstrumentId |
| Identifies an instrument: its country, venue and symbol. More... | |
| struct | MarketSegment |
| The market segment an instrument is listed on, such as KOSPI or NASDAQ. More... | |
| struct | Money |
| An exact amount of money in one currency. More... | |
| struct | OrderAck |
| The broker's acknowledgement that it accepted an instruction. More... | |
| struct | OrderExecution |
| What has filled on one order, and what it cost. More... | |
| struct | OrderHistoryQuery |
| The filter for an order-history inquiry. More... | |
| struct | OrderPage |
| One page of an order listing. More... | |
| struct | OrderRef |
| A broker's reference to one order, used to amend or cancel it. More... | |
| struct | OrderRequest |
| An order to place, in broker-neutral form. More... | |
| struct | OrderShape |
| An order's type, price, trigger, time in force and session, as an amendment states them. More... | |
| struct | OrderSnapshot |
| The state of one order, as a broker listing reported it. More... | |
| struct | PlacedOrder |
| An accepted order: the acknowledgement and the reference to address it with. More... | |
| struct | PriceLimits |
| The highest and lowest price an instrument may trade at today. More... | |
| struct | PriceRule |
| The price grid (tick sizes) an instrument's order prices must sit on. More... | |
| struct | QuoteSnapshot |
| A quote: the last traded price of an instrument at a point in time. More... | |
| class | Result |
| Either a value or a BrokerError. More... | |
| struct | SellableBasis |
| What a sellable quantity covers, and how RiskGuard must treat resting sells against it. More... | |
| class | StatedDate |
| A date a broker stated, did not state, or stated in a form that could not be read. More... | |
| struct | TickBand |
| One band of a price grid: the tick size from a price upward, until the next band. More... | |
| struct | TopOfBook |
| The best bid and offer, with the size at each. An absent field was not stated, never zero. More... | |
| struct | TradePrint |
| One executed trade, as the broker reported it. More... | |
| struct | TradingCalendar |
| The trading days a broker reported for one market, ascending by date. More... | |
| struct | TradingDay |
| One calendar date and whether the market opens on it. More... | |
| class | VenueKey |
| Which venue a commission rate applies to: any venue, a normalized Venue, or a raw code. More... | |
| struct | WorkingOrder |
| An order still open to modification or cancellation. More... | |
| struct | WorkingOrders |
| The orders open to modification or cancellation at one point in time. More... | |
Typedefs | |
| using | tcp = net::ip::tcp |
| Short for boost::asio::ip::tcp. | |
Enumerations | |
| enum class | SecurityType { UNKNOWN , STOCK , FOREIGN_STOCK , DEPOSITARY_RECEIPT , INFRASTRUCTURE_FUND , REIT , ETF , FOREIGN_ETF , ETN , STOCK_WARRANT } |
| What kind of security an instrument is. More... | |
| enum class | InstrumentStatus { UNKNOWN , SCHEDULED , ACTIVE , DELISTED } |
| Whether an instrument is listed, awaiting listing, or delisted. More... | |
| enum class | DateExclusion { EXCLUDED , NOT_EXCLUDED , UNREADABLE } |
| What an instrument's listing and delisting dates say about one day. More... | |
| enum class | BarInterval { ONE_MINUTE , ONE_DAY , ONE_WEEK , ONE_MONTH , ONE_YEAR , FIVE_MINUTES , FIFTEEN_MINUTES , THIRTY_MINUTES , ONE_HOUR } |
| The period one bar covers. More... | |
| enum class | BarStamp { OPEN , CLOSE } |
| Which edge of its period a bar's timestamp marks. More... | |
| enum class | Country { KR , US } |
| A country (market) the library supports. More... | |
| enum class | Venue { UNSPECIFIED , KRX , NXT , COMBINED } |
| A trading venue: an exchange, or the combined view across exchanges. More... | |
| enum class | ErrorCategory { CANCELLED , TRANSPORT , HTTP , AUTHENTICATION , RATE_LIMIT , PROTOCOL , INVALID_ARGUMENT } |
| The kind of failure a BrokerError reports. More... | |
| enum class | SellableSource { HOLDINGS , INQUIRY , NONE } |
| Where the library gets a broker's sellable quantity. More... | |
| enum class | VenueKeyKind { ANY , NORMALIZED , RAW } |
| Which kind of venue a VenueKey names. More... | |
| enum class | CommissionOrigin { BROKER_PUBLISHED , CALLER_STATED } |
| Where a commission schedule's numbers came from. More... | |
| enum class | RateApplicability { NO , YES , UNREADABLE } |
| Whether a commission rate applies on a date. More... | |
| enum class | OrderSide { BUY , SELL } |
| The side of an order: its economic direction, buy or sell. More... | |
| enum class | OrderType { UNKNOWN , LIMIT , MARKET , CONDITIONAL_LIMIT , BEST_LIMIT , PRIMARY_LIMIT , MID_PRICE , STOP_LIMIT , CLOSING_PRICE } |
| How an order's price is decided (its price basis). More... | |
| enum class | TimeInForce { UNKNOWN , DAY , IMMEDIATE_OR_CANCEL , FILL_OR_KILL } |
| How long an order stays valid and what happens to an unfilled remainder. More... | |
| enum class | OrderSession { UNKNOWN , REGULAR , OPENING_AUCTION , CLOSING_AUCTION , PRE_MARKET , AFTER_HOURS , AFTER_HOURS_AUCTION , AFTER_MARKET , GTP } |
| The trading session an order is submitted into. More... | |
| enum class | OrderStatus { UNKNOWN , PENDING , PENDING_CANCEL , PENDING_REPLACE , PARTIAL_FILLED , FILLED , CANCELED , REJECTED , CANCEL_REJECTED , REPLACE_REJECTED , REPLACED } |
| Where an order stands in its lifecycle. More... | |
Functions | |
| constexpr Venue | kis_effective_route (Venue asked) noexcept |
| Returns the venue a KIS order actually reaches. | |
| constexpr Venue | kiwoom_route (Venue asked) noexcept |
| Returns the venue a Kiwoom order reaches: the one it names. Kiwoom has no default venue, so an order naming none is refused before sending. | |
| template<typename Caps> | |
| constexpr bool | reads_every_capability () |
| Reads every capability constant of a capability set, so a missing one fails to compile here. | |
| template<typename Client> | |
| constexpr bool | answers_every_capability () |
| Reads every capability of a client's traits (see reads_every_capability). | |
| template<typename Client, typename CompletionToken> | |
| auto | async_accounts (Client &client, CompletionToken &&token) |
| Lists a broker's accounts, before a session exists; requires BrokerCaps<Client>::has_account_discovery (KIS reads its account from configuration). | |
| template<typename Client> | |
| Result< std::vector< AccountInfo< Client > > > | list_accounts (Client &client) |
| Lists a broker's accounts with a blocking client, before a session exists; requires BrokerCaps<Client>::has_account_discovery. | |
| template<typename Enum, std::size_t N, typename IsEnumerator> | |
| constexpr bool | lists_every_value (const std::array< Enum, N > &values, IsEnumerator is_enumerator) noexcept |
| Tests whether a list holds every value of an enum exactly once, in any order. | |
| template<typename Enum, std::size_t N, typename IsEnumerator> | |
| constexpr bool | lists_every_value (const Enum(&values)[N], IsEnumerator is_enumerator) noexcept |
| Tests whether a list holds every value of an enum exactly once, in any order. | |
| template<typename Enum, std::size_t N, typename Name> | |
| constexpr std::optional< Enum > | value_named (const std::array< Enum, N > &values, Name name, std::string_view text) noexcept |
| Returns the value of a list whose name is text, so a parser reads exactly what its writer writes. | |
| MarketSegment | market_segment (std::string_view code) |
| Maps a broker's segment code to a MarketSegment. | |
| PriceRule | price_rule_for (Country country, SecurityType type) |
| Returns the library's price grid for a kind of security in a country. | |
| constexpr std::string_view | bar_interval_name (BarInterval interval) noexcept |
| Returns a short name for an interval, such as "1m", "5m", "1h" or "1d". | |
| constexpr std::optional< std::chrono::seconds > | bar_interval_length (BarInterval interval) noexcept |
| Returns an interval's fixed length, for an intraday interval. | |
| void | order_depth (DepthSnapshot &book) |
| Sorts a book's levels best first: bids descending, asks ascending. | |
| constexpr std::string_view | venue_name (Venue venue) noexcept |
| Returns a display name for a venue, such as "KRX". | |
| Decimal64 | decimal_normalized (const Decimal64 &value) |
| Removes trailing fractional zeros, so equal numbers compare equal with ==. | |
| std::optional< Decimal64 > | decimal_add (const Decimal64 &lhs, const Decimal64 &rhs) |
| Adds two decimals exactly. | |
| std::optional< Decimal64 > | decimal_subtract (const Decimal64 &lhs, const Decimal64 &rhs) |
| Subtracts two decimals exactly. | |
| std::optional< Decimal64 > | decimal_halve (const Decimal64 &value) |
| Halves a decimal exactly, adding a decimal place when needed. | |
| std::optional< Decimal64 > | decimal_multiply (const Decimal64 &lhs, const Decimal64 &rhs) |
| Multiplies two decimals exactly; the scales add. | |
| std::optional< Decimal64 > | decimal_divide (const Decimal64 &lhs, const Decimal64 &rhs, std::uint8_t scale) |
| Divides two decimals, truncating toward zero at a given scale. | |
| std::optional< Decimal64 > | decimal_floor_to_multiple (const Decimal64 &value, const Decimal64 &step) |
| Rounds down to a multiple of a step (toward negative infinity). | |
| bool | decimal_less (const Decimal64 &lhs, const Decimal64 &rhs) |
| Compares two decimals numerically, whatever their scales. | |
| constexpr bool | error_category_is_rate_limit (ErrorCategory category) noexcept |
| Tests whether an error of this category is a broker asking the caller to slow down, so the request may be tried again later and the pacer should hold. | |
| constexpr std::string_view | sellable_coverage_name (SellableBasis::Coverage coverage) noexcept |
| Returns a lowercase name for a coverage, such as "whole_holding", for logs. | |
| constexpr std::string_view | sellable_resting_name (SellableBasis::RestingTreatment treatment) noexcept |
| Returns a lowercase name for a treatment, such as "deduct", for logs. | |
| constexpr std::string_view | sellable_source_name (SellableSource source) noexcept |
| Returns a lowercase name for a source, such as "inquiry", for logs. | |
| Date | date_from_epoch_days (std::int64_t days) |
| Converts a day count since 1970-01-01 to a Gregorian date. | |
| bool | is_valid_date (const Date &date) |
| Tests whether a date exists in the Gregorian calendar, in years 1 to 9999. | |
| constexpr std::string_view | venue_key_kind_name (VenueKeyKind kind) noexcept |
| Returns a lowercase name for a key kind, such as "raw", for reports. | |
| constexpr bool | commission_origin_is_broker (CommissionOrigin origin) noexcept |
| Tests whether commission rates of this origin came from the broker. | |
| constexpr bool | commission_origin_names_tariff (CommissionOrigin origin) noexcept |
| Tests whether a schedule of this origin must name the tariff it was read from. | |
| constexpr std::string_view | commission_origin_name (CommissionOrigin origin) noexcept |
| Returns a lowercase name for an origin, such as "caller_stated", for reports. | |
| constexpr bool | carries_caller_price (OrderType type) noexcept |
| Tests whether an order type takes a price from the caller. | |
| constexpr bool | carries_trigger_price (OrderType type) noexcept |
| Tests whether an order type takes a trigger price. | |
| constexpr bool | time_in_force_expires_at_close (TimeInForce condition) noexcept |
| Tests whether an order with this condition expires at the session's close, so its filled quantity is final once the session has ended. | |
| constexpr bool | order_status_cancel_pending (OrderStatus status) noexcept |
| Tests whether a cancellation of an order in this status is already on its way, so asking again can only be refused. | |
| std::optional< Decimal64 > | amended_trigger_price (const AmendInstruction &instruction) |
| Returns the trigger price an amendment leaves the order with. | |
| template<typename Broker> | |
| OrderShape | resting_shape (const WorkingOrder< Broker > &order) |
| Returns a working order's current shape. | |
| template<typename Broker> | |
| AmendInstruction | cancel_all (const WorkingOrder< Broker > &order) |
| Makes an instruction cancelling all that remains of an order. | |
| template<typename Broker> | |
| AmendInstruction | cancel_quantity (const WorkingOrder< Broker > &order, Decimal64 quantity) |
| Makes an instruction cancelling part of an order. | |
| template<typename Broker> | |
| AmendInstruction | replace_with (const WorkingOrder< Broker > &order, OrderShape shape, std::optional< Decimal64 > quantity=std::nullopt) |
| Makes an instruction changing a working order to a new shape. | |
| template<typename Broker> | |
| AmendInstruction | reprice (const WorkingOrder< Broker > &order, Decimal64 price, std::optional< Decimal64 > quantity=std::nullopt) |
| Makes an instruction changing only a working order's price. | |
| std::string | format_iso8601_utc (std::chrono::system_clock::time_point value) |
| Formats an instant as an ISO 8601 timestamp in UTC, such as 2026-10-06T00:30:00Z. | |
| std::optional< std::chrono::system_clock::time_point > | parse_iso8601_timestamp (std::string_view value) |
| Parses an ISO 8601 timestamp, YYYY-MM-DDTHH:MM:SS[.fraction] followed by Z or a +hh:mm/-hh:mm offset. | |
Variables | |
| constexpr std::array< BarInterval, 9 > | all_bar_intervals |
| Every BarInterval, in declaration order. | |
| constexpr std::array< Country, 2 > | all_countries {Country::KR, Country::US} |
| Every Country, in declaration order. | |
| constexpr std::array< Venue, 4 > | all_venues {Venue::UNSPECIFIED, Venue::KRX, Venue::NXT, Venue::COMBINED} |
| Every Venue, in declaration order. | |
| constexpr std::array< OrderSide, 2 > | all_order_sides {OrderSide::BUY, OrderSide::SELL} |
| Every OrderSide, in declaration order. | |
| constexpr std::array< OrderType, 9 > | all_order_types |
| Every OrderType, in declaration order. | |
| constexpr std::array< TimeInForce, 4 > | all_times_in_force |
| Every TimeInForce, in declaration order. | |
| constexpr std::array< OrderSession, 9 > | all_order_sessions |
| Every OrderSession, in declaration order. | |
The library: broker-neutral types (core), and the modules below.
Include <algotradelib/core> for orders, quotes, bars, instruments and the calendar, and <algotradelib/broker> for the broker port (BrokerSession, BlockingSession, BrokerTraits, BrokerCaps); each module has its own umbrella header (<algotradelib/runner>, <algotradelib/kis>, ...).
| using algotradelib::tcp = net::ip::tcp |
Short for boost::asio::ip::tcp.
Definition at line 43 of file http_client.hpp.
|
strong |
The period one bar covers.
Only periods a broker publishes; an interval a broker does not publish is refused, not built by aggregating shorter bars.
| Enumerator | |
|---|---|
| FIVE_MINUTES | Five minutes. |
| FIFTEEN_MINUTES | Fifteen minutes. |
| THIRTY_MINUTES | Thirty minutes. |
| ONE_HOUR | Sixty minutes. |
Definition at line 20 of file market_data.hpp.
|
strong |
Which edge of its period a bar's timestamp marks.
Brokers differ: Toss stamps a minute bar at its close (covering [t - 1m, t)) and a daily bar at local midnight, its open; KIS reports a daily bar by its trading date. Reading an open-stamped bar as close-stamped looks ahead by one bar.
| Enumerator | |
|---|---|
| OPEN | The timestamp is the first instant of the period. |
| CLOSE | The timestamp is the instant the period ended. |
Definition at line 117 of file market_data.hpp.
|
strong |
|
strong |
|
strong |
What an instrument's listing and delisting dates say about one day.
Definition at line 459 of file instrument.hpp.
|
strong |
The kind of failure a BrokerError reports.
For an order, runner::outcome_of turns the category into whether the order may exist.
|
strong |
Whether an instrument is listed, awaiting listing, or delisted.
Definition at line 125 of file instrument.hpp.
|
strong |
The trading session an order is submitted into.
A session the broker does not offer is refused on a request before any I/O.
|
strong |
|
strong |
Where an order stands in its lifecycle.
CANCEL_REJECTED, REPLACE_REJECTED and REPLACED describe a cancel or modify instruction, which brokers list as rows of their own. UNKNOWN is a status the library does not recognize; one such row does not fail a listing.
|
strong |
How an order's price is decided (its price basis).
The execution condition is TimeInForce and the session is OrderSession; a broker's single order code (such as KIS ORD_DVSN) maps to all three. A request is accepted only for combinations the broker publishes; an adapter refuses others before any I/O. On a read, an unrecognized combination is UNKNOWN. carries_caller_price says which bases take a price.
|
strong |
Whether a commission rate applies on a date.
|
strong |
What kind of security an instrument is.
UNKNOWN appears only on reads, for a type the library does not normalize.
Definition at line 111 of file instrument.hpp.
|
strong |
|
strong |
How long an order stays valid and what happens to an unfilled remainder.
The session is a separate field, OrderSession: an at-the-close order is DAY in the CLOSING_AUCTION session. UNKNOWN appears only on reads, never on requests.
|
strong |
|
strong |
|
inline |
Returns the trigger price an amendment leaves the order with.
| instruction | The amendment. |
Definition at line 2271 of file types.hpp.
Referenced by amended_trigger_price().
|
constexpr |
Reads every capability of a client's traits (see reads_every_capability).
| Client | The broker client type. |
Definition at line 259 of file broker_caps.hpp.
Referenced by answers_every_capability().
| auto algotradelib::async_accounts | ( | Client & | client, |
| CompletionToken && | token ) |
Lists a broker's accounts, before a session exists; requires BrokerCaps<Client>::has_account_discovery (KIS reads its account from configuration).
| Client | An asynchronous broker client type. |
| CompletionToken | A completion token for void(Result<std::vector<AccountInfo<Client>>>). |
| client | The client. |
| token | The completion token; the handler runs once, on its associated executor. |
Definition at line 1274 of file broker_session.hpp.
Referenced by async_accounts(), and algotradelib::conformance::call_claimed_async_verbs().
|
inlineconstexprnoexcept |
Returns an interval's fixed length, for an intraday interval.
| interval | The interval. |
Definition at line 84 of file market_data.hpp.
Referenced by bar_interval_length(), and algotradelib::backtest::interval_duration().
|
inlineconstexprnoexcept |
Returns a short name for an interval, such as "1m", "5m", "1h" or "1d".
| interval | The interval. |
Definition at line 54 of file market_data.hpp.
Referenced by bar_interval_name(), algotradelib::kis::unsupported_bar_interval(), and algotradelib::kiwoom::unsupported_bar_interval().
|
inline |
Makes an instruction cancelling all that remains of an order.
| Broker | The broker tag. |
| order | The working order. |
Definition at line 2362 of file types.hpp.
Referenced by algotradelib::live::SessionExecutor< Session >::cancel(), and cancel_all().
|
inline |
Makes an instruction cancelling part of an order.
| Broker | The broker tag. |
| order | The working order. |
| quantity | The quantity to cancel; check BrokerCaps::has_partial_cancel first. |
Definition at line 2385 of file types.hpp.
Referenced by cancel_quantity().
|
inlineconstexprnoexcept |
Tests whether an order type takes a price from the caller.
A type that does not is sent without a price; a type that does must have one.
| type | The order type. |
Definition at line 1748 of file types.hpp.
Referenced by carries_caller_price(), and algotradelib::runner::unresolvable_reason().
|
inlineconstexprnoexcept |
Tests whether an order type takes a trigger price.
A trigger stated on any other type is refused, not dropped. The trigger's direction, tick grid and relation to the limit are the broker's rules and are not checked by the library.
| type | The order type. |
Definition at line 1774 of file types.hpp.
Referenced by amended_trigger_price(), carries_trigger_price(), algotradelib::backtest::NextBarFillModel::decide(), algotradelib::kiwoom::invalid_trigger(), algotradelib::strategy::is_stop_order(), and algotradelib::runner::unresolvable_reason().
|
inlineconstexprnoexcept |
Tests whether commission rates of this origin came from the broker.
| origin | The origin. |
Definition at line 1386 of file types.hpp.
Referenced by algotradelib::backtest::commission_model_from(), and commission_origin_is_broker().
|
inlineconstexprnoexcept |
Returns a lowercase name for an origin, such as "caller_stated", for reports.
| origin | The origin. |
Definition at line 1416 of file types.hpp.
Referenced by commission_origin_name().
|
inlineconstexprnoexcept |
Tests whether a schedule of this origin must name the tariff it was read from.
| origin | The origin. |
Definition at line 1401 of file types.hpp.
Referenced by commission_origin_names_tariff(), and algotradelib::backtest::CommissionPolicy::scheduled().
|
inline |
Converts a day count since 1970-01-01 to a Gregorian date.
Howard Hinnant's civil_from_days, exact for any day count whose year fits an int (far beyond years 1 to 9999). The result is not checked against is_valid_date's year range.
| days | Days after 1970-01-01; negative counts go backwards. |
Definition at line 1186 of file types.hpp.
Referenced by date_from_epoch_days(), and algotradelib::strategy::SessionWindow::local_date().
|
inline |
Adds two decimals exactly.
| lhs | The first addend. |
| rhs | The second addend. |
Definition at line 509 of file types.hpp.
Referenced by algotradelib::runner::ChargedCosts::add(), algotradelib::backtest::ReplayLedger::apply(), algotradelib::backtest::SlippageModel::apply(), algotradelib::strategy::closes_toward_flat(), decimal_add(), algotradelib::backtest::ReplayLedger::equity_in(), algotradelib::strategy::RiskGuard::evaluate(), algotradelib::DepthSnapshot::mid(), algotradelib::strategy::Portfolio< Broker >::net_quantity_of(), algotradelib::strategy::projected_gross_exposure(), algotradelib::strategy::reconcile(), algotradelib::PriceRule::round_to_tick(), and algotradelib::strategy::Portfolio< Broker >::working_quantity().
|
inline |
Divides two decimals, truncating toward zero at a given scale.
decimal_divide(x, y, 0) is the number of whole y in x, as when sizing an order in shares.
| lhs | The dividend. |
| rhs | The divisor. |
| scale | The number of fractional digits to keep. |
Definition at line 602 of file types.hpp.
Referenced by algotradelib::backtest::SlippageModel::apply(), decimal_divide(), algotradelib::backtest::CommissionModel::on(), algotradelib::strategy::vanilla::VolatilityTargetSizing::on_bar(), algotradelib::strategy::vanilla::EqualWeightRebalance::on_phase(), algotradelib::strategy::reconcile(), and algotradelib::strategy::weight_target().
|
inline |
Rounds down to a multiple of a step (toward negative infinity).
The result is never greater than value, on either side of zero.
| value | The value. |
| step | The step, such as a lot size; must be positive. |
Definition at line 639 of file types.hpp.
Referenced by algotradelib::backtest::NextBarFillModel::decide(), and decimal_floor_to_multiple().
Halves a decimal exactly, adding a decimal place when needed.
| value | The value. |
Definition at line 549 of file types.hpp.
Referenced by decimal_halve(), and algotradelib::DepthSnapshot::mid().
Compares two decimals numerically, whatever their scales.
| lhs | The first value. |
| rhs | The second value. |
Definition at line 665 of file types.hpp.
Referenced by algotradelib::backtest::ReplayLedger::apply(), algotradelib::backtest::SlippageModel::apply(), algotradelib::strategy::closes_toward_flat(), algotradelib::runner::Runner< Strategy, CapsType, Tag, Executor >::confirm_from_history(), algotradelib::backtest::NextBarFillModel::decide(), decimal_less(), algotradelib::strategy::RiskGuard::evaluate(), algotradelib::backtest::CommissionModel::on(), algotradelib::strategy::vanilla::VolatilityTargetSizing::on_bar(), order_depth(), algotradelib::strategy::projected_gross_exposure(), algotradelib::strategy::reconcile(), algotradelib::strategy::Portfolio< Broker >::sellable_reading_for(), algotradelib::PriceRule::tick_at(), algotradelib::strategy::weight_target(), algotradelib::backtest::NextBarFillModel::with_sell_tax(), and algotradelib::strategy::Portfolio< Broker >::working_quantity().
|
inline |
Multiplies two decimals exactly; the scales add.
| lhs | The first factor. |
| rhs | The second factor. |
Definition at line 571 of file types.hpp.
Referenced by algotradelib::backtest::ReplayLedger::apply(), algotradelib::backtest::SlippageModel::apply(), algotradelib::backtest::NextBarFillModel::decide(), decimal_multiply(), algotradelib::backtest::ReplayLedger::equity_in(), algotradelib::strategy::RiskGuard::evaluate(), algotradelib::backtest::ReplayLedger::mark(), algotradelib::backtest::CommissionModel::on(), algotradelib::strategy::projected_gross_exposure(), algotradelib::strategy::reconcile(), and algotradelib::strategy::weight_target().
Removes trailing fractional zeros, so equal numbers compare equal with ==.
| value | The value. |
Definition at line 455 of file types.hpp.
Referenced by decimal_add(), decimal_divide(), decimal_floor_to_multiple(), decimal_halve(), decimal_multiply(), decimal_normalized(), decimal_subtract(), and algotradelib::PriceRule::round_to_tick().
|
inline |
Subtracts two decimals exactly.
| lhs | The minuend. |
| rhs | The subtrahend. |
Definition at line 530 of file types.hpp.
Referenced by algotradelib::backtest::ReplayLedger::apply(), algotradelib::backtest::SlippageModel::apply(), algotradelib::strategy::closes_toward_flat(), algotradelib::backtest::NextBarFillModel::decide(), decimal_subtract(), algotradelib::strategy::RiskGuard::evaluate(), algotradelib::strategy::projected_gross_exposure(), algotradelib::strategy::reconcile(), algotradelib::runner::Runner< Strategy, CapsType, Tag, Executor >::retry_retained_targets(), algotradelib::PriceRule::round_to_tick(), algotradelib::runner::ChargedCosts::since(), algotradelib::DepthSnapshot::spread(), and algotradelib::strategy::Portfolio< Broker >::working_quantity().
|
inlineconstexprnoexcept |
Tests whether an error of this category is a broker asking the caller to slow down, so the request may be tried again later and the pacer should hold.
| category | The category. |
Definition at line 722 of file types.hpp.
Referenced by algotradelib::runner::broker_rate_limited(), error_category_is_rate_limit(), and algotradelib::live::poll_outcome_of().
|
inline |
Formats an instant as an ISO 8601 timestamp in UTC, such as 2026-10-06T00:30:00Z.
| value | The instant; fractions of a second are dropped. |
Definition at line 2453 of file types.hpp.
Referenced by format_iso8601_utc(), and algotradelib::runner::journal_entry_to_line().
|
inline |
Tests whether a date exists in the Gregorian calendar, in years 1 to 9999.
| date | The date. |
Definition at line 1212 of file types.hpp.
Referenced by is_valid_date(), and parse_iso8601_timestamp().
Returns the venue a KIS order actually reaches.
| asked | The order's venue. |
Definition at line 394 of file traits.hpp.
Referenced by algotradelib::BrokerTraits< kis::KisBlockingClient >::effective_route(), algotradelib::BrokerTraits< kis::KisClient >::effective_route(), and kis_effective_route().
Returns the venue a Kiwoom order reaches: the one it names. Kiwoom has no default venue, so an order naming none is refused before sending.
| asked | The order's venue. |
Definition at line 573 of file traits.hpp.
Referenced by algotradelib::BrokerTraits< kiwoom::KiwoomBlockingClient >::effective_route(), algotradelib::BrokerTraits< kiwoom::KiwoomClient >::effective_route(), and kiwoom_route().
| Result< std::vector< AccountInfo< Client > > > algotradelib::list_accounts | ( | Client & | client | ) |
Lists a broker's accounts with a blocking client, before a session exists; requires BrokerCaps<Client>::has_account_discovery.
| Client | A blocking broker client type. |
| client | The client. |
Definition at line 1311 of file broker_session.hpp.
Referenced by algotradelib::conformance::call_claimed_blocking_verbs(), and list_accounts().
|
constexprnoexcept |
Tests whether a list holds every value of an enum exactly once, in any order.
The same check for a built-in array, such as runner::all_poll_kinds.
| Enum | The enum. |
| N | The list's length. |
| IsEnumerator | A callable taking an Enum and returning bool. |
| values | The list. |
| is_enumerator | Whether a value is one of the enum's. |
Definition at line 107 of file enum_values.hpp.
|
constexprnoexcept |
Tests whether a list holds every value of an enum exactly once, in any order.
The enum must be scoped (enum class), and its values 0 to N - 1: no enumerator may state its own value. Then N distinct enumerators below N are all of them, and N itself must not be one, or the enum is longer than the list (unless N values already fill the underlying type).
Use it in a static_assert beside the list. Pass a test that is true exactly for the enum's values, such as the enum's name function, whose switch has a case for each value and returns "" after it:
| Enum | The enum. |
| N | The list's length. |
| IsEnumerator | A callable taking an Enum and returning bool. |
| values | The list. |
| is_enumerator | Whether a value is one of the enum's. |
Definition at line 86 of file enum_values.hpp.
Referenced by lists_every_value(), and lists_every_value().
|
inline |
Maps a broker's segment code to a MarketSegment.
| code | The code, such as "KOSDAQ". |
Definition at line 88 of file instrument.hpp.
Referenced by market_segment().
|
inline |
Sorts a book's levels best first: bids descending, asks ascending.
| book | The book to sort in place. |
Definition at line 274 of file market_data.hpp.
Referenced by order_depth().
|
inlineconstexprnoexcept |
Tests whether a cancellation of an order in this status is already on its way, so asking again can only be refused.
| status | The status. |
Definition at line 1899 of file types.hpp.
Referenced by order_status_cancel_pending(), and algotradelib::strategy::reconcile().
|
inline |
Parses an ISO 8601 timestamp, YYYY-MM-DDTHH:MM:SS[.fraction] followed by Z or a +hh:mm/-hh:mm offset.
Fractional seconds are truncated to the millisecond.
| value | The text, such as 2026-10-06T09:30:00.250+09:00. |
Definition at line 2478 of file types.hpp.
Referenced by parse_iso8601_timestamp().
|
inline |
Returns the library's price grid for a kind of security in a country.
KRX stocks, foreign stocks, depositary receipts, infrastructure funds and REITs get the equity table; ETFs, ETNs, warrants and unknown types get an UNKNOWN rule. US listings are unconstrained, whatever their type.
| country | The listing country. |
| type | The security type. |
Definition at line 333 of file instrument.hpp.
Referenced by price_rule_for().
|
constexpr |
Reads every capability constant of a capability set, so a missing one fails to compile here.
| Caps | BrokerCaps<Client>, or a hand-written set such as strategy::NoCaps. |
Definition at line 217 of file broker_caps.hpp.
Referenced by answers_every_capability(), and reads_every_capability().
|
inline |
Makes an instruction changing a working order to a new shape.
An unset time in force or session stays as the order has it; an unset trigger stays only if both shape and the order are STOP_LIMIT (see amended_trigger_price). A set value is a deliberate change, made where the broker can and refused where it cannot. To change only the price, use reprice.
| Broker | The broker tag. |
| order | The working order. |
| shape | The new shape, such as OrderShape{OrderType::LIMIT, price}. |
| quantity | The quantity to amend, or unset for all that remains. |
Definition at line 2414 of file types.hpp.
Referenced by replace_with(), and reprice().
|
inline |
Makes an instruction changing only a working order's price.
| Broker | The broker tag. |
| order | The working order. |
| price | The new price. |
| quantity | The quantity to amend, or unset for all that remains. |
Definition at line 2438 of file types.hpp.
Referenced by reprice().
|
inline |
Returns a working order's current shape.
| Broker | The broker tag. |
| order | The working order. |
Definition at line 2345 of file types.hpp.
Referenced by replace_with(), reprice(), and resting_shape().
|
inlineconstexprnoexcept |
Returns a lowercase name for a coverage, such as "whole_holding", for logs.
| coverage | The coverage. |
Definition at line 987 of file types.hpp.
Referenced by sellable_coverage_name().
|
inlineconstexprnoexcept |
Returns a lowercase name for a treatment, such as "deduct", for logs.
| treatment | The treatment. |
Definition at line 1005 of file types.hpp.
Referenced by sellable_resting_name().
|
inlineconstexprnoexcept |
Returns a lowercase name for a source, such as "inquiry", for logs.
| source | The source. |
Definition at line 1106 of file types.hpp.
Referenced by sellable_source_name().
|
inlineconstexprnoexcept |
Tests whether an order with this condition expires at the session's close, so its filled quantity is final once the session has ended.
| condition | The condition. |
Definition at line 1822 of file types.hpp.
Referenced by algotradelib::runner::Runner< Strategy, CapsType, Tag, Executor >::feed(), and time_in_force_expires_at_close().
|
constexprnoexcept |
Returns the value of a list whose name is text, so a parser reads exactly what its writer writes.
| Enum | The enum. |
| N | The list's length. |
| Name | A callable taking an Enum and returning something comparable with std::string_view. |
| values | Every value of the enum, such as all_venues. |
| name | The name function the writer uses. |
| text | The text to read. |
Definition at line 129 of file enum_values.hpp.
Referenced by algotradelib::runner::journal_action_from(), algotradelib::runner::journal_outcome_from(), algotradelib::runner::stop_intent_from(), and value_named().
|
inlineconstexprnoexcept |
Returns a lowercase name for a key kind, such as "raw", for reports.
| kind | The kind. |
Definition at line 1361 of file types.hpp.
Referenced by venue_key_kind_name().
|
inlineconstexprnoexcept |
Returns a display name for a venue, such as "KRX".
| venue | The venue. |
Definition at line 58 of file types.hpp.
Referenced by venue_name().
|
inlineconstexpr |
Every BarInterval, in declaration order.
Definition at line 37 of file market_data.hpp.
|
inlineconstexpr |
|
inlineconstexpr |
Every OrderSession, in declaration order.
|
inlineconstexpr |
|
inlineconstexpr |
Every OrderType, in declaration order.
|
inlineconstexpr |
Every TimeInForce, in declaration order.