-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
44 lines (34 loc) · 1.38 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2024 Devexperts LLC.
// SPDX-License-Identifier: MPL-2.0
#include <dxfeed_graal_cpp_api/api.hpp>
#include <iostream>
/*
* A simple sample that shows how to subscribe to quotes for one instrument,
* and print all received quotes to the console.
* Use default DXFeed instance for that data feed address is defined by "dxfeed.properties" file.
* The properties file is copied to the build output directory from the project directory.
*/
int main(int argc, char *argv[]) {
using namespace dxfcpp;
try {
// Specified instrument name, for example AAPL, IBM, MSFT, etc.
auto symbol = argc > 1 ? argv[1] : "AAPL";
// Creates a subscription attached to a default DXFeed with a Quote event type.
// The endpoint address to use is stored in the "dxfeed.properties" file.
auto subscription = DXFeed::getInstance()->createSubscription(Quote::TYPE);
// Listener must be attached before symbols are added.
subscription->addEventListener([](const auto &events) {
// Prints all received events.
for (const auto &e : events) {
std::cout << e << "\n";
}
});
// Adds specified symbol.
subscription->addSymbols(symbol);
std::cin.get();
} catch (const RuntimeException &e) {
std::cerr << e << '\n';
return 1;
}
return 0;
}