Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EN-7587] Implement FetchDailyCandles sample #50

Merged
merged 28 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
21bf8f6
[EN-7587] Implement FetchDailyCandles sample
ttldtor May 23, 2024
28d6616
[EN-7587] Implement FetchDailyCandles sample
ttldtor May 26, 2024
77fe5b1
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin May 27, 2024
3089348
[EN-7587] Implement FetchDailyCandles sample
ttldtor May 29, 2024
2623e20
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 2, 2024
0692dc1
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 9, 2024
b590882
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 9, 2024
70eb5e6
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 9, 2024
0e919c8
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 9, 2024
c2f8ebd
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 10, 2024
94d5421
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 10, 2024
dfe8fe2
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 10, 2024
c59fd02
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 10, 2024
5d4c1c4
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 10, 2024
4b48f6e
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 17, 2024
6d8b0e8
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 17, 2024
8525150
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 17, 2024
723de08
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 19, 2024
11dfa26
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 19, 2024
b9fc079
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 23, 2024
5e2f52c
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 24, 2024
04c38da
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 24, 2024
a1cf71f
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 25, 2024
2e23a30
[EN-7587] Implement FetchDailyCandles sample
AnatolyKalin Jun 25, 2024
009f8d8
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 28, 2024
349dd21
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 28, 2024
4637843
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 29, 2024
20ccd9f
[EN-7587] Implement FetchDailyCandles sample
ttldtor Jun 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
xcode: '15.0'
cc: 'clang'
cxx: 'clang++'
buildType: [ Release, Debug ]
buildType: [ Release, Debug, RelWithDebInfo ]

name: "${{ matrix.config.name }}-${{matrix.buildType}}"
runs-on: ${{ matrix.config.image }}
Expand Down
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ set(dxFeedGraalCxxApi_Exceptions_Sources
)

set(dxFeedGraalCxxApi_Isolated_Sources
src/isolated/api/IsolatedDXFeed.cpp
src/isolated/api/IsolatedDXEndpoint.cpp
src/isolated/api/IsolatedDXFeedSubscription.cpp
src/isolated/api/IsolatedDXPublisher.cpp
src/isolated/api/IsolatedDXPublisherObservableSubscription.cpp
src/isolated/api/osub/IsolatedObservableSubscriptionChangeListener.cpp
src/isolated/promise/IsolatedPromise.cpp
src/isolated/internal/IsolatedString.cpp
src/isolated/internal/IsolatedTimeFormat.cpp
)
Expand Down Expand Up @@ -227,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 @@ -314,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 Expand Up @@ -372,6 +380,14 @@ set(DXFCXX_GCC_LIKE_LINK_OPTIONS "-fPIC")
#A workaround to fix 'relocation truncated to fit: IMAGE_REL_AMD64_SECREL' error (MinGW + Debug)
set(DXFCXX_MINGW_DEBUG_LINK_OPTIONS "-Wl,--disable-dynamicbase,--disable-high-entropy-va,--default-image-base-low")

