Skip to content

Commit

Permalink
[EN-7587] Implement FetchDailyCandles sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Jun 30, 2024
1 parent 4637843 commit 20ccd9f
Show file tree
Hide file tree
Showing 10 changed files with 437 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ set(dxFeedGraalCxxApi_OnDemand_Sources
src/ondemand/OnDemandService.cpp
)

set(dxFeedGraalCxxApi_Promise_Sources
src/promise/Promise.cpp
)

set(dxFeedGraalCxxApi_Symbols_Sources
src/symbols/StringSymbol.cpp
src/symbols/SymbolWrapper.cpp
Expand Down Expand Up @@ -317,6 +321,7 @@ set(dxFeedGraalCxxApi_Sources
${dxFeedGraalCxxApi_ApiOsub_Sources}
${dxFeedGraalCxxApi_Ipf_Sources}
${dxFeedGraalCxxApi_OnDemand_Sources}
${dxFeedGraalCxxApi_Promise_Sources}
${dxFeedGraalCxxApi_Symbols_Sources}
${dxFeedGraalCxxApi_System_Sources}
${dxFeedGraalCxxApi_Event_Sources}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ versions):
is a simple demonstration of how to get various scheduling information for instruments
- [x] [OnDemandSample](https://github.com/dxFeed/dxfeed-graal-cxx-api/blob/main/samples/cpp/OnDemandSample/src/main.cpp)
a sample that demonstrates how to use the dxFeed on-demand history data replay service API
- [x] [FetchDailyCandles](https://github.com/dxFeed/dxfeed-graal-cxx-api/blob/main/samples/cpp/FetchDailyCandles/src/main.cpp)
a sample that demonstrates how to fetch last 20 days of candles for a specified symbol and print them.

## Current State

Expand Down
1 change: 1 addition & 0 deletions include/dxfeed_graal_cpp_api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996)
#include "isolated/api/IsolatedDXPublisher.hpp"
#include "isolated/api/IsolatedDXPublisherObservableSubscription.hpp"
#include "isolated/api/osub/IsolatedObservableSubscriptionChangeListener.hpp"
#include "isolated/promise/IsolatedPromise.hpp"
#include "isolated/internal/IsolatedString.hpp"
#include "isolated/internal/IsolatedTimeFormat.hpp"
#include "isolated/internal/IsolatedTools.hpp"
Expand Down
21 changes: 18 additions & 3 deletions include/dxfeed_graal_cpp_api/api/DXFeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
JavaObjectHandle<DXFeed> handle_;
static std::shared_ptr<DXFeed> create(void *feedHandle);

void *getTimeSeriesPromiseImpl(const EventTypeEnum &eventType, const SymbolWrapper &symbol, std::int64_t fromTime,
std::int64_t toTime) const;

protected:
DXFeed() noexcept : handle_{} {
if constexpr (Debugger::isDebug) {
Expand Down Expand Up @@ -295,9 +298,21 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
return sub;
}

Promise<std::vector<std::shared_ptr<TimeSeriesEvent>>> getTimeSeriesPromise(const EventTypeEnum &eventType,
const SymbolWrapper &symbol, std::int64_t fromTime,
std::int64_t toTime);
/**
* Requests time series of events for the specified event type, symbol, and a range of time.
* @tparam E The type of event.
* @param symbol The symbol.
* @param fromTime The time, inclusive, to request events from (see TimeSeriesEvent::getTime()).
* @param toTime The time, inclusive, to request events to (see TimeSeriesEvent::getTime()).
* Use `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX` macro to retrieve events without an
* upper limit on time.
* @return The promise for the result of the request.
*/
template <Derived<TimeSeriesEvent> E>
Promise<std::vector<std::shared_ptr<E>>> getTimeSeriesPromise(const SymbolWrapper &symbol, std::int64_t fromTime,
std::int64_t toTime) const {
return Promise<std::vector<std::shared_ptr<E>>>(getTimeSeriesPromiseImpl(E::TYPE, symbol, fromTime, toTime));
}

std::string toString() const noexcept override;
};
Expand Down
Loading

0 comments on commit 20ccd9f

Please sign in to comment.