Skip to content

Commit

Permalink
[MDAPI-37][C++] Retrieve latest events from feed
Browse files Browse the repository at this point in the history
Fix IsolatedDXFeed::getLastEvent
  • Loading branch information
ttldtor committed Jul 26, 2024
1 parent 0d9db2b commit 218a7a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 1 addition & 3 deletions samples/cpp/DxFeedSample/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void testTradeSnapshots(const std::string &symbol) {
sub->addSymbols(symbol);

while (true) {
std::cout << feed->getLastEvent(std::make_shared<Trade>(symbol))->toString() + "\n";
std::cout << "LAST: " + feed->getLastEvent(std::make_shared<Trade>(symbol))->toString() + "\n";
std::this_thread::sleep_for(1000ms);
}
}
Expand Down Expand Up @@ -94,8 +94,6 @@ DxFeedSample <symbol>
testQuoteListener(symbol);
testQuoteAndTradeListener(symbol);
testTradeSnapshots(symbol);

//std::cin.get();
} catch (const RuntimeException &e) {
std::cerr << e << '\n';
}
Expand Down
20 changes: 13 additions & 7 deletions src/isolated/api/IsolatedDXFeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@ DXFCPP_BEGIN_NAMESPACE

namespace isolated::api::IsolatedDXFeed {


// dxfg_DXFeed_getLastEvent
/* int32_t */ std::shared_ptr<EventType> getLastEvent(/* dxfg_feed_t * */ const JavaObjectHandle<DXFeed>& feed, /* dxfg_event_type_t * */ const StringLikeWrapper& symbolName, const EventTypeEnum& eventType) {
/* int32_t */ std::shared_ptr<EventType> getLastEvent(/* dxfg_feed_t * */ const JavaObjectHandle<DXFeed> &feed,
/* dxfg_event_type_t * */ const StringLikeWrapper &symbolName,
const EventTypeEnum &eventType) {
if (!feed) {
throw InvalidArgumentException(
"Unable to execute function `dxfg_DXFeed_getLastEvent`. The `feed` handle is invalid");
}

auto e = event::IsolatedEventType::toUnique(event::IsolatedEventType::create(symbolName, eventType));
const auto e = event::IsolatedEventType::toUnique(event::IsolatedEventType::create(symbolName, eventType));

runGraalFunctionAndThrowIfMinusOne(dxfg_DXFeed_getLastEvent, static_cast<dxfg_feed_t *>(feed.get()),
static_cast<dxfg_event_type_t *>(e.get()));

return EventMapper::fromGraal(e.get());
}

/*
int32_t dxfg_DXFeed_getLastEvents(graal_isolatethread_t *thread, dxfg_feed_t *feed, dxfg_event_type_list *events);
dxfg_promise_event_t* dxfg_DXFeed_getLastEventPromise(graal_isolatethread_t *thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz, dxfg_symbol_t *symbol);
dxfg_promise_list* dxfg_DXFeed_getLastEventsPromises(graal_isolatethread_t *thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz, dxfg_symbol_list *symbols);
dxfg_promise_events_t* dxfg_DXFeed_getIndexedEventsPromise(graal_isolatethread_t *thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz, dxfg_symbol_t *symbol, dxfg_indexed_event_source_t* source);
int32_t dxfg_DXFeed_getLastEvents(graal_isolatethread_t *thread, dxfg_feed_t *feed,
dxfg_event_type_list *events); dxfg_promise_event_t* dxfg_DXFeed_getLastEventPromise(graal_isolatethread_t
*thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz, dxfg_symbol_t *symbol); dxfg_promise_list*
dxfg_DXFeed_getLastEventsPromises(graal_isolatethread_t *thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz,
dxfg_symbol_list *symbols); dxfg_promise_events_t* dxfg_DXFeed_getIndexedEventsPromise(graal_isolatethread_t
*thread, dxfg_feed_t *feed, dxfg_event_clazz_t eventClazz, dxfg_symbol_t *symbol, dxfg_indexed_event_source_t* source);
*/

Expand Down

0 comments on commit 218a7a2

Please sign in to comment.