-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (36 loc) · 1.6 KB
/
main.cpp
File metadata and controls
47 lines (36 loc) · 1.6 KB
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
45
46
47
// Copyright (c) 2025 Devexperts LLC.
// SPDX-License-Identifier: MPL-2.0
#include <dxfeed_graal_cpp_api/api.hpp>
#include <iostream>
using namespace dxfcpp;
using namespace dxfcpp::literals;
using namespace std::literals;
/// Write events to a tape file.
int main() {
try {
// Disable QD logging.
// Logging::init();
// Create an appropriate endpoint.
const auto endpoint = DXEndpoint::newBuilder()
// Is required for tape connector to be able to receive everything.
->withProperty(DXEndpoint::DXFEED_WILDCARD_ENABLE_PROPERTY, "true")
->withRole(DXEndpoint::Role::PUBLISHER)
->build();
// Connect to the address, remove [format=text] or change on [format=binary] for binary format
endpoint->connect("tape:WriteTapeFile.out.txt[format=text]");
// Get a publisher.
const auto pub = endpoint->getPublisher();
// Creates new Quote market events.
auto quote1 = std::make_shared<Quote>("TEST1")->withBidPrice(10.1).withAskPrice(10.2).sharedAs<Quote>();
auto quote2 = std::make_shared<Quote>("TEST2")->withBidPrice(17.1).withAskPrice(17.2).sharedAs<Quote>();
// Publish events.
pub->publishEvents({quote1, quote2});
// Wait until all data is written, close, and wait until it closes.
endpoint->awaitProcessed();
endpoint->closeAndAwaitTermination();
} catch (const RuntimeException &e) {
std::cerr << e << '\n';
return 1;
}
return 0;
}