![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
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. | |
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.
|
inlinenoexcept |
Returns the idempotency key.
Definition at line 416 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns the instrument to trade.
Definition at line 368 of file intent.hpp.
Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns the limit price.
Definition at line 398 of file intent.hpp.
|
inlinestatic |
Makes a limit order.
| instrument | The instrument to trade. |
| side | Buy or sell. |
| size | How much to trade; see SizeSpec. |
| limit | The limit price. |
| time_in_force | How long the order stays valid. |
Definition at line 261 of file intent.hpp.
Referenced by limit(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
inlinestatic |
Makes a market order, which carries no price.
| instrument | The instrument to trade. |
| side | Buy or sell. |
| size | How much to trade; see SizeSpec. |
| time_in_force | How long the order stays valid. |
Definition at line 322 of file intent.hpp.
Referenced by algotradelib::strategy::vanilla::EqualWeightRebalance::on_phase().
|
inlinenoexcept |
Returns the side.
Definition at line 374 of file intent.hpp.
Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns how much to trade.
Definition at line 392 of file intent.hpp.
Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
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.
| instrument | The instrument to trade. |
| side | Buy or sell. |
| size | How much to trade; see SizeSpec. |
| trigger | The price that releases the order. |
| limit | The limit price once released. |
| time_in_force | How long the order stays valid. |
Definition at line 294 of file intent.hpp.
|
inlinenoexcept |
Returns the tag.
Definition at line 410 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile(), algotradelib::strategy::weight_target(), and with_tag().
|
inlinenoexcept |
Returns how long the order stays valid.
Definition at line 386 of file intent.hpp.
Referenced by limit(), market(), algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns the trigger price.
Definition at line 404 of file intent.hpp.
Referenced by algotradelib::strategy::reconcile(), stop_limit(), and algotradelib::strategy::weight_target().
|
inlinenoexcept |
Returns the order type.
Definition at line 380 of file intent.hpp.
|
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.
| key | The key. |
Definition at line 358 of file intent.hpp.
|
inline |
Returns a copy with a tag.
| tag | A label of your choice, carried to the order and its fills; the library does not interpret it. |
Definition at line 343 of file intent.hpp.