Slick Trader 0.11.0
Multi-broker algorithmic trading engine with plugin strategies and a live web dashboard
Loading...
Searching...
No Matches
order_entry.cpp
Go to the documentation of this file.
2#include <slick/logger.hpp>
3
4namespace slick::trader {
5
6const char* post_only_problem(PostOnlyPolicy policy, const SharedTopOfBook* top, Side side, OrderType type,
7 TimeInForce tif, price_t price, bool& warned, std::string_view who) {
8 if (!rests(type, tif)) {
9 return nullptr;
10 }
11 switch (policy) {
13 return "this exchange takes no post-only orders (post_only_policy is \"reject\")";
15 if (!warned) {
16 warned = true;
17 LOG_WARN("{}: \"post_only_policy\" is \"accept\" - post-only orders are sent as ordinary orders and can "
18 "take liquidity",
19 who);
20 }
21 return nullptr;
23 return nullptr; // the exchange itself will not match it on entry
25 break;
26 }
27 if (!top) {
28 return "post-only cannot be checked: the instrument has no market data";
29 }
30 // The one side the order could trade against, as the market data worker last built it.
31 const price_t opposite = (side == Side::BUY ? top->ask : top->bid).load(std::memory_order_acquire);
32 if (opposite == SharedTopOfBook::UNKNOWN) {
33 return "post-only cannot be checked: the book is not in sequence";
34 }
35 if (opposite == SharedTopOfBook::EMPTY) {
36 return nullptr; // nothing to trade against
37 }
38 return (side == Side::BUY ? price >= opposite : price <= opposite) ? "post-only order would cross the book"
39 : nullptr;
40}
41
42} // namespace slick::trader
int64_t price_t
Definition types.hpp:16
const char * post_only_problem(PostOnlyPolicy policy, const SharedTopOfBook *top, Side side, OrderType type, TimeInForce tif, price_t price, bool &warned, std::string_view who)
bool rests(OrderType type, TimeInForce tif) noexcept
static constexpr price_t UNKNOWN