# https://developercommunity.visualstudio.com/t/Invalid-code-generation-in-release-1940/10678572?sort=newest&viewtype=all
# https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1710
# https://github.com/actions/runner-images/issues/10004
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_definitions(${PROJECT_NAME} PUBLIC _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
target_compile_definitions(${PROJECT_NAME}_static PUBLIC _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
endif ()

target_compile_options(${PROJECT_NAME}
PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:${DXFCXX_MSVC_COMPILE_OPTIONS}>
Expand Down Expand Up @@ -468,6 +484,7 @@ if (DXFCXX_BUILD_SAMPLES)
add_subdirectory(samples/cpp/PrintQuoteEvents)
add_subdirectory(samples/cpp/PublishProfiles)
add_subdirectory(samples/cpp/DxFeedSample)
add_subdirectory(samples/cpp/FetchDailyCandles)
add_subdirectory(samples/cpp/WriteTapeFile)
add_subdirectory(samples/cpp/ConvertTapeFile)
add_subdirectory(samples/cpp/DxFeedFileParser)
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
5 changes: 5 additions & 0 deletions include/dxfeed_graal_cpp_api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996)
#include "exceptions/JavaException.hpp"
#include "exceptions/GraalException.hpp"

#include "isolated/api/IsolatedDXFeed.hpp"
#include "isolated/api/IsolatedDXEndpoint.hpp"
#include "isolated/api/IsolatedDXFeedSubscription.hpp"
#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"

#include "ondemand/OnDemandService.hpp"

#include "promise/Promise.hpp"

DXFCXX_DISABLE_MSC_WARNINGS_POP()
36 changes: 28 additions & 8 deletions include/dxfeed_graal_cpp_api/api/DXFeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
#include "../internal/Handler.hpp"
#include "../internal/Isolate.hpp"
#include "../internal/JavaObjectHandle.hpp"
#include "../promise/Promise.hpp"

#include "DXFeedSubscription.hpp"

Expand Down Expand Up @@ -124,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 All @@ -146,7 +150,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
*
* @return The DXFeed instance
*/
static std::shared_ptr<DXFeed> getInstance() noexcept;
static std::shared_ptr<DXFeed> getInstance();

/**
* Attaches the given subscription to this feed. This method does nothing if the
Expand All @@ -164,7 +168,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @param subscription The subscription.
* @see DXFeedSubscription
*/
void attachSubscription(std::shared_ptr<DXFeedSubscription> subscription) noexcept;
void attachSubscription(std::shared_ptr<DXFeedSubscription> subscription);

/**
* Detaches the given subscription from this feed. This method does nothing if the
Expand All @@ -178,7 +182,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @param subscription The subscription.
* @see DXFeedSubscription
*/
void detachSubscription(std::shared_ptr<DXFeedSubscription> subscription) noexcept;
void detachSubscription(std::shared_ptr<DXFeedSubscription> subscription);

/**
* Detaches the given subscription from this feed and clears data delivered to this subscription
Expand All @@ -188,7 +192,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @param subscription The subscription.
* @see DXFeed::detachSubscription()
*/
void detachSubscriptionAndClear(std::shared_ptr<DXFeedSubscription> subscription) noexcept;
void detachSubscriptionAndClear(std::shared_ptr<DXFeedSubscription> subscription);

/**
* Creates new subscription for a single event type that is <i>attached</i> to this feed.
Expand All @@ -202,7 +206,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @param eventType The type of event
* @return The new subscription
*/
std::shared_ptr<DXFeedSubscription> createSubscription(const EventTypeEnum &eventType) noexcept;
std::shared_ptr<DXFeedSubscription> createSubscription(const EventTypeEnum &eventType);

/**
* Creates new subscription for multiple event types that is <i>attached</i> to this feed.
Expand Down Expand Up @@ -235,7 +239,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @return The new subscription
*/
template <typename EventTypeIt>
std::shared_ptr<DXFeedSubscription> createSubscription(EventTypeIt begin, EventTypeIt end) noexcept {
std::shared_ptr<DXFeedSubscription> createSubscription(EventTypeIt begin, EventTypeIt end) {
if constexpr (Debugger::isDebug) {
Debugger::debug("{}::createSubscription(eventTypes = " + namesToString(begin, end) + ")");
}
Expand All @@ -259,7 +263,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @param eventTypes The initializer list of event types
* @return The new subscription
*/
std::shared_ptr<DXFeedSubscription> createSubscription(std::initializer_list<EventTypeEnum> eventTypes) noexcept;
std::shared_ptr<DXFeedSubscription> createSubscription(std::initializer_list<EventTypeEnum> eventTypes);

/**
* Creates new subscription for multiple event types that is <i>attached</i> to this feed.
Expand All @@ -281,7 +285,7 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
* @return The new subscription
*/
template <typename EventTypesCollection>
std::shared_ptr<DXFeedSubscription> createSubscription(EventTypesCollection &&eventTypes) noexcept {
std::shared_ptr<DXFeedSubscription> createSubscription(EventTypesCollection &&eventTypes) {
if constexpr (Debugger::isDebug) {
Debugger::debug(toString() + "::createSubscription(eventTypes = " +
namesToString(std::begin(eventTypes), std::end(eventTypes)) + ")");
Expand All @@ -294,6 +298,22 @@ struct DXFCPP_EXPORT DXFeed : SharedEntity {
return sub;
}

/**
* 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