From e87e834adc627660eacd06a9ff2d2587a67b762e Mon Sep 17 00:00:00 2001 From: Anatoly Kalin Date: Tue, 29 Aug 2023 19:54:49 +0300 Subject: [PATCH] [EN-7409] Implement WriteTapeFile sample --- .../entity/SharedEntity.hpp | 4 + .../event/market/Order.hpp | 776 +++++++++++++++++- .../event/market/OrderBase.hpp | 19 +- .../event/market/Quote.hpp | 125 ++- .../event/market/SpreadOrder.hpp | 775 ++++++++++++++++- samples/cpp/WriteTapeFile/CMakeLists.txt | 25 +- 6 files changed, 1674 insertions(+), 50 deletions(-) diff --git a/include/dxfeed_graal_cpp_api/entity/SharedEntity.hpp b/include/dxfeed_graal_cpp_api/entity/SharedEntity.hpp index d75b019e..511862d5 100644 --- a/include/dxfeed_graal_cpp_api/entity/SharedEntity.hpp +++ b/include/dxfeed_graal_cpp_api/entity/SharedEntity.hpp @@ -36,6 +36,8 @@ struct DXFCPP_EXPORT SharedEntity : public Entity, std::enable_shared_from_this< /** * Returns a pointer to the current object wrapped in a smart pointer to type T * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new T(...))` or `std::make_shared(...)` + * * @tparam T The type to convert to a pointer to * @return a smart pointer to type T */ @@ -46,6 +48,8 @@ struct DXFCPP_EXPORT SharedEntity : public Entity, std::enable_shared_from_this< /** * Returns a pointer to the current object wrapped in a smart pointer to type T * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new T(...))` or `std::make_shared(...)` + * * @tparam T The type to convert to a pointer to * @return a smart pointer to type T */ diff --git a/include/dxfeed_graal_cpp_api/event/market/Order.hpp b/include/dxfeed_graal_cpp_api/event/market/Order.hpp index d660bb32..b1e17ea3 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Order.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Order.hpp @@ -30,9 +30,8 @@ struct EventMapper; * multiple sources for the same market symbol and are distinguished by their @ref Order::getIndex "index". Index is a * unique per symbol identifier of the event. * It is unique across all the sources of depth information for the symbol. - * The event with @ref Order::getSize() "size" either `0` or `NaN` is a signal to remove previously received order for the - * corresponding index. - * The method Order::hasSize() is a convenient method to test for size presence. + * The event with @ref Order::getSize() "size" either `0` or `NaN` is a signal to remove previously received order for + * the corresponding index. The method Order::hasSize() is a convenient method to test for size presence. * *

Events from finer-grained Scope of detail give more information and include events * from coarse-grained Scope of detail. For a consistent representation of the market depth @@ -54,12 +53,13 @@ struct EventMapper; *

Publishing order books

* * When publishing an order event with DXPublisher::publishEvents() method, least significant 32 bits of - * order @ref Order::getIndex() "index" must be in a range of from 0 to `std::numeric_limits::max()` inclusive. - * Use Order::setSource() method after Order::setIndex() to properly include source identifier into the index. + * order @ref Order::getIndex() "index" must be in a range of from 0 to `std::numeric_limits::max()` + * inclusive. Use Order::setSource() method after Order::setIndex() to properly include source identifier into the + * index. * * A snapshot has to be published in the descending order of @ref Order::getIndex() "index", starting with - * an event with the largest index and marking it with EventFlag::SNAPSHOT_BEGIN bit in @ref Order::getEventFlags() "eventFlags", - * and finishing the snapshot with an event that has zero 32 least significant bits of index. + * an event with the largest index and marking it with EventFlag::SNAPSHOT_BEGIN bit in @ref Order::getEventFlags() + * "eventFlags", and finishing the snapshot with an event that has zero 32 least significant bits of index. * EventFlag::SNAPSHOT_END bit in @ref Order::getEventFlags() "eventFlags" is optional during publishing. * It will be properly set on receiving end anyway. * @@ -104,7 +104,6 @@ class DXFCPP_EXPORT Order : public OrderBase { static void freeGraalData(void *graalNative) noexcept; public: - static std::shared_ptr fromGraal(void *graalNative) noexcept; /** @@ -114,14 +113,14 @@ class DXFCPP_EXPORT Order : public OrderBase { * * @return The pointer to the filled dxFeed Graal SDK structure */ - void* toGraal() const noexcept override; + void *toGraal() const noexcept override; /** * Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary). * * @param graalNative The pointer to the dxFeed Graal SDK structure. */ - static void freeGraal(void* graalNative) noexcept; + static void freeGraal(void *graalNative) noexcept; public: /// The alias to a type of shared pointer to the Order object @@ -144,6 +143,734 @@ class DXFCPP_EXPORT Order : public OrderBase { explicit Order(std::string eventSymbol) noexcept : OrderBase(std::move(eventSymbol)) { } + /** + * Changes event's symbol and returns the current order. + * + * @param eventSymbol The symbol of this event. + * @return The current order. + */ + Order &withEventSymbol(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return *this; + } + + /** + * Changes event's symbol and returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param eventSymbol The symbol of this event. + * @return A shared pointer to the current order. + */ + Order::Ptr withEventSymbolShared(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes event's creation time and returns the current order. + * + * @param eventTime the difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return The current order. + */ + Order &withEventTime(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return *this; + } + + /** + * Changes event's creation time and returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param eventTime the difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return A shared pointer to the current order. + */ + Order::Ptr withEventTimeShared(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes event's source and returns the current order. + * This method changes highest bits of the @ref OrderBase::getIndex() "index" of this event. + * + * @param source source of this event. + * @return The current order. + */ + Order &withSource(const OrderSource &source) noexcept { + OrderBase::setSource(source); + + return *this; + } + + /** + * Changes event's source and returns a shared pointer to the current order. + * This method changes highest bits of the @ref OrderBase::getIndex() "index" of this event. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param source source of this event. + * @return A shared pointer to the current order. + */ + Order::Ptr withSourceShared(const OrderSource &source) noexcept { + OrderBase::setSource(source); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes transactional event flags and returns the current order. + * See EventFlag "Event Flags" section. + * + * @param eventFlags transactional event flags. + * @return The current order. + */ + Order &withEventFlags(std::int32_t eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return *this; + } + + /** + * Changes transactional event flags and returns a shared pointer to the current order. + * See EventFlag "Event Flags" section. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param eventFlags transactional event flags. + * @return A shared pointer to the current order. + */ + Order::Ptr withEventFlagsShared(std::int32_t eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes transactional event flags and returns the current order. + * See EventFlag "Event Flags" section. + * + * @param eventFlags transactional event flags' mask. + * @return The current order. + */ + Order &withEventFlags(const EventFlagsMask &eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return *this; + } + + /** + * Changes transactional event flags and returns a shared pointer to the current order. + * See EventFlag "Event Flags" section. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param eventFlags transactional event flags' mask. + * @return A shared pointer to the current order. + */ + Order::Ptr withEventFlagsShared(const EventFlagsMask &eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes unique per-symbol index of this order and returns it. Note, that this method also changes + * @ref OrderBase::getSource() "source", whose id occupies highest bits of index. + * Use OrderBase::setSource() after invocation of this method to set the desired value of source. + * + * @param index unique per-symbol index of this order. + * @return The current order. + */ + Order &withIndex(std::int64_t index) noexcept { + OrderBase::setIndex(index); + + return *this; + } + + /** + * Changes unique per-symbol index of this order and returns a shared pointer to it. Note, that this method also + * changes + * @ref OrderBase::getSource() "source", whose id occupies highest bits of index. + * Use OrderBase::setSource() after invocation of this method to set the desired value of source. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param index unique per-symbol index of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withIndexShared(std::int64_t index) noexcept { + OrderBase::setIndex(index); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of this order and returns it. + * Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC. + * + * @param time time of this order. + * @return The current order. + */ + Order &withTime(std::int64_t time) noexcept { + OrderBase::setTime(time); + + return *this; + } + + /** + * Changes time of this order and returns a shared pointer to it. + * Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param time time of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withTimeShared(std::int64_t time) noexcept { + OrderBase::setTime(time); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes microseconds and nanoseconds time part of this order. + * Returns the current order. + * + * @param timeNanoPart microseconds and nanoseconds time part of this order. + * @return The current order. + */ + Order &withTimeNanoPart(std::int32_t timeNanoPart) noexcept { + OrderBase::setTimeNanoPart(timeNanoPart); + + return *this; + } + + /** + * Changes microseconds and nanoseconds time part of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param timeNanoPart microseconds and nanoseconds time part of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withTimeNanoPartShared(std::int32_t timeNanoPart) noexcept { + OrderBase::setTimeNanoPart(timeNanoPart); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes @ref OrderBase::getSequence() "sequence number" of this order. + * Returns the current order. + * + * @param sequence the sequence. + * @return The current order. + * @see OrderBase::getSequence() + */ + Order &withSequence(std::int32_t sequence) noexcept { + OrderBase::setSequence(sequence); + + return *this; + } + + /** + * Changes @ref OrderBase::getSequence() "sequence number" of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param sequence the sequence. + * @return A shared pointer to the current order. + * @see OrderBase::getSequence() + */ + Order::Ptr withSequenceShared(std::int32_t sequence) noexcept { + OrderBase::setSequence(sequence); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of this order and returns it. + * Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC. + * + * @param timeNanos The time of this order in nanoseconds. + * @return The current order. + */ + Order &withTimeNanos(std::int64_t timeNanos) noexcept { + OrderBase::setTimeNanos(timeNanos); + + return *this; + } + + /** + * Changes time of this order. + * Returns a shared pointer to the current order. + * Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param timeNanos time of this order in nanoseconds. + * @return A shared pointer to the current order. + */ + Order::Ptr withTimeNanosShared(std::int64_t timeNanos) noexcept { + OrderBase::setTimeNanos(timeNanos); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes action of this order and returns it. + * + * @param action The side of this order. + * @return The current order. + */ + Order &withAction(const OrderAction &action) noexcept { + OrderBase::setAction(action); + + return *this; + } + + /** + * Changes action of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param action The action of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withActionShared(const OrderAction &action) noexcept { + OrderBase::setAction(action); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of the last action and returns current order. + * + * @param actionTime The last order action time. + * @return The current order. + */ + Order &withActionTime(std::int64_t actionTime) noexcept { + OrderBase::setActionTime(actionTime); + + return *this; + } + + /** + * Changes time of the last action and returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param actionTime The last order action time. + * @return A shared pointer to the current order. + */ + Order::Ptr withActionTimeShared(std::int64_t actionTime) noexcept { + OrderBase::setActionTime(actionTime); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes order ID. + * Returns the current order. + * + * @param orderId The order ID. + * @return The current order. + */ + Order &withOrderId(std::int64_t orderId) noexcept { + OrderBase::setOrderId(orderId); + + return *this; + } + + /** + * Changes order ID. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param orderId order ID. + * @return A shared pointer to the current order. + */ + Order::Ptr withOrderIdShared(std::int64_t orderId) noexcept { + OrderBase::setOrderId(orderId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes auxiliary order ID. + * Returns the current order. + * + * @param auxOrderId The auxiliary order ID. + * @return The current order. + */ + Order &withAuxOrderId(std::int64_t auxOrderId) noexcept { + OrderBase::setAuxOrderId(auxOrderId); + + return *this; + } + + /** + * Changes auxiliary order ID. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param auxOrderId The auxiliary order ID. + * @return A shared pointer to the current order. + */ + Order::Ptr withAuxOrderIdShared(std::int64_t auxOrderId) noexcept { + OrderBase::setAuxOrderId(auxOrderId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes price of this order. + * Returns the current order. + * + * @param price The price of this order. + * @return The current order. + */ + Order &withPrice(double price) noexcept { + OrderBase::setPrice(price); + + return *this; + } + + /** + * Changes price of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param price The price of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withPriceShared(double price) noexcept { + OrderBase::setPrice(price); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes size of this order. + * Returns the current order. + * + * @param size The size of this order. + * @return The current order. + */ + Order &withSize(double size) noexcept { + OrderBase::setSize(size); + + return *this; + } + + /** + * Changes size of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param size The size of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withSizeShared(double size) noexcept { + OrderBase::setSize(size); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes executed size of this order. + * Returns the current order. + * + * @param executedSize The executed size of this order. + * @return The current order. + */ + Order &withExecutedSize(double executedSize) noexcept { + OrderBase::setExecutedSize(executedSize); + + return *this; + } + + /** + * Changes executed size of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param executedSize The executed size of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withExecutedSizeShared(double executedSize) noexcept { + OrderBase::setExecutedSize(executedSize); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes number of individual orders in this aggregate order. + * Returns the current order. + * + * @param count The number of individual orders in this aggregate order. + * @return The current order. + */ + Order &withCount(std::int64_t count) noexcept { + OrderBase::setCount(count); + + return *this; + } + + /** + * Changes number of individual orders in this aggregate order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param count The number of individual orders in this aggregate order. + * @return A shared pointer to the current order. + */ + Order::Ptr withCountShared(std::int64_t count) noexcept { + OrderBase::setCount(count); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade ID. + * Returns the current order. + * + * @param tradeId The trade ID. + * @return The current order. + */ + Order &withTradeId(std::int64_t tradeId) noexcept { + OrderBase::setTradeId(tradeId); + + return *this; + } + + /** + * Changes trade ID. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param tradeId The trade ID. + * @return A shared pointer to the current order. + */ + Order::Ptr withTradeShared(std::int64_t tradeId) noexcept { + OrderBase::setTradeId(tradeId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade price. + * Returns the current order. + * + * @param tradePrice The trade price. + * @return The current order. + */ + Order &withTradePrice(double tradePrice) noexcept { + OrderBase::setTradePrice(tradePrice); + + return *this; + } + + /** + * Changes trade price. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param tradePrice The trade price. + * @return A shared pointer to the current order. + */ + Order::Ptr withTradePriceShared(double tradePrice) noexcept { + OrderBase::setTradePrice(tradePrice); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade size. + * Returns the current order. + * + * @param tradeSize The trade size. + * @return The current order. + */ + Order &withTradeSize(double tradeSize) noexcept { + OrderBase::setTradeSize(tradeSize); + + return *this; + } + + /** + * Changes trade size. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param tradeSize The trade size. + * @return A shared pointer to the current order. + */ + Order::Ptr withTradeSizeShared(double tradeSize) noexcept { + OrderBase::setTradeSize(tradeSize); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes exchange code of this order. + * Returns the current order. + * + * @param exchangeCode The exchange code of this order. + * @return The current order. + */ + Order &withExchangeCode(char exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return *this; + } + + /** + * Changes exchange code of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param exchangeCode The exchange code of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withExchangeCodeShared(char exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes exchange code of this order. + * Returns the current order. + * + * @param exchangeCode The exchange code of this order. + * @return The current order. + */ + Order &withExchangeCode(std::int16_t exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return *this; + } + + /** + * Changes exchange code of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param exchangeCode The exchange code of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withExchangeCodeShared(std::int16_t exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes side of this order. + * Returns the current order. + * + * @param side The side of this order. + * @return The current order. + */ + Order &withOrderSide(const Side &side) noexcept { + OrderBase::setOrderSide(side); + + return *this; + } + + /** + * Changes side of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param side The side of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withOrderSideShared(const Side &side) noexcept { + OrderBase::setOrderSide(side); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes scope of this order. + * Returns the current order. + * + * @param scope The scope of this order. + * @return The current order. + */ + Order &withScope(const Scope &scope) noexcept { + OrderBase::setScope(scope); + + return *this; + } + + /** + * Changes scope of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param scope The scope of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withScopeShared(const Scope &scope) noexcept { + OrderBase::setScope(scope); + + return shared_from_this()->sharedAs(); + } + + // ---------------------------- + /** * Returns market maker or other aggregate identifier of this order. * This value is defined for Scope::AGGREGATE and Scope::ORDER orders. @@ -163,6 +890,35 @@ class DXFCPP_EXPORT Order : public OrderBase { orderData_.marketMaker = std::move(marketMaker); } + /** + * Changes market maker or other aggregate identifier of this order. + * Returns the current order. + * + * @param marketMaker The market maker or other aggregate identifier of this order. + * @return The current order. + */ + Order &withMarketMaker(std::string marketMaker) noexcept { + setMarketMaker(std::move(marketMaker)); + + return *this; + } + + /** + * Changes market maker or other aggregate identifier of this order. + * Returns a shared pointer to the current order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Order(...))` or `std::make_shared(...)` + * + * @param marketMaker The market maker or other aggregate identifier of this order. + * @return A shared pointer to the current order. + */ + Order::Ptr withMarketMakerShared(std::string marketMaker) noexcept { + setMarketMaker(std::move(marketMaker)); + + return shared_from_this()->sharedAs(); + } + /** * Returns a string representation of the current object. * diff --git a/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp b/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp index 69705c99..7387145f 100644 --- a/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/OrderBase.hpp @@ -53,8 +53,9 @@ struct EventMapper; * The corresponding information is carried in @ref OrderBase::getEventFlags() "eventFlags" property. * The logic behind this property is detailed in IndexedEvent class documentation. * - *

The event @ref OrderBase::getSource() "source" identifier for an order is a part of the unique event @ref OrderBase::getIndex() "index". - * It occupies highest bits of the @ref OrderBase::getIndex() "index" (index is not-negative). The lowest bits of + *

The event @ref OrderBase::getSource() "source" identifier for an order is a part of the unique event @ref + * OrderBase::getIndex() "index". It occupies highest bits of the @ref OrderBase::getIndex() "index" (index is + * not-negative). The lowest bits of * @ref OrderBase::getIndex() "index" contain source-specific event index which is always zero in * an event that is marked with EventFlag::SNAPSHOT_END bit in @ref OrderBase::getEventFlags() "eventFlags". * @@ -262,7 +263,7 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent { /** * Changes time and sequence of this order. - * Do not use this method directly. + * @warning Do not use this method directly. * Change @ref OrderBase::setTime() "time" and/or @ref OrderBase::setSequence() "sequence". * * @param timeSequence the time and sequence. @@ -375,7 +376,7 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent { /** * Changes action of this order. * - * @param action side of this order. + * @param action The action of this order. */ void setAction(const OrderAction &action) noexcept { orderBaseData_.flags = setBits(orderBaseData_.flags, ACTION_MASK, ACTION_SHIFT, action.getCode()); @@ -593,6 +594,16 @@ class DXFCPP_EXPORT OrderBase : public MarketEvent, public IndexedEvent { static_cast(getBits(orderBaseData_.flags, EXCHANGE_MASK, EXCHANGE_SHIFT)))); } + /** + * Returns exchange code of this order as UTF8 string. + * + * @return exchange code of this order as UTF8 string. + */ + std::string getExchangeCodeString() const noexcept { + return {1ULL, static_cast( + static_cast(getBits(orderBaseData_.flags, EXCHANGE_MASK, EXCHANGE_SHIFT)))}; + } + /** * Changes exchange code of this order. * diff --git a/include/dxfeed_graal_cpp_api/event/market/Quote.hpp b/include/dxfeed_graal_cpp_api/event/market/Quote.hpp index 13bb3bf8..00776c39 100644 --- a/include/dxfeed_graal_cpp_api/event/market/Quote.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/Quote.hpp @@ -103,6 +103,62 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { explicit Quote(std::string eventSymbol) noexcept : MarketEvent(std::move(eventSymbol)) { } + /** + * Changes event's symbol and returns the current quote. + * + * @param eventSymbol The symbol of this event. + * @return The current quote. + */ + Quote &withEventSymbol(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return *this; + } + + /** + * Changes event's symbol and returns a shared pointer to the current quote. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * + * @param eventSymbol The symbol of this event. + * @return A shared pointer to the current quote. + */ + Quote::Ptr withEventSymbolShared(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes event's creation time and returns the current quote. + * + * @param eventTime the difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return The current quote. + */ + Quote &withEventTime(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return *this; + } + + /** + * Changes event's creation time and returns a shared pointer to the current quote. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * + * @param eventTime the difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return A shared pointer to the current quote. + */ + Quote::Ptr withEventTimeShared(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return shared_from_this()->sharedAs(); + } + /** * Returns sequence number of this quote to distinguish quotes that have the same @ref Quote::getTime() "time". This * sequence number does not have to be unique and does not need to be sequential. Sequence can range from 0 to @@ -142,13 +198,17 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { } /** - * Changes @ref Quote::getSequence() "sequence number" of this quote and returns a shared pointer to the current quote. + * Changes @ref Quote::getSequence() "sequence number" of this quote and returns a shared pointer to the current + * quote. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` * * @param sequence The sequence. * @return A shared pointer to the current quote. * @see Quote::getSequence() */ - Ptr withSequenceShared(std::int32_t sequence) noexcept { + Quote::Ptr withSequenceShared(std::int32_t sequence) noexcept { setSequence(sequence); return shared_from_this()->sharedAs(); @@ -208,13 +268,16 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { } /** - * Changes microseconds and nanoseconds part of time of the last bid or ask change and returns a shared pointer to the current quote. - * This method changes Quote::getTimeNanos() result. + * Changes microseconds and nanoseconds part of time of the last bid or ask change and returns a shared pointer to + * the current quote. This method changes Quote::getTimeNanos() result. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` * * @param timeNanoPart The microseconds and nanoseconds part of time of the last bid or ask change. * @return A shared pointer to the current quote. */ - Ptr withTimeNanoPartShared(std::int32_t timeNanoPart) noexcept { + Quote::Ptr withTimeNanoPartShared(std::int32_t timeNanoPart) noexcept { setTimeNanoPart(timeNanoPart); return shared_from_this()->sharedAs(); @@ -271,10 +334,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * You can set the actual millisecond-precision time here to publish event and the millisecond part * will make the Quote::getTime() of this quote even precise up to a millisecond. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param bidTime The time of the last bid change. * @return A shared pointer to the current quote. */ - Ptr withBidTimeShared(std::int64_t bidTime) noexcept { + Quote::Ptr withBidTimeShared(std::int64_t bidTime) noexcept { setBidTime(bidTime); return shared_from_this()->sharedAs(); @@ -316,10 +382,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes bid exchange code and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param bidExchangeCode The bid exchange code. * @return A shared pointer to the current quote. */ - Ptr withBidExchangeCodeShared(char bidExchangeCode) noexcept { + Quote::Ptr withBidExchangeCodeShared(char bidExchangeCode) noexcept { setBidExchangeCode(bidExchangeCode); return shared_from_this()->sharedAs(); @@ -347,10 +416,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes bid exchange code and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param bidExchangeCode The bid exchange code. * @return A shared pointer to the current quote. */ - Ptr withBidExchangeCodeShared(std::int16_t bidExchangeCode) noexcept { + Quote::Ptr withBidExchangeCodeShared(std::int16_t bidExchangeCode) noexcept { setBidExchangeCode(bidExchangeCode); return shared_from_this()->sharedAs(); @@ -389,10 +461,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes bid price and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param bidPrice The bid price. * @return A shared pointer to the current quote. */ - Ptr withBidPriceShared(double bidPrice) noexcept { + Quote::Ptr withBidPriceShared(double bidPrice) noexcept { setBidPrice(bidPrice); return shared_from_this()->sharedAs(); @@ -431,10 +506,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes bid size and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param bidSize The bid size. * @retrun A shared pointer to the current quote. */ - Ptr withBidSizeShared(double bidSize) noexcept { + Quote::Ptr withBidSizeShared(double bidSize) noexcept { setBidSize(bidSize); return shared_from_this()->sharedAs(); @@ -478,7 +556,7 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * @param askTime The time of the last ask change. * @return The current quote. */ - Quote& withAskTime(std::int64_t askTime) noexcept { + Quote &withAskTime(std::int64_t askTime) noexcept { setAskTime(askTime); return *this; @@ -491,10 +569,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { * You can set the actual millisecond-precision time here to publish event and the millisecond part * will make the Quote::getTime() of this quote even precise up to a millisecond. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param askTime The time of the last ask change. * @return A shared pointer to the current quote. */ - Ptr withAskTimeShared(std::int64_t askTime) noexcept { + Quote::Ptr withAskTimeShared(std::int64_t askTime) noexcept { setAskTime(askTime); return shared_from_this()->sharedAs(); @@ -536,10 +617,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes ask exchange code and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param askExchangeCode The ask exchange code. * @return A shared pointer to the current quote. */ - Ptr withAskExchangeCodeShared(char askExchangeCode) noexcept { + Quote::Ptr withAskExchangeCodeShared(char askExchangeCode) noexcept { setAskExchangeCode(askExchangeCode); return shared_from_this()->sharedAs(); @@ -567,10 +651,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes ask exchange code and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param askExchangeCode The ask exchange code. * @return A shared pointer to the current quote. */ - Ptr withAskExchangeCodeShared(std::int16_t askExchangeCode) noexcept { + Quote::Ptr withAskExchangeCodeShared(std::int16_t askExchangeCode) noexcept { setAskExchangeCode(askExchangeCode); return shared_from_this()->sharedAs(); @@ -609,10 +696,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes ask price and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param askPrice The ask price. * @return A shared pointer to the current quote. */ - Ptr withAskPriceShared(double askPrice) noexcept { + Quote::Ptr withAskPriceShared(double askPrice) noexcept { setAskPrice(askPrice); return shared_from_this()->sharedAs(); @@ -651,10 +741,13 @@ class DXFCPP_EXPORT Quote final : public MarketEvent, public LastingEvent { /** * Changes ask size and returns a shared pointer to the current quote. * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * Quote(...))` or `std::make_shared(...)` + * * @param askSize The ask size. * @retrun A shared pointer to the current quote. */ - Ptr withAskSizeShared(double askSize) noexcept { + Quote::Ptr withAskSizeShared(double askSize) noexcept { setAskSize(askSize); return shared_from_this()->sharedAs(); diff --git a/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp b/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp index c5392a2b..9167211f 100644 --- a/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp +++ b/include/dxfeed_graal_cpp_api/event/market/SpreadOrder.hpp @@ -55,13 +55,14 @@ struct EventMapper; *

Publishing order books

* * When publishing an order event with DXPublisher::publishEvents() method, least significant 32 bits of - * order @ref SpreadOrder::getIndex() "index" must be in a range of from 0 to `std::numeric_limits::max()` inclusive. - * Use @ref SpreadOrder::setSource() "setSource" method after @ref SpreadOrder::setIndex() "setIndex" to properly - * include source identifier into the index. + * order @ref SpreadOrder::getIndex() "index" must be in a range of from 0 to `std::numeric_limits::max()` + * inclusive. Use @ref SpreadOrder::setSource() "setSource" method after @ref SpreadOrder::setIndex() "setIndex" to + * properly include source identifier into the index. * - * A snapshot has to be published in the descending order of @ref SpreadOrder::getIndex() "index", starting with - * an event with the largest index and marking it with SpreadOrder::SNAPSHOT_BEGIN bit in @ref SpreadOrder::getEventFlags() "eventFlags", - * and finishing the snapshot with an event that has zero 32 least significant bits of index. + * A snapshot has to be published in the descending order of @ref SpreadOrder::getIndex() "index", starting + * with an event with the largest index and marking it with SpreadOrder::SNAPSHOT_BEGIN bit in @ref + * SpreadOrder::getEventFlags() "eventFlags", and finishing the snapshot with an event that has zero 32 least + * significant bits of index. * @ref SpreadOrder::SNAPSHOT_END bit in @ref SpreadOrder::getEventFlags() "eventFlags" is optional during publishing. * It will be properly set on receiving end anyway. * @@ -102,7 +103,6 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { static void freeGraalData(void *graalNative) noexcept; public: - static std::shared_ptr fromGraal(void *graalNative) noexcept; /** @@ -112,14 +112,14 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { * * @return The pointer to the filled dxFeed Graal SDK structure */ - void* toGraal() const noexcept override; + void *toGraal() const noexcept override; /** * Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary). * * @param graalNative The pointer to the dxFeed Graal SDK structure. */ - static void freeGraal(void* graalNative) noexcept; + static void freeGraal(void *graalNative) noexcept; public: /// The alias to a type of shared pointer to the SpreadOrder object @@ -142,6 +142,734 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { explicit SpreadOrder(std::string eventSymbol) noexcept : OrderBase(std::move(eventSymbol)) { } + /** + * Changes event's symbol and returns the current spread order. + * + * @param eventSymbol The symbol of this event. + * @return The current spread order. + */ + SpreadOrder &withEventSymbol(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return *this; + } + + /** + * Changes event's symbol and returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param eventSymbol The symbol of this event. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withEventSymbolShared(const std::string &eventSymbol) noexcept { + MarketEvent::setEventSymbol(eventSymbol); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes event's creation time and returns the current spread order. + * + * @param eventTime the difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return The current spread order. + */ + SpreadOrder &withEventTime(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return *this; + } + + /** + * Changes event's creation time and returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param eventTime The difference, measured in milliseconds, between the event creation time and + * midnight, January 1, 1970 UTC. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withEventTimeShared(std::int64_t eventTime) noexcept { + MarketEvent::setEventTime(eventTime); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes event's source and returns the current spread order. + * This method changes highest bits of the @ref OrderBase::getIndex() "index" of this event. + * + * @param source The source of this event. + * @return The current spread order. + */ + SpreadOrder &withSource(const OrderSource &source) noexcept { + OrderBase::setSource(source); + + return *this; + } + + /** + * Changes event's source and returns a shared pointer to the current spread order. + * This method changes highest bits of the @ref OrderBase::getIndex() "index" of this event. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param source The source of this event. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withSourceShared(const OrderSource &source) noexcept { + OrderBase::setSource(source); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes transactional event flags and returns the current spread order. + * See EventFlag "Event Flags" section. + * + * @param eventFlags The transactional event flags. + * @return The current spread order. + */ + SpreadOrder &withEventFlags(std::int32_t eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return *this; + } + + /** + * Changes transactional event flags and returns a shared pointer to the current spread order. + * See EventFlag "Event Flags" section. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param eventFlags The transactional event flags. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withEventFlagsShared(std::int32_t eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes transactional event flags and returns the current spread order. + * See EventFlag "Event Flags" section. + * + * @param eventFlags The transactional event flags' mask. + * @return The current spread order. + */ + SpreadOrder &withEventFlags(const EventFlagsMask &eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return *this; + } + + /** + * Changes transactional event flags and returns a shared pointer to the current spread order. + * See EventFlag "Event Flags" section. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param eventFlags The transactional event flags' mask. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withEventFlagsShared(const EventFlagsMask &eventFlags) noexcept { + OrderBase::setEventFlags(eventFlags); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes unique per-symbol index of this spread order and returns it. Note, that this method also changes + * @ref OrderBase::getSource() "source", whose id occupies highest bits of index. + * Use OrderBase::setSource() after invocation of this method to set the desired value of source. + * + * @param index The unique per-symbol index of this spread order. + * @return The current spread order. + */ + SpreadOrder &withIndex(std::int64_t index) noexcept { + OrderBase::setIndex(index); + + return *this; + } + + /** + * Changes unique per-symbol index of this spread order and returns a shared pointer to it. Note, that this method + * also changes + * @ref OrderBase::getSource() "source", whose id occupies highest bits of index. + * Use OrderBase::setSource() after invocation of this method to set the desired value of source. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param index The unique per-symbol index of this order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withIndexShared(std::int64_t index) noexcept { + OrderBase::setIndex(index); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of this spread order and returns it. + * Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC. + * + * @param time The time of this spread order. + * @return The current spread order. + */ + SpreadOrder &withTime(std::int64_t time) noexcept { + OrderBase::setTime(time); + + return *this; + } + + /** + * Changes time of this spread order and returns a shared pointer to it. + * Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param time The time of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTimeShared(std::int64_t time) noexcept { + OrderBase::setTime(time); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes microseconds and nanoseconds time part of this spread order. + * Returns the current spread order. + * + * @param timeNanoPart The microseconds and nanoseconds time part of this spread order. + * @return The current spread order. + */ + SpreadOrder &withTimeNanoPart(std::int32_t timeNanoPart) noexcept { + OrderBase::setTimeNanoPart(timeNanoPart); + + return *this; + } + + /** + * Changes microseconds and nanoseconds time part of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param timeNanoPart The microseconds and nanoseconds time part of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTimeNanoPartShared(std::int32_t timeNanoPart) noexcept { + OrderBase::setTimeNanoPart(timeNanoPart); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes @ref OrderBase::getSequence() "sequence number" of this spread order. + * Returns the current spread order. + * + * @param sequence The sequence. + * @return The current spread order. + * @see OrderBase::getSequence() + */ + SpreadOrder &withSequence(std::int32_t sequence) noexcept { + OrderBase::setSequence(sequence); + + return *this; + } + + /** + * Changes @ref OrderBase::getSequence() "sequence number" of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param sequence The sequence. + * @return A shared pointer to the current spread order. + * @see OrderBase::getSequence() + */ + SpreadOrder::Ptr withSequenceShared(std::int32_t sequence) noexcept { + OrderBase::setSequence(sequence); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of this spread order and returns it. + * Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC. + * + * @param timeNanos The time of this order in nanoseconds. + * @return The current spread order. + */ + SpreadOrder &withTimeNanos(std::int64_t timeNanos) noexcept { + OrderBase::setTimeNanos(timeNanos); + + return *this; + } + + /** + * Changes time of this spread order. + * Returns a shared pointer to the current spread order. + * Time is measured in nanoseconds between the current time and midnight, January 1, 1970 UTC. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param timeNanos The time of this spread order in nanoseconds. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTimeNanosShared(std::int64_t timeNanos) noexcept { + OrderBase::setTimeNanos(timeNanos); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes action of this spread order and returns it. + * + * @param action The side of this spread order. + * @return The current spread order. + */ + SpreadOrder &withAction(const OrderAction &action) noexcept { + OrderBase::setAction(action); + + return *this; + } + + /** + * Changes action of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param action The action of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withActionShared(const OrderAction &action) noexcept { + OrderBase::setAction(action); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes time of the last action and returns current spread order. + * + * @param actionTime The last spread order action time. + * @return The current spread order. + */ + SpreadOrder &withActionTime(std::int64_t actionTime) noexcept { + OrderBase::setActionTime(actionTime); + + return *this; + } + + /** + * Changes time of the last action and returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param actionTime The last spread order action time. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withActionTimeShared(std::int64_t actionTime) noexcept { + OrderBase::setActionTime(actionTime); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes order ID. + * Returns the current spread order. + * + * @param orderId The spread order ID. + * @return The current spread order. + */ + SpreadOrder &withOrderId(std::int64_t orderId) noexcept { + OrderBase::setOrderId(orderId); + + return *this; + } + + /** + * Changes spread order ID. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param orderId The spread order ID. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withOrderIdShared(std::int64_t orderId) noexcept { + OrderBase::setOrderId(orderId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes auxiliary spread order ID. + * Returns the current spread order. + * + * @param auxOrderId The auxiliary spread order ID. + * @return The current spread order. + */ + SpreadOrder &withAuxOrderId(std::int64_t auxOrderId) noexcept { + OrderBase::setAuxOrderId(auxOrderId); + + return *this; + } + + /** + * Changes auxiliary spread order ID. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param auxOrderId The auxiliary spread order ID. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withAuxOrderIdShared(std::int64_t auxOrderId) noexcept { + OrderBase::setAuxOrderId(auxOrderId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes price of this spread order. + * Returns the current spread order. + * + * @param price The price of this spread order. + * @return The current spread order. + */ + SpreadOrder &withPrice(double price) noexcept { + OrderBase::setPrice(price); + + return *this; + } + + /** + * Changes price of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param price The price of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withPriceShared(double price) noexcept { + OrderBase::setPrice(price); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes size of this spread order. + * Returns the current spread order. + * + * @param size The size of this spread order. + * @return The current spread order. + */ + SpreadOrder &withSize(double size) noexcept { + OrderBase::setSize(size); + + return *this; + } + + /** + * Changes size of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param size The size of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withSizeShared(double size) noexcept { + OrderBase::setSize(size); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes executed size of this spread order. + * Returns the current spread order. + * + * @param executedSize The executed size of this spread order. + * @return The current spread order. + */ + SpreadOrder &withExecutedSize(double executedSize) noexcept { + OrderBase::setExecutedSize(executedSize); + + return *this; + } + + /** + * Changes executed size of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param executedSize The executed size of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withExecutedSizeShared(double executedSize) noexcept { + OrderBase::setExecutedSize(executedSize); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes number of individual spread orders in this aggregate spread order. + * Returns the current spread order. + * + * @param count The number of individual orders in this aggregate spread order. + * @return The current spread order. + */ + SpreadOrder &withCount(std::int64_t count) noexcept { + OrderBase::setCount(count); + + return *this; + } + + /** + * Changes number of individual spread orders in this aggregate spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param count The number of individual spread orders in this aggregate spread spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withCountShared(std::int64_t count) noexcept { + OrderBase::setCount(count); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade ID. + * Returns the current spread order. + * + * @param tradeId The trade ID. + * @return The current spread order. + */ + SpreadOrder &withTradeId(std::int64_t tradeId) noexcept { + OrderBase::setTradeId(tradeId); + + return *this; + } + + /** + * Changes trade ID. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param tradeId The trade ID. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTradeShared(std::int64_t tradeId) noexcept { + OrderBase::setTradeId(tradeId); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade price. + * Returns the current spread order. + * + * @param tradePrice The trade price. + * @return The current spread order. + */ + SpreadOrder &withTradePrice(double tradePrice) noexcept { + OrderBase::setTradePrice(tradePrice); + + return *this; + } + + /** + * Changes trade price. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param tradePrice The trade price. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTradePriceShared(double tradePrice) noexcept { + OrderBase::setTradePrice(tradePrice); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes trade size. + * Returns the current spread order. + * + * @param tradeSize The trade size. + * @return The current spread order. + */ + SpreadOrder &withTradeSize(double tradeSize) noexcept { + OrderBase::setTradeSize(tradeSize); + + return *this; + } + + /** + * Changes trade size. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param tradeSize The trade size. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withTradeSizeShared(double tradeSize) noexcept { + OrderBase::setTradeSize(tradeSize); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes exchange code of this spread order. + * Returns the current spread order. + * + * @param exchangeCode The exchange code of this spread order. + * @return The current spread order. + */ + SpreadOrder &withExchangeCode(char exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return *this; + } + + /** + * Changes exchange code of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param exchangeCode The exchange code of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withExchangeCodeShared(char exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes exchange code of this spread order. + * Returns the current spread order. + * + * @param exchangeCode The exchange code of this spread order. + * @return The current spread order. + */ + SpreadOrder &withExchangeCode(std::int16_t exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return *this; + } + + /** + * Changes exchange code of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param exchangeCode The exchange code of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withExchangeCodeShared(std::int16_t exchangeCode) noexcept { + OrderBase::setExchangeCode(exchangeCode); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes side of this spread order. + * Returns the current spread order. + * + * @param side The side of this spread order. + * @return The current spread order. + */ + SpreadOrder &withOrderSide(const Side &side) noexcept { + OrderBase::setOrderSide(side); + + return *this; + } + + /** + * Changes side of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param side The side of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withOrderSideShared(const Side &side) noexcept { + OrderBase::setOrderSide(side); + + return shared_from_this()->sharedAs(); + } + + /** + * Changes scope of this spread order. + * Returns the current spread order. + * + * @param scope The scope of this spread order. + * @return The current spread order. + */ + SpreadOrder &withScope(const Scope &scope) noexcept { + OrderBase::setScope(scope); + + return *this; + } + + /** + * Changes scope of this spread order. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param scope The scope of this spread order. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withScopeShared(const Scope &scope) noexcept { + OrderBase::setScope(scope); + + return shared_from_this()->sharedAs(); + } + + // ----------- + /** * Returns spread symbol of this event. * @@ -160,6 +888,35 @@ class DXFCPP_EXPORT SpreadOrder : public OrderBase { spreadOrderData_.spreadSymbol = std::move(spreadSymbol); } + /** + * Changes spread symbol of this event. + * Returns the current spread order. + * + * @param spreadSymbol spread symbol of this event. + * @return The current spread order. + */ + SpreadOrder &withSpreadSymbol(std::string spreadSymbol) noexcept { + setSpreadSymbol(std::move(spreadSymbol)); + + return *this; + } + + /** + * Changes spread symbol of this event. + * Returns a shared pointer to the current spread order. + * + * @warning Please do not use this method unless the object was created with `std::shared_ptr(new + * SpreadOrder(...))` or `std::make_shared(...)` + * + * @param spreadSymbol spread symbol of this event. + * @return A shared pointer to the current spread order. + */ + SpreadOrder::Ptr withSpreadSymbolShared(std::string spreadSymbol) noexcept { + setSpreadSymbol(std::move(spreadSymbol)); + + return shared_from_this()->sharedAs(); + } + /** * Returns a string representation of the current object. * diff --git a/samples/cpp/WriteTapeFile/CMakeLists.txt b/samples/cpp/WriteTapeFile/CMakeLists.txt index 8bcd78f3..a0a2257d 100644 --- a/samples/cpp/WriteTapeFile/CMakeLists.txt +++ b/samples/cpp/WriteTapeFile/CMakeLists.txt @@ -48,26 +48,29 @@ if (DXFCXX_ENABLE_VS_ASAN) ) endif () +target_include_directories(${PROJECT_NAME} PRIVATE ../../../include) + if (DXFCXX_ENABLE_ASAN_UBSAN) target_compile_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined" "-fPIC") target_link_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined" "-fPIC") -endif () -target_include_directories(${PROJECT_NAME} PRIVATE ../../../include) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) -#target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) -target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + $) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) -add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - $ - # ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties - $) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME}) - # install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR})