algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::OrderIntent Class Reference

One order a strategy asks the runner to place. More...

#include <algotradelib/src/strategy/intent.hpp>

Public Member Functions

OrderIntent with_tag (std::string tag) const
 Returns a copy with a tag.
OrderIntent with_client_order_id (std::string key) const
 Returns a copy with a broker idempotency key.
const InstrumentId & instrument () const noexcept
 Returns the instrument to trade.
OrderSide side () const noexcept
 Returns the side.
OrderType type () const noexcept
 Returns the order type.
TimeInForce time_in_force () const noexcept
 Returns how long the order stays valid.
const SizeSpec & size () const noexcept
 Returns how much to trade.
const std::optional< Price > & limit () const noexcept
 Returns the limit price.
const std::optional< Price > & trigger () const noexcept
 Returns the trigger price.
const std::string & tag () const noexcept
 Returns the tag.
const std::optional< std::string > & client_order_id () const noexcept
 Returns the idempotency key.

Static Public Member Functions

static OrderIntent limit (InstrumentId instrument, OrderSide side, SizeSpec size, Price limit, TimeInForce time_in_force=TimeInForce::DAY)
 Makes a limit order.
static OrderIntent stop_limit (InstrumentId instrument, OrderSide side, SizeSpec size, Price trigger, Price limit, TimeInForce time_in_force=TimeInForce::DAY)
 Makes a stop-limit order: a limit order the broker releases when the trigger price is reached.
static OrderIntent market (InstrumentId instrument, OrderSide side, SizeSpec size, TimeInForce time_in_force=TimeInForce::DAY)
 Makes a market order, which carries no price.

Detailed Description

One order a strategy asks the runner to place.

Make one with limit, market or stop_limit; add a tag with with_tag and an idempotency key with with_client_order_id. Submit it with ctx.submit(intent).

Definition at line 249 of file intent.hpp.

Member Function Documentation

◆ client_order_id()

const std::optional< std::string > & algotradelib::strategy::OrderIntent::client_order_id ( ) const
inlinenoexcept

Returns the idempotency key.

Returns
The key set with with_client_order_id, or std::nullopt.

Definition at line 416 of file intent.hpp.

Referenced by algotradelib::strategy::reconcile(), and algotradelib::strategy::weight_target().

◆ instrument()

const InstrumentId & algotradelib::strategy::OrderIntent::instrument ( ) const
inlinenoexcept

Returns the instrument to trade.

Returns
The instrument.

Definition at line 368 of file intent.hpp.

Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ limit() [1/2]

const std::optional< Price > & algotradelib::strategy::OrderIntent::limit ( ) const
inlinenoexcept

Returns the limit price.

Returns
The price for a limit or stop-limit order; std::nullopt for a market order.

Definition at line 398 of file intent.hpp.

◆ limit() [2/2]

OrderIntent algotradelib::strategy::OrderIntent::limit ( InstrumentId instrument,
OrderSide side,
SizeSpec size,
Price limit,
TimeInForce time_in_force = TimeInForce::DAY )
inlinestatic

Makes a limit order.

Parameters
instrumentThe instrument to trade.
sideBuy or sell.
sizeHow much to trade; see SizeSpec.
limitThe limit price.
time_in_forceHow long the order stays valid.
Returns
The intent.

Definition at line 261 of file intent.hpp.

Referenced by limit(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ market()

OrderIntent algotradelib::strategy::OrderIntent::market ( InstrumentId instrument,
OrderSide side,
SizeSpec size,
TimeInForce time_in_force = TimeInForce::DAY )
inlinestatic

Makes a market order, which carries no price.

Parameters
instrumentThe instrument to trade.
sideBuy or sell.
sizeHow much to trade; see SizeSpec.
time_in_forceHow long the order stays valid.
Returns
The intent.

Definition at line 322 of file intent.hpp.

Referenced by algotradelib::strategy::vanilla::EqualWeightRebalance::on_phase().

◆ side()

OrderSide algotradelib::strategy::OrderIntent::side ( ) const
inlinenoexcept

Returns the side.

Returns
Buy or sell.

Definition at line 374 of file intent.hpp.

Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ size()

const SizeSpec & algotradelib::strategy::OrderIntent::size ( ) const
inlinenoexcept

Returns how much to trade.

Returns
The size.

Definition at line 392 of file intent.hpp.

Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ stop_limit()

OrderIntent algotradelib::strategy::OrderIntent::stop_limit ( InstrumentId instrument,
OrderSide side,
SizeSpec size,
Price trigger,
Price limit,
TimeInForce time_in_force = TimeInForce::DAY )
inlinestatic

Makes a stop-limit order: a limit order the broker releases when the trigger price is reached.

Which direction of move reaches the trigger, and how the trigger may relate to the limit, is the broker's rule and is not checked here. A backtest models the release and the fill with stated assumptions and counts them in ReportCaveats; see NextBarFillModel::decide.

Parameters
instrumentThe instrument to trade.
sideBuy or sell.
sizeHow much to trade; see SizeSpec.
triggerThe price that releases the order.
limitThe limit price once released.
time_in_forceHow long the order stays valid.
Returns
The intent.

Definition at line 294 of file intent.hpp.

◆ tag()

const std::string & algotradelib::strategy::OrderIntent::tag ( ) const
inlinenoexcept

Returns the tag.

Returns
The label set with with_tag, or an empty string.

Definition at line 410 of file intent.hpp.

Referenced by algotradelib::strategy::reconcile(), algotradelib::strategy::weight_target(), and with_tag().

◆ time_in_force()

TimeInForce algotradelib::strategy::OrderIntent::time_in_force ( ) const
inlinenoexcept

Returns how long the order stays valid.

Returns
The time in force.

Definition at line 386 of file intent.hpp.

Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ trigger()

const std::optional< Price > & algotradelib::strategy::OrderIntent::trigger ( ) const
inlinenoexcept

Returns the trigger price.

Returns
The trigger for a stop-limit order; std::nullopt otherwise.

Definition at line 404 of file intent.hpp.

Referenced by algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().

◆ type()

OrderType algotradelib::strategy::OrderIntent::type ( ) const
inlinenoexcept

Returns the order type.

Returns
LIMIT, MARKET or STOP_LIMIT.

Definition at line 380 of file intent.hpp.

◆ with_client_order_id()

OrderIntent algotradelib::strategy::OrderIntent::with_client_order_id ( std::string key) const
inline

Returns a copy with a broker idempotency key.

Set it only where Ctx::caps::has_client_order_id is true (test it with if constexpr): a runner whose broker has no idempotency key refuses the intent rather than dropping the key.

Parameters
keyThe key.
Returns
The copy carrying key.

Definition at line 358 of file intent.hpp.

◆ with_tag()

OrderIntent algotradelib::strategy::OrderIntent::with_tag ( std::string tag) const
inline

Returns a copy with a tag.

Parameters
tagA label of your choice, carried to the order and its fills; the library does not interpret it.
Returns
The tagged copy.

Definition at line 343 of file intent.hpp.


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