Skip to content

Commit

Permalink
[MDAPI-82][C++] Implement MarketDepthModel
Browse files Browse the repository at this point in the history
MarketDepthModelListener
  • Loading branch information
AnatolyKalin committed Nov 26, 2024
1 parent 1546360 commit 992e332
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
65 changes: 65 additions & 0 deletions include/dxfeed_graal_cpp_api/model/MarketDepthModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,83 @@
DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)

#include "../entity/SharedEntity.hpp"
#include "../event/EventSourceWrapper.hpp"
#include "../event/market/OrderBase.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "IndexedTxModel.hpp"
#include "MarketDepthModelListener.hpp"

#include <memory>
#include <unordered_set>

DXFCPP_BEGIN_NAMESPACE

struct DXFeed;
struct SymbolWrapper;

struct DXFCPP_EXPORT MarketDepthModel : RequireMakeShared<MarketDepthModel> {

struct DXFCPP_EXPORT Builder : RequireMakeShared<Builder> {
std::shared_ptr<IndexedTxModel::Builder> builder;
std::shared_ptr<MarketDepthModelListenerCommon> listener;
std::size_t depthLimit;
std::int64_t aggregationPeriodMillis;

std::shared_ptr<Builder> withFeed(std::shared_ptr<DXFeed> feed) {
builder = builder->withFeed(feed);

return sharedAs<Builder>();
}

std::shared_ptr<Builder> withSymbol(const SymbolWrapper &symbol) {
builder = builder->withSymbol(symbol);

return sharedAs<Builder>();
}

template <Derived<OrderBase> E>
std::shared_ptr<Builder> withListener(std::shared_ptr<MarketDepthModelListener<E>> listener) {
//TODO: implement

return sharedAs<Builder>();
}

template <typename EventSourceIt>
std::shared_ptr<Builder> withSources(EventSourceIt begin, EventSourceIt end) const {
builder = builder->withSources(begin, end);

return sharedAs<Builder>();
}

template <ConvertibleToEventSourceWrapperCollection EventSourceCollection>
std::shared_ptr<Builder> withSources(EventSourceCollection &&sources) const {
return withSources(std::begin(sources), std::end(sources));
}

std::shared_ptr<Builder> withSources(std::initializer_list<EventSourceWrapper> sources) const;

std::shared_ptr<Builder> withDepthLimit(std::size_t depthLimit) const;

std::shared_ptr<Builder> withAggregationPeriod(std::int64_t aggregationPeriodMillis) const;

std::shared_ptr<Builder> withAggregationPeriod(std::chrono::milliseconds aggregationPeriod) const;

std::shared_ptr<MarketDepthModel> build() const;
};

static std::shared_ptr<Builder> newBuilder();

std::size_t getDepthLimit() const;

void setDepthLimit(std::size_t depthLimit);

std::int64_t getAggregationPeriod() const;

void setAggregationPeriod(std::int64_t aggregationPeriodMillis);

void setAggregationPeriod(std::chrono::milliseconds aggregationPeriod);

void close();
};

DXFCPP_END_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)

DXFCPP_BEGIN_NAMESPACE

struct DXFCPP_EXPORT MarketDepthModelListenerCommon : virtual SharedEntity {

};

template <Derived<OrderBase> E>
struct DXFCPP_EXPORT MarketDepthModelListener : RequireMakeShared<MarketDepthModelListener<E>> {
struct DXFCPP_EXPORT MarketDepthModelListener : MarketDepthModelListenerCommon, RequireMakeShared<MarketDepthModelListener<E>> {
static std::shared_ptr<MarketDepthModelListener<E>>
create(std::function<void(const std::vector<std::shared_ptr<E>> & /* buy */,
const std::vector<std::shared_ptr<E>> & /* sell */)>
Expand Down

0 comments on commit 992e332

Please sign in to comment.