One order a strategy asks the runner to place.
More...
#include <algotradelib/src/strategy/intent.hpp>
|
| const std::optional< Price > & | limit () const noexcept |
| | Returns the limit price.
|
| 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 > & | 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 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.
◆ client_order_id()
◆ instrument()
Returns the instrument to trade.
- Returns
- The instrument.
Definition at line 368 of file intent.hpp.
◆ limit() [1/2]
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]
Makes a limit order.
- Parameters
-
| 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. |
- Returns
- The intent.
Definition at line 261 of file intent.hpp.
◆ market()
Makes a market order, which carries no price.
- Parameters
-
| 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. |
- Returns
- The intent.
Definition at line 322 of file intent.hpp.
◆ side()
Returns the side.
- Returns
- Buy or sell.
Definition at line 374 of file intent.hpp.
◆ size()
Returns how much to trade.
- Returns
- The size.
Definition at line 392 of file intent.hpp.
◆ stop_limit()
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
-
| 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. |
- Returns
- The intent.
Definition at line 294 of file intent.hpp.
◆ tag()
Returns the tag.
- Returns
- The label set with with_tag, or an empty string.
Definition at line 410 of file intent.hpp.
◆ time_in_force()
Returns how long the order stays valid.
- Returns
- The time in force.
Definition at line 386 of file intent.hpp.
◆ trigger()
Returns the trigger price.
- Returns
- The trigger for a stop-limit order; std::nullopt otherwise.
Definition at line 404 of file intent.hpp.
◆ type()
Returns the order type.
- Returns
- LIMIT, MARKET or STOP_LIMIT.
Definition at line 380 of file intent.hpp.
◆ with_client_order_id()
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
-
- Returns
- The copy carrying key.
Definition at line 358 of file intent.hpp.
◆ with_tag()
Returns a copy with a tag.
- Parameters
-
| tag | A 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: