-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (47 loc) · 1.14 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (47 loc) · 1.14 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
48
49
50
51
52
53
54
#include <iostream>
#include <nlohmann/json.hpp>
#include "client.hpp"
#include "common/config/log.hpp"
#include "common/log.hpp"
int main(int argc, char** argv)
{
boost::asio::io_context ioc;
try
{
using namespace phemex::common;
// init log
auto& logger = Log::Get(config::Log{}, argv[0]);
auto client =
std::make_shared<phemex::Client>(ioc, [](const auto& message) {
const auto j = nlohmann::json::parse(message);
// handle orderbook messages
if (j.count("orderbook"))
{
}
// handle kline messages
else if (j.count("kline"))
{
}
// handle trade messages
else if (j.count("trade"))
{
}
// handle reply messages
else
{
}
});
client->SubscribeOrderBook("BTCUSD");
client->SubscribeKline("BTCUSD", 60);
client->SubscribeTrade("BTCUSD");
ioc.run();
logger.Flush();
}
catch (std::exception& e)
{
std::cerr << "Error: failed to start phemex api, reason: " << e.what()
<< std::endl;
return 1;
}
return 0;
}