algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
reconcile.hpp File Reference

Reconciliation: turning a strategy's intents and targets into the orders and cancellations to send. More...

#include "./intent.hpp"
#include "./portfolio.hpp"
#include <algotradelib/core>
#include <optional>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for reconcile.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  algotradelib::strategy::Rejection
 One instruction that was not placed, and why. More...
struct  algotradelib::strategy::PlannedOrder
 One order the runner is to place. More...
struct  algotradelib::strategy::Plan< Broker >
 What to send: first every cancellation, then every placement. More...
struct  algotradelib::strategy::TradeTolerance
 How small a difference from a target is not worth an order. More...
struct  algotradelib::strategy::ReconcileInputs
 What reconciliation needs besides the intent and the portfolio; the runner fills it in. More...
struct  algotradelib::strategy::WeightTarget
 The result of weight_target: a target position or a refusal, exactly one of them. More...

Namespaces

namespace  algotradelib
 The library: broker-neutral types (core), and the modules below.
namespace  algotradelib::strategy
 What a strategy sees and emits: events, intents, the portfolio, reconciliation and risk limits.

Enumerations

enum class  algotradelib::strategy::RejectReason {
  algotradelib::strategy::NO_REFERENCE_DATA , algotradelib::strategy::UNKNOWN_PRICE_GRID , algotradelib::strategy::NO_PRICE_AVAILABLE , algotradelib::strategy::NO_PORTFOLIO_VALUE ,
  algotradelib::strategy::QUANTITY_ROUNDS_TO_ZERO , algotradelib::strategy::NOT_REPRESENTABLE , algotradelib::strategy::NO_PERMITTED_PRICE , algotradelib::strategy::BROKER_REFUSED ,
  algotradelib::strategy::BINDING_REFUSED , algotradelib::strategy::TRIGGER_OFF_GRID , algotradelib::strategy::STOP_ORDER_RESTING , algotradelib::strategy::UNSUPPORTED_WEIGHT ,
  algotradelib::strategy::NEGATIVE_SIZE
}
 Why an instruction was not placed. More...

Functions

constexpr std::string_view algotradelib::strategy::reject_reason_name (RejectReason reason) noexcept
 Returns a lowercase name for a reason, such as "no_reference_data", for logs.
bool algotradelib::strategy::is_stop_order (const OrderSnapshot &order)
 Tests whether a working order is a stop order: a trigger-price type, or one carrying a trigger price.
template<typename Broker>
Plan< Broker > algotradelib::strategy::reconcile (const TargetPosition &target, const Portfolio< Broker > &portfolio, const ReconcileInputs &inputs)
 Plans the cancellations and the order that move a holding to a target position.
template<typename Broker>
Plan< Broker > algotradelib::strategy::reconcile (const OrderIntent &intent, const Portfolio< Broker > &portfolio, const ReconcileInputs &inputs)
 Plans the order for one intent, without comparing against the portfolio.
WeightTarget algotradelib::strategy::weight_target (const OrderIntent &intent, const ReconcileInputs &inputs)
 Converts a weight-sized intent into the target position it states.

Detailed Description

Reconciliation: turning a strategy's intents and targets into the orders and cancellations to send.

The reconcile functions are pure: no I/O and no state. A target is compared with the position plus the orders already working, so restating it does not order twice. A buy above the day's band is clamped down to it and a sell below it up (a less aggressive price is left as it is), prices are rounded onto the tick grid, and quantities rounded down onto the lot; each adjustment is flagged on the PlannedOrder.

Definition in file reconcile.hpp.